Ignore:
Timestamp:
2003-06-13T11:24:14+12:00 (21 years ago)
Author:
kjdon
Message:

the remove and configure plugin/classifier buttons are now disabled if there is no selection in the list. also teh two lists have been made singly selectable - no more multiple selections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r4598 r4638  
    669669        central_pane = new JPanel();
    670670        configure = new JButton(get("Configure"));
     671        configure.setEnabled(false);
    671672        configure.setMnemonic(KeyEvent.VK_C);
    672673        header_pane = new JPanel();
     
    715716        movement_pane = new JPanel();
    716717        plugin = new JComboBox(available);
    717                 //plugin.setEditable(true);
     718        //plugin.setEditable(true);
    718719        plugin.setSelectedIndex(0);
    719720        plugin_label = new JLabel(get("PlugIn"));
    720721        plugin_list = new JList(assigned);
    721722        plugin_list.setCellRenderer(new ListRenderer());
     723        plugin_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    722724        plugin_list_label = new JLabel(get("Assigned"));
    723725        plugin_list_label.setHorizontalAlignment(JLabel.CENTER);
     
    726728        plugin_pane = new JPanel();
    727729        remove = new JButton(get("Remove"));
     730        remove.setEnabled(false);
    728731        remove.setMnemonic(KeyEvent.VK_R);
    729732        title = new JLabel(get("Title"));
    730733        title.setHorizontalAlignment(JLabel.CENTER);
    731734        title.setOpaque(true);
    732                 // Listeners
     735        // Listeners
    733736        add.addActionListener(new AddListener());
    734737        configure.addActionListener(new ConfigureListener());
     
    740743        remove.addActionListener(new RemoveListener());
    741744        plugin_list.addMouseListener(new ClickListener());
    742                 // Layout
     745        plugin_list.addListSelectionListener(new ListListener());
     746        // Layout
    743747        title.setBorder(BorderFactory.createEmptyBorder(0,0,2,0));
    744748
     
    907911        }
    908912    }
     913
     914    /** listens for changes in the list selection and enables the configure and remove buttons if there is a selection, disables them if there is no selection */
     915    private class ListListener
     916        implements ListSelectionListener {
     917
     918        public void valueChanged(ListSelectionEvent e) {
     919        if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one)
     920            if (plugin_list.isSelectionEmpty()) {
     921            configure.setEnabled(false);
     922            remove.setEnabled(false);
     923            } else {
     924            configure.setEnabled(true);
     925            remove.setEnabled(true);
     926            }
     927        }
     928        }
     929    }
     930
    909931    /** Listens for actions apon the move buttons in the manager controls, and if detected calls the <i>movePlugIn()</i> method of the manager with the appropriate details. */
    910932    private class MoveListener
Note: See TracChangeset for help on using the changeset viewer.