1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
/*******************************************************************************
* Copyright (c) 2006, 2015 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.ui;
import java.util.EventObject;
/**
* Event object describing a change to a set of Saveable objects.
*
* @since 3.2
*/
public class SaveablesLifecycleEvent extends EventObject {
/**
* Serial version UID for this class.
* <p>
* Note: This class is not intended to be serialized.
* </p>
*/
private static final long serialVersionUID = -3530773637989046452L;
/**
* Event type constant specifying that the given saveables have been opened.
*/
public static final int POST_OPEN = 1;
/**
* Event type constant specifying that the given saveables are about to be
* closed. Listeners may veto the closing if isForce() is false.
*/
public static final int PRE_CLOSE = 2;
/**
* Event type constant specifying that the given saveables have been closed.
*/
public static final int POST_CLOSE = 3;
/**
* Event type constant specifying that the dirty state of the given saveables
* has changed.
*/
public static final int DIRTY_CHANGED = 4;
private int eventType;
private Saveable[] saveables;
private boolean force;
private boolean veto = false;
/**
* Creates a new SaveablesLifecycleEvent.
*
* @param source
* The source of the event. If an ISaveablesSource notifies
* about changes to the saveables returned by
* {@link ISaveablesSource#getSaveables()}, the source must be
* the ISaveablesSource object.
* @param eventType
* the event type, currently one of POST_OPEN, PRE_CLOSE,
* POST_CLOSE, DIRTY_CHANGED
* @param saveables
* The affected saveables
* @param force
* true if the event type is PRE_CLOSE and this is a closed force
* that cannot be canceled.
*/
public SaveablesLifecycleEvent(Object source, int eventType,
Saveable[] saveables, boolean force) {
super(source);
this.eventType = eventType;
this.saveables = saveables;
this.force = force;
}
/**
* Returns the eventType, currently one of POST_OPEN, PRE_CLOSE, POST_CLOSE,
* DIRTY_CHANGED. Listeners should silently ignore unknown event types since
* new event types might be added in the future.
*
* @return the eventType
*/
public int getEventType() {
return eventType;
}
/**
* Returns the affected saveables.
*
* @return the saveables
*/
public Saveable[] getSaveables() {
return saveables;
}
/**
* Returns the veto. This value is ignored for POST_OPEN,POST_CLOSE, and
* DIRTY_CHANGED.
*
* @return Returns the veto.
*/
public boolean isVeto() {
return veto;
}
/**
* @param veto
* The veto to set.
*/
public void setVeto(boolean veto) {
this.veto = veto;
}
/**
* Sets the force flag. This value is ignored for POST_OPEN, POST_CLOSE, and
* DIRTY_CHANGED.
*
* @return Returns the force.
*/
public boolean isForce() {
return force;
}
}
|