001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.core;
011:
012: /**
013: * @see IModelChangedEvent
014: *
015: * @since 2.0
016: */
017: public class ModelChangedEvent implements IModelChangedEvent {
018: private int type;
019: private IModelChangeProvider provider;
020: private Object[] changedObjects;
021: private Object oldValue, newValue;
022: private String changedProperty;
023:
024: /**
025: * The constructor of the event.
026: *
027: * @param provider
028: * the change provider
029: * @param type
030: * the event type
031: * @param objects
032: * the changed objects
033: * @param changedProperty
034: * or <samp>null </samp> if not applicable
035: */
036: public ModelChangedEvent(IModelChangeProvider provider, int type,
037: Object[] objects, String changedProperty) {
038: this .type = type;
039: this .provider = provider;
040: this .changedObjects = objects;
041: this .changedProperty = changedProperty;
042: }
043:
044: /**
045: * A costructor that should be used for changes of object properties.
046: *
047: * @param provider
048: * the event provider
049: * @param object
050: * affected object
051: * @param changedProperty
052: * changed property of the affected object
053: * @param oldValue
054: * the value before the change
055: * @param newValue
056: * the value after the change
057: */
058: public ModelChangedEvent(IModelChangeProvider provider,
059: Object object, String changedProperty, Object oldValue,
060: Object newValue) {
061: this .type = CHANGE;
062: this .provider = provider;
063: this .changedObjects = new Object[] { object };
064: this .changedProperty = changedProperty;
065: this .oldValue = oldValue;
066: this .newValue = newValue;
067: }
068:
069: /**
070: * @see IModelChangedEvent#getChangeProvider
071: */
072: public IModelChangeProvider getChangeProvider() {
073: return provider;
074: }
075:
076: /**
077: * @see IModelChangedEvent#getChangedObjects
078: */
079: public Object[] getChangedObjects() {
080: return (changedObjects == null) ? new Object[0]
081: : changedObjects;
082: }
083:
084: /**
085: * @see IModelChangedEvent#getChangedProperty
086: */
087: public String getChangedProperty() {
088: return changedProperty;
089: }
090:
091: /**
092: * Returns the old property value.
093: *
094: * @return the value before the change
095: */
096: public Object getOldValue() {
097: return oldValue;
098: }
099:
100: /**
101: * Returns the new property value.
102: *
103: * @return the value after the change
104: */
105: public Object getNewValue() {
106: return newValue;
107: }
108:
109: /**
110: * Returns the event change type
111: *
112: * @return the event change type
113: *
114: * @see IModelChangedEvent#getChangeType
115: */
116: public int getChangeType() {
117: return type;
118: }
119: }
|