Changeset 7252
- Timestamp:
- 2004-04-29T16:24:33+12:00 (20 years ago)
- 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 127 127 metadataset_view = new MetadataSetView(); 128 128 plugin_manager = new PlugInManager(); 129 plugin_manager.placeSeparator ();129 plugin_manager.placeSeparators(); 130 130 subcollection_manager = new SubcollectionManager(); 131 131 subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes()); -
trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java
r7245 r7252 57 57 /** The library 'reserve' of base plugins. */ 58 58 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. */ 60 60 private boolean modify_row_count = false; 61 61 /** The controls for editing the contents of this manager. */ … … 63 63 private DOMProxyListModel model; 64 64 private JPanel separator; 65 private PlugIn separator_plugin; 65 private PlugIn top_separator_plugin; 66 private PlugIn bottom_separator_plugin; 66 67 /** Constructor. 67 68 */ … … 71 72 model = this; 72 73 // Reload/Create the library 73 loadPlugIns(); 74 loadPlugIns(); // adds all the plugins to the library 74 75 savePlugIns(); 75 76 // Create the separator, cause we can reuse it. … … 91 92 public void assignPlugIn(PlugIn plugin) { 92 93 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); 97 99 } 98 100 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; 99 111 } 100 112 … … 144 156 return null; 145 157 } 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 } 147 165 /** Overrides getSize in DOMProxyListModel to take into account the row count modifier used to hide the last three rows in lower detail modes 148 166 * @return an int indicating the number of rows in the model, or more correctly the desired number of rows to display … … 151 169 int result = super.getSize(); 152 170 if(modify_row_count) { 153 result = result - 3;171 result = result - 5; 154 172 } 155 173 return result; … … 170 188 * @param all true to move to move all the way, false for a single step. 171 189 */ 190 // why are all the error notices there when the buttons are disabled is you cant move??? 172 191 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) { 175 194 //Gatherer.println("Not enough plugins to allow moving."); 176 195 return; 177 196 } 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)) { 179 198 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.Move.Fixed"), Dictionary.get("CDM.Move.Title"), JOptionPane.ERROR_MESSAGE); 180 199 return; … … 185 204 // Remove the moving plugin 186 205 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); //************ 192 207 Gatherer.c_man.configurationChanged(); 193 208 } … … 195 210 // Remove the moving plugin 196 211 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(); 206 215 } 207 216 } … … 219 228 return; 220 229 } 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); 228 231 if(next_plugin.isSeparator()) { 229 232 String args[] = new String[1]; … … 237 240 Gatherer.c_man.configurationChanged(); 238 241 } 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 } 239 256 } 240 257 } … … 242 259 /** 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. 243 260 */ 244 public void placeSeparator () {261 public void placeSeparators() { 245 262 ///ystem.err.println("Placing separator."); 246 263 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 } 248 271 boolean found_fixed = false; 249 272 int index = separator_index - 1; 250 273 while(index > 0) { 251 PlugIn plugin = (PlugIn)getElementAt(index);274 plugin = (PlugIn) super.getElementAt(index); 252 275 String name = plugin.getName(); 253 276 if(name.equals(StaticStrings.RECPLUG_STR) || name.equals(StaticStrings.ARCPLUG_STR)) { … … 271 294 element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, CollectionConfiguration.SEPARATOR_ATTRIBUTE); 272 295 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); 274 298 ///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); 276 301 } 277 302 … … 306 331 if(modify_row_count) { 307 332 fireIntervalRemoved(this, original_size - 4, original_size - 1); 333 fireIntervalRemoved(this, 0,1); 308 334 } 309 335 else { 336 fireIntervalAdded(this, 0, 1); 310 337 fireIntervalAdded(this, original_size - 4, original_size - 1); 311 338 } 312 339 } 313 340 341 /** Determine the first separat */ 314 342 /** Determine the current separator index. */ 315 343 private int findSeparatorIndex() { 316 344 int separator_index = super.getSize() - 1; 317 345 while(separator_index >= 0) { 318 PlugIn search = (PlugIn) getElementAt(separator_index);346 PlugIn search = (PlugIn) super.getElementAt(separator_index); 319 347 if(search.isSeparator()) { 320 348 return separator_index; … … 322 350 separator_index--; 323 351 } 352 System.err.println("separator index is "+separator_index); 324 353 return separator_index; 325 354 } … … 948 977 configure.setEnabled(true); 949 978 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)) { 952 981 //move_top_button.setEnabled(false); 953 982 move_up_button.setEnabled(false); … … 957 986 } 958 987 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); 961 991 if(!first_plugin.equals(selected_plugin)) { 962 992 //move_top_button.setEnabled(true); … … 968 998 } 969 999 // 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()); 971 1001 int selected_index = plugin_list.getSelectedIndex(); 972 if(selected_index != separator_index - 1) {1002 if(selected_index < bottom_index - 1) { 973 1003 move_down_button.setEnabled(true); 974 1004 //move_bottom_button.setEnabled(true);
Note:
See TracChangeset
for help on using the changeset viewer.