Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2e0a40d3f4018bf29831b2cae2403a487179ff1b (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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
/*****************************************************************************
 * Copyright (c) 2013, 2014 CEA LIST 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:
 *  Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *  Christian W. Damus (CEA) - bug 323802
 *  Nicolas FAUVERGUE (ALL4tEC) nicolas.fauvergue@all4tec.net - Bug 476618
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.properties.modelelement;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.papyrus.infra.emf.nattable.selection.EObjectSelectionExtractor;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnDisplayFilterHeaderObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnDisplayIndexHeaderObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnDisplayLabelHeaderObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnFeatureLabelDisplayIconObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnFeatureLabelDisplayIsDerivedObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnFeatureLabelDisplayLabelObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnFeatureLabelDisplayMultiplicityObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnFeatureLabelDisplayNameObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnFeatureLabelDisplayTypeObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnIndexHeaderStyleObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnObjectLabelDisplayIconObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnObjectLabelDisplayLabelObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnPasteEObjectAxisIdentifierObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnPasteEObjectContainmentFeatureObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnPasteEObjectElementTypeIdObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnPasteObjectDetachedModeObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.ColumnPasteObjectPostActionsObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowDisplayIndexHeaderObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowDisplayLabelHeaderObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowFeatureLabelDisplayIconObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowFeatureLabelDisplayIsDerivedObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowFeatureLabelDisplayLabelObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowFeatureLabelDisplayMultiplicityObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowFeatureLabelDisplayNameObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowFeatureLabelDisplayTypeObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowIndexHeaderStyleObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowObjectLabelDisplayIconObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowObjectLabelDisplayLabelObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowPasteEObjectAxisIdentifierObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowPasteEObjectContainmentFeatureObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowPasteEObjectElementTypeIdObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowPasteObjectDetachedModeObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.observable.RowPasteObjectPostActionsObservableValue;
import org.eclipse.papyrus.infra.nattable.properties.provider.AxisIdentifierLabelProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.ColumnAxisIdentifierContentProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.ColumnContainmentFeatureContentProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.ColumnElementTypeIdContentProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.ColumnPostActionIdsProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.ContextFeatureContentProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.RowAxisIdentifierContentProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.RowContainmentFeatureContentProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.RowElementTypeIdContentProvider;
import org.eclipse.papyrus.infra.nattable.properties.provider.RowPostActionIdsProvider;
import org.eclipse.papyrus.infra.nattable.properties.utils.Constants;
import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
import org.eclipse.papyrus.infra.nattable.utils.NattableModelManagerFactory;
import org.eclipse.papyrus.infra.viewpoints.configuration.PapyrusView;
import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;


public class NatTableModelElement extends EMFModelElement {

	/**
	 * this listener used to update the value of the property view
	 */
	private Adapter tableListener;

	/**
	 * the map linking the propertypath and the observable values
	 */
	private Map<String, IObservable> observableValues;

	/**
	 * the collection of the interesting features to update the property view
	 */
	private Collection<EStructuralFeature> interestingFeatures;

	/**
	 * the row header axis configuration
	 */
	private AbstractHeaderAxisConfiguration rowHeaderAxisConfiguration;

	/**
	 * the column header axis configuration
	 */
	private AbstractHeaderAxisConfiguration columnHeaderAxisConfiguration;

	/**
	 * the list of the column label provider configuration
	 */
	private Collection<ILabelProviderConfiguration> columnLabelProviderConfigurations;


	/**
	 * the list of the row label provider configuration
	 */
	private Collection<ILabelProviderConfiguration> rowLabelProviderConfigurations;

	/**
	 * a table manager created to get possible axis contents
	 */
	private INattableModelManager tableModelManager;

	/**
	 *
	 * Constructor.
	 *
	 * @param source
	 *            the table
	 * @param domain
	 *            the editing domain
	 */
	public NatTableModelElement(final Table source, final EditingDomain domain) {
		super(source, domain);
		init();
	}

	/**
	 * Add the listener
	 */
	private void init() {
		tableModelManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(getEditedTable(), new EObjectSelectionExtractor());
		this.observableValues = new HashMap<String, IObservable>();
		this.interestingFeatures = new ArrayList<EStructuralFeature>();
		interestingFeatures.add(NattablePackage.eINSTANCE.getTable_Prototype());
		interestingFeatures.add(NattablePackage.eINSTANCE.getTable_Owner());
		interestingFeatures.add(NattablePackage.eINSTANCE.getTable_Context());
		interestingFeatures.add(NattablePackage.eINSTANCE.getTable_InvertAxis());
		interestingFeatures.add(NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration());
		interestingFeatures.add(NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration());
		interestingFeatures.add(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayFilter());
		interestingFeatures.add(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayIndex());
		interestingFeatures.add(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayLabel());
		interestingFeatures.add(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_IndexStyle());
		interestingFeatures.add(NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayIsDerived());
		interestingFeatures.add(NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayMultiplicity());
		interestingFeatures.add(NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayName());
		interestingFeatures.add(NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayType());
		interestingFeatures.add(NattablelabelproviderPackage.eINSTANCE.getObjectLabelProviderConfiguration_DisplayIcon());
		interestingFeatures.add(NattablelabelproviderPackage.eINSTANCE.getObjectLabelProviderConfiguration_DisplayLabel());

		this.tableListener = new AdapterImpl() {

			/**
			 *
			 * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
			 *
			 * @param msg
			 */
			@Override
			public void notifyChanged(Notification msg) {
				if (interestingFeatures.contains(msg.getFeature())) {
					updateValues();
				}
			}
		};
		// we add a listener on the main object managed by the property view
		source.eAdapters().add(tableListener);
		initOtherFieldsAndAddOthersListeners();

	}

	/**
	 * init the fields of the elements to listen (excepted the table itself)+ add listeners on them
	 */
	private void initOtherFieldsAndAddOthersListeners() {

		columnHeaderAxisConfiguration = HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisInTable(getEditedTable());
		rowHeaderAxisConfiguration = HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTable(getEditedTable());

		// COLUMNS MANAGEMENT
		// we add a listener on the columnHeaderAxisConfiguration
		if (columnHeaderAxisConfiguration != null) {
			columnHeaderAxisConfiguration.eAdapters().add(tableListener);
		}

		if (columnHeaderAxisConfiguration != null) {
			columnLabelProviderConfigurations = columnHeaderAxisConfiguration.getOwnedLabelConfigurations();
		}

		if (this.columnLabelProviderConfigurations != null) {
			// we add listener on all column label configurations
			for (final ILabelProviderConfiguration conf : columnLabelProviderConfigurations) {
				conf.eAdapters().add(tableListener);
			}
		}

		// ROW MANAGEMENT
		// we add a listener on the rowHeaderAxisConfiguration
		if (rowHeaderAxisConfiguration != null) {
			rowHeaderAxisConfiguration.eAdapters().add(tableListener);
		}

		if (rowHeaderAxisConfiguration != null) {
			rowLabelProviderConfigurations = rowHeaderAxisConfiguration.getOwnedLabelConfigurations();
		}

		if (this.rowLabelProviderConfigurations != null) {
			// we add listener on all column label configurations
			for (final ILabelProviderConfiguration conf : rowLabelProviderConfigurations) {
				conf.eAdapters().add(tableListener);
			}
		}



	}

	/**
	 * remove the listener
	 */
	private void removeListeners() {
		// COLUMNS MANAGEMENT
		// we add a listener on the columnHeaderAxisConfiguration
		if (columnHeaderAxisConfiguration != null) {
			columnHeaderAxisConfiguration.eAdapters().remove(tableListener);
		}



		if (this.columnLabelProviderConfigurations != null) {
			// we add listener on all column label configurations
			for (final ILabelProviderConfiguration conf : columnLabelProviderConfigurations) {
				conf.eAdapters().remove(tableListener);
			}
		}

		// ROW MANAGEMENT
		// we add a listener on the rowHeaderAxisConfiguration
		if (rowHeaderAxisConfiguration != null) {
			rowHeaderAxisConfiguration.eAdapters().remove(tableListener);
		}

		if (this.rowLabelProviderConfigurations != null) {
			// we add listener on all column label configurations
			for (final ILabelProviderConfiguration conf : rowLabelProviderConfigurations) {
				conf.eAdapters().remove(tableListener);
			}
		}
	}

	/**
	 * update all values in the property view
	 */
	private void updateValues() {
		// we do the update with asyncExec to be sure that the new values have been set before to update it
		Display.getDefault().asyncExec(new Runnable() {

			/**
			 *
			 * @see java.lang.Runnable#run()
			 *
			 */
			@Override
			public void run() {
				removeListeners();
				initOtherFieldsAndAddOthersListeners();

				final Event event = new Event();
				for (final IObservable current : observableValues.values()) {
					if (current instanceof Listener) {
						((Listener) current).handleEvent(event);
					}
				}
			}
		});
	}

	/**
	 *
	 * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#dispose()
	 *
	 */
	@Override
	public void dispose() {
		super.dispose();
		source.eAdapters().remove(tableListener);
		removeListeners();
		observableValues.clear();
		columnLabelProviderConfigurations = null;
		rowLabelProviderConfigurations = null;
		tableModelManager.dispose();
		tableModelManager = null;
	}


	/**
	 *
	 * @return
	 */
	private Table getEditedTable() {
		return (Table) source;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#doGetObservable(java.lang.String)
	 *
	 * @param propertyPath
	 * @return
	 */
	@Override
	protected IObservable doGetObservable(final String propertyPath) {
		IObservable value = this.observableValues.get(propertyPath);
		if (value == null) {
			Table table = getEditedTable();
			// column header properties
			if (Constants.LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION_DISPLAY_FILTER.equals(propertyPath)) {
				value = new ColumnDisplayFilterHeaderObservableValue(table);
			} else if (Constants.LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION_DISPLAY_INDEX.equals(propertyPath)) {
				value = new ColumnDisplayIndexHeaderObservableValue(table);
			} else if (Constants.LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				value = new ColumnDisplayLabelHeaderObservableValue(table);
			} else if (Constants.LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION_INDEX_STYLE.equals(propertyPath)) {
				value = new ColumnIndexHeaderStyleObservableValue(table);


				// row header property
			} else if (Constants.LOCAL_ROW_HEADER_AXIS_CONFIGURATION_DISPLAY_INDEX.equals(propertyPath)) {
				value = new RowDisplayIndexHeaderObservableValue(table);
			} else if (Constants.LOCAL_ROW_HEADER_AXIS_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				value = new RowDisplayLabelHeaderObservableValue(table);
			} else if (Constants.LOCAL_ROW_HEADER_AXIS_CONFIGURATION_INDEX_STYLE.equals(propertyPath)) {
				value = new RowIndexHeaderStyleObservableValue(table);


				// feature column label property
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				value = new ColumnFeatureLabelDisplayIconObservableValue(table);
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				value = new ColumnFeatureLabelDisplayLabelObservableValue(table);
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_IS_DERIVED.equals(propertyPath)) {
				value = new ColumnFeatureLabelDisplayIsDerivedObservableValue(table);
			} else if (Constants.COLUMN__FEATURE_LABEL_CONFIGURATION_DISPLAY_NAME.equals(propertyPath)) {
				value = new ColumnFeatureLabelDisplayNameObservableValue(table);
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_TYPE.equals(propertyPath)) {
				value = new ColumnFeatureLabelDisplayTypeObservableValue(table);
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_MULTIPLICITY.equals(propertyPath)) {
				value = new ColumnFeatureLabelDisplayMultiplicityObservableValue(table);


				// object column label property
			} else if (Constants.COLUMN_OBJECT_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				value = new ColumnObjectLabelDisplayIconObservableValue(table);
			} else if (Constants.COLUMN_OBJECT_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				value = new ColumnObjectLabelDisplayLabelObservableValue(table);
			} else

			// feature row label property
				if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				value = new RowFeatureLabelDisplayIconObservableValue(table);
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				value = new RowFeatureLabelDisplayLabelObservableValue(table);
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_IS_DERIVED.equals(propertyPath)) {
				value = new RowFeatureLabelDisplayIsDerivedObservableValue(table);
			} else if (Constants.ROW__FEATURE_LABEL_CONFIGURATION_DISPLAY_NAME.equals(propertyPath)) {
				value = new RowFeatureLabelDisplayNameObservableValue(table);
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_TYPE.equals(propertyPath)) {
				value = new RowFeatureLabelDisplayTypeObservableValue(table);
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_MULTIPLICITY.equals(propertyPath)) {
				value = new RowFeatureLabelDisplayMultiplicityObservableValue(table);


				// object row label property
			} else if (Constants.ROW_OBJECT_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				value = new RowObjectLabelDisplayIconObservableValue(table);
			} else if (Constants.ROW_OBJECT_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				value = new RowObjectLabelDisplayLabelObservableValue(table);
			}

			// paste row EObject
			else if (Constants.ROW_PASTED_EOBJECT_CONTAINMENT_FEATURE.equals(propertyPath)) {
				value = new RowPasteEObjectContainmentFeatureObservableValue(table);
			} else if (Constants.ROW_PASTED_EOBJECT_ID.equals(propertyPath)) {
				value = new RowPasteEObjectElementTypeIdObservableValue(table);
			} else if (Constants.ROW_PASTED_OBJECT_DETACHED_MODE_FEATURE.equals(propertyPath)) {
				value = new RowPasteObjectDetachedModeObservableValue(getEditedTable());
			} else if (Constants.ROW_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
				value = new RowPasteObjectPostActionsObservableValue(getDomain(), getEditedTable());
			} else if (Constants.ROW_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath)) {
				value = new RowPasteEObjectAxisIdentifierObservableValue(table);
			}

			// paste column EObject
			else if (Constants.COLUMN_PASTED_EOBJECT_CONTAINMENT_FEATURE.equals(propertyPath)) {
				value = new ColumnPasteEObjectContainmentFeatureObservableValue(table);
			} else if (Constants.COLUMN_PASTED_EOBJECT_ID.equals(propertyPath)) {
				value = new ColumnPasteEObjectElementTypeIdObservableValue(table);
			} else if (Constants.COLUMN_PASTED_OBJECT_DETACHED_MODE_FEATURE.equals(propertyPath)) {
				value = new ColumnPasteObjectDetachedModeObservableValue(getEditedTable());
			} else if (Constants.COLUMN_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
				value = new ColumnPasteObjectPostActionsObservableValue(getDomain(), getEditedTable());
			} else if (Constants.COLUMN_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath)) {
				value = new ColumnPasteEObjectAxisIdentifierObservableValue(table);
			}

			if (value != null) {
				this.observableValues.put(propertyPath, value);
			}
		}
		if (value != null) {
			return value;
		}
		return super.doGetObservable(propertyPath);
	}

	/**
	 * @param propertyPath
	 * @return
	 */
	@Override
	protected boolean isFeatureEditable(String propertyPath) {
		boolean res = super.isFeatureEditable(propertyPath);
		if (!res) {
			// feature column label property
			if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				res = true;
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				res = true;
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_IS_DERIVED.equals(propertyPath)) {
				res = true;
			} else if (Constants.COLUMN__FEATURE_LABEL_CONFIGURATION_DISPLAY_NAME.equals(propertyPath)) {
				res = true;
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_TYPE.equals(propertyPath)) {
				res = true;
			} else if (Constants.COLUMN_FEATURE_LABEL_CONFIGURATION_DISPLAY_MULTIPLICITY.equals(propertyPath)) {
				res = true;

				// object column label property
			} else if (Constants.COLUMN_OBJECT_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				res = true;
			} else if (Constants.COLUMN_OBJECT_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				res = true;
			}



			// feature row label property
			else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				res = true;
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				res = true;
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_IS_DERIVED.equals(propertyPath)) {
				res = true;
			} else if (Constants.ROW__FEATURE_LABEL_CONFIGURATION_DISPLAY_NAME.equals(propertyPath)) {
				res = true;
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_TYPE.equals(propertyPath)) {
				res = true;
			} else if (Constants.ROW_FEATURE_LABEL_CONFIGURATION_DISPLAY_MULTIPLICITY.equals(propertyPath)) {
				res = true;

				// object row label property
			} else if (Constants.ROW_OBJECT_LABEL_CONFIGURATION_DISPLAY_ICON.equals(propertyPath)) {
				res = true;
			} else if (Constants.ROW_OBJECT_LABEL_CONFIGURATION_DISPLAY_LABEL.equals(propertyPath)) {
				res = true;
			}

			// paste row EObject
			else if (Constants.ROW_PASTED_EOBJECT_CONTAINMENT_FEATURE.equals(propertyPath)) {
				res = new RowContainmentFeatureContentProvider(getEditedTable()).getElements().length != 0;
			} else if (Constants.ROW_PASTED_EOBJECT_ID.equals(propertyPath)) {
				res = new RowElementTypeIdContentProvider(this.tableModelManager).getElements().length != 0;
			} else if (Constants.ROW_PASTED_OBJECT_DETACHED_MODE_FEATURE.equals(propertyPath)) {
				res = true;
			} else if (Constants.ROW_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
				res = new RowPostActionIdsProvider(this.tableModelManager).getElements().length != 0;
			} else if (Constants.ROW_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath)) {
				res = new RowAxisIdentifierContentProvider(this.tableModelManager).getElements().length != 0;

				// paste column EObject
			} else if (Constants.COLUMN_PASTED_EOBJECT_CONTAINMENT_FEATURE.equals(propertyPath)) {
				res = new ColumnContainmentFeatureContentProvider(getEditedTable()).getElements().length != 0;
			} else if (Constants.COLUMN_PASTED_EOBJECT_ID.equals(propertyPath)) {
				res = new ColumnElementTypeIdContentProvider(this.tableModelManager).getElements().length != 0;
			} else if (Constants.COLUMN_PASTED_OBJECT_DETACHED_MODE_FEATURE.equals(propertyPath)) {
				res = true;
			} else if (Constants.COLUMN_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
				res = new ColumnPostActionIdsProvider(this.tableModelManager).getElements().length != 0;
			} else if (Constants.COLUMN_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath)) {
				res = new ColumnAxisIdentifierContentProvider(this.tableModelManager).getElements().length != 0;
			}
		}

		return res;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#getContentProvider(java.lang.String)
	 *
	 * @param propertyPath
	 * @return
	 */
	@Override
	public IStaticContentProvider getContentProvider(final String propertyPath) {
		IStaticContentProvider provider = null;
		if (Constants.TABLE_CONTEXT.equals(propertyPath)) {
			Table table = getEditedTable();
			provider = new ContextFeatureContentProvider(table, getRoot(table.getContext()));
		} else if (Constants.ROW_PASTED_EOBJECT_CONTAINMENT_FEATURE.equals(propertyPath)) {
			provider = new RowContainmentFeatureContentProvider(getEditedTable());
		} else if (Constants.COLUMN_PASTED_EOBJECT_CONTAINMENT_FEATURE.equals(propertyPath)) {
			provider = new ColumnContainmentFeatureContentProvider(getEditedTable());
		} else if (Constants.ROW_PASTED_EOBJECT_ID.equals(propertyPath)) {
			provider = new RowElementTypeIdContentProvider(this.tableModelManager);
		} else if (Constants.COLUMN_PASTED_EOBJECT_ID.equals(propertyPath)) {
			provider = new ColumnElementTypeIdContentProvider(this.tableModelManager);
		} else if (Constants.ROW_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
			provider = new RowPostActionIdsProvider(this.tableModelManager);
		} else if (Constants.COLUMN_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
			provider = new RowPostActionIdsProvider(this.tableModelManager);
		} else if (Constants.ROW_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath)) {
			provider = new RowAxisIdentifierContentProvider(tableModelManager);
		} else if (Constants.COLUMN_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath)) {
			provider = new ColumnAxisIdentifierContentProvider(tableModelManager);
		}
		if (provider != null) {
			return provider;
		}
		return super.getContentProvider(propertyPath);
	}
	
	/**
	 *
	 * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#isUnique(java.lang.String)
	 *
	 * @param propertyPath
	 * @return
	 */
	@Override
	public boolean isUnique(final String propertyPath) {
		if (Constants.ROW_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
			return true;
		} else if (Constants.COLUMN_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
			return true;
		}
		return super.isUnique(propertyPath);
	}

	/**
	 *
	 * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#isOrdered(java.lang.String)
	 *
	 * @param propertyPath
	 * @return
	 */
	@Override
	public boolean isOrdered(final String propertyPath) {
		if (Constants.ROW_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
			return true;
		} else if (Constants.COLUMN_PASTED_OBJECT_POST_ACTIONS_FEATURE.equals(propertyPath)) {
			return true;
		}
		return super.isOrdered(propertyPath);
	}

	@Override
	public ILabelProvider getLabelProvider(String propertyPath) {
		ILabelProvider provider = null;
		if (propertyPath.endsWith("prototype")) { //$NON-NLS-1$
			provider = new ILabelProvider() {
				@Override
				public void addListener(ILabelProviderListener listener) {
				}

				@Override
				public void removeListener(ILabelProviderListener listener) {
				}

				@Override
				public void dispose() {
				}

				@Override
				public boolean isLabelProperty(Object element, String property) {
					return false;
				}

				@Override
				public Image getImage(Object element) {
					if (element == null) {
						return null;
					}
					ViewPrototype proto = ViewPrototype.get((PapyrusView) element);
					return proto.getIcon();
				}

				@Override
				public String getText(Object element) {
					if (element == null) {
						return null;
					}
					ViewPrototype proto = ViewPrototype.get((PapyrusView) element);
					return proto.getQualifiedName();
				}
			};
		}
		
		if (Constants.COLUMN_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath) || Constants.ROW_PASTED_EOBJECT_AXIS_IDENTIFIER_FEATURE.equals(propertyPath)) {
			provider = new AxisIdentifierLabelProvider(tableModelManager);
		}
		
		if(null == provider){
			provider = super.getLabelProvider(propertyPath);
		}
		return provider;
	}

	/**
	 * Gets the root EObject from the given one
	 *
	 * @param obj
	 *            An object
	 * @return The root object which is an ancestor of the given one
	 */
	private EObject getRoot(EObject obj) {
		EObject current = obj;
		EObject parent = obj.eContainer();
		while (parent != null) {
			current = parent;
			parent = parent.eContainer();
		}
		return current;
	}
}

Back to the top