Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAsma Smaoui2017-03-13 16:17:53 +0000
committerGerrit Code Review @ Eclipse.org2017-03-15 09:48:10 +0000
commit01e3b27d5f3cc1204f2a6f95cee209afb4ef2796 (patch)
tree3f441d730ddc7534ce54df89c7c3797de3a69531
parentac34b9f670165eb09afb54193ff2b3eec5175756 (diff)
downloadorg.eclipse.papyrus-rt-01e3b27d5f3cc1204f2a6f95cee209afb4ef2796.tar.gz
org.eclipse.papyrus-rt-01e3b27d5f3cc1204f2a6f95cee209afb4ef2796.tar.xz
org.eclipse.papyrus-rt-01e3b27d5f3cc1204f2a6f95cee209afb4ef2796.zip
Bug 513060 - [Tooling] Improve and simplify the embedded editor for port
* propose a papyrus rt port configuration with the same name as the default xtext configuration with higher priority to be applied when creating port Change-Id: Ifc089f6ff49c5cd698a2a99eda8eb1550c015e13 Signed-off-by: Asma Smaoui <asma.smaoui@cea.fr>
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/plugin.xml13
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorConfiguration.java42
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorParser.java110
3 files changed, 165 insertions, 0 deletions
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/plugin.xml b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/plugin.xml
index 442d45f4e..0a9089ae8 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/plugin.xml
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/plugin.xml
@@ -84,4 +84,17 @@
path="elementtypes/uml-rt.modelexplorer.elementtypesconfigurations">
</elementTypeSet>
</extension>
+ <extension
+ point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
+ <DirectEditor
+ language="Advanced Port Textual Editor"
+ objectToEdit="org.eclipse.uml2.uml.Port">
+ <Priority
+ name="High">
+ </Priority>
+ <simpleeditor
+ editorConfiguration="org.eclipse.papyrusrt.umlrt.tooling.modelexplorer.preferences.PropertyDirectEditorConfiguration">
+ </simpleeditor>
+ </DirectEditor>
+ </extension>
</plugin>
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorConfiguration.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorConfiguration.java
new file mode 100644
index 000000000..3f224f47d
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorConfiguration.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrusrt.umlrt.tooling.modelexplorer.preferences;
+
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.AbstractBasicDirectEditorConfiguration;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * Specific editor for UML-RT Port. By default, this is a simple direct editor.
+ */
+public class PropertyDirectEditorConfiguration extends AbstractBasicDirectEditorConfiguration {
+
+
+ @Override
+ public String getTextToEdit(final Object objectToEdit) {
+ if (objectToEdit instanceof NamedElement) {
+ return ((NamedElement) objectToEdit).getName();
+ }
+
+ return super.getTextToEdit(objectToEdit);
+ }
+
+ @Override
+ public IParser createDirectEditorParser() {
+ return new PropertyDirectEditorParser(getTextToEdit(objectToEdit));
+ }
+
+
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorParser.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorParser.java
new file mode 100644
index 000000000..4e3a721aa
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.modelexplorer/src/org/eclipse/papyrusrt/umlrt/tooling/modelexplorer/preferences/PropertyDirectEditorParser.java
@@ -0,0 +1,110 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.modelexplorer.preferences;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Specific Parser for the Named Element.
+ */
+public class PropertyDirectEditorParser implements IParser {
+
+ /**
+ * Name of the current Name Element.
+ */
+ private String textToEdit;
+
+ /**
+ * Constructor.
+ *
+ */
+ public PropertyDirectEditorParser(final String textToEdit) {
+ this.textToEdit = textToEdit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getEditString(final IAdaptable element, final int flags) {
+ return textToEdit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getParseCommand(final IAdaptable element, final String newString, final int flags) {
+ CompositeCommand compositeCommand = new CompositeCommand("Rename"); //$NON-NLS-1$
+
+ EObject eObjectElement = element.getAdapter(EObject.class);
+
+ if (eObjectElement instanceof NamedElement) {
+ if (null != newString && !newString.isEmpty()) {
+ SetRequest setRequest = new SetRequest(eObjectElement, UMLPackage.eINSTANCE.getNamedElement_Name(), newString);
+
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(eObjectElement);
+ ICommand editCommand = provider.getEditCommand(setRequest);
+
+ compositeCommand.add(editCommand);
+ }
+ }
+
+ return compositeCommand;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(final IAdaptable element, final int flags) {
+ return textToEdit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(final Object event, final int flags) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IContentAssistProcessor getCompletionProcessor(final IAdaptable element) {
+ // Not used
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IParserEditStatus isValidEditString(final IAdaptable element, final String editString) {
+ // Not used
+ return null;
+ }
+}

Back to the top