Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2014-02-10 16:39:15 -0500
committerAnsgar Radermacher2014-02-10 16:39:15 -0500
commit74df1a9a52ad683d15a09cd9db1931c95f11b80a (patch)
tree2fd25dc5eb62fe5a7ddd4315b0e389b07c0843a4 /plugins
parent937aa8afbdc6acf396f04c67ad752c78f59026f4 (diff)
downloadorg.eclipse.papyrus-74df1a9a52ad683d15a09cd9db1931c95f11b80a.tar.gz
org.eclipse.papyrus-74df1a9a52ad683d15a09cd9db1931c95f11b80a.tar.xz
org.eclipse.papyrus-74df1a9a52ad683d15a09cd9db1931c95f11b80a.zip
Bug 315231 - [All Diagrams] Direct Edit : Xtext / Papyrus integration (amended)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/RenameNamedElementHandler.java12
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/plugin.xml29
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java2
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java (renamed from plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java)75
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java1
6 files changed, 60 insertions, 62 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF
index e956db144ed..3b783af1a81 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.uml.tools.utils;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.qualifier
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/RenameNamedElementHandler.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/RenameNamedElementHandler.java
index 10da6b11ccf..c44568e05e9 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/RenameNamedElementHandler.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/RenameNamedElementHandler.java
@@ -27,10 +27,10 @@ import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.views.modelexplorer.DirectEditorEditingSupport;
import org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Property;
/**
* This handler allows to rename {@link NamedElement}
@@ -98,18 +98,18 @@ public class RenameNamedElementHandler extends AbstractCommandHandler {
if(enabled) {
List<EObject> selectedElements = getSelectedElements();
EObject selection = selectedElements.get(0);
- enabled = !EMFHelper.isReadOnly(selection) && !isHandledByXText(selection);
+ enabled = !EMFHelper.isReadOnly(selection) && !isHandledByDirectEditor(selection);
}
return enabled;
}
/**
- * Check whether the editing of an element is handled by an xtext editor. In this case, we do
+ * Check whether the editing of an element is handled by a direct editor. In this case, we do
* not want to open the rename pop-up.
* @param element an element that should be edited.
- * @return true, if handled by xtext
+ * @return true, if handled by a direct editor
*/
- protected boolean isHandledByXText(EObject element) {
- return (element instanceof Property);
+ protected boolean isHandledByDirectEditor(EObject element) {
+ return DirectEditorEditingSupport.getConfiguration(element) != null;
}
}
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/plugin.xml b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/plugin.xml
index 1e06d4149ec..1ba6fcef7e8 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/plugin.xml
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/plugin.xml
@@ -212,33 +212,4 @@
</DirectEditor>
</extension>
-
- <extension
- point="org.eclipse.emf.validation.constraintProviders">
- <category
- name="Test" id="org.eclipse.emf.validation.pde.example.general.ui.library"/>
- <constraintProvider cache="true">
- <package namespaceUri="http://www.eclipse.org/uml2/4.0.0/UML"/>
- <constraints categories="test">
- <constraint
- lang="Java"
- class="org.eclipse.papyrus.uml.textedit.property.xtext.ui.validation.TestConstraint"
- severity="ERROR"
- mode="Batch"
- name="TEST"
-
- id="org.eclipse.emf.validation.pde.example.general.ui.NameNotEmpty"
- statusCode="1">
- <message>
- BLA
- </message>
- <target class="Property"/>
- <target class="Model"/>
- <target class="Namespace"/>
- </constraint>
- </constraints>
- </constraintProvider>
- </extension>
-
-
</plugin>
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java
index a126e999d25..0a5d85665db 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/CustomCommonViewer.java
@@ -111,7 +111,7 @@ public class CustomCommonViewer extends CommonViewer {
protected boolean isEditorActivationEvent(
ColumnViewerEditorActivationEvent event) {
// activation will uses F2 (also used by rename-popup, but not taken into account by the latter
- // for model elements for which an xtext editor exists)
+ // for model elements for which a direct-editor exists)
return event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED &&
event.keyCode == SWT.F2;
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java
index f89cbce87c0..e5a02516a0c 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/DirectEditorEditingSupport.java
@@ -1,4 +1,18 @@
-package org.eclipse.papyrus.views.modelexplorer.xtext;
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ *
+ * Andreas Muelder - Initial contribution and API
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
@@ -20,9 +34,7 @@ import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
import org.eclipse.swt.widgets.Composite;
/**
- *
- * @author andreas muelder - Initial contribution and API
- *
+ * Support for direct editors
*/
public class DirectEditorEditingSupport extends EditingSupport {
@@ -32,7 +44,7 @@ public class DirectEditorEditingSupport extends EditingSupport {
@Override
protected CellEditor getCellEditor(final Object element) {
- ICustomDirectEditorConfiguration configuration = getConfiguration(element);
+ ICustomDirectEditorConfiguration configuration = getConfigurationAE(element);
EObject semanticObject = (EObject) ((IAdaptable) element)
.getAdapter(EObject.class);
Composite parent = (Composite) getViewer().getControl();
@@ -41,12 +53,12 @@ public class DirectEditorEditingSupport extends EditingSupport {
@Override
protected boolean canEdit(Object element) {
- return getConfiguration(element) != null;
+ return getConfigurationAE(element) != null;
}
@Override
protected Object getValue(Object element) {
- ICustomDirectEditorConfiguration configuration = getConfiguration(element);
+ ICustomDirectEditorConfiguration configuration = getConfigurationAE(element);
Object semanticObject = ((IAdaptable) element)
.getAdapter(EObject.class);
return configuration.createParser((EObject) semanticObject)
@@ -55,7 +67,7 @@ public class DirectEditorEditingSupport extends EditingSupport {
@Override
protected void setValue(Object element, Object value) {
- ICustomDirectEditorConfiguration configuration = getConfiguration(element);
+ ICustomDirectEditorConfiguration configuration = getConfigurationAE(element);
EObject semanticObject = (EObject) ((IAdaptable) element)
.getAdapter(EObject.class);
IParser parser = configuration.createParser(semanticObject);
@@ -68,28 +80,43 @@ public class DirectEditorEditingSupport extends EditingSupport {
new GMFtoEMFCommandWrapper(command));
}
- protected ICustomDirectEditorConfiguration getConfiguration(Object element) {
+ /**
+ * Obtain direct editor configuration for an element that can be adapted to
+ * an EObject
+ * @param element an adaptable element
+ * @return The direct editor configuration, if it exists.
+ */
+ public static ICustomDirectEditorConfiguration getConfigurationAE(Object element) {
if (element instanceof IAdaptable) {
EObject semanticObject = (EObject) ((IAdaptable) element)
.getAdapter(EObject.class);
- IPreferenceStore store = Activator.getDefault()
- .getPreferenceStore();
- String semanticClassName = semanticObject.eClass()
- .getInstanceClassName();
- String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
- + semanticClassName;
- String languagePreferred = store.getString(key);
+ return getConfiguration(semanticObject);
+ }
+ return null;
+ }
+
+ /**
+ * Obtain direct editor configuration for a semantic element
+ * @param element a sementic element
+ * @return The direct editor configuration, if it exists.
+ */
+ public static ICustomDirectEditorConfiguration getConfiguration(EObject semanticElement) {
+
+ IPreferenceStore store = Activator.getDefault()
+ .getPreferenceStore();
+ String semanticClassName = semanticElement.eClass()
+ .getInstanceClassName();
+ String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ + semanticClassName;
+ String languagePreferred = store.getString(key);
- if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$
- IDirectEditorConfiguration configuration = DirectEditorsUtil
- .findEditorConfiguration(languagePreferred,
- semanticClassName);
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- return (ICustomDirectEditorConfiguration) configuration;
- }
+ if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$
+ IDirectEditorConfiguration configuration = DirectEditorsUtil
+ .findEditorConfiguration(languagePreferred, semanticClassName);
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ return (ICustomDirectEditorConfiguration) configuration;
}
}
return null;
}
-
} \ No newline at end of file
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
index 23cb924faef..554ff75f703 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
@@ -74,7 +74,6 @@ import org.eclipse.papyrus.views.modelexplorer.matching.IMatchingItem;
import org.eclipse.papyrus.views.modelexplorer.matching.LinkItemMatchingItem;
import org.eclipse.papyrus.views.modelexplorer.matching.ModelElementItemMatchingItem;
import org.eclipse.papyrus.views.modelexplorer.matching.ReferencableMatchingItem;
-import org.eclipse.papyrus.views.modelexplorer.xtext.DirectEditorEditingSupport;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;

Back to the top