source: trunk/gli/src/org/greenstone/gatherer/cdm/SubcollectionManager.java@ 6540

Last change on this file since 6540 was 6389, checked in by jmt12, 20 years ago

Introduced the idea of detail modes - these have an effect on several parts of the gui, such as disabling or hiding all regular expression based controls, simplifying the output from perl scripts and (having been given yet another new last minute feature to implement) displays a completely different create pane. Mode is stored in the config.xml and is changable via the Preferences controls

  • Property svn:keywords set to Author Date Id Revision
File size: 24.1 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
29/**************************************************************************************
30 * Written: ??/??/02
31 * Revised: 04/07/03 - DOM support
32 **************************************************************************************/
33import java.awt.*;
34import java.awt.event.*;
35import java.util.*;
36import javax.swing.*;
37import javax.swing.event.*;
38import org.greenstone.gatherer.Configuration;
39import org.greenstone.gatherer.Dictionary;
40import org.greenstone.gatherer.Gatherer;
41import org.greenstone.gatherer.cdm.CollectionConfiguration;
42import org.greenstone.gatherer.cdm.CollectionDesignManager;
43import org.greenstone.gatherer.cdm.Control;
44import org.greenstone.gatherer.cdm.DOMProxyListModel;
45import org.greenstone.gatherer.cdm.Subcollection;
46import org.greenstone.gatherer.gui.GLIButton;
47import org.greenstone.gatherer.gui.NonWhitespaceField;
48import org.greenstone.gatherer.msm.ElementWrapper;
49import org.greenstone.gatherer.msm.MSMUtils;
50import org.greenstone.gatherer.util.ExclusiveListSelectionListener;
51import org.greenstone.gatherer.util.StaticStrings;
52import org.greenstone.gatherer.util.Utility;
53import org.w3c.dom.*;
54
55/** This class maintains a list of subcollections within our collection.
56 * @author John Thompson, Greenstone Digital Library, University of Waikato
57 * @version 2.4
58 */
59public class SubcollectionManager
60 extends DOMProxyListModel {
61
62 static final private String DISABLED_CONTROLS = "Disabled";
63 static final private String ENABLED_CONTROLS = "Normal";
64 static final private String CLASS_DICTIONARY_NAME = "CDM.SubcollectionManager.";
65
66 /** The controls used to edit the settings of this manager. */
67 private Control controls = null;
68
69 private DOMProxyListModel model;
70
71 /** Constructor.
72 * @see org.greenstone.gatherer.Gatherer
73 * @see org.greenstone.gatherer.cdm.CollectionConfiguration
74 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
75 * @see org.greenstone.gatherer.cdm.DOMProxyListModel
76 * @see org.greenstone.gatherer.cdm.Subcollection
77 */
78 public SubcollectionManager() {
79 super(CollectionDesignManager.collect_config.getDocumentElement(), StaticStrings.SUBCOLLECTION_ELEMENT, new Subcollection());
80 Gatherer.println("SubcollectionManager: " + getSize() + " subcollections parsed.");
81 this.model = this;
82 }
83
84 /** Method to add a new subcollection.
85 * @param subcollection the Subcollection to add
86 * @see org.greenstone.gatherer.Gatherer
87 * @see org.greenstone.gatherer.cdm.CollectionConfiguration
88 * @see org.greenstone.gatherer.cdm.DOMProxyListModel
89 * @see org.greenstone.gatherer.collection.CollectionManager
90 */
91 public void addSubcollection(Subcollection subcollection) {
92 if(!contains(subcollection)) {
93 Element element = subcollection.getElement();
94 // Locate where we should insert this new subcollection.
95 Node target_node = CollectionConfiguration.findInsertionPoint(element);
96 // Failing that we insert immediately after a language string
97 add(root, subcollection, target_node);
98 Gatherer.c_man.configurationChanged();
99 }
100 }
101
102 public void destroy() {
103 if(controls != null) {
104 controls.destroy();
105 controls = null;
106 }
107 }
108
109 /** Method to retrieve the controls for this manager.
110 * @return the Control used to edit the subcollection data
111 */
112 public Control getControls() {
113 if(controls == null) {
114 controls = new SubcollectionControl();
115 }
116 return controls;
117 }
118
119 /** Method to retrieve a certain subcollection by its name.
120 * @param name a String which is used as the key for finding the matching subcollection
121 * @return the requested Subcollection or null if no such subcollection exists.
122 */
123 public Subcollection getSubcollection(String name) {
124 Subcollection result = null;
125 int size = getSize();
126 for(int i = 0; i < size; i++) {
127 Subcollection subcollection = (Subcollection) getElementAt(i);
128 if(subcollection.getName().equals(name)) {
129 result = subcollection;
130 }
131 }
132 return result;
133 }
134
135 /** Method to get all of the subcollections defined.
136 * @return an ArrayList of subcollections
137 */
138 /* private ArrayList getSubcollections() {
139 return children();
140 } */
141
142 /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
143 * @param mode the new mode as an int
144 */
145 public void modeChanged(int mode) {
146 if(controls != null) {
147 ((SubcollectionControl)controls).modeChanged(mode);
148 }
149 }
150
151 /** Method to remove the given subcollection.
152 * @param subcollection the Subcollection you want to remove
153 * @see org.greenstone.gatherer.Gatherer
154 * @see org.greenstone.gatherer.collection.CollectionManager
155 */
156 public void removeSubcollection(Subcollection subcollection) {
157 remove(subcollection);
158 Gatherer.c_man.configurationChanged();
159 }
160
161 public void updateSubcollection(Subcollection subcollection, String name, boolean include, String source, String pattern, String flags) {
162 subcollection.setFlags(flags);
163 subcollection.setInclusive(include);
164 subcollection.setName(name);
165 subcollection.setPattern(pattern);
166 subcollection.setSource(source);
167 refresh(subcollection);
168 Gatherer.c_man.configurationChanged();
169 }
170
171 /** This class creates a JPanel containing serveral more controls used for editing subcollection information. */
172 private class SubcollectionControl
173 extends JPanel
174 implements Control {
175
176 private CardLayout card_layout;
177 private JButton add_button;
178 private JButton remove_button;
179 private JButton update_button;
180 private JComboBox source_combobox;
181 private JList subcollection_list;
182 private JPanel border_pane;
183 private JTabbedPane tabbed_pane;
184 private JTextArea instructions_area;
185 private JTextField flags_field;
186 private JTextField match_field;
187 private JTextField name_field;
188 private JRadioButton exclude_button;
189 private JRadioButton include_button;
190
191 /** Constructor */
192 public SubcollectionControl() {
193 // Create
194 JPanel header_pane = new JPanel();
195 instructions_area = new JTextArea();
196 instructions_area.setEditable(false);
197 instructions_area.setLineWrap(true);
198 instructions_area.setRows(6);
199 instructions_area.setWrapStyleWord(true);
200 Dictionary.registerText(instructions_area, "CDM.SubcollectionManager.Instructions");
201
202 border_pane = new JPanel();
203 card_layout = new CardLayout();
204
205 tabbed_pane = new JTabbedPane();
206 JLabel title = new JLabel();
207 title.setHorizontalAlignment(JLabel.CENTER);
208 Dictionary.registerText(title, "CDM.SubcollectionManager.Title");
209
210 JPanel button_pane_3 = new JPanel();
211 add_button = new GLIButton();
212 add_button.setMnemonic(KeyEvent.VK_A);
213 add_button.setEnabled(false);
214 Dictionary.registerBoth(add_button, "CDM.SubcollectionManager.Add", "CDM.SubcollectionManager.Add_Tooltip");
215 remove_button = new GLIButton();
216 remove_button.setMnemonic(KeyEvent.VK_R);
217 remove_button.setEnabled(false);
218 Dictionary.registerBoth(remove_button, "CDM.SubcollectionManager.Remove", "CDM.SubcollectionManager.Remove_Tooltip");
219 update_button = new GLIButton();
220 update_button.setMnemonic(KeyEvent.VK_C);
221 update_button.setEnabled(false);
222 Dictionary.registerBoth(update_button, "CDM.SubcollectionManager.Replace", "CDM.SubcollectionManager.Replace_Tooltip");
223
224 JPanel button_pane = new JPanel();
225 JPanel button_pane_1 = new JPanel();
226 include_button = new JRadioButton();
227 include_button.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
228 include_button.setMnemonic(KeyEvent.VK_I);
229 include_button.setOpaque(false);
230 Dictionary.registerText(include_button, "CDM.SubcollectionManager.Include");
231 exclude_button = new JRadioButton();
232 exclude_button.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
233 exclude_button.setMnemonic(KeyEvent.VK_X);
234 exclude_button.setOpaque(false);
235 Dictionary.registerText(exclude_button, "CDM.SubcollectionManager.Exclude");
236
237 JLabel flags_label = new JLabel();
238 Dictionary.registerText(flags_label, "CDM.SubcollectionManager.Flags");
239 flags_field = new NonWhitespaceField();
240 Dictionary.registerTooltip(flags_field, "CDM.SubcollectionManager.Flags_Tooltip");
241
242 JPanel inclusive_pane = new JPanel();
243 JLabel inclusive_label = new JLabel();
244 Dictionary.registerText(inclusive_label, "CDM.SubcollectionManager.Inclusive");
245
246 JLabel match_label = new JLabel();
247 Dictionary.registerText(match_label, "CDM.SubcollectionManager.Match");
248 match_field = new JTextField();
249 Dictionary.registerTooltip(match_field, "CDM.SubcollectionManager.Match_Tooltip");
250
251 JLabel name_label = new JLabel();
252 Dictionary.registerText(name_label, "CDM.SubcollectionManager.Name");
253 name_field = new NonWhitespaceField();
254 Dictionary.registerTooltip(name_field, "CDM.SubcollectionManager.Name_Tooltip");
255
256 JLabel source_label = new JLabel();
257 Dictionary.registerText(source_label, "CDM.SubcollectionManager.Source");
258 Vector source_model = Gatherer.c_man.getCollection().msm.getAssignedElements();
259 source_model.add(0, StaticStrings.FILENAME_STR);
260 source_combobox = new JComboBox(source_model);
261 Dictionary.registerTooltip(source_combobox, "CDM.SubcollectionManager.Source_Tooltip");
262
263 subcollection_list = new JList(model);
264 subcollection_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
265 JPanel subcollection_pane = new JPanel();
266 ButtonGroup bg = new ButtonGroup();
267 bg.add(include_button);
268 bg.add(exclude_button);
269 include_button.setSelected(true);
270 JPanel subcollection_list_pane = new JPanel();
271 JLabel subcollection_list_label = new JLabel();
272 Dictionary.registerText(subcollection_list_label, "CDM.SubcollectionManager.Assigned");
273
274 // Create a message pane which explains why these controls are not currently active
275 JPanel message_pane = new JPanel();
276 String args[] = new String[3];
277 args[0] = Gatherer.config.getModeAsString();
278 args[1] = Dictionary.get("Preferences.Mode.Systems");
279 args[2] = Dictionary.get("Preferences.Mode.Expert");
280 JTextArea message_textarea = new JTextArea();
281 Dictionary.registerText(message_textarea, "CDM.SubcollectionManager.Partitions_Disabled", args);
282 message_textarea.setEditable(false);
283 message_textarea.setHighlighter(null); // Prevent highlighting
284 message_textarea.setLineWrap(true);
285 message_textarea.setOpaque(false); // Make it transparent
286 message_textarea.setWrapStyleWord(true);
287
288 // Add listeners
289 SubCollectionChangeListener cl = new SubCollectionChangeListener();
290 add_button.addActionListener(new AddSubCollectionListener());
291 remove_button.addActionListener(new RemoveSubCollectionListener());
292 update_button.addActionListener(new UpdateSubCollectionListener());
293 exclude_button.addActionListener(cl);
294 include_button.addActionListener(cl);
295 source_combobox.addActionListener(cl);
296 flags_field.getDocument().addDocumentListener(cl);
297 match_field.getDocument().addDocumentListener(cl);
298 name_field.getDocument().addDocumentListener(cl);
299 subcollection_list.addListSelectionListener(new SubCollectionListListener());
300
301 // Layout
302 instructions_area.setBorder(BorderFactory.createEmptyBorder(2,5,2,5));
303
304 header_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
305 header_pane.setLayout(new BorderLayout());
306 header_pane.add(title, BorderLayout.NORTH);
307 header_pane.add(new JScrollPane(instructions_area), BorderLayout.CENTER);
308
309 inclusive_pane.setLayout(new GridLayout());
310 inclusive_pane.add(include_button);
311 inclusive_pane.add(exclude_button);
312
313 button_pane_1.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
314 button_pane_1.setLayout(new GridLayout(5, 2));
315 button_pane_1.add(name_label);
316 button_pane_1.add(name_field);
317 button_pane_1.add(source_label);
318 button_pane_1.add(source_combobox);
319 button_pane_1.add(match_label);
320 button_pane_1.add(match_field);
321 button_pane_1.add(inclusive_label);
322 button_pane_1.add(inclusive_pane);
323 button_pane_1.add(flags_label);
324 button_pane_1.add(flags_field);
325
326 button_pane_3.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
327 button_pane_3.setLayout(new GridLayout(1,3));
328 button_pane_3.add(add_button);
329 button_pane_3.add(update_button);
330 button_pane_3.add(remove_button);
331
332 button_pane.setLayout(new BorderLayout());
333 button_pane.add(button_pane_1, BorderLayout.CENTER);
334 button_pane.add(button_pane_3, BorderLayout.SOUTH);
335
336 subcollection_list_pane.setLayout(new BorderLayout());
337 subcollection_list_pane.add(subcollection_list_label, BorderLayout.NORTH);
338 subcollection_list_pane.add(new JScrollPane(subcollection_list), BorderLayout.CENTER);
339 subcollection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
340 subcollection_pane.setLayout(new BorderLayout());
341 subcollection_pane.add(subcollection_list_pane, BorderLayout.CENTER);
342 subcollection_pane.add(button_pane, BorderLayout.SOUTH);
343
344 tabbed_pane.addTab(Dictionary.get("CDM.SubcollectionManager.Subcollection_Controls"), subcollection_pane);
345 tabbed_pane.addTab(Dictionary.get("CDM.SubcollectionManager.Subindex_Controls"), (JPanel) CollectionDesignManager.subcollectionindex_manager.getControls());
346 tabbed_pane.addTab(Dictionary.get("CDM.SubcollectionManager.Language_Controls"), (JPanel) CollectionDesignManager.language_manager.getControls());
347
348 message_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
349 message_pane.setLayout(new GridLayout(3,1,0,0));
350 message_pane.add(new JPanel());
351 message_pane.add(message_textarea);
352 message_pane.add(new JPanel());
353
354 border_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
355 border_pane.setLayout(card_layout);
356 if(Gatherer.config.getMode() > Configuration.LIBRARIAN_MODE) {
357 border_pane.add(tabbed_pane, ENABLED_CONTROLS);
358 border_pane.add(message_pane, DISABLED_CONTROLS);
359 }
360 else {
361 border_pane.add(message_pane, DISABLED_CONTROLS);
362 border_pane.add(tabbed_pane, ENABLED_CONTROLS);
363 }
364
365 setLayout(new BorderLayout());
366 add(header_pane, BorderLayout.NORTH);
367 add(border_pane, BorderLayout.CENTER);
368 }
369
370 /** Method to unregister any listeners to avoid memory leaks.
371 */
372 public void destroy() {
373 }
374
375 public void gainFocus() {
376 // Rebuild the sources combobox
377 Vector source_model = Gatherer.c_man.getCollection().msm.getAssignedElements();
378 source_model.add(0, "Filename"); // Add filename as a possible source.
379 source_combobox.setModel(new DefaultComboBoxModel(source_model));
380 }
381
382 public void loseFocus() {
383 }
384
385 /** Called when the detail mode has changed which in turn controls if any of the partition controls are visible, or if they are instead replaced with a message explaining why they are not.
386 * @param mode the new mode as an int
387 */
388 public void modeChanged(int mode) {
389 if(mode > Configuration.LIBRARIAN_MODE) {
390 card_layout.show(border_pane, ENABLED_CONTROLS);
391 }
392 else {
393 card_layout.show(border_pane, DISABLED_CONTROLS);
394 }
395 }
396
397 /** Listens for actions apon the 'add' button in the SubcollectionManager controls, and if detected calls the addSubcollection method of the manager with a newly created subcollection. */
398 private class AddSubCollectionListener
399 implements ActionListener {
400 /** Any implementation of ActionListener must include this method so we can be informed when an action has been performed on one of our target controls. In this case we wish to retrieve information from the various edit controls, and if we have sufficient data to build a new subcollection do so.
401 * @param event An <strong>ActionEvent</strong> containing information about the event.
402 * @see org.greenstone.gatherer.cdm.Subcollection
403 * @see org.greenstone.gatherer.msm.ElementWrapper
404 */
405 public void actionPerformed(ActionEvent event) {
406 String name = name_field.getText();
407 String source = null;
408 Object object = source_combobox.getSelectedItem();
409 if(object instanceof ElementWrapper) {
410 ElementWrapper element_wrapper = (ElementWrapper)object;
411 source = element_wrapper.getName();
412 if(source.indexOf(MSMUtils.NS_SEP) == -1) {
413 source = Utility.EXTRACTED_METADATA_NAMESPACE + MSMUtils.NS_SEP + source;
414 }
415 }
416 else {
417 source = object.toString();
418 }
419 String pattern = match_field.getText();
420 String flags = flags_field.getText();
421 if(name.length() > 0 && (source == null || source.length() > 0) && pattern.length() > 0) {
422 Subcollection subcollection = new Subcollection(name, include_button.isSelected(), source, pattern, flags);
423 addSubcollection(subcollection);
424 // Change the selection to the new subcollection
425 subcollection_list.setSelectedValue(subcollection, true);
426 }
427 add_button.setEnabled(false);
428 }
429 }
430
431 /** This class listens for any key entry in a text field, selection change in a combobox or button click, and updates a subcollection as appropriate. Its also convenient to use this class to test if the add button should be active yet. */
432 private class SubCollectionChangeListener
433 implements DocumentListener, ActionListener {
434 /** Any implementation of ActionListener must include this method so we can be informed when an action has been performed on one of our target controls. In this case we want to record that somethings changed, then validate the controls.
435 * @param event An <strong>ActionEvent</strong> containing information about the event.
436 */
437 public void actionPerformed(ActionEvent event) {
438 validateAdd();
439 }
440
441 public void changedUpdate(DocumentEvent event) {
442 validateAdd();
443 }
444
445 public void insertUpdate(DocumentEvent event) {
446 validateAdd();
447
448 }
449
450 public void removeUpdate(DocumentEvent event) {
451 validateAdd();
452 }
453
454 /** Method to validate the current subcollection editor values, and enable or disable controls (add button) based on said values. */
455 private void validateAdd() {
456 if(name_field.getText().length() > 0 && match_field.getText().length() > 0) {
457 if (getSubcollection(name_field.getText()) == null) {
458 add_button.setEnabled(true);
459 } else {
460 add_button.setEnabled(false);
461 }
462 }
463 else {
464 add_button.setEnabled(false);
465 }
466 }
467 }
468
469 /** Listens for actions apon the 'remove' button in the SubcollectionManager controls, and if detected calls the remove method of the manager with the SubIndex selected for removal. */
470 private class RemoveSubCollectionListener
471 implements ActionListener {
472 /** Any implementation of ActionListener must include this method so we can be informed when an action has been performed on one of our target controls. In this case we want to check if they have a subcolleciton selected, and if so remove both it and any subindexes based on it.
473 * @param event An <strong>ActionEvent</strong> containing information about the event.
474 * @see org.greenstone.gatherer.cdm.Subcollection
475 */
476 public void actionPerformed(ActionEvent event) {
477 if(!subcollection_list.isSelectionEmpty()) {
478 Subcollection subcollection = (Subcollection)subcollection_list.getSelectedValue();
479 removeSubcollection(subcollection);
480 // And remove subcollection indexes dependant on this subcollection
481 CollectionDesignManager.subcollectionindex_manager.removeSubcollectionIndexes(subcollection);
482 }
483 remove_button.setEnabled(false);
484 }
485 }
486
487 private class UpdateSubCollectionListener
488 implements ActionListener {
489 public void actionPerformed(ActionEvent event) {
490 if(!subcollection_list.isSelectionEmpty()) {
491 Subcollection subcollection = (Subcollection)subcollection_list.getSelectedValue();
492 String name = name_field.getText();
493 String source = null;
494 Object object = source_combobox.getSelectedItem();
495 if(object instanceof ElementWrapper) {
496 ElementWrapper element_wrapper = (ElementWrapper)object;
497 source = element_wrapper.getName();
498 if(source.indexOf(MSMUtils.NS_SEP) == -1) {
499 source = Utility.EXTRACTED_METADATA_NAMESPACE + MSMUtils.NS_SEP + source;
500 }
501 }
502 else {
503 source = object.toString();
504 }
505 String pattern = match_field.getText();
506 String flags = flags_field.getText();
507 if(name.length() > 0 && (source == null || source.length() > 0) && pattern.length() > 0) {
508 updateSubcollection(subcollection, name, include_button.isSelected(), source, pattern, flags);
509 }
510 }
511 }
512 }
513
514 /** This class listens for selections in the list on the subcollections pane of the SubcollectionManager, and updates the controls as necessary to reflect selection. */
515 private class SubCollectionListListener
516 implements ListSelectionListener {
517 /** Any implementation of ListSelectionListener must include this method so we can be informed when the selection changes. In this case we want to execute any changes the users made to the entry, then update the controls with details of the new selection.
518 * @param event A <strong>ListSelectionEvent</strong> containing information related to this event.
519 * @see org.greenstone.gatherer.cdm.Subcollection
520 * @see org.greenstone.gatherer.msm.ElementWrapper
521 */
522 public void valueChanged(ListSelectionEvent event) {
523 // Now the entry
524 if(!subcollection_list.isSelectionEmpty()) {
525 Subcollection subcollection = (Subcollection) subcollection_list.getSelectedValue();
526 flags_field.setText(subcollection.getFlags());
527 include_button.setSelected(subcollection.isInclusive());
528 exclude_button.setSelected(!subcollection.isInclusive());
529 match_field.setText(subcollection.getPattern());
530 name_field.setText(subcollection.getName());
531 String s = subcollection.getSource();
532 int pos = 0;
533 Object value = source_combobox.getItemAt(pos);
534 //ystem.err.println("Search for: " + s);
535 while(value != null) {
536 if(value instanceof ElementWrapper) {
537 ElementWrapper e = (ElementWrapper) value;
538 String e_name = e.getName();
539 if(e_name.indexOf(MSMUtils.NS_SEP) == -1) {
540 e_name = Utility.EXTRACTED_METADATA_NAMESPACE + MSMUtils.NS_SEP + e_name;
541 }
542 //ystem.err.print("Compare to: " + e_name);
543 if(e_name.equals(s)) {
544 source_combobox.setSelectedIndex(pos);
545 value = null;
546 //ystem.err.println(" - Match");
547 }
548 else {
549 pos++;
550 value = source_combobox.getItemAt(pos);
551 //ystem.err.println(" - Fail");
552 }
553 }
554 else if(value.toString().equals(s)) {
555 source_combobox.setSelectedIndex(pos);
556 value = null;
557 }
558 else {
559 pos++;
560 value = source_combobox.getItemAt(pos);
561 }
562 }
563 // Can't add one thats already there.
564 add_button.setEnabled(false);
565 // You can update or remove it though...
566 remove_button.setEnabled(true);
567 update_button.setEnabled(true);
568 }
569 else {
570 flags_field.setText("");
571 include_button.setSelected(true);
572 match_field.setText("");
573 name_field.setText("");
574 source_combobox.setSelectedIndex(0);
575 remove_button.setEnabled(false);
576 update_button.setEnabled(false);
577 }
578 }
579 }
580 }
581}
Note: See TracBrowser for help on using the repository browser.