Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2014-03-05 22:19:11 +0000
committerAnsgar Radermacher2014-03-05 22:21:16 +0000
commitfce3c69578df3a5f0b36f143f87797a38877d241 (patch)
tree4ffba35a0d9f2251ea1697e14bf4c4cf06bb60c2 /plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext
parentbb2fce9bb78302f164d4d9eaba9c7b699b60d862 (diff)
downloadorg.eclipse.papyrus-fce3c69578df3a5f0b36f143f87797a38877d241.tar.gz
org.eclipse.papyrus-fce3c69578df3a5f0b36f143f87797a38877d241.tar.xz
org.eclipse.papyrus-fce3c69578df3a5f0b36f143f87797a38877d241.zip
Bug 315231 - [All Diagrams] Direct Edit : Xtext / Papyrus integration: enable xtext editing within property for selections in model explorer
Diffstat (limited to 'plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext')
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java28
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java24
2 files changed, 31 insertions, 21 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java
index bdab8a28cb3..b3f878687fc 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java
@@ -15,6 +15,7 @@
package org.eclipse.papyrus.uml.properties.xtext.sheet;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
@@ -220,11 +221,11 @@ public class AdvancedEditingPropertySection extends
protected DefaultXtextDirectEditorConfiguration getConfigurationFromSelection() {
- IGraphicalEditPart part = getEditPartFromSelection();
- if (part != null) {
+ EObject semanticElement = getSemanticObjectFromSelection();
+ if (semanticElement != null) {
IPreferenceStore store = Activator.getDefault()
.getPreferenceStore();
- String semanticClassName = part.resolveSemanticElement().eClass()
+ String semanticClassName = semanticElement.eClass()
.getInstanceClassName();
String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ semanticClassName;
@@ -237,7 +238,7 @@ public class AdvancedEditingPropertySection extends
if (configuration instanceof DefaultXtextDirectEditorConfiguration) {
DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration;
- xtextConfiguration.preEditAction(part.resolveSemanticElement());
+ xtextConfiguration.preEditAction(semanticElement);
return xtextConfiguration;
}
}
@@ -245,18 +246,21 @@ public class AdvancedEditingPropertySection extends
return null;
}
- protected IGraphicalEditPart getEditPartFromSelection() {
+ protected EObject getSemanticObjectFromSelection() {
Object selection = getPrimarySelection();
if (selection instanceof IGraphicalEditPart) {
- return (IGraphicalEditPart) selection;
+ return ((IGraphicalEditPart) selection).resolveSemanticElement();
+ }
+ else if (selection instanceof IAdaptable) {
+ return (EObject) ((IAdaptable) selection).getAdapter(EObject.class);
}
return null;
}
protected IParser getParser() {
- final IGraphicalEditPart part = getEditPartFromSelection();
- if (configuration != null && part != null) {
- return configuration.createParser(part.resolveSemanticElement());
+ final EObject semanticElement = getSemanticObjectFromSelection();
+ if (configuration != null && semanticElement != null) {
+ return configuration.createParser(semanticElement);
}
return null;
}
@@ -275,9 +279,9 @@ public class AdvancedEditingPropertySection extends
xtextAdapter = new StyledTextXtextAdapter(
configuration.getInjector());
- IGraphicalEditPart part = getEditPartFromSelection();
- if (part != null) {
- newConfiguration.preEditAction(part.resolveSemanticElement());
+ EObject semanticElement = getSemanticObjectFromSelection();
+ if (semanticElement != null) {
+ newConfiguration.preEditAction(semanticElement);
}
xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
index b8bd9e2a7fa..1e35d5aa728 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
@@ -1,6 +1,8 @@
package org.eclipse.papyrus.uml.properties.xtext.sheet;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IFilter;
import org.eclipse.papyrus.extensionpoints.editors.Activator;
@@ -12,23 +14,27 @@ import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
public class AdvancedEditingPropertySectionFilter implements IFilter {
public boolean select(Object toTest) {
- if (toTest instanceof IGraphicalEditPart) {
- IGraphicalEditPart part = (IGraphicalEditPart) toTest;
- if (part.resolveSemanticElement() == null) {
- return false;
- }
+ EObject semanticElement = null;
+ if (toTest instanceof IAdaptable) {
+ semanticElement = (EObject) ((IAdaptable) toTest).getAdapter(EObject.class);
+ }
+ else if (toTest instanceof GraphicalEditPart) {
+ GraphicalEditPart part = (GraphicalEditPart) toTest;
+ semanticElement = part.resolveSemanticElement();
+ }
+ if (semanticElement != null) {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
- + part.resolveSemanticElement().eClass().getInstanceClassName();
+ + semanticElement.eClass().getInstanceClassName();
+
String languagePreferred = store.getString(key);
if (languagePreferred != null && !languagePreferred.equals("")) {
IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(
- languagePreferred, part.resolveSemanticElement().eClass()
+ languagePreferred, semanticElement.eClass()
.getInstanceClassName());
return configuration instanceof ICustomDirectEditorConfiguration;
}
-
}
return false;
}

Back to the top