Changeset 9151


Ignore:
Timestamp:
2005-02-23T14:07:26+13:00 (19 years ago)
Author:
kjdon
Message:

added some more methods to get name, enabled and value, and changed the tooltip updating stuff cos it wasn't working

File:
1 edited

Legend:

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

    r9139 r9151  
    5959    protected JComponent value_control;
    6060    protected JCheckBox enabled;
     61
    6162    public ArgumentControl(Argument argument, boolean enable, String value) {
    6263    super();
     
    197198    }
    198199
     200    public String getName() {
     201    return argument.getName();
     202    }
     203
     204    public String getValue() {
     205    String value = null;
     206    if(value_control == null) {
     207        // Flag value, nothing to do.
     208    }
     209    else if(value_control instanceof JTextField) {
     210        value = ((JTextField)value_control).getText();
     211    }
     212    else if(value_control instanceof JSpinner) {
     213        value = ((JSpinner)value_control).getValue().toString();
     214    }
     215    else if(value_control instanceof JComboBox) {
     216        value = (((JComboBox)value_control).getSelectedItem()).toString();
     217    }
     218    return value;
     219    }
    199220    /** Retrieve the control used for storing values.
    200221     * @return JComponent
     
    202223    public JComponent getValueControl() {
    203224    return value_control;
     225    }
     226
     227    public boolean isEnabled() {
     228    if (enabled == null) {
     229        return true; // always enabled
     230    }
     231    return enabled.isSelected();
    204232    }
    205233
     
    278306        String description = (String) arg_list.get(key);
    279307        if(description != null) {
    280             description = Utility.formatHTMLWidth(DESCRIPTION_SEP + description, 60);
    281             String original = source.getToolTipText();
    282             if(original == null) {
    283             original = "";
    284             }
    285             // Remove any existing extra description.
    286             if(original.indexOf(DESCRIPTION_SEP) != -1) {
    287             original = original.substring(0, original.indexOf(DESCRIPTION_SEP));
    288             }
    289             source.setToolTipText(original + description);
     308            description = Utility.formatHTMLWidth(description, 60);
     309            source.setToolTipText(description);
    290310        }
    291311        }
Note: See TracChangeset for help on using the changeset viewer.