KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > SaveablesLifecycleEvent


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui;
13
14 import java.util.EventObject JavaDoc;
15
16
17 /**
18  * Event object describing a change to a set of Saveable objects.
19  *
20  * @since 3.2
21  */

22 public class SaveablesLifecycleEvent extends EventObject JavaDoc {
23
24     /**
25      * Serial version UID for this class.
26      * <p>
27      * Note: This class is not intended to be serialized.
28      * </p>
29      */

30     private static final long serialVersionUID = -3530773637989046452L;
31
32     /**
33      * Event type constant specifying that the given saveables have been opened.
34      */

35     public static final int POST_OPEN = 1;
36
37     /**
38      * Event type constant specifying that the given saveables are about to be
39      * closed. Listeners may veto the closing if isForce() is false.
40      */

41     public static final int PRE_CLOSE = 2;
42
43     /**
44      * Event type constant specifying that the given saveables have been closed.
45      */

46     public static final int POST_CLOSE = 3;
47
48     /**
49      * Event type constant specifying that the dirty state of the given saveables
50      * has changed.
51      */

52     public static final int DIRTY_CHANGED = 4;
53
54     private int eventType;
55
56     private Saveable[] saveables;
57
58     private boolean force;
59
60     private boolean veto = false;
61
62     /**
63      * Creates a new SaveablesLifecycleEvent.
64      *
65      * @param source
66      * The source of the event. If an ISaveablesSource notifies
67      * about changes to the saveables returned by
68      * {@link ISaveablesSource#getSaveables()}, the source must be
69      * the ISaveablesSource object.
70      * @param eventType
71      * the event type, currently one of POST_OPEN, PRE_CLOSE,
72      * POST_CLOSE, DIRTY_CHANGED
73      * @param saveables
74      * The affected saveables
75      * @param force
76      * true if the event type is PRE_CLOSE and this is a closed force
77      * that cannot be canceled.
78      */

79     public SaveablesLifecycleEvent(Object JavaDoc source, int eventType,
80             Saveable[] saveables, boolean force) {
81         super(source);
82         this.eventType = eventType;
83         this.saveables = saveables;
84         this.force = force;
85     }
86
87     /**
88      * Returns the eventType, currently one of POST_OPEN, PRE_CLOSE, POST_CLOSE,
89      * DIRTY_CHANGED. Listeners should silently ignore unknown event types since
90      * new event types might be added in the future.
91      *
92      * @return the eventType
93      */

94     public int getEventType() {
95         return eventType;
96     }
97
98     /**
99      * Returns the affected saveables.
100      *
101      * @return the saveables
102      */

103     public Saveable[] getSaveables() {
104         return saveables;
105     }
106
107     /**
108      * Returns the veto. This value is ignored for POST_OPEN,POST_CLOSE, and
109      * DIRTY_CHANGED.
110      *
111      * @return Returns the veto.
112      */

113     public boolean isVeto() {
114         return veto;
115     }
116
117     /**
118      * @param veto
119      * The veto to set.
120      */

121     public void setVeto(boolean veto) {
122         this.veto = veto;
123     }
124
125     /**
126      * Sets the force flag. This value is ignored for POST_OPEN, POST_CLOSE, and
127      * DIRTY_CHANGED.
128      *
129      * @return Returns the force.
130      */

131     public boolean isForce() {
132         return force;
133     }
134
135 }
136
Popular Tags