source: trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java@ 10332

Last change on this file since 10332 was 10237, checked in by mdewsnip, 19 years ago

New code for "incremental" building, by Matthew Whyte.

I've only had time to look at this briefly; I've fixed a few obvious problems but I imagine this will be pretty flaky for a while.

  • Property svn:keywords set to Author Date Id Revision
File size: 67.5 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26 */
27package org.greenstone.gatherer.cdm;
28
29import java.awt.*;
30import java.awt.event.*;
31import java.util.*;
32import javax.swing.*;
33import javax.swing.event.*;
34import org.greenstone.gatherer.Configuration;
35import org.greenstone.gatherer.DebugStream;
36import org.greenstone.gatherer.Dictionary;
37import org.greenstone.gatherer.Gatherer;
38import org.greenstone.gatherer.gui.GComboBox;
39import org.greenstone.gatherer.gui.GLIButton;
40import org.greenstone.gatherer.metadata.MetadataElement;
41import org.greenstone.gatherer.metadata.MetadataSetManager;
42import org.greenstone.gatherer.util.CheckList;
43import org.greenstone.gatherer.util.JarTools;
44import org.greenstone.gatherer.util.StaticStrings;
45import org.w3c.dom.*;
46/** This class is resposible for storing the indexes which have been assigned to this collection and the default index, and providing methods for interacting with both these data pools. It also knows how to turn itself into a String as it would be displayed in the collection configuration file.
47 * @author John Thompson, Greenstone Digital Library, University of Waikato
48 * @version 2.3
49 */
50public class IndexManager
51 extends DOMProxyListModel {
52
53 static final private Dimension FIELD_SIZE = new Dimension(200,30);
54 static final private String MGINDEXES = "mg indexes";
55 static final private String MGPPINDEXES = "mgpp indexes";
56
57 /** The controls for editing the indexes. */
58 private Control controls = null;
59 /** A model of the levels, also based on the DOM. */
60 private DOMProxyListModel levels_model = null;
61 /** A reference to ourselves so our inner methods have access. */
62 private DOMProxyListModel model = null;
63 /** The default index. */
64 private Index default_index = null;
65
66 /** Constructor. */
67 public IndexManager(Element indexes) {
68 super(indexes, CollectionConfiguration.INDEX_ELEMENT, new Index());
69 DebugStream.println("IndexManager: " + getSize() + " indexes parsed.");
70 model = this;
71 // Parse and retrieve the default index
72 NodeList default_index_elements = CollectionDesignManager.collect_config.getDocumentElement().getElementsByTagName(CollectionConfiguration.INDEX_DEFAULT_ELEMENT);
73 if(default_index_elements.getLength() > 0) {
74 default_index = new Index((Element)default_index_elements.item(0));
75 }
76 // Parse and retrieve the levels element
77 Element levels_element = CollectionDesignManager.collect_config.getLevels();
78 levels_model = new DOMProxyListModel(levels_element, CollectionConfiguration.CONTENT_ELEMENT, new Level());
79 DebugStream.println(" + " + levels_model.getSize() + " levels parsed.");
80 }
81
82 /** Method to add a new index.
83 * @param index The <strong>Index</strong> to add.
84 * @see org.greenstone.gatherer.Gatherer
85 * @see org.greenstone.gatherer.collection.CollectionManager
86 */
87 private void addIndex(Index index, CollectionMeta metadatum) {
88 ///ystem.err.println("Adding an index: " + index.toString());
89 if(!contains(index)) {
90 CollectionDesignManager.collectionmeta_manager.addMetadatum(metadatum);
91 // Retrieve the currently last index
92 if(getSize() > 0) {
93 Index last_index = (Index)getElementAt(getSize() - 1);
94 addAfter(index, last_index);
95
96 }
97 else {
98 add(index);
99 // Also set this index as the default one, but only if there are levels available (ie mg only)
100 if(index.getLevel() != -1) {
101 setDefault(index);
102 }
103 }
104 Gatherer.c_man.configurationChanged();
105 }
106 else {
107 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.IndexManager.Index_Exists"), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);
108 }
109 }
110
111 private void addLevel(Level level, CollectionMeta metadatum) {
112 if(!levels_model.contains(level)) {
113 CollectionDesignManager.collectionmeta_manager.addMetadatum(metadatum);
114 // Retrieve the currently last level
115 if(levels_model.getSize() > 0) {
116 Level last_level = (Level)levels_model.getElementAt(levels_model.getSize() - 1);
117 levels_model.addAfter(level, last_level);
118 }
119 else {
120 levels_model.add(level);
121 }
122 Gatherer.c_man.configurationChanged();
123 }
124 else {
125 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.IndexManager.Level_Exists"), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);
126 }
127 }
128
129 public void destroy() {
130 if(controls != null) {
131 controls.destroy();
132 controls = null;
133 }
134 default_index = null;
135 model = null;
136 }
137
138 /** Method to acquire the controls for editing the indexes.
139 * @return the Control
140 */
141 public Control getControls() {
142 if(controls == null) {
143 // Build controls
144 controls = new IndexControl();
145 }
146 return controls;
147 }
148
149 /** Method to get the default index.
150 * @return The default <strong>Index</strong>.
151 */
152 public Index getDefault() {
153 if(default_index != null && default_index.isAssigned()) {
154 return default_index;
155 }
156 else {
157 return null;
158 }
159 }
160
161 /** Method to retrieve a certain index, as referenced by an index number.
162 * @param index An <i>int</i> which indicates the position of the desired index.
163 * @return The <strong>Index</strong> at the given index, or <i>null</i> if no such index exists.
164 */
165 public Index getIndex(int index) {
166 if(0 <= index && index < getSize()) {
167 return (Index)getElementAt(index);
168 }
169 return null;
170 }
171
172 /** Method to retrieve a certain index, given its id.
173 * @param id the id of the index as a String
174 * @return the Index that matches id, or null if no such index exists
175 */
176 public Index getIndex(String id) {
177 int size = getSize();
178 for(int i = 0; i < size; i++) {
179 Index index = (Index) getElementAt(i);
180 if(index.getID().equals(id)) {
181 return index;
182 }
183 }
184 return null;
185 }
186
187 public ArrayList getIndexes() {
188 return children();
189 }
190
191 public Level getLevel(String name) {
192 int levels_model_size = levels_model.getSize();
193 for(int i = 0; i < levels_model_size; i++) {
194 Level level = (Level) levels_model.getElementAt(i);
195 if(level.getLevel().equals(name)) {
196 return level;
197 }
198 }
199 return null;
200 }
201
202
203 private void moveIndex(Index index, boolean move_up)
204 {
205 // Determine the current position of the index
206 int position = indexOf(index);
207 // Determine if it can be moved, ie if its not already at the top trying to move up, or at the bottom trying to move down.
208 if(position == -1) {
209 return;
210 }
211 if(position == 0 && move_up) {
212 return;
213 }
214 if(position == (getSize()) - 1 && !move_up) {
215 return;
216 }
217
218 // Ok, move up
219 if (move_up) {
220 position--;
221 remove(index);
222 add(position, index);
223 }
224
225 // Or move down
226 else {
227 position++;
228 remove(index);
229 add(position, index);
230 }
231
232 // Schedule the collection for saving
233 Gatherer.c_man.configurationChanged();
234 }
235
236
237 private void moveLevel(Level level, boolean move_up) {
238 // Determine the leveles current position
239 int position = levels_model.indexOf(level);
240 // Determine if it can be moved, ie if its not already at the top trying to move up, or at the bottom trying to move down.
241 if(position == -1) {
242 return;
243 }
244 if(position == 0 && move_up) {
245 return;
246 }
247 if(position == (levels_model.getSize()) - 1 && !move_up) {
248 return;
249 }
250 // Ok, move up
251 if(move_up) {
252 position--;
253 levels_model.remove(level);
254 levels_model.add(position, level);
255 }
256 // Or move down
257 else {
258 position++;
259 levels_model.remove(level);
260 levels_model.add(position, level);
261 }
262 // Schedule the collection for saving
263 Gatherer.c_man.configurationChanged();
264 }
265
266 /** Method to remove a certain index.
267 * @param index the Index to remove.
268 * @see org.greenstone.gatherer.Gatherer
269 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
270 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
271 * @see org.greenstone.gatherer.collection.CollectionManager
272 */
273 private void removeIndex(Index index) {
274 if(index != null) {
275 // Remove any current metadata from this index
276 CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + index.getID());
277 // Check if the index removed happens to be the default index
278 if(default_index != null && default_index.equals(index)) {
279 // If so our first solution is to set the first index to be default
280 if(getSize() > 0) {
281 Index another_index = (Index) getElementAt(0);
282 setDefault(another_index);
283 another_index = null;
284 }
285 else {
286 default_index.setAssigned(false);
287 }
288 }
289 // Remove the index
290 remove(index);
291 Gatherer.c_man.configurationChanged();
292 }
293 }
294
295 private void removeLevel(Level level) {
296 if(level != null) {
297 // Remove any current metadata from this level
298 CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + level.getLevel());
299 // Remove the level
300 levels_model.remove(level);
301 Gatherer.c_man.configurationChanged();
302 }
303 }
304
305 /** Method to set the default index.
306 * @param index the new default Index
307 * @see org.greenstone.gatherer.Gatherer
308 * @see org.greenstone.gatherer.collection.CollectionManager
309 */
310 public void setDefault(Index index) {
311 if(index != null) {
312 if(default_index == null) {
313 // Create the default index element, and place immediately after indexes element.
314 Element default_index_element = root.getOwnerDocument().createElement(CollectionConfiguration.INDEX_DEFAULT_ELEMENT);
315 default_index = new Index(default_index_element);
316 Node target_node = CollectionConfiguration.findInsertionPoint(default_index_element);
317 if(target_node != null) {
318 root.getOwnerDocument().getDocumentElement().insertBefore(default_index_element, target_node);
319 }
320 else {
321 root.getOwnerDocument().getDocumentElement().appendChild(default_index_element);
322 }
323 }
324 default_index.setAssigned(true);
325 default_index.setLevel(index.getLevel());
326 default_index.setSources(index.getSources());
327 }
328 else {
329 if(default_index != null) {
330 default_index.setAssigned(false);
331 }
332 }
333 Gatherer.c_man.configurationChanged();
334 }
335
336 /** This method is reponsible for changing the underlying Index commands from MG to MGPP and back again. This turns out to be easyish for MG->MGPP and very hard for the reverse. For the former we remove the level fragment and make sure the same levels are set, then we produce a list of the sources involved, breaking down comma seperated lists and making sure each item it unique. Changing back the other way turns out to be impossible, so we don't (beyond generating document:text, section:text and paragraph:text if text is an index and the respective levels are present). In either case we start by creating a comment containing the old index information.
337 * @param state true to enable MGPP indexes, false to use standard MG style ones
338 */
339 public void setMGPPEnabled(boolean state) {
340 if(state == root.getAttribute(CollectionConfiguration.MGPP_ATTRIBUTE).equals(CollectionConfiguration.TRUE_STR)) {
341 // we are not changing state
342 return;
343
344 }
345 // change MG -> MGPP
346 if(state) {
347 Element mg_element = root;
348 // Retrieve and assign the MGPP indexes element.
349 Element mgpp_element = CollectionDesignManager.collect_config.getMGPPIndexes();
350 mgpp_element.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.TRUE_STR);
351 levels_model.root.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.TRUE_STR);
352 // If the MGPP indexes element is empty (ie was created by CollectionConfiguration), generate new MGPP index from the existing index
353 NodeList indexes = mgpp_element.getElementsByTagName(CollectionConfiguration.INDEX_ELEMENT);
354 if(indexes.getLength() == 0) {
355 ArrayList levels_list = new ArrayList();
356 ArrayList sources_list = new ArrayList();
357 // We first use details from the default index if any
358 if(default_index != null) {
359 int level_int = default_index.getLevel();
360 if(0 <= level_int && level_int < 3) {
361 String level = Index.LEVEL[level_int];
362 if(!levels_list.contains(level)) {
363 levels_list.add(level);
364 }
365 level = null;
366 }
367 ArrayList sources = default_index.getSources();
368 sources.removeAll(sources_list);
369 sources_list.addAll(sources);
370 }
371 int size = getSize();
372 for(int i = 0; i < size; i++) {
373 Index index = (Index) getElementAt(i);
374 int level_int = index.getLevel();
375 if(0 <= level_int && level_int < 3) {
376 String level = Index.LEVEL[level_int];
377 if(!levels_list.contains(level)) {
378 levels_list.add(level);
379 }
380 level = null;
381 }
382 ArrayList sources = index.getSources();
383 sources.removeAll(sources_list);
384 sources_list.addAll(sources);
385 index = null;
386 }
387 // Replace mg element with mgpp element
388 setRoot(mgpp_element);
389
390 // We now have a list of sources and a list of levels, so create new indexes and levels based on these
391 int sources_list_size = sources_list.size();
392 for(int j = 0; j < sources_list_size; j++) {
393 Object source_object = sources_list.get(j);
394 String source_str = null;
395 if(source_object instanceof MetadataElement) {
396 source_str = ((MetadataElement) source_object).getFullName();
397 }
398 else {
399 source_str = source_object.toString();
400 }
401 ArrayList new_sources = new ArrayList();
402 new_sources.add(source_object);
403 source_object = null;
404 Index new_index = new Index(new_sources);
405 // Try to retrieve existing metadatum
406 source_str = new_index.getID();
407 CollectionMeta metadatum = CollectionDesignManager.collectionmeta_manager.getMetadatum(CollectionConfiguration.STOP_CHARACTER + source_str, false);
408 // If no metadata was found, add new pseudo metadata using the id
409 if(metadatum == null) {
410 metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + source_str);
411 metadatum.setAssigned(true);
412 metadatum.setValue(source_str);
413 }
414 // If it was found, ensure it is assigned
415 else {
416 metadatum.setAssigned(true);
417 }
418 source_str = null;
419 addIndex(new_index, metadatum);
420 metadatum = null;
421 new_index = null;
422 new_sources = null;
423 source_str = null;
424 }
425 int levels_list_size = levels_list.size();
426 for(int k = 0; k < levels_list_size; k++) {
427 Level new_level = new Level((String)levels_list.get(k));
428 if(!levels_model.contains(new_level)) {
429 levels_model.add(levels_model.getSize(), new_level);
430 }
431 new_level = null;
432 }
433 }
434 else {
435 // Replace mg element with mgpp element
436 setRoot(mgpp_element);
437 }
438 // Unassign MG element and default index
439 mg_element.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.FALSE_STR);
440 mg_element = null;
441 if(default_index != null) {
442 default_index.setAssigned(false);
443 }
444 }
445 // change MGPP -> MG
446 else {
447 Element mgpp_element = root;
448 // Retrieve and assign MG element and default index element
449 Element mg_element = CollectionDesignManager.collect_config.getMGIndexes();
450 mg_element.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.TRUE_STR);
451 if(default_index != null) {
452 default_index.setAssigned(true);
453 }
454 // If mg element has no indexes, and the current mgpp index include a text one, then generate text indexes for each of the registered levels.
455 NodeList indexes = mgpp_element.getElementsByTagName(CollectionConfiguration.INDEX_ELEMENT);
456 if(indexes.getLength() == 0) {
457 Index index = getIndex(CollectionConfiguration.TEXT_STR);
458 if(index != null) {
459 // Replace mgpp element with mg element
460 setRoot(mg_element);
461 int level_size = levels_model.getSize();
462 for(int i = 0; i < level_size; i++) {
463 Level level = (Level) levels_model.getElementAt(i);
464 Index new_index = new Index(level.getLevel(), index.getSources());
465 // Try to retrieve existing metadatum
466 String source_str = new_index.getID();
467 CollectionMeta metadatum = CollectionDesignManager.collectionmeta_manager.getMetadatum(CollectionConfiguration.STOP_CHARACTER + source_str, false);
468 // If no metadata was found, add new pseudo metadata using the id
469 if(metadatum == null) {
470 metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + source_str);
471 metadatum.setAssigned(true);
472 metadatum.setValue(source_str);
473 }
474 // If it was found, ensure it is assigned
475 else {
476 metadatum.setAssigned(true);
477 }
478 source_str = null;
479 addIndex(new_index, metadatum);
480 new_index = null;
481 level = null;
482 }
483 }
484 }
485 else {
486 // Replace mgpp element with mg element
487 setRoot(mg_element);
488 }
489 // Unassign mgpp element and levels
490 mgpp_element.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.FALSE_STR);
491 levels_model.root.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, CollectionConfiguration.FALSE_STR);
492 }
493
494 }
495
496
497 /** This class creates a set of controls for editing the indexes. */
498 private class IndexControl
499 extends JPanel
500 implements Control {
501
502 private CardLayout card_layout;
503 private CheckList source_list;
504 private JButton add_button;
505 private JButton move_down_button;
506 private JButton move_up_button;
507 private JButton remove_button;
508 private JButton replace_button;
509 private JButton set_default_button;
510 private JComboBox level_combobox;
511 private JList index_list;
512 private JTextArea instruction_textarea;
513 private JTextField name_textfield ;
514 // when we are in mgpp mode, we want to remove the mg listener
515 // the underlying model is the same between the two JLists, and
516 // both listeners get notified when the model changes, but the mg
517 // listener doesn't care about mgpp events
518 private ListSelectionListener index_list_listener;
519
520 private MGPPControl mgppindexes_control;
521
522 /** Constructor.
523 * @see org.greenstone.gatherer.Configuration
524 * @see org.greenstone.gatherer.Gatherer
525 * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.AddListener
526 * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.NameListener
527 * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.RemoveListener
528 * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.SetDefaultListener
529 * @see org.greenstone.gatherer.collection.CollectionManager
530 */
531 public IndexControl() {
532 super();
533
534 ArrayList new_data = new ArrayList();
535 new_data.add(CollectionConfiguration.TEXT_STR);
536 new_data.addAll(MetadataSetManager.getEveryMetadataSetElement());
537 // Creation
538 JPanel mgindexes_panel = new JPanel();
539 card_layout = new CardLayout();
540
541 // MG Index Controls
542
543 JPanel mg_indexes_pane = new JPanel();
544
545 JPanel instruction_pane = new JPanel();
546 JLabel title_label = new JLabel();
547 title_label.setHorizontalAlignment(JLabel.CENTER);
548 Dictionary.registerText(title_label, "CDM.IndexManager.Title");
549
550 instruction_textarea = new JTextArea();
551 instruction_textarea.setEditable(false);
552 instruction_textarea.setLineWrap(true);
553 instruction_textarea.setRows(6);
554 instruction_textarea.setWrapStyleWord(true);
555 Dictionary.registerText(instruction_textarea, "CDM.IndexManager.Instructions");
556
557 JPanel assigned_indexes_pane = new JPanel();
558 JLabel index_label = new JLabel();
559 Dictionary.registerText(index_label, "CDM.IndexManager.Indexes");
560 index_list = new JList(model);
561 index_list.setCellRenderer(new IndexListRenderer());
562 index_list.setVisibleRowCount(2);
563 JPanel movement_pane = new JPanel();
564
565 move_up_button = new JButton("", JarTools.getImage("arrow-up.gif"));
566 move_up_button.setEnabled(false);
567 move_up_button.setMnemonic(KeyEvent.VK_U);
568 Dictionary.registerBoth(move_up_button, "CDM.Move.Move_Up", "CDM.Move.Move_Up_Tooltip");
569
570 move_down_button = new JButton("", JarTools.getImage("arrow-down.gif"));
571 move_down_button.setEnabled(false);
572 move_down_button.setMnemonic(KeyEvent.VK_D);
573 Dictionary.registerBoth(move_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip");
574
575 set_default_button = new GLIButton();
576 set_default_button.setEnabled(false);
577 set_default_button.setMnemonic(KeyEvent.VK_S);
578 Dictionary.registerBoth(set_default_button, "CDM.IndexManager.Set_Default", "CDM.IndexManager.Set_Default_Tooltip");
579
580 JPanel index_pane = new JPanel();
581 JPanel details_pane = new JPanel();
582 JPanel labels_pane = new JPanel();
583 JPanel boxes_pane = new JPanel();
584 JPanel content_pane = new JPanel();
585
586 JLabel name_label = new JLabel();
587 Dictionary.registerText(name_label, "CDM.IndexManager.Index_Name");
588 name_textfield = new JTextField();
589 name_textfield.setPreferredSize(FIELD_SIZE);
590 Dictionary.registerTooltip(name_textfield, "CDM.IndexManager.Index_Name_Tooltip");
591
592 JLabel source_label = new JLabel();
593 Dictionary.registerText(source_label, "CDM.IndexManager.Source");
594 source_list = new CheckList(false);
595 source_list.setListData(new_data);
596 Dictionary.registerTooltip(source_list, "CDM.IndexManager.Source_Tooltip");
597
598 JLabel level_label = new JLabel();
599 Dictionary.registerText(level_label, "CDM.IndexManager.Level");
600 level_combobox = new JComboBox();
601 level_combobox.setPreferredSize(FIELD_SIZE);
602 level_combobox.addItem(CollectionConfiguration.DOCUMENT_STR);//Dictionary.get("CDM.IndexManager.Document"));
603 level_combobox.addItem(CollectionConfiguration.PARAGRAPH_STR);//Dictionary.get("CDM.IndexManager.Paragraph"));
604 level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section"));
605 level_combobox.setEditable(false);
606 Dictionary.registerTooltip(level_combobox, "CDM.IndexManager.Level_Tooltip");
607
608 JPanel button_pane = new JPanel();
609 add_button = new GLIButton();
610 add_button.setEnabled(false);
611 add_button.setMnemonic(KeyEvent.VK_A);
612 Dictionary.registerBoth(add_button, "CDM.IndexManager.Add_Index", "CDM.IndexManager.Add_Index_Tooltip");
613
614 remove_button = new GLIButton();
615 remove_button.setEnabled(false);
616 remove_button.setMnemonic(KeyEvent.VK_R);
617 Dictionary.registerBoth(remove_button, "CDM.IndexManager.Remove_Index", "CDM.IndexManager.Remove_Index_Tooltip");
618 replace_button = new GLIButton();
619 replace_button.setEnabled(false);
620 replace_button.setMnemonic(KeyEvent.VK_P);
621 Dictionary.registerBoth(replace_button, "CDM.IndexManager.MGPP.Replace_Index", "CDM.IndexManager.MGPP.Replace_Index_Tooltip");
622
623 // This class is getting a little crowded, so I'll generate the many mgpp controls in a inner class.
624 mgppindexes_control = new MGPPControl();
625
626 // Listeners
627 add_button.addActionListener(new AddListener());
628 add_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
629 move_down_button.addActionListener(new MoveListener(false));
630 move_down_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
631 move_up_button.addActionListener(new MoveListener(true));
632 move_up_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
633 remove_button.addActionListener(new RemoveListener());
634 remove_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
635 replace_button.addActionListener(new ReplaceListener());
636 replace_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
637 set_default_button.addActionListener(new SetDefaultListener());
638 set_default_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
639 name_textfield.getDocument().addDocumentListener(new NameListener());
640 level_combobox.addItemListener(new LevelListener());
641 // Create the index_list_listener but don't add in to the list - this gets done in gainFocus, we don't want it twice.
642 index_list_listener = new IndexListListener();
643 source_list.addListSelectionListener(new SourceListListener());
644
645 // Layout
646 instruction_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
647 instruction_pane.setLayout(new BorderLayout());
648 instruction_pane.add(title_label, BorderLayout.NORTH);
649 instruction_pane.add(new JScrollPane(instruction_textarea), BorderLayout.CENTER);
650
651 movement_pane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0));
652 movement_pane.setLayout(new GridLayout(3,1));
653 movement_pane.add(move_up_button);
654 movement_pane.add(move_down_button);
655 movement_pane.add(set_default_button);
656
657 assigned_indexes_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
658 assigned_indexes_pane.setLayout(new BorderLayout());
659 assigned_indexes_pane.add(index_label, BorderLayout.NORTH);
660 assigned_indexes_pane.add(new JScrollPane(index_list), BorderLayout.CENTER);
661 assigned_indexes_pane.add(movement_pane, BorderLayout.EAST);
662
663 labels_pane.setLayout(new BorderLayout());
664 labels_pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));
665 labels_pane.add(name_label, BorderLayout.NORTH);
666 labels_pane.add(source_label, BorderLayout.CENTER);
667 labels_pane.add(level_label, BorderLayout.SOUTH);
668
669 boxes_pane.setLayout(new BorderLayout());
670 boxes_pane.add(name_textfield, BorderLayout.NORTH);
671 boxes_pane.add(new JScrollPane(source_list), BorderLayout.CENTER);
672 boxes_pane.add(level_combobox, BorderLayout.SOUTH);
673
674 details_pane.setLayout(new BorderLayout());
675 details_pane.add(labels_pane, BorderLayout.WEST);
676 details_pane.add(boxes_pane, BorderLayout.CENTER);
677
678 button_pane.setLayout(new GridLayout(1,3));
679 button_pane.add(add_button);
680 button_pane.add(replace_button);
681 button_pane.add(remove_button);
682
683 index_pane.setLayout(new BorderLayout());
684 index_pane.add(details_pane, BorderLayout.CENTER);
685 index_pane.add(button_pane, BorderLayout.SOUTH);
686
687 content_pane.setLayout(new BorderLayout());
688 content_pane.add(assigned_indexes_pane, BorderLayout.NORTH);
689 content_pane.add(index_pane, BorderLayout.CENTER);
690
691 mgindexes_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
692 mgindexes_panel.setLayout(new BorderLayout());
693 mgindexes_panel.add(instruction_pane, BorderLayout.NORTH);
694 mgindexes_panel.add(content_pane, BorderLayout.CENTER);
695
696 setLayout(card_layout);
697 add(mgindexes_panel, MGINDEXES);
698 add(mgppindexes_control, MGPPINDEXES);
699 }
700
701
702 /* Destructor, removes persistant listeners from the Dictionary.
703 */
704 public void destroy() {
705 mgppindexes_control.destroy();
706 mgppindexes_control = null;
707 }
708
709 public void gainFocus() {
710 boolean mgpp_enabled = CollectionDesignManager.searchtype_manager.isMGPPEnabled();
711 if(instruction_textarea != null) {
712 instruction_textarea.setCaretPosition(0);
713 }
714 if(mgpp_enabled) {
715 // remove the mg index list listener first
716 index_list.removeListSelectionListener(index_list_listener);
717 mgppindexes_control.gainFocus();
718 }
719 else {
720 // remove the mgpp listener first
721 mgppindexes_control.removeIndexListListener();
722 // add the mg listener back in
723 index_list.addListSelectionListener(index_list_listener);
724 // Reload the assigned indexes list.
725 ArrayList new_data = new ArrayList();
726 new_data.add(CollectionConfiguration.TEXT_STR);
727 new_data.addAll(MetadataSetManager.getEveryMetadataSetElement());
728 // reset the model in the list and combobox
729 source_list.setListData(new_data);
730 new_data = null;
731 // refresh the indexList
732 index_list.updateUI();
733 // if there is one selected, fill in the controls
734 updateControlsWithSelectedIndex();
735 }
736 // Bring the appropriate card to the front
737 if(mgpp_enabled) {
738 card_layout.show(this, MGPPINDEXES);
739 }
740 else {
741 card_layout.show(this, MGINDEXES);
742 }
743 }
744
745 public void loseFocus() {
746 }
747
748 private void updateControlsWithSelectedIndex() {
749
750 Index selected_index = (Index)index_list.getSelectedValue();
751 if (selected_index == null) {
752 return;
753 }
754 String id = selected_index.getID();
755 if (id == null || id.equals("")) {
756 return;
757 }
758 String name = CollectionDesignManager.collectionmeta_manager.getMetadatum("." + id).getValue(true);
759 name_textfield.setText(name);
760 level_combobox.setSelectedIndex(selected_index.getLevel());
761 source_list.clearTicked();
762 ArrayList sources = selected_index.getSources();
763 source_list.setTickedObjects(sources.toArray());
764
765 }
766
767 private void validateAddButton()
768 {
769 boolean add_enabled = false;
770 boolean replace_enabled = false;
771
772 // Indexes must have a name
773 if (name_textfield.getText().length() == 0) {
774 add_enabled = false;
775 }
776 // Can't add a new index if no sources are selected
777 else if (source_list.isNothingTicked()) {
778 add_enabled = false;
779 }
780 // If we get this far, create a dummy index and see if it's already assigned in the collection
781 else {
782 Object object[] = source_list.getTicked().toArray();
783 ArrayList sources = new ArrayList();
784 for(int i = 0; i < object.length; i++) {
785 sources.add(object[i]);
786 }
787 object = null;
788 Index index = new Index(level_combobox.getSelectedIndex(), sources);
789 sources = null;
790 if (model.contains(index)) {
791 add_enabled = false;
792
793 // Here we need to check if we have changed the name - if so, we can enable the replace button
794 if (index_list.getSelectedIndex() != -1) {
795 Index selected_index = (Index)index_list.getSelectedValue();
796 String name = name_textfield.getText();
797 String index_name = CollectionDesignManager.collectionmeta_manager.getMetadatum(CollectionConfiguration.STOP_CHARACTER+selected_index.getID()).getValue(true);
798 if (!index_name.equals(name)){
799 replace_enabled = true;
800 }
801 }
802 }
803 else {
804 add_enabled = true;
805
806 // We have a new index, do we have something selected in the index list? if so, enable the replace button
807 if (index_list.getSelectedIndex() != -1) {
808 replace_enabled = true;
809 }
810 }
811 }
812
813 // We should now know the add_button state
814 add_button.setEnabled(add_enabled);
815 replace_button.setEnabled(replace_enabled);
816 }
817
818
819 private class AddListener
820 implements ActionListener
821 {
822 public void actionPerformed(ActionEvent event)
823 {
824 String name = name_textfield.getText();
825 if (!source_list.isNothingTicked() && name.length() != 0) {
826 ArrayList sources = source_list.getTicked();
827 Index index = new Index(level_combobox.getSelectedIndex(), sources);
828
829 // Before we add the index to the model, we have to add the collection metadata for this
830 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
831 metadatum.setValue(name);
832
833 // Finally, add the index
834 addIndex(index, metadatum);
835 index_list.setSelectedValue(index, true);
836 }
837 }
838 }
839
840
841 /** Listens for selections within the list on the IndexManager controls, and if a change is detected enables, or disables, controls appropriately. */
842 private class IndexListListener
843 implements ListSelectionListener
844 {
845 /** This method is called whenever the source list selection changes. When it does we need to fill in the various parts of the list description panel
846 * @param event A <strong>ListSelectionEvent</strong> containing further information about the list selection.
847 */
848 public void valueChanged(ListSelectionEvent event)
849 {
850 if (event.getValueIsAdjusting()) {
851 return;
852 }
853
854 Object value = index_list.getSelectedValue();
855 if (value == null) {
856 move_down_button.setEnabled(false);
857 move_up_button.setEnabled(false);
858 remove_button.setEnabled(false);
859 replace_button.setEnabled(false);
860 set_default_button.setEnabled(false);
861 return;
862 }
863
864 // Enable the buttons appropriately
865 remove_button.setEnabled(true);
866 set_default_button.setEnabled(default_index == null || !default_index.equals(value));
867 int i = index_list.getSelectedIndex();
868 int size = index_list.getModel().getSize();
869 if (i > 0) {
870 move_up_button.setEnabled(true);
871 }
872 else {
873 move_up_button.setEnabled(false);
874 }
875 if (i < size-1){
876 move_down_button.setEnabled(true);
877 }
878 else {
879 move_down_button.setEnabled(false);
880 }
881
882 // Need to fill in the rest of the bits
883 updateControlsWithSelectedIndex();
884 }
885 }
886
887 private class IndexListRenderer
888 extends DefaultListCellRenderer {
889
890 /** Return a component that has been configured to display the specified value. */
891 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
892 JLabel component = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
893 if(default_index != null && default_index.equals(value)) {
894 component.setText(component.getText() + " " + Dictionary.get("CDM.IndexManager.Default_Index_Indicator"));
895 }
896 return component;
897 }
898
899 }
900
901 private class LevelListener
902 implements ItemListener {
903 public void itemStateChanged(ItemEvent event) {
904 if(event.getStateChange() == ItemEvent.SELECTED) {
905 // just want to validate the add button
906 validateAddButton();
907
908 }
909 }
910 }
911
912 private class MoveListener
913 implements ActionListener {
914
915 private boolean move_up;
916
917 public MoveListener(boolean move_up) {
918 this.move_up = move_up;
919 }
920
921 public void actionPerformed(ActionEvent event) {
922 // Retrieve the selected index
923 Index index = (Index) index_list.getSelectedValue();
924 if(index != null) {
925 moveIndex(index, move_up);
926 // Ensure the index that moved is still selected
927 index_list.setSelectedValue(index, true);
928 index = null;
929 }
930 }
931 }
932
933
934 /** Listens for key presses within the name field, and enabled or disables controls as appropriate. */
935 private class NameListener
936 implements DocumentListener
937 {
938 public void changedUpdate(DocumentEvent e)
939 {
940 validateAddButton();
941 }
942
943 public void insertUpdate(DocumentEvent e)
944 {
945 validateAddButton();
946 }
947
948 public void removeUpdate(DocumentEvent e)
949 {
950 validateAddButton();
951 }
952 }
953
954
955 private class RemoveListener
956 implements ActionListener
957 {
958 public void actionPerformed(ActionEvent event)
959 {
960 int i = index_list.getSelectedIndex();
961 if (i != -1) {
962 removeIndex((Index) index_list.getSelectedValue());
963 }
964 int size = index_list.getModel().getSize();
965 if (i == size) {
966 i--;
967 }
968 index_list.setSelectedIndex(i);
969
970 // This will produce an event on the list, updating the other buttons
971 if (size == 0) {
972 // We have removed the last index, should be able to add what's filled in currently, if valid
973 validateAddButton();
974 }
975 }
976 }
977
978
979 private class ReplaceListener
980 implements ActionListener
981 {
982 public void actionPerformed(ActionEvent event)
983 {
984 if (index_list.isSelectionEmpty()) {
985 // This should never happen, but just in case...
986 replace_button.setEnabled(false);
987 return;
988 }
989
990 // We'll just remove the old one and add the new one
991 removeIndex((Index) index_list.getSelectedValue());
992 replace_button.setEnabled(false);
993 add_button.setEnabled(true);
994 add_button.doClick();
995 add_button.setEnabled(false);
996 }
997 }
998
999
1000 private class SetDefaultListener
1001 implements ActionListener {
1002
1003 public void actionPerformed(ActionEvent event) {
1004 Index index = (Index) index_list.getSelectedValue();
1005 if(index != null) {
1006 setDefault(index);
1007 // This should cause a repaint of just the desired row
1008 index_list.setSelectedValue(index, true);
1009 }
1010 set_default_button.setEnabled(false);
1011 }
1012 }
1013
1014
1015 private class SourceListListener
1016 implements ListSelectionListener
1017 {
1018 public void valueChanged(ListSelectionEvent event)
1019 {
1020 validateAddButton();
1021 }
1022 }
1023 }
1024
1025 private class MGPPControl
1026 extends JPanel {
1027
1028 private GComboBox index_combobox;
1029 private GComboBox level_combobox;
1030 private JButton add_index_button;
1031 private JButton add_all_button;
1032 private JButton add_level_button;
1033 private JButton move_index_down_button;
1034 private JButton move_level_down_button;
1035 private JButton move_index_up_button;
1036 private JButton move_level_up_button;
1037 private JButton replace_index_button;
1038 private JButton remove_index_button;
1039 private JButton remove_level_button;
1040 private JLabel current_levels_label;
1041 private JLabel current_indexes_label;
1042 private JLabel index_label;
1043 private JLabel index_name_label;
1044 private JLabel level_label;
1045 private JLabel level_name_label;
1046 private JLabel move_index_down_label;
1047 private JLabel move_level_down_label;
1048 private JLabel move_index_up_label;
1049 private JLabel move_level_up_label;
1050 private JLabel title_label;
1051 private JList current_levels_list;
1052 private JList current_indexes_list;
1053 private JTabbedPane tabbed_pane;
1054 private JTextArea instructions_textarea;
1055 private JTextField index_name_field;
1056 private JTextField level_name_field;
1057
1058 // when we are in mg mode, we want to remove the mgpp listener
1059 // the underlying model is the same between the two JLists, and
1060 // both listeners get notified when the model changes, but the mgpp
1061 // listener doesn't care about mg events
1062 private ListSelectionListener mgpp_index_list_listener;
1063
1064 public MGPPControl() {
1065 // Create Indexes
1066 JPanel indexes_panel = new JPanel();
1067
1068 JPanel current_indexes_panel = new JPanel();
1069
1070 current_indexes_label = new JLabel();
1071 Dictionary.registerText(current_indexes_label, "CDM.IndexManager.MGPP.Current_Indexes");
1072 current_indexes_list = new JList(model);
1073 current_indexes_list.setVisibleRowCount(5);
1074 current_indexes_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1075
1076 JPanel index_movement_panel = new JPanel();
1077
1078 move_index_up_button = new JButton("", JarTools.getImage("arrow-up.gif"));
1079 move_index_up_button.setEnabled(false);
1080 move_index_up_button.setMnemonic(KeyEvent.VK_U);
1081 Dictionary.registerBoth(move_index_up_button, "CDM.Move.Move_Up", "CDM.Move.Move_Up_Tooltip");
1082
1083 move_index_down_button = new JButton("", JarTools.getImage("arrow-down.gif"));
1084 move_index_down_button.setEnabled(false);
1085 move_index_down_button.setMnemonic(KeyEvent.VK_D);
1086 Dictionary.registerBoth(move_index_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip");
1087
1088 JPanel index_spacer_panel = new JPanel();
1089 JPanel index_body_panel = new JPanel();
1090 JPanel index_details_panel = new JPanel();
1091 JPanel index_labels_panel = new JPanel();
1092
1093 index_name_label = new JLabel();
1094 Dictionary.registerText(index_name_label, "CDM.IndexManager.Index_Name");
1095
1096 index_name_field = new JTextField();
1097 index_name_field.setPreferredSize(FIELD_SIZE);
1098 Dictionary.registerTooltip(index_name_field, "CDM.IndexManager.Index_Name_Tooltip");
1099
1100 JPanel index_boxes_panel = new JPanel();
1101
1102 index_label = new JLabel("CDM.IndexManager.MGPP.Index");
1103 Dictionary.registerText(index_label, "CDM.IndexManager.MGPP.Index");
1104
1105 index_combobox = new GComboBox();
1106 index_combobox.setPreferredSize(FIELD_SIZE);
1107 index_combobox.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false));
1108 index_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
1109 index_combobox.setEditable(false); // Warning: setting this to true opens a big can of worms
1110 index_combobox.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false));
1111 index_combobox.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false));
1112 Dictionary.registerTooltip(index_combobox, "CDM.IndexManager.MGPP.Index_Tooltip");
1113
1114 JPanel index_button_panel = new JPanel();
1115
1116 add_index_button = new GLIButton();
1117 add_index_button.setEnabled(false);
1118 add_index_button.setMnemonic(KeyEvent.VK_A);
1119 Dictionary.registerBoth(add_index_button, "CDM.IndexManager.Add_Index", "CDM.IndexManager.Add_Index_Tooltip");
1120
1121 add_all_button = new GLIButton();
1122 add_all_button.setEnabled(true);
1123 add_all_button.setMnemonic(KeyEvent.VK_L);
1124 Dictionary.registerBoth(add_all_button, "CDM.IndexManager.MGPP.Add_All_Metadata", "CDM.IndexManager.MGPP.Add_All_Metadata_Tooltip");
1125
1126 replace_index_button = new GLIButton();
1127 replace_index_button.setEnabled(false);
1128 replace_index_button.setMnemonic(KeyEvent.VK_C);
1129 Dictionary.registerBoth(replace_index_button, "CDM.IndexManager.MGPP.Replace_Index", "CDM.IndexManager.MGPP.Replace_Index_Tooltip");
1130
1131 remove_index_button = new GLIButton();
1132 remove_index_button.setEnabled(false);
1133 remove_index_button.setMnemonic(KeyEvent.VK_A);
1134 Dictionary.registerBoth(remove_index_button, "CDM.IndexManager.Remove_Index", "CDM.IndexManager.Remove_Index_Tooltip");
1135
1136 JPanel index_empty_panel = new JPanel();
1137
1138 // Connect Indexes
1139 EnableAddIndexListener index_eal = new EnableAddIndexListener();
1140 add_index_button.addActionListener(new AddIndexActionListener());
1141 add_all_button.addActionListener(new AddAllActionListener());
1142
1143 // Create the index_list_listener but don't add in to the list - this gets done in gainFocus, we don't want it twice.
1144 mgpp_index_list_listener = new CurrentIndexesListSelectionListener();
1145 index_combobox.addActionListener(index_eal);
1146 ((JTextField)index_combobox.getEditor().getEditorComponent()).getDocument().addDocumentListener(index_eal);
1147 index_name_field.getDocument().addDocumentListener(index_eal);
1148 move_index_down_button.addActionListener(new MoveIndexDownListener());
1149 move_index_up_button.addActionListener(new MoveIndexUpListener());
1150 replace_index_button.addActionListener(new ReplaceIndexActionListener());
1151 remove_index_button.addActionListener(new RemoveIndexActionListener(index_eal));
1152
1153 // Layout Indexes
1154 index_movement_panel.setLayout(new GridLayout(2,1));
1155 index_movement_panel.add(move_index_up_button);
1156 index_movement_panel.add(move_index_down_button);
1157
1158 current_indexes_panel.setLayout(new BorderLayout());
1159 current_indexes_panel.add(current_indexes_label, BorderLayout.NORTH);
1160 current_indexes_panel.add(new JScrollPane(current_indexes_list), BorderLayout.CENTER);
1161 current_indexes_panel.add(index_movement_panel, BorderLayout.EAST);
1162
1163
1164 index_labels_panel.setLayout(new GridLayout(2,1));
1165 index_labels_panel.add(index_name_label);
1166 index_labels_panel.add(index_label);
1167
1168 index_boxes_panel.setLayout(new GridLayout(2,1));
1169 index_boxes_panel.add(index_name_field);
1170 index_boxes_panel.add(index_combobox);
1171
1172 index_details_panel.setLayout(new BorderLayout(5,0));
1173 index_details_panel.add(index_labels_panel, BorderLayout.WEST);
1174 index_details_panel.add(index_boxes_panel, BorderLayout.CENTER);
1175
1176 index_button_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
1177 index_button_panel.setLayout(new GridLayout(2,2,5,0));
1178 index_button_panel.add(add_index_button);
1179 index_button_panel.add(add_all_button);
1180 index_button_panel.add(replace_index_button);
1181 index_button_panel.add(remove_index_button);
1182
1183 index_body_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
1184 index_body_panel.setLayout(new BorderLayout());
1185 index_body_panel.add(index_details_panel, BorderLayout.CENTER);
1186 index_body_panel.add(index_button_panel, BorderLayout.SOUTH);
1187
1188 index_spacer_panel.setLayout(new BorderLayout());
1189 index_spacer_panel.add(index_body_panel, BorderLayout.NORTH);
1190 index_spacer_panel.add(index_empty_panel, BorderLayout.CENTER);
1191
1192 indexes_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
1193 indexes_panel.setLayout(new BorderLayout());
1194 indexes_panel.add(current_indexes_panel, BorderLayout.NORTH);
1195 indexes_panel.add(index_spacer_panel, BorderLayout.CENTER);
1196
1197 // Create Levels
1198 JPanel levels_panel = new JPanel();
1199
1200 JPanel current_levels_panel = new JPanel();
1201
1202 current_levels_label = new JLabel();
1203 Dictionary.registerText(current_levels_label, "CDM.IndexManager.MGPP.Current_Levels");
1204
1205 current_levels_list = new JList(levels_model);
1206 current_levels_list.setVisibleRowCount(5);
1207 current_levels_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1208 JPanel level_movement_panel = new JPanel();
1209
1210 move_level_up_button = new JButton("", JarTools.getImage("arrow-up.gif"));
1211 move_level_up_button.setEnabled(false);
1212 move_level_up_button.setMnemonic(KeyEvent.VK_U);
1213 Dictionary.registerBoth(move_level_up_button, "CDM.Move.Move_Up", "CDM.Move.Move_Up_Tooltip");
1214
1215 move_level_down_button = new JButton("", JarTools.getImage("arrow-down.gif"));
1216 move_level_down_button.setEnabled(false);
1217 move_level_down_button.setMnemonic(KeyEvent.VK_D);
1218 Dictionary.registerBoth(move_level_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip");
1219
1220 JPanel level_spacer_panel = new JPanel();
1221 JPanel level_body_panel = new JPanel();
1222 JPanel level_details_panel = new JPanel();
1223 JPanel level_labels_panel = new JPanel();
1224 JPanel level_boxes_panel = new JPanel();
1225
1226 level_name_label = new JLabel();
1227 Dictionary.registerText(level_name_label, "CDM.IndexManager.MGPP.Level_Name");
1228
1229 level_name_field = new JTextField();
1230 level_name_field.setPreferredSize(FIELD_SIZE);
1231 Dictionary.registerTooltip(level_name_field, "CDM.IndexManager.MGPP.Level_Name_Tooltip");
1232
1233
1234 level_label = new JLabel();
1235 Dictionary.registerText(level_label, "CDM.IndexManager.MGPP.Level");
1236
1237 level_combobox = new GComboBox(Index.LEVEL);
1238 level_combobox.setPreferredSize(FIELD_SIZE);
1239 level_combobox.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false));
1240 level_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
1241 level_combobox.setEditable(false);
1242 level_combobox.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false));
1243 level_combobox.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false));
1244 Dictionary.registerTooltip(level_combobox, "CDM.IndexManager.Level_Tooltip");
1245
1246 JPanel level_button_panel = new JPanel();
1247
1248 add_level_button = new GLIButton("CDM.IndexManager.MGPP.Add_Level");
1249 add_level_button.setEnabled(false);
1250 add_level_button.setMnemonic(KeyEvent.VK_A);
1251 Dictionary.registerBoth(add_level_button, "CDM.IndexManager.MGPP.Add_Level", "CDM.IndexManager.MGPP.Add_Level_Tooltip");
1252
1253 remove_level_button = new GLIButton("CDM.IndexManager.MGPP.Remove_Level");
1254 remove_level_button.setEnabled(false);
1255 remove_level_button.setMnemonic(KeyEvent.VK_A);
1256 Dictionary.registerBoth(remove_level_button, "CDM.IndexManager.MGPP.Remove_Level", "CDM.IndexManager.MGPP.Remove_Level_Tooltip");
1257
1258 JPanel level_empty_panel = new JPanel();
1259
1260 // Connect Levels
1261 EnableAddLevelListener level_eal = new EnableAddLevelListener();
1262 add_level_button.addActionListener(new AddLevelActionListener());
1263 current_levels_list.addListSelectionListener(new CurrentLevelsListSelectionListener());
1264 level_combobox.addActionListener(level_eal);
1265 ((JTextField)level_combobox.getEditor().getEditorComponent()).getDocument().addDocumentListener(level_eal);
1266 level_name_field.getDocument().addDocumentListener(level_eal);
1267 move_level_down_button.addActionListener(new MoveLevelDownListener());
1268 move_level_up_button.addActionListener(new MoveLevelUpListener());
1269 remove_level_button.addActionListener(new RemoveLevelActionListener(level_eal));
1270 // Layout Levels
1271
1272 level_movement_panel.setLayout(new GridLayout(2,1));
1273 level_movement_panel.add(move_level_up_button);
1274 level_movement_panel.add(move_level_down_button);
1275
1276 current_levels_panel.setLayout(new BorderLayout());
1277 current_levels_panel.add(current_levels_label, BorderLayout.NORTH);
1278 current_levels_panel.add(new JScrollPane(current_levels_list), BorderLayout.CENTER);
1279 current_levels_panel.add(level_movement_panel, BorderLayout.EAST);
1280
1281 level_labels_panel.setLayout(new GridLayout(2,1));
1282 level_labels_panel.add(level_name_label);
1283 level_labels_panel.add(level_label);
1284
1285 level_boxes_panel.setLayout(new GridLayout(2,1));
1286 level_boxes_panel.add(level_name_field);
1287 level_boxes_panel.add(level_combobox);
1288
1289 level_details_panel.setLayout(new BorderLayout(5,0));
1290 level_details_panel.add(level_labels_panel, BorderLayout.WEST);
1291 level_details_panel.add(level_boxes_panel, BorderLayout.CENTER);
1292
1293 level_button_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
1294 level_button_panel.setLayout(new GridLayout(1,2,5,0));
1295 level_button_panel.add(add_level_button);
1296 level_button_panel.add(remove_level_button);
1297
1298 level_body_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
1299 level_body_panel.setLayout(new BorderLayout());
1300 level_body_panel.add(level_details_panel, BorderLayout.CENTER);
1301 level_body_panel.add(level_button_panel, BorderLayout.SOUTH);
1302
1303 level_spacer_panel.setLayout(new BorderLayout());
1304 level_spacer_panel.add(level_body_panel, BorderLayout.NORTH);
1305 level_spacer_panel.add(level_empty_panel, BorderLayout.CENTER);
1306
1307 levels_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
1308 levels_panel.setLayout(new BorderLayout());
1309 levels_panel.add(current_levels_panel, BorderLayout.NORTH);
1310 levels_panel.add(level_spacer_panel, BorderLayout.CENTER);
1311
1312 // Create General
1313 JPanel header_panel = new JPanel();
1314
1315 title_label = new JLabel();
1316 title_label.setHorizontalAlignment(JLabel.CENTER);
1317 Dictionary.registerText(title_label, "CDM.IndexManager.MGPP.Title");
1318
1319 instructions_textarea = new JTextArea();
1320 instructions_textarea.setEditable(false);
1321 instructions_textarea.setLineWrap(true);
1322 instructions_textarea.setRows(6);
1323 instructions_textarea.setWrapStyleWord(true);
1324 Dictionary.registerText(instructions_textarea, "CDM.IndexManager.MGPP.Instructions");
1325
1326 tabbed_pane = new JTabbedPane();
1327
1328 // Layout General
1329 header_panel.setBorder(BorderFactory.createEmptyBorder(0,0,2,0));
1330 header_panel.setLayout(new BorderLayout());
1331 header_panel.add(title_label, BorderLayout.NORTH);
1332 header_panel.add(new JScrollPane(instructions_textarea), BorderLayout.CENTER);
1333
1334 tabbed_pane.add(Dictionary.get("CDM.IndexManager.MGPP.Indexes"), indexes_panel);
1335 tabbed_pane.add(Dictionary.get("CDM.IndexManager.MGPP.Levels"), levels_panel);
1336
1337 setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
1338 setLayout(new BorderLayout());
1339 add(header_panel, BorderLayout.NORTH);
1340 add(tabbed_pane, BorderLayout.CENTER);
1341 }
1342
1343 public void destroy() {
1344 }
1345
1346 public void gainFocus() {
1347 // add in the mgpp listener
1348 current_indexes_list.addListSelectionListener(mgpp_index_list_listener);
1349 // Reload the assigned indexes list.
1350 index_combobox.removeAllItems();
1351 index_combobox.addItem(CollectionConfiguration.ALLFIELDS_STR);
1352 index_combobox.addItem(CollectionConfiguration.METADATA_STR);
1353 index_combobox.addItem(CollectionConfiguration.TEXT_STR);
1354 ArrayList every_metadata_set_element = MetadataSetManager.getEveryMetadataSetElement();
1355 for(int i = 0; i < every_metadata_set_element.size(); i++) {
1356 index_combobox.addItem(every_metadata_set_element.get(i));
1357 }
1358 // Ensure the level manager has at least documents assigned
1359 if(levels_model.getSize() == 0) {
1360 Level level = new Level(CollectionConfiguration.DOCUMENT_STR);
1361 // Create new metadatum
1362 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + CollectionConfiguration.DOCUMENT_STR);
1363 metadatum.setValue(CollectionConfiguration.DOCUMENT_STR);
1364 // Assign new level
1365 addLevel(level, metadatum);
1366 level = null;
1367 }
1368
1369 // refresh
1370 current_indexes_list.updateUI();
1371 }
1372
1373 public void removeIndexListListener() {
1374
1375 current_indexes_list.removeListSelectionListener(mgpp_index_list_listener);
1376 }
1377
1378 private class AddIndexActionListener
1379 implements ActionListener {
1380 public void actionPerformed(ActionEvent event) {
1381 // Retrieve the name
1382 String name = index_name_field.getText();
1383 // Retrieve the source
1384 Object source = index_combobox.getSelectedItem();
1385
1386 // If this object isn't yet in the combobox add it.
1387 if(index_combobox.getSelectedIndex() == -1) {
1388 index_combobox.insertItemAt(source, index_combobox.getItemCount());
1389 }
1390 // Create new index
1391 ArrayList sources = new ArrayList();
1392 sources.add(source);
1393 Index index = new Index(sources);
1394 if(!model.contains(index)) {
1395 // Create new metadatum
1396 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
1397 metadatum.setValue(name);
1398 // Assign new index
1399 addIndex(index, metadatum);
1400 current_indexes_list.setSelectedValue(index, true);
1401 }
1402 // Done. Disable add
1403 add_index_button.setEnabled(false);
1404 }
1405 }
1406
1407 private class AddAllActionListener
1408 implements ActionListener {
1409
1410 public void actionPerformed(ActionEvent event) {
1411 for(int i = 0; i < index_combobox.getItemCount(); i++) {
1412 Object source = index_combobox.getItemAt(i);
1413 // Create new index
1414 ArrayList sources = new ArrayList();
1415 sources.add(source);
1416 Index index = new Index(sources);
1417 sources = null;
1418 if(!model.contains(index)) {
1419 // Determine the metadatum value
1420 String name = source.toString();
1421 if(name.startsWith(StaticStrings.EXTRACTED_NAMESPACE)) {
1422 name = name.substring(StaticStrings.EXTRACTED_NAMESPACE.length());
1423 }
1424 // Create new metadatum
1425 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
1426 metadatum.setValue(name);
1427 name = null;
1428 // Assign new index
1429 addIndex(index, metadatum);
1430 }
1431 source = null;
1432 index = null;
1433 }
1434 // Done. Disable add
1435 add_index_button.setEnabled(false);
1436 }
1437 }
1438
1439 private class AddLevelActionListener
1440 implements ActionListener {
1441 public void actionPerformed(ActionEvent event) {
1442 // Retrieve the name
1443 String name = level_name_field.getText();
1444 // Retrieve the source
1445 String source = (String)level_combobox.getSelectedItem();
1446 Level level = new Level(source);
1447 // Create new metadatum
1448 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + source);
1449 metadatum.setValue(name);
1450 // Assign new level
1451 int size = levels_model.getSize();
1452 addLevel(level, metadatum);
1453 current_levels_list.setSelectedValue(level, true);
1454 add_level_button.setEnabled(false);
1455 }
1456 }
1457
1458 private class CurrentIndexesListSelectionListener
1459 implements ListSelectionListener {
1460 public void valueChanged(ListSelectionEvent event) {
1461 if(event.getValueIsAdjusting()) {
1462 return;
1463 }
1464
1465 Index index = (Index)current_indexes_list.getSelectedValue();
1466 if(index != null) {
1467 String full_text = index.toString();
1468 if(full_text.indexOf("\"") != -1) {
1469 index_name_field.setText(index.getName());
1470 }
1471 ArrayList sources = index.getSources();
1472 index_combobox.setSelectedItem(sources.get(0));
1473
1474
1475 move_index_down_button.setEnabled((model.indexOf(index) < model.getSize() - 1));
1476 move_index_up_button.setEnabled((model.indexOf(index) > 0));
1477 remove_index_button.setEnabled(true);
1478 }
1479 else {
1480 move_index_down_button.setEnabled(false);
1481 move_index_up_button.setEnabled(false);
1482 remove_index_button.setEnabled(false);
1483 }
1484 }
1485 }
1486
1487 private class CurrentLevelsListSelectionListener
1488 implements ListSelectionListener {
1489 public void valueChanged(ListSelectionEvent event) {
1490
1491 if(event.getValueIsAdjusting()) {
1492 return;
1493 }
1494
1495 Level level = (Level)current_levels_list.getSelectedValue();
1496 if(level != null) {
1497 String full_text = level.toString();
1498 if(full_text.indexOf("\"") != -1) {
1499 level_name_field.setText(level.getName());
1500 }
1501 String level_id = level.getLevel();
1502 level_combobox.setSelectedItem(level_id);
1503 move_level_down_button.setEnabled((levels_model.indexOf(level) < levels_model.getSize() - 1));
1504 move_level_up_button.setEnabled((levels_model.indexOf(level) > 0));
1505 remove_level_button.setEnabled(true);
1506 }
1507 else {
1508 move_level_down_button.setEnabled(false);
1509 move_level_up_button.setEnabled(false);
1510 remove_level_button.setEnabled(false);
1511 }
1512 }
1513 }
1514
1515 private class EnableAddIndexListener
1516 implements ActionListener, DocumentListener {
1517 /** Called whenever a selection action occurs on the combobox.
1518 * @param event an ActionEvent containing information about the selection event
1519 */
1520 public void actionPerformed(ActionEvent event) {
1521 validateAddButtonIndex();
1522 }
1523
1524 /** Gives notification that an attribute or set of attributes changed.
1525 * @param event a DocumentEvent containing information about the text changed
1526 */
1527 public void changedUpdate(DocumentEvent event) {
1528 validateAddButtonIndex();
1529 }
1530
1531 /** Gives notification that there was an insert into the document.
1532 * @param event a DocumentEvent containing information about the text added
1533 */
1534 public void insertUpdate(DocumentEvent event) {
1535 validateAddButtonIndex();
1536 }
1537
1538 /** Gives notification that a portion of the document has been removed.
1539 * @param event a DocumentEvent containing information about the text removed
1540 */
1541 public void removeUpdate(DocumentEvent event) {
1542 validateAddButtonIndex();
1543 }
1544
1545 /** Change the enable state of the add button depending on the current value in the search type combobox. */
1546 public void validateAddButtonIndex() {
1547 String name = index_name_field.getText();
1548 Object selected_object = index_combobox.getSelectedItem();
1549 boolean add_enabled = false;
1550 boolean replace_enabled = false;
1551
1552 if(name.length() > 0 && selected_object != null) {
1553 // Unfortunately we have to generate a valid id
1554 String id = null;
1555 // Special cases
1556 if (selected_object instanceof String && (selected_object.equals(CollectionConfiguration.ALLFIELDS_STR) || selected_object.equals(CollectionConfiguration.METADATA_STR) || selected_object.equals(CollectionConfiguration.TEXT_STR))) {
1557 id = (String) selected_object;
1558 }
1559 else if (selected_object instanceof MetadataElement) {
1560 id = ((MetadataElement) selected_object).getFullName();
1561 }
1562 else {
1563 System.err.println("Internal Error: Unexpected selected_object in IndexManager.");
1564 return;
1565 }
1566 if(id.startsWith(StaticStrings.EXTRACTED_NAMESPACE)) {
1567 id = id.substring(StaticStrings.EXTRACTED_NAMESPACE.length());
1568 }
1569
1570 Index index = getIndex(id);
1571 if(index == null) {
1572 add_enabled = true;
1573 // we have a new index. is something selected? if so, we can replace
1574 if (current_indexes_list.getSelectedIndex() != -1) {
1575 replace_enabled = true;
1576 }
1577 }
1578 else {
1579 // the index is already there
1580 add_enabled = false;
1581 // but if the name is changed, we can do a replace
1582 if(!name.equals(index.getName())) {
1583 replace_enabled = true;
1584 }
1585
1586 }
1587 }
1588 else {
1589 add_enabled = false;
1590 replace_enabled = false;
1591
1592 }
1593
1594 // We should now know the button state
1595 add_index_button.setEnabled(add_enabled);
1596 replace_index_button.setEnabled(replace_enabled);
1597
1598 }
1599 }
1600
1601 private class EnableAddLevelListener
1602 implements ActionListener, DocumentListener {
1603 /** Called whenever a selection action occurs on the combobox.
1604 * @param event an ActionEvent containing information about the selection event
1605 */
1606 public void actionPerformed(ActionEvent event) {
1607 validateAddButtonLevel();
1608 }
1609
1610 /** Gives notification that an attribute or set of attributes changed.
1611 * @param event a DocumentEvent containing information about the text changed
1612 */
1613 public void changedUpdate(DocumentEvent event) {
1614 validateAddButtonLevel();
1615 }
1616
1617 /** Gives notification that there was an insert into the document.
1618 * @param event a DocumentEvent containing information about the text added
1619 */
1620 public void insertUpdate(DocumentEvent event) {
1621 validateAddButtonLevel();
1622 }
1623
1624 /** Gives notification that a portion of the document has been removed.
1625 * @param event a DocumentEvent containing information about the text removed
1626 */
1627 public void removeUpdate(DocumentEvent event) {
1628 validateAddButtonLevel();
1629 }
1630
1631 /** Change the enable state of the add button depending on the current value in the search type combobox. */
1632 public void validateAddButtonLevel() {
1633 String name = level_name_field.getText();
1634 Object selected_object = level_combobox.getSelectedItem();
1635 if(name.length() > 0 && selected_object != null) {
1636 add_level_button.setEnabled(getLevel((String)selected_object) == null);
1637 }
1638 else {
1639 add_level_button.setEnabled(false);
1640 }
1641 }
1642 }
1643
1644 private class MoveIndexDownListener
1645 implements ActionListener {
1646 public void actionPerformed(ActionEvent event) {
1647 // Retrieve the first selected item
1648 Index index = (Index) current_indexes_list.getSelectedValue();
1649 moveIndex(index, false);
1650 current_indexes_list.setSelectedValue(index, true);
1651 }
1652 }
1653
1654 private class MoveLevelDownListener
1655 implements ActionListener {
1656 public void actionPerformed(ActionEvent event) {
1657 // Retrieve the first selected item
1658 Level level = (Level) current_levels_list.getSelectedValue();
1659 moveLevel(level, false);
1660 current_levels_list.setSelectedValue(level, true);
1661 }
1662 }
1663
1664 private class MoveIndexUpListener
1665 implements ActionListener {
1666 public void actionPerformed(ActionEvent event) {
1667 // Retrieve the first selected item
1668 Index index = (Index) current_indexes_list.getSelectedValue();
1669 moveIndex(index, true);
1670 current_indexes_list.setSelectedValue(index, true);
1671 }
1672 }
1673
1674 private class MoveLevelUpListener
1675 implements ActionListener {
1676 public void actionPerformed(ActionEvent event) {
1677 // Retrieve the first selected item
1678 Level level = (Level) current_levels_list.getSelectedValue();
1679 moveLevel(level, true);
1680 current_levels_list.setSelectedValue(level, true);
1681 }
1682 }
1683
1684 /** Replace really only replaces the string. */
1685 private class ReplaceIndexActionListener
1686 implements ActionListener {
1687
1688 public void actionPerformed(ActionEvent event) {
1689 // We'll just remove the old one and add the new one
1690 removeIndex((Index) current_indexes_list.getSelectedValue());
1691 replace_index_button.setEnabled(false);
1692 add_index_button.setEnabled(true);
1693 add_index_button.doClick(); // this adds the new one
1694 add_index_button.setEnabled(false);
1695
1696 //Object[] selected_objects = current_indexes_list.getSelectedValues();
1697 //if(selected_objects.length == 1) {
1698 Index index = (Index)current_indexes_list.getSelectedValue();
1699 if (index != null) {
1700 //Index index = (Index) selected_objects[0];
1701 // Remove old name
1702 CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + index.getID());
1703 // Enter new name
1704 String name = index_name_field.getText();
1705 // Create new metadatum
1706 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
1707 //index = null;
1708 metadatum.setValue(name);
1709 name = null;
1710 // Assign new index
1711 CollectionDesignManager.collectionmeta_manager.addMetadatum(metadatum);
1712 metadatum = null;
1713 }
1714 //current_indexes_list.setSelectedValue(selected_objects[0], true);
1715 current_indexes_list.setSelectedValue(index, true);
1716 // Done. Disable add
1717 add_index_button.setEnabled(false);
1718 replace_index_button.setEnabled(false);
1719 }
1720 }
1721
1722 private class RemoveIndexActionListener
1723 implements ActionListener {
1724
1725 private EnableAddIndexListener eal = null;
1726
1727 public RemoveIndexActionListener(EnableAddIndexListener eal) {
1728 this.eal = eal;
1729 }
1730
1731 public void actionPerformed(ActionEvent event) {
1732 // Retrieve the selected items
1733 //Object[] selected_objects = current_indexes_list.getSelectedValues();
1734 // Clear selection
1735 //current_indexes_list.clearSelection();
1736 //for(int i = 0; i < selected_objects.length; i++) {
1737 // Index index = (Index) selected_objects[i];
1738 // Remove any related metadata
1739 // CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + index.getID());
1740 // Remove the index
1741 // removeIndex(index);
1742 //}
1743 // Disable remove button
1744 //remove_index_button.setEnabled(false);
1745 // Check if add should be reenabled
1746 //eal.validateAddButtonIndex();
1747 int i = current_indexes_list.getSelectedIndex();
1748 if (i != -1) {
1749 Index index = (Index) current_indexes_list.getSelectedValue();
1750 // Remove any related metadata
1751 CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + index.getID());
1752 removeIndex(index);
1753
1754 //if (i != -1) {
1755 //removeIndex((Index) index_list.getSelectedValue());
1756 //}
1757 int size = current_indexes_list.getModel().getSize();
1758 if (i == size) {
1759 i--;
1760 }
1761 current_indexes_list.setSelectedIndex(i);
1762 }
1763 if (i==-1) {
1764 // empty list, disable remove button
1765 remove_index_button.setEnabled(false);
1766 }
1767 // Check if add should be reenabled
1768 eal.validateAddButtonIndex();
1769
1770 // This will produce an event on the list, updating the other buttons
1771 //if (size == 0) {
1772 // We have removed the last index, should be able to add what's filled in currently, if valid
1773 // validateAddButton();
1774 // }
1775 }
1776 }
1777
1778 private class RemoveLevelActionListener
1779 implements ActionListener {
1780
1781 private EnableAddLevelListener eal = null;
1782
1783 public RemoveLevelActionListener(EnableAddLevelListener eal) {
1784 this.eal = eal;
1785 }
1786
1787 public void actionPerformed(ActionEvent event) {
1788
1789 int i = current_levels_list.getSelectedIndex();
1790 if (i != -1) {
1791 Level level = (Level) current_levels_list.getSelectedValue();
1792 CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + level.getLevel());
1793 removeLevel(level);
1794 if (i == current_levels_list.getModel().getSize()) {
1795 i--;
1796 }
1797 current_levels_list.setSelectedIndex(i);
1798 }
1799 // Retrieve the selected items
1800 //Object[] selected_objects = current_levels_list.getSelectedValues();
1801 // Clear selection
1802 //current_levels_list.clearSelection();
1803 //for(int i = 0; i < selected_objects.length; i++) {
1804
1805 //Level level = (Level) selected_objects[i];
1806 // Remove any related metadata
1807 //CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + level.getLevel());
1808 // Remove the index
1809 //removeLevel(level);
1810 //}
1811
1812 if (i==-1) {
1813 // Disable remove button
1814 remove_level_button.setEnabled(false);
1815 }
1816 // If there are no levels left, put document back in
1817// if(levels_model.getSize() == 0) {
1818// Level level = new Level(CollectionConfiguration.DOCUMENT_STR);
1819// // Create new metadatum
1820// CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + CollectionConfiguration.DOCUMENT_STR);
1821// metadatum.setValue(CollectionConfiguration.DOCUMENT_STR);
1822// // Assign new level
1823// addLevel(level, metadatum);
1824// level = null;
1825// }
1826 // Check if add should be reenabled
1827 eal.validateAddButtonLevel();
1828 }
1829 }
1830 } // MGPPControls
1831
1832}
Note: See TracBrowser for help on using the repository browser.