Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a3952f540d277365eee622d8103446d33070a380 (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
/*****************************************************************************
 * Copyright (c) 2019 CEA LIST and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *
 *****************************************************************************/

package org.eclipse.papyrus.infra.emf.expressions.edit.internal.properties;

import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.ui.provider.PropertySource;
import org.eclipse.papyrus.emf.ui.editor.factories.AbstractEStructuralFeatureDialogEditorFactory;
import org.eclipse.papyrus.emf.ui.properties.CustomPropertyDescriptor;
import org.eclipse.papyrus.infra.emf.expressions.booleanexpressions.BooleanExpressionsPackage;
import org.eclipse.papyrus.infra.emf.expressions.edit.internal.editor.factories.MultiBooleanExpressionsReferenceEditorFactory;
import org.eclipse.papyrus.infra.emf.expressions.edit.internal.editor.factories.SingleBooleanExpressionReferenceEditorFactory;
import org.eclipse.papyrus.infra.emf.expressions.edit.internal.editor.factories.SingleEAttributeReferenceExpressionEditorFactory;
import org.eclipse.ui.views.properties.IPropertyDescriptor;

/**
 * The {@link PropertySource} used to provide a better edition way for some properties of the EMF Expressions
 */
public class EMFExpressionPropertySource extends PropertySource {

	/**
	 * Constructor.
	 *
	 * @param object
	 * @param itemPropertySource
	 */
	public EMFExpressionPropertySource(final Object object, final IItemPropertySource itemPropertySource) {
		super(object, itemPropertySource);
	}

	/**
	 * @see org.eclipse.emf.edit.ui.provider.PropertySource#createPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor)
	 *
	 * @param itemPropertyDescriptor
	 * @return
	 */
	@Override
	protected IPropertyDescriptor createPropertyDescriptor(final IItemPropertyDescriptor itemPropertyDescriptor) {
		final EStructuralFeature f = (EStructuralFeature) itemPropertyDescriptor.getFeature(this.object);
		AbstractEStructuralFeatureDialogEditorFactory editorFactory = null;
		if (f == BooleanExpressionsPackage.eINSTANCE.getAndExpression_ReferencedExpressions()
				|| f == BooleanExpressionsPackage.eINSTANCE.getOrExpression_ReferencedExpressions()) {
			editorFactory = new MultiBooleanExpressionsReferenceEditorFactory(f);
		}
		if (f == BooleanExpressionsPackage.eINSTANCE.getNotExpression_ReferencedExpression()
				|| f == BooleanExpressionsPackage.eINSTANCE.getReferenceBooleanExpression_ReferencedExpression()) {
			editorFactory = new SingleBooleanExpressionReferenceEditorFactory(f);
		}
		if (f == BooleanExpressionsPackage.eINSTANCE.getSingleEAttributeValueEqualityExpression_EAttribute()) {
			editorFactory = new SingleEAttributeReferenceExpressionEditorFactory();
		}
		if (null != editorFactory) {
			return new CustomPropertyDescriptor(this.object, itemPropertyDescriptor, editorFactory);
		}
		return super.createPropertyDescriptor(itemPropertyDescriptor);
	}
}

Back to the top