Ignore:
Timestamp:
2018-12-16T20:59:37+13:00 (5 years ago)
Author:
ak19
Message:

Simplifying setNamesRecursively and its usage. And printComponentNames is now automatically called by new version of now-overloaded setNamesRecursively(), but only if new flag DEBUGGING_TEST_MODE set

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/gui/TestingPreparation.java

    r32689 r32695  
    66
    77public class TestingPreparation {
    8     public static boolean TEST_MODE = false;
    9    
     8    public static boolean TEST_MODE = true; // TODO: set to true for debugging. Reset to false when committing to svn
     9    public static boolean DEBUGGING_TEST_MODE = true;
    1010   
    1111    /*
     
    2121      - https://stackoverflow.com/questions/28639294/in-java-how-to-get-name-of-component-which-is-clicked
    2222    */
     23    public static void setNamesRecursively(Component root) {
     24    if(!TEST_MODE) return;
     25
     26    // setNamesRecursively won't assign a name if one is already set
     27    // But GUIManager for instance g_man has a name "frame0" assigned automatically
     28    // Setting explicitly since GUIManager is preferred for its name
     29   
     30    // Workaround to force replacement of non-informative names like frame0 for GUIManager
     31    // and dialog0 for OpenCollectioNDialog
     32    // Workaround is to not check if name already set for root, but to set it ourselves
     33    String className = root.getClass().getSimpleName();
     34    root.setName(className);
     35
     36    setNamesRecursively("", root);
     37    if (DEBUGGING_TEST_MODE) printComponentNames(root, "");
     38    }
     39   
    2340    public static void setNamesRecursively(String prefix, Component root) {
    2441    if(!TEST_MODE) return;
     
    110127
    111128   
    112     // For debugging swing Component names assigned with Container's setName()
     129    // For debugging swing Component names assigned with Container's setName()   
    113130    public static void printComponentNames(Component root, String tabbing) {
    114131    if(!TEST_MODE) return;
Note: See TracChangeset for help on using the changeset viewer.