Changeset 32706 for main


Ignore:
Timestamp:
12/17/18 23:38:02 (2 years ago)
Author:
ak19
Message:

Committing the non-EDT related changes to GLI. More changes to setNamesRecursively: for GLI GUI buttons (class GLIButton) these are still standalone rather than compound widgets that contain further widgets within them. So want to set names of GLIButtons (and JButtons) to be their container-class.GLIButton.button-membervar-name. 2. Preferences dialog nulls member handles to important widgets whose names I want to set before the widget is even made visible. In testing mode, I want to prevent these from being set to null so I can set their names in order to access them.

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

Legend:

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

    r31880 r32706  
    172172        tab_pane.setSelectedComponent(general_preferences);
    173173    }
    174    
    175     // Clean up
    176     general_preferences = null;
    177     connection_preferences = null;
    178     frame_location = null;
    179     frame_size = null;
    180     cancel_button = null;
    181     ok_button = null;
    182     button_pane = null;
    183     tab_pane = null;
    184     content_pane = null;
    185 
     174
     175    // Clean up if not in GLI GUI test mode
     176    // If in test mode, I need widgets like tab_pane and buttons to exist
     177    if(!TestingPreparation.TEST_MODE) {
     178        general_preferences = null;
     179        connection_preferences = null;
     180        frame_location = null;
     181        frame_size = null;
     182        cancel_button = null;
     183        ok_button = null;
     184        button_pane = null;
     185        tab_pane = null;
     186        content_pane = null;
     187    }
     188
     189    TestingPreparation.setNamesRecursively(this);
     190   
    186191    setVisible(true);
    187192    }
  • main/trunk/gli/src/org/greenstone/gatherer/gui/TestingPreparation.java

    r32700 r32706  
    3434    root.setName(className);
    3535
    36     setNamesRecursively("", root, "", true);
     36    setNamesRecursively("", root, "", true, className);
    3737    //if (DEBUGGING_TEST_MODE) printComponentNames(root, "");
    3838    }
    3939   
    40     private static void setNamesRecursively(String prefix, Component root, String tabSpace, boolean isTrueRoot) {
     40    private static void setNamesRecursively(String prefix, Component root, String tabSpace, boolean isTrueRoot, String rootClassName) {
    4141    if(!TEST_MODE) return; 
    4242       
     
    5151        if(!prefix.equals("")){
    5252            // TODO: set this to something more meaningful?
    53             root.setName(prefix + "." + className);         
     53            root.setName(prefix + "." + className);
    5454        }
    5555        else {
     
    5757        }
    5858        } // else swing Component name already set
    59 
     59       
    6060        // now we can print out this element's name for debugging
    6161        if (DEBUGGING_TEST_MODE) System.err.println(tabSpace + root.getName());
     
    6363       
    6464        if(root.getName() == null || root.getName().equals("")) {
    65         root.setName(className);
    66         } else if(!isTrueRoot) {       
     65        // if it's a non-member var GLIButton, give it a more sensible name
     66        if(JButton.class.isAssignableFrom(root.getClass())) {
     67            JButton button = (JButton)root;
     68            root.setName(rootClassName + ".GLIButton." + button.getText()); // getLabel() deprecated
     69        } else {
     70            root.setName(className);
     71        }
     72        } else if(!isTrueRoot) {
     73
     74        // GLIButtons are GLI GUI package but they have no member vars so
     75        // they would have been processed with their containing classes: their names
     76        // are already set.
     77        // But their names still have to be displayed if debugging
     78        if(JButton.class.isAssignableFrom(root.getClass())) {
     79            if (DEBUGGING_TEST_MODE) System.err.println(tabSpace + root.getName());
     80        }
     81       
    6782        // then the name of this GLI GUI element (i.e. of GLI GUI package) was already set
    6883        // we've recursively dealt with this GLI element and its children already
     
    96111            try {
    97112            Container memberComponent = (Container)memberVars[i].get(root);
    98            
     113
     114            //System.err.println("### Found (null?) member var: " + memberVars[i].getName());
    99115            if(memberComponent != null) {
    100 
     116                //System.err.println("@@@ Found member var: " + memberVars[i].getName());
     117               
    101118                // member var is a JComponent but not of GLI package, so locally instantiated
    102                 if(!memberVarClass.getPackage().getName().contains("org.greenstone.gatherer.gui")) {
     119                // or member var can be GLIButtons which are of GLI GUI package
     120                // but they contain no Component member vars we care about so
     121                // process GLIButtons with their containing classes
     122                if(JButton.class.isAssignableFrom(memberVarClass)
     123                   || !memberVarClass.getPackage().getName().contains("org.greenstone.gatherer.gui"))
     124                {
    103125                String memberprefix = prefix + "." + memberVars[i].getName(); // append member var name
    104126               
    105127                // now can call setName() on the actual member variable
    106128                memberComponent.setName(memberprefix);
    107                 setNamesRecursively(memberprefix, memberComponent, tabSpace+"  ", false);
     129                rootClassName = memberprefix; // pass nearest parent GLI GUI class name as param
     130                // for namespacing any local JButton members declared in memberVarClass
     131                setNamesRecursively(memberprefix, memberComponent, tabSpace+"  ", false, rootClassName);
    108132                }
    109133
     
    116140                //String memberprefix = memberVarClass.getSimpleName();
    117141                //memberComponent.setName(memberprefix);
    118                 setNamesRecursively("", memberComponent, tabSpace+"  ", false);
     142                setNamesRecursively("", memberComponent, tabSpace+"  ", false, rootClassName);
    119143                }
    120144                           
     
    140164        // if we haven't already set a name for any child JComponents with the above,
    141165        // then the following will do so now
    142         setNamesRecursively(className, children[i], tabSpace+"  ", false);
     166        setNamesRecursively(className, children[i], tabSpace+"  ", false, rootClassName);
    143167    }   
    144168
Note: See TracChangeset for help on using the changeset viewer.