source: trunk/gli/src/org/greenstone/gatherer/msm/MSMEvent.java@ 5785

Last change on this file since 5785 was 5785, checked in by mdewsnip, 20 years ago

Commented out about 60 unused functions.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.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 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37package org.greenstone.gatherer.msm;
38
39/**
40 * Title: The Gatherer<br>
41 * Description: The Gatherer: a tool for gathering and enriching digital collections.<br>
42 * Copyright: Copyright (c) 2001<br>
43 * Company: The University of Waikato<br>
44 * @author John Thompson, Greenstone Digital Libraries
45 * @version 2.1
46 */
47import java.awt.AWTEvent;
48import java.io.*;
49import org.greenstone.gatherer.file.FileNode;
50import org.greenstone.gatherer.msm.ElementWrapper;
51import org.greenstone.gatherer.msm.Metadata;
52import org.greenstone.gatherer.msm.MSMAction;
53import org.greenstone.gatherer.valuetree.GValueModel;
54/** An event object which contains useful information about the event that generated it, which in this case is probably an element update (this means a MSMAction object should be provided). */
55public class MSMEvent
56 extends AWTEvent {
57 /** The element associated with this event. */
58 private ElementWrapper element = null;
59 /** The file associated with this event. */
60 private File file = null;
61 /** The record associated with this event. */
62 private FileNode record = null;
63 /** The value tree model after adding a new value. */
64 private GValueModel new_model = null;
65 /** The value tree model prior to adding a new value. */
66 private GValueModel old_model = null;
67 /** A unique id given to any file or metadata task so it can be undone in its entirity. */
68 private long id;
69 /** The new metadata associated with this event. */
70 private Metadata new_metadata = null;
71 /** The old metadata associated with this event. */
72 private Metadata old_metadata = null;
73 /** The profile associated with this event. */
74 private MSMAction profile = null;
75 /** The value associated with this event. */
76 private String value = null;
77 /** The message counter. */
78 static private int count = 0;
79 /** Constructor.
80 * @param source The <strong>Object</strong> that caused this event.
81 * @param id An <i>long</i> identifier.
82 * @param element The <strong>ElementWrapper</strong> affected.
83 */
84 public MSMEvent(Object source, long id, ElementWrapper element, GValueModel old_model, GValueModel new_model) {
85 super(source, 0);
86 this.element = element;
87 this.id = id;
88 this.new_model = new_model;
89 this.old_model = old_model;
90 this.profile = null;
91 this.record = null;
92 }
93 /** Constructor for a metadata change event involving a file. */
94 public MSMEvent(Object source, long id, File file, Metadata old_metadata, Metadata new_metadata) {
95 super(source, 0);
96 this.element = null;
97 this.file = file;
98 this.id = id;
99 this.new_metadata = new_metadata;
100 this.old_metadata = old_metadata;
101 this.profile = null;
102 }
103 /** Constructor for a metadata change event involving a filenode. */
104 public MSMEvent(Object source, long id, FileNode record, Metadata old_metadata, Metadata new_metadata) {
105 super(source, 0);
106 this.element = null;
107 this.id = id;
108 this.new_metadata = new_metadata;
109 this.old_metadata = old_metadata;
110 this.record = record;
111 this.profile = null;
112 }
113 /** Constructor.
114 * @param source The <strong>Object</strong> that caused this event.
115 * @param id An <i>long</i> identifier.
116 * @param profile The <strong>MSMAction</strong> profile if one is applicable.
117 */
118 public MSMEvent(Object source, long id, MSMAction profile) {
119 super(source, 00);
120 this.element = null;
121 this.id = id;
122 this.record = null;
123 this.profile = profile;
124 }
125 /** Constructor for a metadata element changed event.
126 * @param source The <strong>Object</strong> that caused this event.
127 * @param element A reference to the effected metadata <strong>ElementWrapper</strong>, or <i>null</i> if element no longer exists.
128 * @param value The old name of the element (if its name has changed). If <i>null</i> old name defaults to element.toString().
129 */
130 public MSMEvent(Object source, ElementWrapper element, String value) {
131 super(source, count++);
132 this.element = element;
133 this.value = value;
134 }
135 /** Method to retrieve of the element associated with this event.
136 * @return A <strong>ElementWrapper</strong>, or <i>null</i> if there is none.
137 */
138 public ElementWrapper getElement() {
139 return element;
140 }
141
142 public File getFile() {
143 return file;
144 }
145 /** Method to retrieve the new metadata associated with this event.
146 * @return A <strong>Metadata</strong>, or <i>null</i> if there is none.
147 */
148 public Metadata getNewMetadata() {
149 return new_metadata;
150 }
151 /* private GValueModel getNewModel() {
152 return new_model;
153 } */
154 /** Method to retrieve the old metadata associated with this event.
155 * @return A <strong>Metadata</strong>, or <i>null</i> if there is none.
156 */
157 public Metadata getOldMetadata() {
158 return old_metadata;
159 }
160 /* private GValueModel getOldModel() {
161 return old_model;
162 } */
163 /** Method to retrieve of the profile associated with this event.
164 * @return A <strong>MSMAction</strong> which details the action profile, or <i>null</i> if no profile exists.
165 */
166 /* private MSMAction getProfile() {
167 return profile;
168 } */
169 /** Retrieve the record associated with this event. */
170 public FileNode getRecord() {
171 return record;
172 }
173 /** Retrieve the associated with this event.
174 * @return A <strong>String</strong>.
175 */
176 public String getValue() {
177 String result = null;
178 if(value != null) {
179 result = value;
180 }
181 else if(element != null) {
182 result = element.toString();
183 }
184 return result;
185 }
186 public long ID() {
187 return id;
188 }
189
190 public String toString() {
191 StringBuffer text = new StringBuffer("");
192 if(old_metadata != null) {
193 text.append(old_metadata.toString());
194 }
195 text.append(" => ");
196 if(new_metadata != null) {
197 text.append(new_metadata.toString());
198 }
199 return text.toString();
200 }
201}
Note: See TracBrowser for help on using the repository browser.