// Path: ESignUI/src/main/java/tr/gov/turkiye/esignuidesk/config/Config.java
// public class Config {
//     //Main frame configuration
//     public static final int FRAME_WIDTH = 530;
//     public static final int FRAME_HEIGHT = 275;
//     public static final int FRAME_STARTING_X = 30;
//     public static final int FRAME_STARTING_Y = 30;
//     
//     //Main panel configuration
//     public static final int DEF_PANEL_WIDTH = FRAME_WIDTH;
//     public static final int DEF_PANEL_HEIGHT = FRAME_HEIGHT-25;
//     public static final int DEF_PANEL_STARTING_X = 0;
//     public static final int DEF_PANEL_STARTING_Y = 0;
//     
//     public static final Locale locale = new Locale("tr","TR");
// //    public static final Locale locale = new Locale("en","EN");    
//     
//     //Screen ids are used on logic manager to interpret where requests are coming from.
//     public static final int CARD_SELECT_SCREEN_ID = 1;
//     public static final int CERT_SHOW_SCREEN_ID = 2;
//     public static final int PIN_PANE_ID = 3;
//     public static final int DONE_PANE_ID = 4;
//     
//     public static final int DEBUG_TYPE = 1; //0=do nothing,1=print stack trace to console,2=print localized message to console, 3=send to server etc.
//     
//     public static final String certInfoPaneName = "certInfoPane";
//     public static final String certPaneName = "certPane";
//     public static final String pinPaneName = "pinPane";
//     
//     public static final Point pinBtnStartPoint = new Point(20, 60);
//     public static final Dimension numberBtnSize = new Dimension(40,40);
//     
//     public static final String defaultFileName = "signed_document_";
//     
//     public static final String dateSFormat = "dd.MM.yyyy";
//     public static final String timeSFormat = "dd-MM-yyyy_hh_mm_ss";
// }
// 
// Path: ESignUI/src/main/java/tr/gov/turkiye/esignuidesk/controller/LogManager.java
// public class LogManager {
//     /**
//      * Handles error and shows message pane if desired. 
//      * In addition message of message pane can be set if msg parameter is given.
//      * If its null then throwable message is used.
//      * 
//      * @param e
//      * @param showMsgPane 
//      * @param msg 
//      */
//     public static void handleError(Throwable e, boolean showMsgPane, String msg) {
//         if(e!=null)
//             catchErrMsg(e);
//         if(showMsgPane) {
//             if(msg!=null)
//                 GUIManager.showErrMsg(msg);
//             else
//                 if(e!=null)
//                     GUIManager.showErrMsg(e.getMessage());
//         }
//     }
//     
//     /**
//      * Catches exception and treats according to developer's wish.
//      * @param e 
//      */
//     private static void catchErrMsg(Throwable e) {
//         if(Config.DEBUG_TYPE==1) {
//             printConsoleErrMsg(e);
//         } else if(Config.DEBUG_TYPE==2){
//             printConsoleErrMsg(e.getLocalizedMessage());
//         } else if(Config.DEBUG_TYPE==3) {
//             //Should be handled if wanna be used
//         }
//     }
//     
//     /**
//      * Print stack trace to console.
//      * @param e 
//      */
//     private static void printConsoleErrMsg(Throwable e) {
//         e.printStackTrace();
//     }
//     
//     /**
//      * Prints error message to console.
//      * @param msg 
//      */
//     private static void printConsoleErrMsg(String msg) {
//         System.out.println(msg);
//     }
// }


import java.awt.Component;
import java.awt.Point;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JButton;
import tr.gov.turkiye.esignuidesk.config.Config;
import tr.gov.turkiye.esignuidesk.controller.LogManager;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tr.gov.turkiye.esignuidesk.support;


/**
 *
 * @author iakpolat
 */
public class Utils {
    
    /**
     * Takes number from button name.
     * @param btn
     * @return 
     */
    public static int getButtonNumber(JButton btn) {
        int value = -1;
        String svalue = btn.getText();
        try {
            value = Integer.parseInt(svalue);
        } catch(NumberFormatException nfe) {
        }
        
        return value;
    }

