Changeset 7252


Ignore:
Timestamp:
2004-04-29T16:24:33+12:00 (20 years ago)
Author:
kjdon
Message:

GAPlug is now a special plugin that appears at the top of teh list, and only in Expert mode (like arc and rec plugs). there are now two separator lines in teh plugin list, and other plugins sit between the two separators.

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

Legend:

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

    r6851 r7252  
    127127    metadataset_view = new MetadataSetView();
    128128    plugin_manager = new PlugInManager();
    129     plugin_manager.placeSeparator();
     129    plugin_manager.placeSeparators();
    130130    subcollection_manager = new SubcollectionManager();
    131131    subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r7245 r7252  
    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 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 first two and 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 separator_plugin;
     65    private PlugIn top_separator_plugin;
     66    private PlugIn bottom_separator_plugin;
    6667    /** Constructor.
    6768     */
     
    7172    model = this;
    7273    // Reload/Create the library
    73     loadPlugIns();
     74    loadPlugIns(); // adds all the plugins to the library
    7475    savePlugIns();
    7576    // Create the separator, cause we can reuse it.
     
    9192    public void assignPlugIn(PlugIn plugin) {
    9293    if(plugin.getName().equals(StaticStrings.RECPLUG_STR) || plugin.getName().equals(StaticStrings.ARCPLUG_STR)) {
    93         addAfter(plugin, separator_plugin); // Adds after separator
    94     }
    95     else {
    96         addBefore(plugin, separator_plugin);
     94        addAfter(plugin, bottom_separator_plugin); // Adds after separator
     95    } else if (plugin.getName().equals(StaticStrings.GAPLUG_STR)) {
     96        addBefore(plugin, top_separator_plugin);
     97    } else {
     98        addBefore(plugin, bottom_separator_plugin);
    9799    }
    98100    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;
    99111    }
    100112
     
    144156    return null;
    145157    }
    146 
     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    }
    147165    /** Overrides getSize in DOMProxyListModel to take into account the row count modifier used to hide the last three rows in lower detail modes
    148166     * @return an int indicating the number of rows in the model, or more correctly the desired number of rows to display
     
    151169    int result = super.getSize();
    152170    if(modify_row_count) {
    153         result = result - 3;
     171        result = result - 5;
    154172    }
    155173    return result;
     
    170188     * @param all true to move to move all the way, false for a single step.
    171189     */
     190    // why are all the error notices there when the buttons are disabled is you cant move???
    172191    public void movePlugIn(PlugIn plugin, boolean direction, boolean all) {
    173     // Can't ever move RecPlug or ArcPlug.
    174     if(super.getSize() < 3) {
     192    // Can't ever move RecPlug or ArcPlug or GAPlug
     193    if(super.getSize() < 7) {
    175194        //Gatherer.println("Not enough plugins to allow moving.");
    176195        return;
    177196    }
    178     if(plugin.getName().equals(StaticStrings.ARCPLUG_STR) || plugin.getName().equals(StaticStrings.RECPLUG_STR)) {
     197    if(plugin.getName().equals(StaticStrings.ARCPLUG_STR) || plugin.getName().equals(StaticStrings.RECPLUG_STR) || plugin.getName().equals(StaticStrings.GAPLUG_STR)) {
    179198        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.Move.Fixed"), Dictionary.get("CDM.Move.Title"), JOptionPane.ERROR_MESSAGE);
    180199        return;
     
    185204        // Remove the moving plugin
    186205        remove(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;
     206        addAfter(plugin, top_separator_plugin); //************
    192207        Gatherer.c_man.configurationChanged();
    193208        }
     
    195210        // Remove the moving plugin
    196211        remove(plugin);
    197         // Locate the plugin immediately before the separator. We have to ensure the separator index is up to date, given we've just removed a plugin.
    198         int separator_index = -1;
    199         if((separator_index = findSeparatorIndex()) != -1) {
    200             PlugIn separator_plugin = (PlugIn) getElementAt(separator_index);
    201             // Add the moving plugin before the separator
    202             addBefore(plugin, separator_plugin);
    203             Gatherer.c_man.configurationChanged();
    204         }
    205         // Otherwise we aren't moving anywhere!
     212        // Add the moving plugin before the separator
     213        addBefore(plugin, bottom_separator_plugin);
     214        Gatherer.c_man.configurationChanged();
    206215        }
    207216    }
     
    219228            return;
    220229        }
    221         remove(plugin);
    222         add(index, plugin);
    223         Gatherer.c_man.configurationChanged();
    224         }
    225         else {
    226         index++;
    227         PlugIn next_plugin = (PlugIn) getElementAt(index);
     230        PlugIn next_plugin = (PlugIn) super.getElementAt(index);
    228231        if(next_plugin.isSeparator()) {
    229232            String args[] = new String[1];
     
    237240        Gatherer.c_man.configurationChanged();
    238241        }
     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        }
    239256    }
    240257    }
     
    242259    /** 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.
    243260     */
    244     public void placeSeparator() {
     261    public void placeSeparators() {
    245262    ///ystem.err.println("Placing separator.");
    246263    int separator_index = super.getSize();
    247     if(separator_index > 0) {
     264    int top_separator_index = 0;
     265    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        }
    248271        boolean found_fixed = false;
    249272        int index = separator_index - 1;
    250273        while(index > 0) {
    251         PlugIn plugin = (PlugIn) getElementAt(index);
     274        plugin = (PlugIn) super.getElementAt(index);
    252275        String name = plugin.getName();
    253276        if(name.equals(StaticStrings.RECPLUG_STR) || name.equals(StaticStrings.ARCPLUG_STR)) {
     
    271294    element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, CollectionConfiguration.SEPARATOR_ATTRIBUTE);
    272295    element.setAttribute(CollectionConfiguration.SEPARATOR_ATTRIBUTE, CollectionConfiguration.TRUE_STR);
    273     separator_plugin = new PlugIn(element, null);
     296    bottom_separator_plugin = new PlugIn(element, null);
     297    top_separator_plugin = new PlugIn((Element)element.cloneNode(true), null);
    274298    ///atherer.println("Adding plugin separator at: " + separator_index);
    275     add(separator_index, separator_plugin);
     299    add(separator_index, bottom_separator_plugin);
     300    add(top_separator_index, top_separator_plugin);
    276301    }
    277302
     
    306331    if(modify_row_count) {
    307332        fireIntervalRemoved(this, original_size - 4, original_size - 1);
     333        fireIntervalRemoved(this, 0,1);
    308334    }
    309335    else {
     336        fireIntervalAdded(this, 0, 1);
    310337        fireIntervalAdded(this, original_size - 4, original_size - 1);
    311338    }
    312339    }
    313340
     341    /** Determine the first separat */
    314342    /** Determine the current separator index. */
    315343    private int findSeparatorIndex() {
    316344    int separator_index = super.getSize() - 1;
    317345    while(separator_index >= 0) {
    318         PlugIn search = (PlugIn) getElementAt(separator_index);
     346        PlugIn search = (PlugIn) super.getElementAt(separator_index);
    319347        if(search.isSeparator()) {
    320348        return separator_index;
     
    322350        separator_index--;
    323351    }
     352    System.err.println("separator index is "+separator_index);
    324353    return separator_index;
    325354    }
     
    948977                configure.setEnabled(true);
    949978                String plugin_name = selected_plugin.getName();
    950                 // Some buttons are only available for plugins other than ArcPlug and RecPlug
    951                 if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR)) {
     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)) {
    952981                //move_top_button.setEnabled(false);
    953982                move_up_button.setEnabled(false);
     
    957986                }
    958987                else {
    959                 // Move ups are only enabled if the selected plugin isn't already at the top
    960                 PlugIn first_plugin = (PlugIn) getElementAt(0);
     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);
    961991                if(!first_plugin.equals(selected_plugin)) {
    962992                    //move_top_button.setEnabled(true);
     
    968998                }
    969999                // And move downs are only allowed when the selected plugin isn't at an index one less than the separator line.
    970                 int separator_index = findSeparatorIndex();
     1000                int bottom_index = (modify_row_count ? model.getSize(): findSeparatorIndex());
    9711001                int selected_index = plugin_list.getSelectedIndex();
    972                 if(selected_index != separator_index - 1) {
     1002                if(selected_index < bottom_index - 1) {
    9731003                    move_down_button.setEnabled(true);
    9741004                    //move_bottom_button.setEnabled(true);
Note: See TracChangeset for help on using the changeset viewer.