diff options
Diffstat (limited to 'plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui')
6 files changed, 264 insertions, 2 deletions
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml index 7e54fcea8eb..5e17171b317 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml @@ -354,6 +354,32 @@ name="Lowest"> </Priority> </DirectEditor> + <DirectEditor + additionalConstraint="org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.constraint.MultiplicityLowerValueDirectEditorConstraint" + contributor="CEA LIST" + icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/ValueSpecification.gif" + language="Advanced Value Specification Textual Editor" + objectToEdit="org.eclipse.uml2.uml.ValueSpecification"> + <popupeditor + editorConfiguration="org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.contribution.MultiplicityLowerValueSpecificationXtextDirectEditorConfiguration"> + </popupeditor> + <Priority + name="Low"> + </Priority> + </DirectEditor> + <DirectEditor + additionalConstraint="org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.constraint.MultiplicityUpperValueDirectEditorConstraint" + contributor="CEA LIST" + icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/ValueSpecification.gif" + language="Advanced Value Specification Textual Editor" + objectToEdit="org.eclipse.uml2.uml.ValueSpecification"> + <popupeditor + editorConfiguration="org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.contribution.MultiplicityUpperValueSpecificationXtextDirectEditorConfiguration"> + </popupeditor> + <Priority + name="Low"> + </Priority> + </DirectEditor> </extension> </plugin> diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/constraint/MultiplicityLowerValueDirectEditorConstraint.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/constraint/MultiplicityLowerValueDirectEditorConstraint.java new file mode 100644 index 00000000000..8fb295e862b --- /dev/null +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/constraint/MultiplicityLowerValueDirectEditorConstraint.java @@ -0,0 +1,67 @@ +/***************************************************************************** + * Copyright (c) 2015 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.constraint; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConstraint; +import org.eclipse.uml2.uml.MultiplicityElement; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.ValueSpecification; + +/** + * This class allow to define a constraint corresponding to the multiplicity lower value. + */ +public class MultiplicityLowerValueDirectEditorConstraint implements IDirectEditorConstraint { + + /** + * Constructor. + */ + public MultiplicityLowerValueDirectEditorConstraint() { + super(); + } + + /** + * @see org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConstraint#getLabel() + * + * @return The label. + */ + public String getLabel() { + return " Multiplicity Element Lower Value"; //$NON-NLS-1$ + } + + /** + * @see org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConstraint#appliesTo(java.lang.Object) + * + * @param selection + * the current selection + * @return <code>true</code> if selection matches the constraint, otherwise <code>false</code> + */ + public boolean appliesTo(final Object selection) { + boolean appliedConstraint = false; + // Check that the selection is a structural feature and the lower value of multiplicity element + if (selection instanceof EStructuralFeature && UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue().equals(selection)) { + appliedConstraint = true; + } else if (selection instanceof ValueSpecification) { + final ValueSpecification valueSpecification = (ValueSpecification) selection; + if (valueSpecification.eContainer() instanceof MultiplicityElement) { + final EObject parent = valueSpecification.eContainer(); + final Object lowerValue = parent.eGet(UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue()); + appliedConstraint = valueSpecification.equals(lowerValue); + } + } + return appliedConstraint; + } + +} diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/constraint/MultiplicityUpperValueDirectEditorConstraint.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/constraint/MultiplicityUpperValueDirectEditorConstraint.java new file mode 100644 index 00000000000..2a848b74854 --- /dev/null +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/constraint/MultiplicityUpperValueDirectEditorConstraint.java @@ -0,0 +1,67 @@ +/***************************************************************************** + * Copyright (c) 2015 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.constraint; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConstraint; +import org.eclipse.uml2.uml.MultiplicityElement; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.ValueSpecification; + +/** + * This class allow to define a constraint corresponding to the multiplicity upper value. + */ +public class MultiplicityUpperValueDirectEditorConstraint implements IDirectEditorConstraint { + + /** + * Constructor. + */ + public MultiplicityUpperValueDirectEditorConstraint() { + super(); + } + + /** + * @see org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConstraint#getLabel() + * + * @return The label. + */ + public String getLabel() { + return " Multiplicity Element Upper Value"; //$NON-NLS-1$ + } + + /** + * @see org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConstraint#appliesTo(java.lang.Object) + * + * @param selection + * the current selection + * @return <code>true</code> if selection matches the constraint, otherwise <code>false</code> + */ + public boolean appliesTo(final Object selection) { + boolean appliedConstraint = false; + // Check that the selection is a structural feature and the lower value of multiplicity element + if (selection instanceof EStructuralFeature && UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue().equals(selection)) { + appliedConstraint = true; + } else if (selection instanceof ValueSpecification) { + final ValueSpecification valueSpecification = (ValueSpecification) selection; + if (valueSpecification.eContainer() instanceof MultiplicityElement) { + final EObject parent = valueSpecification.eContainer(); + final Object upperValue = parent.eGet(UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue()); + appliedConstraint = upperValue.equals(valueSpecification); + } + } + return appliedConstraint; + } + +} diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/MultiplicityLowerValueSpecificationXtextDirectEditorConfiguration.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/MultiplicityLowerValueSpecificationXtextDirectEditorConfiguration.java new file mode 100644 index 00000000000..1a15d2c08a9 --- /dev/null +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/MultiplicityLowerValueSpecificationXtextDirectEditorConfiguration.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2015 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.contribution; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils.commands.MultiplicityLowerValueSetCommand; + +/** + * This class allow to define a direct editor configuration for the multiplicity lower value (with allow to redefine the set command for the specific integer value. + */ +public class MultiplicityLowerValueSpecificationXtextDirectEditorConfiguration extends ValueSpecificationXtextDirectEditorConfiguration { + + /** + * Constructor. + */ + public MultiplicityLowerValueSpecificationXtextDirectEditorConfiguration() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration#getParseCommand(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject) + */ + @Override + protected ICommand getParseCommand(final EObject initialValue, final EObject xtextObject) { + ICommand result = null; + if (objectToEdit instanceof EObject && null != structuralFeature) { + // If the xtext object is not null, that means the xtext was already parsed + if (null == xtextObject) { + result = MultiplicityLowerValueSetCommand.getInstance().createSetCommand(getInjector(), (EObject) objectToEdit, structuralFeature, xtextStringValue, getDefaultLanguages()); + } else { + result = MultiplicityLowerValueSetCommand.getInstance().getParseCommand((EObject) objectToEdit, structuralFeature, xtextObject, xtextStringValue, getDefaultLanguages()); + } + } + return result; + } + +} diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/MultiplicityUpperValueSpecificationXtextDirectEditorConfiguration.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/MultiplicityUpperValueSpecificationXtextDirectEditorConfiguration.java new file mode 100644 index 00000000000..0094a987bd6 --- /dev/null +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/MultiplicityUpperValueSpecificationXtextDirectEditorConfiguration.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2015 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.contribution; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils.commands.MultiplicityUpperValueSetCommand; + +/** + * This class allow to define a direct editor configuration for the multiplicity upper value (with allow to redefine the set command for the specific integer value. + */ +public class MultiplicityUpperValueSpecificationXtextDirectEditorConfiguration extends ValueSpecificationXtextDirectEditorConfiguration { + + /** + * Constructor. + */ + public MultiplicityUpperValueSpecificationXtextDirectEditorConfiguration() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration#getParseCommand(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject) + */ + @Override + protected ICommand getParseCommand(final EObject initialValue, final EObject xtextObject) { + ICommand result = null; + if (objectToEdit instanceof EObject && null != structuralFeature) { + // If the xtext object is not null, that means the xtext was already parsed + if (null == xtextObject) { + result = MultiplicityUpperValueSetCommand.getInstance().createSetCommand(getInjector(), (EObject) objectToEdit, structuralFeature, xtextStringValue, getDefaultLanguages()); + } else { + result = MultiplicityUpperValueSetCommand.getInstance().getParseCommand((EObject) objectToEdit, structuralFeature, xtextObject, xtextStringValue, getDefaultLanguages()); + } + } + return result; + } + +} diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/ValueSpecificationXtextDirectEditorConfiguration.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/ValueSpecificationXtextDirectEditorConfiguration.java index 4a403ff51ec..631e826ebfe 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/ValueSpecificationXtextDirectEditorConfiguration.java +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contribution/ValueSpecificationXtextDirectEditorConfiguration.java @@ -45,12 +45,12 @@ public class ValueSpecificationXtextDirectEditorConfiguration extends DefaultXte /** * The xtext string value. */ - private String xtextStringValue = ""; //$NON-NLS-1$ + protected String xtextStringValue = ""; //$NON-NLS-1$ /** * The structural feature to edit. */ - private EStructuralFeature structuralFeature = null; + protected EStructuralFeature structuralFeature = null; /** * {@inheritDoc} |