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

Last change on this file since 18412 was 18412, checked in by kjdon, 15 years ago

more modifications for RTL GLI, thanks to Amin Hedjazi

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