01: package com.xoetrope.carousel.survey;
02:
03: import java.util.Observable;
04: import net.xoetrope.editor.project.XEditorProject;
05:
06: /**
07: *
08: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
09: * the GNU Public License (GPL), please see license.txt for more details. If
10: * you make commercial use of this software you must purchase a commercial
11: * license from Xoetrope.</p>
12: * <p> $Revision: 1.5 $</p>
13: */
14: public class XNotifier extends Observable {
15: private XEditorProject project;
16: private boolean mark;
17:
18: /**
19: * Creates a new instance of XNotifier
20: * @param project the current project
21: * @param markAsMofied indicates whether the project specified
22: * project should be marked as modified after the observers of this object
23: * are notified.
24: */
25: public XNotifier(XEditorProject currentProject,
26: boolean markAsModified) {
27: super ();
28: project = currentProject;
29: mark = (markAsModified && (project != null));
30: }
31:
32: /**
33: * Gets whether this notifier marks the current project
34: * as modified after notifying its observers.
35: * @return true if project is should be marked as modified,
36: * false otherwise
37: */
38: public boolean markAsModified() {
39: return mark;
40: }
41:
42: /**
43: * Speicified whether this notifier should mark the
44: * project as modified after notifying its observers.
45: * @param markAsModified true if the project should be mark
46: * as modified, false otherwise.
47: */
48: public void markAsModified(boolean markAsModified) {
49: mark = markAsModified;
50: }
51:
52: /**
53: * Notifies all registered observers.
54: * @param o the object to be passed the observers
55: * @param markAsModifies indicates whether the current project
56: * should be marked as modified
57: */
58: public void notifyObservers(Object o, boolean markAsModified) {
59: setChanged();
60: super .notifyObservers(o);
61: if (markAsModified && (project != null))
62: project.setModified(true);
63: }
64:
65: /**
66: * Notifies all registered observers
67: * @parma o the object to be passed to the observers
68: */
69: public void notifyObservers(Object o) {
70: setChanged();
71: super .notifyObservers(o);
72: if (mark)
73: project.setModified(true);
74: }
75: }
|