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: Matthew Whyte, 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 | */
|
---|
27 |
|
---|
28 | package org.greenstone.gatherer.cdm;
|
---|
29 |
|
---|
30 | import org.greenstone.gatherer.Gatherer;
|
---|
31 | import org.greenstone.gatherer.DebugStream;
|
---|
32 | import javax.swing.event.*;
|
---|
33 | import java.awt.event.*;
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * This handles events generated by changing design options.
|
---|
37 | * The rebuildTypeRequired is updated if the rebuild type associated with this
|
---|
38 | * listener requires more 'work' than what is currently set in the {@link CollectionDesignManager}.
|
---|
39 | * @author Matthew Whyte
|
---|
40 | */
|
---|
41 | public class DesignChangeListener implements ActionListener, DocumentListener {
|
---|
42 |
|
---|
43 | /** The rebuild type required associated with this listener */
|
---|
44 | private final int rebuildType;
|
---|
45 |
|
---|
46 | /** Constructor. Sets the build type required. */
|
---|
47 | public DesignChangeListener(int type) {
|
---|
48 | rebuildType = type;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public void maybeSetRebuildRequired() {
|
---|
52 | if(rebuildType > CollectionDesignManager.getRebuildTypeRequired()) {
|
---|
53 | CollectionDesignManager.setRebuildTypeRequired(rebuildType);
|
---|
54 | }
|
---|
55 | //We need to keep track of this seperately, as collect.cfg is uploaded if needed, when the collect.cfg is saved.
|
---|
56 | if(rebuildType == CollectionDesignManager.UPDATE_COLLECT_CFG) {
|
---|
57 | CollectionDesignManager.update_collect_cfg_required = true;
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | /** Gives notification that an event has happened */
|
---|
62 | public void actionPerformed(ActionEvent event) {
|
---|
63 | //DebugStream.println("ActionEvent in Design from: " + event.getSource());
|
---|
64 | maybeSetRebuildRequired();
|
---|
65 | }
|
---|
66 |
|
---|
67 | /** Gives notification that an attribute or set of attributes changed. */
|
---|
68 | public void changedUpdate(DocumentEvent e) {
|
---|
69 | maybeSetRebuildRequired();
|
---|
70 | //DebugStream.println("changedUpdate in Design.");
|
---|
71 | }
|
---|
72 |
|
---|
73 | /** Gives notification that there was an insert into the document. */
|
---|
74 | public void insertUpdate(DocumentEvent e) {
|
---|
75 | maybeSetRebuildRequired();
|
---|
76 | //DebugStream.println("insertUpdate in Design."); //debug
|
---|
77 | }
|
---|
78 |
|
---|
79 | /** Gives notification that a portion of the document has been removed. */
|
---|
80 | public void removeUpdate(DocumentEvent e) {
|
---|
81 | maybeSetRebuildRequired();
|
---|
82 | //DebugStream.println("removeUpdate in Design."); //debug
|
---|
83 | }
|
---|
84 |
|
---|
85 | }
|
---|