Changeset 5753


Ignore:
Timestamp:
2003-10-29T12:17:25+13:00 (21 years ago)
Author:
jmt12
Message:

Fixed the enabled/disabled state of some of the buttons depending on what is selected. Also you can now add the UnknownPlug multiple times, and you can no longer remove the Arc and Rec plugs

File:
1 edited

Legend:

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

    r5593 r5753  
    755755            new_plugin = new PlugIn(element, null);
    756756            }
    757             if(!model.contains(new_plugin)) {
     757            if(!model.contains(new_plugin) || new_plugin.getName().equals(StaticStrings.UNKNOWNPLUG_STR)) {
    758758            // Automatically chain to configuration. This ensures required arguments are filled out.
    759759            ArgumentConfiguration ac = new ArgumentConfiguration(new_plugin);
     
    761761                assignPlugIn(new_plugin);
    762762                plugin_list.setSelectedValue(new_plugin, true);
    763                 // Since we weren't cancelled, and if there was a base plugin, ensure it no longer is shown as available
    764                 if(base_plugin != null) {
     763                // Since we weren't cancelled, and if there was a base plugin, ensure it no longer is shown as available, unless it is the UnknownPlugIn which can be added several times
     764                if(base_plugin != null && !base_plugin.getName().equals(StaticStrings.UNKNOWNPLUG_STR)) {
    765765                plugin.removeItem(base_plugin);
    766766                }
     
    839839            }
    840840            else {
    841             move_top_button.setEnabled(true);
    842             move_up_button.setEnabled(true);
    843             move_down_button.setEnabled(true);
    844             move_bottom_button.setEnabled(true);
    845             configure.setEnabled(true);
    846             remove.setEnabled(true);
     841               configure.setEnabled(true);
     842               // Some buttons are only available for plugins other than ArcPlug and RecPlug
     843               PlugIn selected_plugin = (PlugIn) plugin_list.getSelectedValue();
     844               String plugin_name = selected_plugin.getName();
     845               if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR)) {
     846               move_top_button.setEnabled(false);
     847               move_up_button.setEnabled(false);
     848               move_down_button.setEnabled(false);
     849               move_bottom_button.setEnabled(false);
     850               remove.setEnabled(false);
     851               }
     852               else {
     853              // Move ups are only enabled if the selected plugin isn't already at the top
     854              PlugIn first_plugin = (PlugIn) getElementAt(0);
     855              if(!first_plugin.equals(selected_plugin)) {
     856                 move_top_button.setEnabled(true);
     857                 move_up_button.setEnabled(true);
     858              }
     859              else {
     860                 move_top_button.setEnabled(false);
     861                 move_up_button.setEnabled(false);
     862              }
     863              // And move downs are only allowed when the selected plugin isn't at an index one less than the separator line.
     864              int separator_index = findSeparatorIndex();
     865              int selected_index = plugin_list.getSelectedIndex();
     866              if(selected_index != separator_index - 1) {
     867                 move_down_button.setEnabled(true);
     868                 move_bottom_button.setEnabled(true);
     869              }
     870              else {
     871                 move_down_button.setEnabled(false);
     872                 move_bottom_button.setEnabled(false);
     873              }
     874              remove.setEnabled(true);
     875               }
     876               selected_plugin = null;
     877               plugin_name = null;
    847878            }
    848879        }
Note: See TracChangeset for help on using the changeset viewer.