    /**
     * Puts component to different positions.
     * 
     * @param list ArrayList(Component)
     * @param colCount Max how many columns there will be on a row.
     * @param x Starting x position
     * @param y Starting y position
     * @param width Width of component
     * @param height Height of component
     */
    public static void randomizePositions(ArrayList list, int colCount, int x, int y, int width, int height) {
        ArrayList<Component> tmpList;
        try {
            tmpList = (ArrayList<Component>) list.clone();
        } catch(Exception e) { //If a cast error is occurred
// Path: ESignUI/src/main/java/tr/gov/turkiye/esignuidesk/config/Config.java
// public class Config {
//     //Main frame configuration
//     public static final int FRAME_WIDTH = 530;
//     public static final int FRAME_HEIGHT = 275;
//     public static final int FRAME_STARTING_X = 30;
//     public static final int FRAME_STARTING_Y = 30;
//     
//     //Main panel configuration
//     public static final int DEF_PANEL_WIDTH = FRAME_WIDTH;
//     public static final int DEF_PANEL_HEIGHT = FRAME_HEIGHT-25;
//     public static final int DEF_PANEL_STARTING_X = 0;
//     public static final int DEF_PANEL_STARTING_Y = 0;
//     
//     public static final Locale locale = new Locale("tr","TR");
// //    public static final Locale locale = new Locale("en","EN");    
//     
//     //Screen ids are used on logic manager to interpret where requests are coming from.
//     public static final int CARD_SELECT_SCREEN_ID = 1;
//     public static final int CERT_SHOW_SCREEN_ID = 2;
//     public static final int PIN_PANE_ID = 3;
//     public static final int DONE_PANE_ID = 4;
//     
//     public static final int DEBUG_TYPE = 1; //0=do nothing,1=print stack trace to console,2=print localized message to console, 3=send to server etc.
//     
//     public static final String certInfoPaneName = "certInfoPane";
//     public static final String certPaneName = "certPane";
//     public static final String pinPaneName = "pinPane";
//     
//     public static final Point pinBtnStartPoint = new Point(20, 60);
//     public static final Dimension numberBtnSize = new Dimension(40,40);
//     
//     public static final String defaultFileName = "signed_document_";
//     
//     public static final String dateSFormat = "dd.MM.yyyy";
//     public static final String timeSFormat = "dd-MM-yyyy_hh_mm_ss";
// }
// 
// Path: ESignUI/src/main/java/tr/gov/turkiye/esignuidesk/controller/LogManager.java
// public class LogManager {
//     /**
//      * Handles error and shows message pane if desired. 
//      * In addition message of message pane can be set if msg parameter is given.
//      * If its null then throwable message is used.
//      * 
//      * @param e
//      * @param showMsgPane 
//      * @param msg 
//      */
//     public static void handleError(Throwable e, boolean showMsgPane, String msg) {
//         if(e!=null)
//             catchErrMsg(e);
//         if(showMsgPane) {
//             if(msg!=null)
//                 GUIManager.showErrMsg(msg);
//             else
//                 if(e!=null)
//                     GUIManager.showErrMsg(e.getMessage());
//         }
//     }
//     
//     /**
//      * Catches exception and treats according to developer's wish.
//      * @param e 
//      */
//     private static void catchErrMsg(Throwable e) {
//         if(Config.DEBUG_TYPE==1) {
//             printConsoleErrMsg(e);
//         } else if(Config.DEBUG_TYPE==2){
//             printConsoleErrMsg(e.getLocalizedMessage());
//         } else if(Config.DEBUG_TYPE==3) {
//             //Should be handled if wanna be used
//         }
//     }
//     
//     /**
//      * Print stack trace to console.
//      * @param e 
//      */
//     private static void printConsoleErrMsg(Throwable e) {
//         e.printStackTrace();
//     }
//     
//     /**
//      * Prints error message to console.
//      * @param msg 
//      */
//     private static void printConsoleErrMsg(String msg) {
//         System.out.println(msg);
//     }
// }


// Path: ESignUI/src/main/java/tr/gov/turkiye/esignuidesk/support/Utils.java
import java.awt.Component;
import java.awt.Point;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JButton;
import tr.gov.turkiye.esignuidesk.config.Config;
import tr.gov.turkiye.esignuidesk.controller.LogManager;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tr.gov.turkiye.esignuidesk.support;


/**
 *
 * @author iakpolat
 */
public class Utils {
    
    /**
     * Takes number from button name.
     * @param btn
     * @return 
     */
    public static int getButtonNumber(JButton btn) {
        int value = -1;
        String svalue = btn.getText();
        try {
            value = Integer.parseInt(svalue);
        } catch(NumberFormatException nfe) {
        }
        
        return value;
    }

    /**
     * Puts component to different positions.
     * 
     * @param list ArrayList(Component)
     * @param colCount Max how many columns there will be on a row.
     * @param x Starting x position
     * @param y Starting y position
     * @param width Width of component
     * @param height Height of component
     */
    public static void randomizePositions(ArrayList list, int colCount, int x, int y, int width, int height) {
        ArrayList<Component> tmpList;
        try {
            tmpList = (ArrayList<Component>) list.clone();
        } catch(Exception e) { //If a cast error is occurred
            LogManager.handleError(e, true, null);