Changeset 7270 for trunk


Ignore:
Timestamp:
2004-05-05T10:50:29+12:00 (20 years ago)
Author:
kjdon
Message:

undid most of what I previously commited. GAPlug is now treated like other plugins except that you can't delete it. there is no top separator.

File:
1 edited

Legend:

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

    r7252 r7270  
    5757    /** The library 'reserve' of base plugins. */
    5858    private ArrayList library = null;
    59     /** When asking how many rows are in the model, and if this variables value is true, then this modifier alters the number returned. This funtionality is used to hide the first two and last three rows of the list in low detail modes. */
     59    /** When asking how many rows are in the model, and if this variables value is true, then this modifier alters the number returned. This funtionality is used to hide the last three rows of the list in low detail modes. */
    6060    private boolean modify_row_count = false;
    6161    /** The controls for editing the contents of this manager. */
     
    6363    private DOMProxyListModel model;
    6464    private JPanel separator;
    65     private PlugIn top_separator_plugin;
    66     private PlugIn bottom_separator_plugin;
     65    private PlugIn separator_plugin;
    6766    /** Constructor.
    6867     */
     
    9291    public void assignPlugIn(PlugIn plugin) {
    9392    if(plugin.getName().equals(StaticStrings.RECPLUG_STR) || plugin.getName().equals(StaticStrings.ARCPLUG_STR)) {
    94         addAfter(plugin, bottom_separator_plugin); // Adds after separator
    95     } else if (plugin.getName().equals(StaticStrings.GAPLUG_STR)) {
    96         addBefore(plugin, top_separator_plugin);
     93        addAfter(plugin, separator_plugin); // Adds after separator
    9794    } else {
    98         addBefore(plugin, bottom_separator_plugin);
     95        addBefore(plugin, separator_plugin);
    9996    }
    10097    Gatherer.c_man.configurationChanged();
    101     }
    102 
    103     /** override this because we want to use the real getElementAt */
    104     public synchronized ArrayList children() {
    105     ArrayList child_list = new ArrayList();
    106     int child_count = super.getSize();
    107     for(int i = 0; i < child_count; i++) {
    108         child_list.add(super.getElementAt(i));
    109     }
    110     return child_list;
    11198    }
    11299
     
    156143    return null;
    157144    }
    158     /** override this to hide the first two entries in some cases */
    159     public synchronized Object getElementAt(int index) {
    160     if (modify_row_count) {
    161         index = index+2;
    162     }
    163     return super.getElementAt(index);
    164     }
     145
    165146    /** Overrides getSize in DOMProxyListModel to take into account the row count modifier used to hide the last three rows in lower detail modes
    166147     * @return an int indicating the number of rows in the model, or more correctly the desired number of rows to display
     
    169150    int result = super.getSize();
    170151    if(modify_row_count) {
    171         result = result - 5;
     152        result = result-3;
    172153    }
    173154    return result;
     
    190171    // why are all the error notices there when the buttons are disabled is you cant move???
    191172    public void movePlugIn(PlugIn plugin, boolean direction, boolean all) {
    192     // Can't ever move RecPlug or ArcPlug or GAPlug
    193     if(super.getSize() < 7) {
     173    // Can't ever move RecPlug or ArcPlug
     174    if(super.getSize() < 4) {
    194175        //Gatherer.println("Not enough plugins to allow moving.");
    195176        return;
    196177    }
    197     if(plugin.getName().equals(StaticStrings.ARCPLUG_STR) || plugin.getName().equals(StaticStrings.RECPLUG_STR) || plugin.getName().equals(StaticStrings.GAPLUG_STR)) {
     178    if(plugin.getName().equals(StaticStrings.ARCPLUG_STR) || plugin.getName().equals(StaticStrings.RECPLUG_STR)) {
    198179        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.Move.Fixed"), Dictionary.get("CDM.Move.Title"), JOptionPane.ERROR_MESSAGE);
    199180        return;
     
    204185        // Remove the moving plugin
    205186        remove(plugin);
    206         addAfter(plugin, top_separator_plugin); //************
     187        // Retrieve the first plugin
     188        PlugIn first_plugin = (PlugIn) getElementAt(0);
     189        // Add the moving plugin before the first plugin
     190        addBefore(plugin, first_plugin);
     191        first_plugin = null;
    207192        Gatherer.c_man.configurationChanged();
    208193        }
     
    211196        remove(plugin);
    212197        // Add the moving plugin before the separator
    213         addBefore(plugin, bottom_separator_plugin);
     198        addBefore(plugin, separator_plugin);
    214199        Gatherer.c_man.configurationChanged();
    215200        }
     
    228213            return;
    229214        }
    230         PlugIn next_plugin = (PlugIn) super.getElementAt(index);
     215        remove(plugin);
     216        add(index, plugin);
     217        Gatherer.c_man.configurationChanged();
     218        }
     219        else {
     220        index++;
     221        PlugIn next_plugin = (PlugIn) getElementAt(index);
    231222        if(next_plugin.isSeparator()) {
    232223            String args[] = new String[1];
     
    240231        Gatherer.c_man.configurationChanged();
    241232        }
    242         else {
    243         index++;
    244         PlugIn next_plugin = (PlugIn) super.getElementAt(index);
    245         if(next_plugin.isSeparator()) {
    246             String args[] = new String[1];
    247             args[0] = plugin.getName();
    248             JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.Move.Cannot", args), Dictionary.get("CDM.Move.Title"), JOptionPane.ERROR_MESSAGE);
    249             // Still not going to move RecPlug or ArcPlug.
    250             return;
    251         }
    252         remove(plugin);
    253         add(index, plugin);
    254         Gatherer.c_man.configurationChanged();
    255         }
    256233    }
    257234    }
     
    259236    /** We attempt to place the separator between the unfixed and the fixed plugins. Since we only know of two fixed plugins, we search for either of them, and place the separator before them.
    260237     */
    261     public void placeSeparators() {
     238    public void placeSeparator() {
    262239    ///ystem.err.println("Placing separator.");
    263240    int separator_index = super.getSize();
    264     int top_separator_index = 0;
    265241    if(separator_index > 0) {
    266         // see if GAPlug is there
    267         PlugIn plugin = (PlugIn) super.getElementAt(0);
    268         if (plugin.getName().equals(StaticStrings.GAPLUG_STR)) {
    269         top_separator_index = 1;
    270         }
    271242        boolean found_fixed = false;
    272243        int index = separator_index - 1;
    273244        while(index > 0) {
    274         plugin = (PlugIn) super.getElementAt(index);
     245        PlugIn plugin = (PlugIn) getElementAt(index);
    275246        String name = plugin.getName();
    276247        if(name.equals(StaticStrings.RECPLUG_STR) || name.equals(StaticStrings.ARCPLUG_STR)) {
     
    294265    element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, CollectionConfiguration.SEPARATOR_ATTRIBUTE);
    295266    element.setAttribute(CollectionConfiguration.SEPARATOR_ATTRIBUTE, CollectionConfiguration.TRUE_STR);
    296     bottom_separator_plugin = new PlugIn(element, null);
    297     top_separator_plugin = new PlugIn((Element)element.cloneNode(true), null);
     267    separator_plugin = new PlugIn(element, null);
    298268    ///atherer.println("Adding plugin separator at: " + separator_index);
    299     add(separator_index, bottom_separator_plugin);
    300     add(top_separator_index, top_separator_plugin);
     269    add(separator_index, separator_plugin);
    301270    }
    302271
     
    331300    if(modify_row_count) {
    332301        fireIntervalRemoved(this, original_size - 4, original_size - 1);
    333         fireIntervalRemoved(this, 0,1);
    334302    }
    335303    else {
    336         fireIntervalAdded(this, 0, 1);
    337304        fireIntervalAdded(this, original_size - 4, original_size - 1);
    338305    }
    339306    }
    340307
    341     /** Determine the first separat */
    342308    /** Determine the current separator index. */
    343309    private int findSeparatorIndex() {
    344310    int separator_index = super.getSize() - 1;
    345311    while(separator_index >= 0) {
    346         PlugIn search = (PlugIn) super.getElementAt(separator_index);
     312        PlugIn search = (PlugIn) getElementAt(separator_index);
    347313        if(search.isSeparator()) {
    348314        return separator_index;
     
    350316        separator_index--;
    351317    }
    352     System.err.println("separator index is "+separator_index);
    353318    return separator_index;
    354319    }
     
    977942                configure.setEnabled(true);
    978943                String plugin_name = selected_plugin.getName();
    979                 // Some buttons are only available for plugins other than ArcPlug and RecPlug and GAPlug
    980                 if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR) || plugin_name.equals(StaticStrings.GAPLUG_STR)) {
     944                // Some buttons are only available for plugins other than ArcPlug and RecPlug
     945                if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR) ) {
    981946                //move_top_button.setEnabled(false);
    982947                move_up_button.setEnabled(false);
     
    986951                }
    987952                else {
    988                 // Move ups are only enabled if the selected plugin isn't already at the top (allowing for GAPlug)
    989                 int top_index = (modify_row_count ? 0: 2);
    990                 PlugIn first_plugin = (PlugIn) getElementAt(top_index);
     953                // don't let people remove GAPlug
     954                if (plugin_name.equals(StaticStrings.GAPLUG_STR)) {
     955                    remove.setEnabled(false);
     956                } else {
     957                    remove.setEnabled(true);
     958                }
     959                   
     960                // Move ups are only enabled if the selected plugin isn't already at the top
     961                PlugIn first_plugin = (PlugIn) getElementAt(0);
    991962                if(!first_plugin.equals(selected_plugin)) {
    992963                    //move_top_button.setEnabled(true);
     
    998969                }
    999970                // And move downs are only allowed when the selected plugin isn't at an index one less than the separator line.
    1000                 int bottom_index = (modify_row_count ? model.getSize(): findSeparatorIndex());
     971                int separator_index = findSeparatorIndex();
    1001972                int selected_index = plugin_list.getSelectedIndex();
    1002                 if(selected_index < bottom_index - 1) {
     973                if(selected_index < separator_index - 1) {
    1003974                    move_down_button.setEnabled(true);
    1004975                    //move_bottom_button.setEnabled(true);
     
    1008979                    //move_bottom_button.setEnabled(false);
    1009980                }
    1010                 remove.setEnabled(true);
    1011981                }
    1012982                selected_plugin = null;
Note: See TracChangeset for help on using the changeset viewer.