Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b42426d930ef3c8ce74c1f3a1b877f5a65f010e9 (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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*****************************************************************************
 * Copyright (c) 2010 CEA LIST.
 *    
 * 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:
 *  Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
 *  Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
 *****************************************************************************/
package org.eclipse.papyrus.properties.runtime.modelhandler.emf;

import java.util.List;

import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.papyrus.properties.runtime.controller.EMFPropertyEditorController;
import org.eclipse.papyrus.properties.runtime.propertyeditor.descriptor.IPropertyEditorDescriptor;
import org.eclipse.papyrus.properties.runtime.view.IConfigurableDescriptor;
import org.eclipse.swt.widgets.Composite;


/**
 * Interface that manages conversion of values from String (coming from editors) and the model itself
 */
public interface IEMFModelHandler extends IConfigurableDescriptor {

	/**
	 * Returns the value to edit from the model
	 * 
	 * @param objectToEdit
	 *        the object to edit
	 * 
	 * @return the value to edit from the model
	 */
	public Object getValueToEdit(EObject objectToEdit);

	/**
	 * Sets the new Value in the model
	 * 
	 * @param objectToEdit
	 *        the object to edit
	 * @param newValue
	 *        the new value to set
	 */
	public void setValueInModel(EObject objectToEdit, Object newValue);

	/**
	 * Returns the initialization data that will be given to the property editor
	 * 
	 * @param descriptor
	 *        descriptor of the editor managed by the controller linked to this model handler
	 * @param objectToEdit
	 *        list of objects to edit
	 */
	public void completeEditorDescriptor(IPropertyEditorDescriptor descriptor, List<? extends EObject> objectToEdit);

	/**
	 * checks if the feature is changeable
	 * 
	 * @param objectsToEdit
	 *        the list of objects to edit
	 * @return <code>true</code> if the feature is changeable
	 */
	public boolean isChangeable(List<? extends EObject> objectsToEdit);

	/**
	 * Returns the identifier of this model handler
	 * 
	 * @return the identifier of this model handler
	 */
	public String getId();


	/**
	 * {@inheritDoc}
	 */
	public IEMFModelHandlerState createState(boolean readOnly);

	/**
	 * handle notifications for the model handler
	 * 
	 * @param notification
	 *        the notification to react to
	 * @param objects
	 *        the list of objects on which updates should be performed
	 * @param adapter
	 *        the adapter in charge of notification
	 */
	public void handleNotifyChange(Notification notification, List<? extends EObject> objects, EMFPropertyEditorController adapter);

	/**
	 * Returns available values for the feature managed by the model handler
	 * 
	 * @param object
	 *        the list of available values
	 * @return the list of available values
	 */
	public Object getAvailableValues(EObject object);

	/**
	 * Adds the listeners to the model
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @param controller
	 *        the controller which uses this model handler
	 */
	public void addListenersToModel(List<? extends EObject> objectsToEdit, EMFPropertyEditorController controller);

	/**
	 * Removes the listeners from the model
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @param controller
	 *        the controller which was using this model handler
	 */
	public void removeListenersFromModel(List<? extends EObject> objectsToEdit, EMFPropertyEditorController controller);

	/**
	 * Returns the operation to create a new value for this property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @param parent
	 *        the composite parent, needed in case of user interaction
	 * 
	 * @return the operation to create a new value for this property
	 */
	public List<IUndoableOperation> getCreateValueOperations(List<? extends EObject> objectsToEdit, Composite parent);

	/**
	 * Returns <code>true</code> if the controller can create a new value for the property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @return <code>true</code> if the controller can create a new value for the property
	 */
	public boolean canCreateValueOperations(List<? extends EObject> objectsToEdit);

	/**
	 * Returns the operation to delete a value for this property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @param parent
	 *        the composite parent, needed in case of user interaction
	 * @param indexes
	 *        list of indexes to delete
	 * @return the operation to delete a value for this property
	 * 
	 */
	public IUndoableOperation getDeleteValueOperation(List<? extends EObject> objectsToEdit, Composite parent, List<Integer> indexes);

	/**
	 * Returns <code>true</code> if the controller can delete a value for the property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @return <code>true</code> if the controller can delete a value for the property
	 */
	public boolean canCreateDeleteValueOperation(List<? extends EObject> objectsToEdit);

	/**
	 * Returns the operation to edit a value for this property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @param index
	 *        the index of the value to edit
	 * @param parent
	 *        the parent for the editor
	 * @param value
	 *        the value to set
	 * @return the operation to edit a value for this property
	 */
	public IUndoableOperation getEditValueOperation(List<? extends EObject> objectsToEdit, int index, Composite parent, Object value);

	/**
	 * Returns <code>true</code> if the controller can edit a value for the property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @return <code>true</code> if the controller can edit a value for the property
	 */
	public boolean canCreateEditValueOperation(List<? extends EObject> objectsToEdit);

	/**
	 * Returns the operation to move a list of values for this property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @param indexes
	 *        the list of indexes to move
	 * @param parent
	 *        the parent for the editor
	 * @param delta
	 *        the delta applied to all moved objects
	 * @return the operation to edit a value for this property
	 */
	public IUndoableOperation getMoveValueOperation(List<? extends EObject> objectsToEdit, List<Integer> indexes, Composite parent, int delta);

	/**
	 * Returns <code>true</code> if the controller can move a set of values for the property
	 * 
	 * @param objectsToEdit
	 *        the list of object to edit
	 * @param indexes
	 *        the list of indexes to move
	 * @param parent
	 *        the parent for the editor
	 * @param delta
	 *        the delta applied to all moved objects
	 * @return <code>true</code> if the controller can move a set of values for the property
	 */
	public boolean canCreateMoveValueOperation(List<? extends EObject> objectsToEdit, List<Integer> indexes, Composite parent, int delta);



	/**
	 * Returns a list of SetRequest for this object, or <code>null</code> if a request can't be created
	 * 
	 * @param domain
	 *        the transactional editing domain
	 * @param objectToEdit
	 *        the object to edit
	 * @param newValue
	 *        the new value for this object
	 * @return
	 *         a list of SetRequest for this object, or <code>null</code> if a request can't be created
	 */
	public SetRequest[] getSetRequest(TransactionalEditingDomain domain, EObject objectToEdit, Object newValue);
}

Back to the top