diff options
| author | Stéphane Bégaudeau | 2016-08-02 13:41:29 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2016-08-22 13:55:46 +0000 |
| commit | 3c3e22a501ac813e4fbf097c32244923bda3c6cb (patch) | |
| tree | 311a0588cd02d945eaa93426ea02164fa1b608a0 | |
| parent | f0c699a6118b98aa95ab8db6e217363b6e9694b0 (diff) | |
| download | org.eclipse.sirius-3c3e22a501ac813e4fbf097c32244923bda3c6cb.tar.gz org.eclipse.sirius-3c3e22a501ac813e4fbf097c32244923bda3c6cb.tar.xz org.eclipse.sirius-3c3e22a501ac813e4fbf097c32244923bda3c6cb.zip | |
[499050] Contribute the extension reference widget to the default rules
1) Add an identifier to the widgets used by the default rules
2) Add an IDescriptionConverter to replace the widgets of the default
rules used to display a reference by the extension reference widget
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=499050
Change-Id: Ib45314d79fe83e4e5c5e4b0d38efb534165b7b9e
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
4 files changed, 112 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.properties b/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.properties index a63ca165fc..deb7b89fef 100644 --- a/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.properties +++ b/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.properties @@ -16,4 +16,7 @@ referenceDescriptionConverter.Label=Sirius Extension Reference Widget Converter referenceDescriptionConverter.Description=This extension is used to convert the definition of the Extension Reference Widget. viewerFilterProvider.Label=Sirius Viewer Filter Provider -viewerFilterProvider.Description=This extension is used to filter the content of the tree viewer used to select and create a value in the Extension Reference Widget.
\ No newline at end of file +viewerFilterProvider.Description=This extension is used to filter the content of the tree viewer used to select and create a value in the Extension Reference Widget. + +defaultRulesReferenceDescriptionConverter.Label=Sirius Default Rules Converter +defaultRulesReferenceDescriptionConverter.Description=This extension is used to convert the default rules to support the extension reference widget instead of the regular reference widget.
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.xml b/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.xml index 42290a9a43..fb9d9b92f3 100644 --- a/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.xml +++ b/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/plugin.xml @@ -11,6 +11,15 @@ </descriptor> </extension> <extension + point="org.eclipse.sirius.ui.properties.descriptionConverter"> + <descriptor + class="org.eclipse.sirius.ui.properties.ext.widgets.reference.internal.DefaultRulesReferenceDescriptionConverter" + description="%defaultRulesReferenceDescriptionConverter.Description" + id="org.eclipse.sirius.ui.properties.ext.widgets.reference.defaultrules.descriptionConverter" + label="%defaultRulesReferenceDescriptionConverter.Label"> + </descriptor> + </extension> + <extension point="org.eclipse.eef.ide.ui.ext.widgets.reference.eefExtReferenceViewerFilterProvider"> <descriptor class="org.eclipse.sirius.ui.properties.ext.widgets.reference.internal.EEFExtReferenceViewerFilterProvider" diff --git a/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/src/org/eclipse/sirius/ui/properties/ext/widgets/reference/internal/DefaultRulesReferenceDescriptionConverter.java b/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/src/org/eclipse/sirius/ui/properties/ext/widgets/reference/internal/DefaultRulesReferenceDescriptionConverter.java new file mode 100644 index 0000000000..a0aca77dde --- /dev/null +++ b/plugins/org.eclipse.sirius.ui.properties.ext.widgets.reference/src/org/eclipse/sirius/ui/properties/ext/widgets/reference/internal/DefaultRulesReferenceDescriptionConverter.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2016 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.sirius.ui.properties.ext.widgets.reference.internal; + +import java.util.Arrays; +import java.util.Map; + +import org.eclipse.eef.ext.widgets.reference.eefextwidgetsreference.EEFExtReferenceDescription; +import org.eclipse.eef.ext.widgets.reference.eefextwidgetsreference.EefExtWidgetsReferenceFactory; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.sirius.properties.DynamicMappingIf; +import org.eclipse.sirius.properties.WidgetDescription; +import org.eclipse.sirius.ui.properties.api.DescriptionCache; +import org.eclipse.sirius.ui.properties.api.IDescriptionConverter; + +/** + * This {@link IDescriptionConverter} is used to replace the widget used by the + * default rules for the references by the extension reference widget. + * + * @author sbegaudeau + */ +public class DefaultRulesReferenceDescriptionConverter implements IDescriptionConverter { + /** + * The identifier of the widget description for mono-valued containment + * references. + */ + private static final String MONO_CONTAINMENT_REFERENCE_ID = "sirius_default_rules_mono_containment_reference"; //$NON-NLS-1$ + + /** + * The identifier of the widget description for mono-valued non-containment + * references. + */ + private static final String MONO_NONCONTAINMENT_REFERENCE_ID = "sirius_default_rules_mono_noncontainment_reference"; //$NON-NLS-1$ + + /** + * The identifier of the widget description if for multi-valued containment + * references. + */ + private static final String MULTI_CONTAINMENT_REFERENCE_ID = "sirius_default_rules_multi_containment_reference"; //$NON-NLS-1$ + + /** + * The identifier of the widget description if for multi-valued + * non-containment references. + */ + private static final String MULTI_NONCONTAINMENT_REFERENCE_ID = "sirius_default_rules_multi_noncontainment_reference"; //$NON-NLS-1$ + + /** + * The identifier of the descriptions supported by this + * {@link IDescriptionConverter}. + */ + private static final String[] SUPPORTED_IDS = new String[] { MONO_CONTAINMENT_REFERENCE_ID, MONO_NONCONTAINMENT_REFERENCE_ID, MULTI_CONTAINMENT_REFERENCE_ID, MULTI_NONCONTAINMENT_REFERENCE_ID }; + + /** + * The URI of the default rules resource. + */ + private static final String SUPPORTED_URI = "platform:/plugin/org.eclipse.sirius.ui.properties/model/properties.xmi"; //$NON-NLS-1$ + + @Override + public boolean canHandle(EObject description) { + if (description.eResource() != null && SUPPORTED_URI.equals(description.eResource().getURI().toString())) { + if (description instanceof WidgetDescription && ((WidgetDescription) description).eContainer() instanceof DynamicMappingIf) { + WidgetDescription widgetDescription = (WidgetDescription) description; + return Arrays.asList(SUPPORTED_IDS).contains(widgetDescription.getIdentifier()); + } + } + return false; + } + + @Override + public EObject convert(EObject description, Map<String, Object> parameters, DescriptionCache cache) { + if (description instanceof WidgetDescription && ((WidgetDescription) description).eContainer() instanceof DynamicMappingIf) { + WidgetDescription widgetDescription = (WidgetDescription) description; + + if (Arrays.asList(SUPPORTED_IDS).contains(widgetDescription.getIdentifier())) { + EEFExtReferenceDescription eefExtReferenceDescription = EefExtWidgetsReferenceFactory.eINSTANCE.createEEFExtReferenceDescription(); + eefExtReferenceDescription.setIdentifier(widgetDescription.getIdentifier()); + eefExtReferenceDescription.setReferenceNameExpression("aql:eStructuralFeature.name"); //$NON-NLS-1$ + cache.put(widgetDescription, eefExtReferenceDescription); + return eefExtReferenceDescription; + } + } + return null; + } +} diff --git a/plugins/org.eclipse.sirius.ui.properties/model/properties.xmi b/plugins/org.eclipse.sirius.ui.properties/model/properties.xmi index 9c780c4dc3..77e752d8fb 100644 --- a/plugins/org.eclipse.sirius.ui.properties/model/properties.xmi +++ b/plugins/org.eclipse.sirius.ui.properties/model/properties.xmi @@ -19,7 +19,7 @@ <ifs predicateExpression="aql:(eStructuralFeature.eType.instanceTypeName = 'java.lang.String' or eStructuralFeature.eType.instanceTypeName = 'int' or eStructuralFeature.eType.instanceTypeName = 'double' or eStructuralFeature.eType.instanceTypeName = 'char' or eStructuralFeature.eType.instanceTypeName = 'short' or eStructuralFeature.eType.instanceTypeName = 'long' or eStructuralFeature.eType.instanceTypeName = 'float' or eStructuralFeature.eType.instanceTypeName = 'java.util.Date') and not(eStructuralFeature.many)"> <widget xsi:type="properties:TextDescription" - identifier="" + identifier="sirius_default_rules_mono_string" labelExpression="aql:self.eefViewText(eStructuralFeature)+':'" isEnabledExpression="aql:eStructuralFeature.changeable" valueExpression="aql:self.eGet(eStructuralFeature)"> @@ -33,6 +33,7 @@ <ifs predicateExpression="aql:(eStructuralFeature.eType.instanceTypeName = 'java.lang.Boolean' or eStructuralFeature.eType.instanceTypeName = 'boolean') and not(eStructuralFeature.many)"> <widget xsi:type="properties:CheckboxDescription" + identifier="sirius_default_rules_mono_boolean" labelExpression="aql:self.eefViewText(eStructuralFeature)" isEnabledExpression="aql:eStructuralFeature.changeable" valueExpression="aql:self.eGet(eStructuralFeature)"> @@ -46,6 +47,7 @@ <ifs predicateExpression="aql:eStructuralFeature.eType.oclIsKindOf(ecore::EEnum) and not(eStructuralFeature.many)"> <widget xsi:type="properties:RadioDescription" + identifier="sirius_default_rules_enum" labelExpression="aql:self.eefViewText(eStructuralFeature)+':'" helpExpression="" isEnabledExpression="aql:eStructuralFeature.changeable" @@ -63,6 +65,7 @@ <ifs predicateExpression="aql:eStructuralFeature.oclIsKindOf(ecore::EReference) and eStructuralFeature.containment and not(eStructuralFeature.many)"> <widget xsi:type="properties:ReferenceDescription" + identifier="sirius_default_rules_mono_containment_reference" labelExpression="aql:self.eefViewText(eStructuralFeature)+':'" isEnabledExpression="aql:eStructuralFeature.changeable" valueExpression="aql:self.eGet(eStructuralFeature)" @@ -77,7 +80,7 @@ <ifs predicateExpression="aql:eStructuralFeature.oclIsKindOf(ecore::EReference) and not(eStructuralFeature.containment) and not(eStructuralFeature.many)"> <widget xsi:type="properties:SelectDescription" - identifier="" + identifier="sirius_default_rules_mono_noncontainment_reference" labelExpression="aql:self.eefViewText(eStructuralFeature)+':'" isEnabledExpression="aql:eStructuralFeature.changeable" valueExpression="aql:self.eGet(eStructuralFeature)" @@ -93,6 +96,7 @@ <ifs predicateExpression="aql:eStructuralFeature.oclIsKindOf(ecore::EReference) and eStructuralFeature.containment and eStructuralFeature.many"> <widget xsi:type="properties:ReferenceDescription" + identifier="sirius_default_rules_multi_containment_reference" labelExpression="aql:self.eefViewText(eStructuralFeature)+':'" isEnabledExpression="aql:eStructuralFeature.changeable" multiple="true" @@ -108,6 +112,7 @@ <ifs predicateExpression="aql:eStructuralFeature.oclIsKindOf(ecore::EReference) and not(eStructuralFeature.containment) and eStructuralFeature.many"> <widget xsi:type="properties:ReferenceDescription" + identifier="sirius_default_rules_multi_noncontainment_reference" labelExpression="aql:self.eefViewText(eStructuralFeature)+':'" isEnabledExpression="aql:eStructuralFeature.changeable" multiple="true" |
