// 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.lang.reflect.Method;
import tr.gov.turkiye.esignuidesk.annotation.FocusOwner;
import tr.gov.turkiye.esignuidesk.controller.LogManager;
import java.awt.Component;
/*
 * 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 AnnotationHelper {
    
    /**
     * FocusOwner component must return component otherwise its accepted that given class has no focus owner.
     * @param comp
     * @return 
     */
    public static Component getFocusableComponent(Component comp) {
        Method[] methods = comp.getClass().getMethods();
        for(Method method: methods) {
            if(method.getAnnotation(FocusOwner.class)!=null) {
                try {
                    return (Component) method.invoke(comp);
                } catch (Throwable ex) {
// 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/AnnotationHelper.java
import java.lang.reflect.Method;
import tr.gov.turkiye.esignuidesk.annotation.FocusOwner;
import tr.gov.turkiye.esignuidesk.controller.LogManager;
import java.awt.Component;

/*
 * 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 AnnotationHelper {
    
    /**
     * FocusOwner component must return component otherwise its accepted that given class has no focus owner.
     * @param comp
     * @return 
     */
    public static Component getFocusableComponent(Component comp) {
        Method[] methods = comp.getClass().getMethods();
        for(Method method: methods) {
            if(method.getAnnotation(FocusOwner.class)!=null) {
                try {
                    return (Component) method.invoke(comp);
                } catch (Throwable ex) {
                    LogManager.handleError(ex, false, null);