KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > core > ModelChangedEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 package org.eclipse.pde.core;
12 /**
13  * @see IModelChangedEvent
14  *
15  * @since 2.0
16  */

17 public class ModelChangedEvent implements IModelChangedEvent {
18     private int type;
19     private IModelChangeProvider provider;
20     private Object JavaDoc[] changedObjects;
21     private Object JavaDoc oldValue, newValue;
22     private String JavaDoc changedProperty;
23     /**
24      * The constructor of the event.
25      *
26      * @param provider
27      * the change provider
28      * @param type
29      * the event type
30      * @param objects
31      * the changed objects
32      * @param changedProperty
33      * or <samp>null </samp> if not applicable
34      */

35     public ModelChangedEvent(IModelChangeProvider provider, int type,
36             Object JavaDoc[] objects, String JavaDoc changedProperty) {
37         this.type = type;
38         this.provider = provider;
39         this.changedObjects = objects;
40         this.changedProperty = changedProperty;
41     }
42     /**
43      * A costructor that should be used for changes of object properties.
44      *
45      * @param provider
46      * the event provider
47      * @param object
48      * affected object
49      * @param changedProperty
50      * changed property of the affected object
51      * @param oldValue
52      * the value before the change
53      * @param newValue
54      * the value after the change
55      */

56     public ModelChangedEvent(IModelChangeProvider provider, Object JavaDoc object,
57             String JavaDoc changedProperty, Object JavaDoc oldValue, Object JavaDoc newValue) {
58         this.type = CHANGE;
59         this.provider = provider;
60         this.changedObjects = new Object JavaDoc[]{object};
61         this.changedProperty = changedProperty;
62         this.oldValue = oldValue;
63         this.newValue = newValue;
64     }
65     /**
66      * @see IModelChangedEvent#getChangeProvider
67      */

68     public IModelChangeProvider getChangeProvider() {
69         return provider;
70     }
71     /**
72      * @see IModelChangedEvent#getChangedObjects
73      */

74     public Object JavaDoc[] getChangedObjects() {
75         return (changedObjects == null) ? new Object JavaDoc[0] : changedObjects;
76     }
77     /**
78      * @see IModelChangedEvent#getChangedProperty
79      */

80     public String JavaDoc getChangedProperty() {
81         return changedProperty;
82     }
83     /**
84      * Returns the old property value.
85      *
86      * @return the value before the change
87      */

88     public Object JavaDoc getOldValue() {
89         return oldValue;
90     }
91     /**
92      * Returns the new property value.
93      *
94      * @return the value after the change
95      */

96     public Object JavaDoc getNewValue() {
97         return newValue;
98     }
99     /**
100      * Returns the event change type
101      *
102      * @return the event change type
103      *
104      * @see IModelChangedEvent#getChangeType
105      */

106     public int getChangeType() {
107         return type;
108     }
109 }
110
Popular Tags