Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a8489e0ce7222d2b40ceab02241c62ded944e5f6 (plain) (blame)
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
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.pde.core;
/**
 * @see IModelChangedEvent
 * 
 * @since 2.0
 */
public class ModelChangedEvent implements IModelChangedEvent {
	private int type;
	private IModelChangeProvider provider;
	private Object[] changedObjects;
	private Object oldValue, newValue;
	private String changedProperty;
	/**
	 * The constructor of the event.
	 * 
	 * @param provider
	 *            the change provider
	 * @param type
	 *            the event type
	 * @param objects
	 *            the changed objects
	 * @param changedProperty
	 *            or <samp>null </samp> if not applicable
	 */
	public ModelChangedEvent(IModelChangeProvider provider, int type,
			Object[] objects, String changedProperty) {
		this.type = type;
		this.provider = provider;
		this.changedObjects = objects;
		this.changedProperty = changedProperty;
	}
	/**
	 * A costructor that should be used for changes of object properties.
	 * 
	 * @param provider
	 *            the event provider
	 * @param object
	 *            affected object
	 * @param changedProperty
	 *            changed property of the affected object
	 * @param oldValue
	 *            the value before the change
	 * @param newValue
	 *            the value after the change
	 */
	public ModelChangedEvent(IModelChangeProvider provider, Object object,
			String changedProperty, Object oldValue, Object newValue) {
		this.type = CHANGE;
		this.provider = provider;
		this.changedObjects = new Object[]{object};
		this.changedProperty = changedProperty;
		this.oldValue = oldValue;
		this.newValue = newValue;
	}
	/**
	 * @see IModelChangedEvent#getChangeProvider
	 */
	public IModelChangeProvider getChangeProvider() {
		return provider;
	}
	/**
	 * @see IModelChangedEvent#getChangedObjects
	 */
	public Object[] getChangedObjects() {
		return (changedObjects == null) ? new Object[0] : changedObjects;
	}
	/**
	 * @see IModelChangedEvent#getChangedProperty
	 */
	public String getChangedProperty() {
		return changedProperty;
	}
	/**
	 *  Returns the old property value.
	 * 
	 * @return the value before the change
	 */
	public Object getOldValue() {
		return oldValue;
	}
	/**
	 *  Returns the new property value.
	 * 
	 * @return the value after the change
	 */
	public Object getNewValue() {
		return newValue;
	}
	/**
	 *  Returns the event change type
	 *  
	 *  @return the event change type
	 *  
	 *  @see IModelChangedEvent#getChangeType
	 */
	public int getChangeType() {
		return type;
	}
}

Back to the top