Changeset 32695 for main/trunk


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

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

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

    r32689 r32695  
    761761    }*/
    762762
    763         // if we're tutorial testing GLI, want names assigned to the GUI components
    764         if(TestingPreparation.TEST_MODE) {
    765             g_man.setName("GUIManager"); // g_man has a name "frame0" assigned automatically
    766             // setNamesRecursively won't assign a name if one is already set
    767             // Setting explicitly since GUIManager is preferred for its name
    768             TestingPreparation.setNamesRecursively("", g_man);
    769             TestingPreparation.printComponentNames(g_man, "");
    770         }
     763        // if we're tutorial testing GLI, want names assigned to the GUI components
     764        TestingPreparation.setNamesRecursively(g_man);
     765       
    771766       
    772767        // If there was a collection left open last time, reopen it
  • main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r32691 r32695  
    960960    {
    961961    OpenCollectionDialog dialog = new OpenCollectionDialog();
     962    TestingPreparation.setNamesRecursively(dialog);
     963   
    962964        dialog.setComponentOrientation(Dictionary.getOrientation());
    963965    if (dialog.display() == OpenCollectionDialog.OK_OPTION) {
  • 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.