Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7644f607c127ad972e8286eb29aed251e0cab1c9 (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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*******************************************************************************
 * Copyright (c) 2008, 2012 Obeo.
 * 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:
 *     Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.eef.eefnr.components;

// Start of user code for imports
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.WrappedException;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;

import org.eclipse.emf.ecore.resource.ResourceSet;

import org.eclipse.emf.ecore.util.EcoreUtil;

import org.eclipse.emf.eef.eefnr.EefnrFactory;
import org.eclipse.emf.eef.eefnr.EefnrPackage;
import org.eclipse.emf.eef.eefnr.LinkEReferenceViewerSample;
import org.eclipse.emf.eef.eefnr.TextSample;
import org.eclipse.emf.eef.eefnr.TotalSample;

import org.eclipse.emf.eef.eefnr.parts.EefnrViewsRepository;
import org.eclipse.emf.eef.eefnr.parts.LinkEReferenceViewerSamplePropertiesEditionPart;
import org.eclipse.emf.eef.eefnr.parts.impl.LinkEReferenceViewerSamplePropertiesEditionPartImpl;

import org.eclipse.emf.eef.runtime.api.notify.EStructuralFeatureNotificationFilter;
import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.api.notify.NotificationFilter;

import org.eclipse.emf.eef.runtime.context.PropertiesEditingContext;

import org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext;
import org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext;
import org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext.InstanciableTypeFilter;

import org.eclipse.emf.eef.runtime.impl.components.SinglePartPropertiesEditingComponent;

import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent;

import org.eclipse.emf.eef.runtime.impl.utils.EEFConverterUtil;

import org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy;

import org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider;

import org.eclipse.emf.eef.runtime.ui.widgets.ButtonsModeEnum;

import org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings;

import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings;


// End of user code

/**
 * @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a>
 * 
 */
public class LinkEReferenceViewerSamplePropertiesEditionComponent extends SinglePartPropertiesEditingComponent {

	
	public static String BASE_PART = "Base"; //$NON-NLS-1$

	
	/**
	 * Settings for linkereferenceviewerRequiredProperty LinkEReferenceViewer
	 */
	private EObjectFlatComboSettings linkereferenceviewerRequiredPropertySettings;
	
	/**
	 * Creation Settings for linkereferenceviewerRequiredProperty LinkEReferenceViewer
	 */
	private ReferencesTableSettings linkereferenceviewerRequiredPropertyCreateSettings;
	
	/**
	 * Settings for linkereferenceviewerOptionalProperty LinkEReferenceViewer
	 */
	private EObjectFlatComboSettings linkereferenceviewerOptionalPropertySettings;
	
	/**
	 * Creation Settings for linkereferenceviewerOptionalProperty LinkEReferenceViewer
	 */
	private ReferencesTableSettings linkereferenceviewerOptionalPropertyCreateSettings;
	
	/**
	 * Settings for linkereferenceviewerROProperty LinkEReferenceViewer
	 */
	private EObjectFlatComboSettings linkereferenceviewerROPropertySettings;
	
	/**
	 * Creation Settings for linkereferenceviewerROProperty LinkEReferenceViewer
	 */
	private ReferencesTableSettings linkereferenceviewerROPropertyCreateSettings;
	
	
	/**
	 * Default constructor
	 * 
	 */
	public LinkEReferenceViewerSamplePropertiesEditionComponent(PropertiesEditingContext editingContext, EObject linkEReferenceViewerSample, String editing_mode) {
		super(editingContext, linkEReferenceViewerSample, editing_mode);
		parts = new String[] { BASE_PART };
		repositoryKey = EefnrViewsRepository.class;
		partKey = EefnrViewsRepository.LinkEReferenceViewerSample.class;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
	 *      org.eclipse.emf.ecore.resource.ResourceSet)
	 * 
	 */
	public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
		setInitializing(true);
		if (editingPart != null && key == partKey) {
			editingPart.setContext(elt, allResource);
			
			final LinkEReferenceViewerSample linkEReferenceViewerSample = (LinkEReferenceViewerSample)elt;
			final LinkEReferenceViewerSamplePropertiesEditionPart basePart = (LinkEReferenceViewerSamplePropertiesEditionPart)editingPart;
			// init values
			if (isAccessible(EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerRequiredPropery)) {
				// init part
				linkereferenceviewerRequiredPropertySettings = new EObjectFlatComboSettings(linkEReferenceViewerSample, EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerRequiredProperty());
				linkereferenceviewerRequiredPropertyCreateSettings = new ReferencesTableSettings(getlinkereferenceviewerRequiredPropertyCreateSettingsSource(), EefnrPackage.eINSTANCE.getRoot_Samples());
				basePart.initLinkereferenceviewerRequiredPropery(linkereferenceviewerRequiredPropertySettings);
				// set the button mode
				basePart.setLinkereferenceviewerRequiredProperyButtonMode(ButtonsModeEnum.BROWSE);
			}
			if (isAccessible(EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerOptionalPropery)) {
				// init part
				linkereferenceviewerOptionalPropertySettings = new EObjectFlatComboSettings(linkEReferenceViewerSample, EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerOptionalProperty());
				linkereferenceviewerOptionalPropertyCreateSettings = new ReferencesTableSettings(getlinkereferenceviewerOptionalPropertyCreateSettingsSource(), EefnrPackage.eINSTANCE.getRoot_Samples());
				basePart.initLinkereferenceviewerOptionalPropery(linkereferenceviewerOptionalPropertySettings);
				// set the button mode
				basePart.setLinkereferenceviewerOptionalProperyButtonMode(ButtonsModeEnum.BROWSE);
			}
			if (isAccessible(EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerROPropery)) {
				// init part
				linkereferenceviewerROPropertySettings = new EObjectFlatComboSettings(linkEReferenceViewerSample, EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerROPropery());
				linkereferenceviewerROPropertyCreateSettings = new ReferencesTableSettings(getlinkereferenceviewerROPropertyCreateSettingsSource(), EefnrPackage.eINSTANCE.getRoot_Samples());
				basePart.initLinkereferenceviewerROPropery(linkereferenceviewerROPropertySettings);
				// set the button mode
				basePart.setLinkereferenceviewerROProperyButtonMode(ButtonsModeEnum.BROWSE);
			}
			// init filters
			
			
			
			// init values for referenced views
			
			// init filters for referenced views
			
		}
		setInitializing(false);
	}






	/**
	 * {@inheritDoc}
	 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#associatedFeature(java.lang.Object)
	 */
	public EStructuralFeature associatedFeature(Object editorKey) {
		if (editorKey == EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerRequiredPropery) {
			return EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerRequiredProperty();
		}
		if (editorKey == EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerOptionalPropery) {
			return EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerOptionalProperty();
		}
		if (editorKey == EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerROPropery) {
			return EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerROPropery();
		}
		return super.associatedFeature(editorKey);
	}

	/**
	 * {@inheritDoc}
	 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
	 * 
	 */
	public void updateSemanticModel(final IPropertiesEditionEvent event) {
		LinkEReferenceViewerSample linkEReferenceViewerSample = (LinkEReferenceViewerSample)semanticObject;
		if (EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerRequiredPropery == event.getAffectedEditor()) {
			if (event.getKind() == PropertiesEditionEvent.SET) {
				linkereferenceviewerRequiredPropertySettings.setToReference((TextSample)event.getNewValue());
			} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
				EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
				PropertiesEditingProvider provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
				if (provider != null) {
					PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
					if (editionPolicy != null) {
						editionPolicy.execute();
					}
				}
			} else if (event.getKind() == PropertiesEditionEvent.ADD) {
				TextSample eObject = EefnrFactory.eINSTANCE.createTextSample();
				EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, linkereferenceviewerRequiredPropertyCreateSettings, editingContext.getAdapterFactory());
				context.addInstanciableTypeFilter(new InstanciableTypeFilter() {
					public boolean select(EClass instanciableType) {
						return EefnrPackage.Literals.TEXT_SAMPLE == instanciableType;
					}
				});
				PropertiesEditingProvider provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt(eObject, PropertiesEditingProvider.class);
				if (provider != null) {
					PropertiesEditingPolicy policy = provider.getPolicy(context);
					if (policy != null) {
						policy.execute();
					}
				}
				linkereferenceviewerRequiredPropertySettings.setToReference(context.getEObject());
				((LinkEReferenceViewerSamplePropertiesEditionPart)editingPart).setLinkereferenceviewerRequiredPropery(context.getEObject());
			}
		}
		if (EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerOptionalPropery == event.getAffectedEditor()) {
			if (event.getKind() == PropertiesEditionEvent.SET) {
				linkereferenceviewerOptionalPropertySettings.setToReference((TextSample)event.getNewValue());
			} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
				EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
				PropertiesEditingProvider provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
				if (provider != null) {
					PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
					if (editionPolicy != null) {
						editionPolicy.execute();
					}
				}
			} else if (event.getKind() == PropertiesEditionEvent.ADD) {
				TextSample eObject = EefnrFactory.eINSTANCE.createTextSample();
				EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, linkereferenceviewerOptionalPropertyCreateSettings, editingContext.getAdapterFactory());
				context.addInstanciableTypeFilter(new InstanciableTypeFilter() {
					public boolean select(EClass instanciableType) {
						return EefnrPackage.Literals.TEXT_SAMPLE == instanciableType;
					}
				});
				PropertiesEditingProvider provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt(eObject, PropertiesEditingProvider.class);
				if (provider != null) {
					PropertiesEditingPolicy policy = provider.getPolicy(context);
					if (policy != null) {
						policy.execute();
					}
				}
				linkereferenceviewerOptionalPropertySettings.setToReference(context.getEObject());
				((LinkEReferenceViewerSamplePropertiesEditionPart)editingPart).setLinkereferenceviewerOptionalPropery(context.getEObject());
			}
		}
	}

	/**
	 * {@inheritDoc}
	 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
	 */
	public void updatePart(Notification msg) {
		super.updatePart(msg);
		if (editingPart.isVisible()) {
			LinkEReferenceViewerSamplePropertiesEditionPart basePart = (LinkEReferenceViewerSamplePropertiesEditionPart)editingPart;
			if (EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerRequiredProperty().equals(msg.getFeature()) && basePart != null && isAccessible(EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerRequiredPropery))
				basePart.setLinkereferenceviewerRequiredPropery((EObject)msg.getNewValue());
			if (EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerOptionalProperty().equals(msg.getFeature()) && basePart != null && isAccessible(EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerOptionalPropery))
				basePart.setLinkereferenceviewerOptionalPropery((EObject)msg.getNewValue());
			if (EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerROPropery().equals(msg.getFeature()) && basePart != null && isAccessible(EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerROPropery))
				basePart.setLinkereferenceviewerROPropery((EObject)msg.getNewValue());
			
		}
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#getNotificationFilters()
	 */
	@Override
	protected NotificationFilter[] getNotificationFilters() {
		NotificationFilter filter = new EStructuralFeatureNotificationFilter(
			EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerRequiredProperty(),
			EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerOptionalProperty(),
			EefnrPackage.eINSTANCE.getLinkEReferenceViewerSample_LinkereferenceviewerROPropery()		);
		return new NotificationFilter[] {filter,};
	}


	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#isRequired(java.lang.Object, int)
	 * 
	 */
	public boolean isRequired(Object key, int kind) {
		return key == EefnrViewsRepository.LinkEReferenceViewerSample.Properties.linkereferenceviewerRequiredPropery;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
	 * 
	 */
	public Diagnostic validateValue(IPropertiesEditionEvent event) {
		Diagnostic ret = Diagnostic.OK_INSTANCE;
		if (event.getNewValue() != null) {
			try {
			} catch (IllegalArgumentException iae) {
				ret = BasicDiagnostic.toDiagnostic(iae);
			} catch (WrappedException we) {
				ret = BasicDiagnostic.toDiagnostic(we);
			}
		}
		return ret;
	}


	

	
	/**
	 * @ return source setting for linkereferenceviewerRequiredPropertyCreateSettings
	 */
	public EObject getlinkereferenceviewerRequiredPropertyCreateSettingsSource() {
		return semanticObject.eContainer();
	}	
	
	/**
	 * @ return source setting for linkereferenceviewerOptionalPropertyCreateSettings
	 */
	public EObject getlinkereferenceviewerOptionalPropertyCreateSettingsSource() {
		return semanticObject.eContainer();
	}	
	
	/**
	 * @ return source setting for linkereferenceviewerROPropertyCreateSettings
	 */
	public EObject getlinkereferenceviewerROPropertyCreateSettingsSource() {
		return semanticObject.eContainer();
	}	
	

}

Back to the top