diff options
author | Ansgar Radermacher | 2014-03-04 21:04:32 +0000 |
---|---|---|
committer | Ansgar Radermacher | 2014-03-04 21:11:15 +0000 |
commit | 14ebba55b45071e277a56680d2e8cee5eb0f5077 (patch) | |
tree | a6de1fa4377efab9ef2eaad3f8b503745d5e81af /plugins/uml | |
parent | 87d85c55fa7d8fbf1e3c757c9d85525b8c7bb046 (diff) | |
download | org.eclipse.papyrus-14ebba55b45071e277a56680d2e8cee5eb0f5077.tar.gz org.eclipse.papyrus-14ebba55b45071e277a56680d2e8cee5eb0f5077.tar.xz org.eclipse.papyrus-14ebba55b45071e277a56680d2e8cee5eb0f5077.zip |
Bug 315231 - [All Diagrams] Direct Edit : Xtext / Papyrus integration
Xtext editor in property view: only commit, if editor contains changes
Diffstat (limited to 'plugins/uml')
5 files changed, 94 insertions, 32 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF index 209ae0c7788..9f48270c45c 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.105.0", org.eclipse.gmf.runtime.common.ui.services;bundle-version="1.7.0",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.7.0",
org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0",
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.0",
org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="1.0.0",
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml index ed9df447719..6e74c9f1437 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml @@ -25,4 +25,11 @@ </propertyTab>
</propertyTabs>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.core.modelListener">
+ <listener
+ name="advancedEditing.modelListener"
+ realization="org.eclipse.papyrus.uml.properties.xtext.sheet.ModelListener">
+ </listener>
+ </extension>
</plugin>
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 291f284e36e..bdab8a28cb3 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 @@ -71,8 +71,11 @@ public class AdvancedEditingPropertySection extends protected boolean isRedo;
+ protected EObject currentEObj;
+
public AdvancedEditingPropertySection() {
undoRedoStack = new UndoRedoStack<ExtendedModifyEvent>();
+ ModelListener.currentEditor = this;
}
@Override
@@ -135,7 +138,7 @@ public class AdvancedEditingPropertySection extends // ignore focus lost
return;
}
- if (parser != null) {
+ if ((parser != null) && !parser.getEditString(null, 0).equals(textControl.getText())) {
ICommand command = parser.getParseCommand(
new EObjectAdapter(getEObject()),
textControl.getText(), 0);
@@ -274,7 +277,7 @@ public class AdvancedEditingPropertySection extends IGraphicalEditPart part = getEditPartFromSelection();
if (part != null) {
- // newConfiguration.preEditAction(part.resolveSemanticElement());
+ newConfiguration.preEditAction(part.resolveSemanticElement());
}
xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
@@ -290,7 +293,11 @@ public class AdvancedEditingPropertySection extends ((IContextElementProviderWithInit) provider).initResource(
xtextAdapter.getFakeResourceContext().getFakeResource());
}
- }
+ }
+ Object semanticObject = configuration.getObjectToEdit();
+ if (semanticObject instanceof EObject) {
+ currentEObj = (EObject) semanticObject;
+ }
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/ModelListener.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/ModelListener.java new file mode 100644 index 00000000000..8e07a4391c7 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/ModelListener.java @@ -0,0 +1,46 @@ +/***************************************************************************** + * Copyright (c) 2013 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: + * Ansgar Radermacher ansgar.radermacher@cea.fr + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.properties.xtext.sheet; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener; + +/** + * Main listener for model changes (registered via plugin.xml). It will delegate + * to the sub-listeners for specific sub-elements (type, operation, port, ...) that + * can be found in this package + * + * @author ansgar + * + */ +public class ModelListener implements IPapyrusListener { + + public void notifyChanged(Notification notification) { + Object notifier = notification.getNotifier(); + if (notifier instanceof EObject && currentEditor != null) { + EObject notifierEObj = (EObject) notifier; + while (notifierEObj != null) { + if (notifierEObj == currentEditor.currentEObj) { + currentEditor.refresh(); + break; + } + notifierEObj = notifierEObj.eContainer(); + } + } + } + + protected static AdvancedEditingPropertySection currentEditor; +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java index 556bd7aa562..f660024c95b 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java @@ -1,3 +1,4 @@ + package org.eclipse.papyrus.uml.properties.xtext.sheet; import java.util.Stack; @@ -8,41 +9,41 @@ import java.util.Stack; */ public class UndoRedoStack<T> { - private Stack<T> undo; - private Stack<T> redo; + private Stack<T> undo; + private Stack<T> redo; - public UndoRedoStack() { - undo = new Stack<T>(); - redo = new Stack<T>(); - } + public UndoRedoStack() { + undo = new Stack<T>(); + redo = new Stack<T>(); + } - public void pushUndo(T delta) { - undo.add(delta); - } + public void pushUndo(T delta) { + undo.add(delta); + } - public void pushRedo(T delta) { - redo.add(delta); - } + public void pushRedo(T delta) { + redo.add(delta); + } - public T popUndo() { - T res = undo.pop(); - return res; - } + public T popUndo() { + T res = undo.pop(); + return res; + } - public T popRedo() { - T res = redo.pop(); - return res; - } + public T popRedo() { + T res = redo.pop(); + return res; + } - public void clearRedo() { - redo.clear(); - } + public void clearRedo() { + redo.clear(); + } - public boolean hasUndo() { - return !undo.isEmpty(); - } + public boolean hasUndo() { + return !undo.isEmpty(); + } - public boolean hasRedo() { - return !redo.isEmpty(); - } + public boolean hasRedo() { + return !redo.isEmpty(); + } } |