001: /*
002: * <copyright>
003: *
004: * Copyright 2001-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026: package org.cougaar.tools.csmart.core.property;
027:
028: import java.util.EventObject;
029:
030: /**
031: * Defines an Custom Event class for Properties
032: *
033: */
034: public class PropertyEvent extends EventObject {
035: static final long serialVersionUID = -2000572256849383880L;
036:
037: /** Possible Changes **/
038: public static final int VALUE_CHANGED = 0;
039: public static final int DEFAULTVALUE_CHANGED = 1;
040: public static final int LABEL_CHANGED = 2;
041: public static final int NAME_CHANGED = 3;
042: public static final int CLASS_CHANGED = 4;
043: public static final int ALLOWEDVALUES_CHANGED = 5;
044: public static final int PROPERTY_ADDED = 7;
045: public static final int PROPERTY_REMOVED = 8;
046: public static final int TOOLTIP_CHANGED = 9;
047: public static final int HELP_CHANGED = 10;
048:
049: private Object previousValue;
050: private int whatChanged;
051:
052: /**
053: * Creates a new <code>PropertyEvent</code> instance.
054: *
055: * @param src
056: * @param whatChanged
057: */
058: public PropertyEvent(Object src, int whatChanged) {
059: this (src, whatChanged, null);
060: }
061:
062: /**
063: * Creates a new <code>PropertyEvent</code> instance.
064: *
065: * @param src
066: * @param whatChanged
067: * @param previousValue
068: */
069: public PropertyEvent(Object src, int whatChanged,
070: Object previousValue) {
071: super (src);
072: this .whatChanged = whatChanged;
073: this .previousValue = previousValue;
074: }
075:
076: /**
077: * Gets what changed to cause this event.
078: *
079: * @return an <code>int</code> value
080: */
081: public int getWhatChanged() {
082: return whatChanged;
083: }
084:
085: /**
086: * Gets the previous value, before the change.
087: *
088: * @return an <code>Object</code> value
089: */
090: public Object getPreviousValue() {
091: return previousValue;
092: }
093:
094: /**
095: * Gets the Property that changed.
096: *
097: * @return a <code>Property</code> value
098: */
099: public Property getProperty() {
100: Object result = getSource();
101: if (result instanceof Property)
102: return (Property) result;
103: return null;
104: }
105: }
|