diff options
author | Gabriel Pascual | 2014-10-21 14:49:03 +0000 |
---|---|---|
committer | Gabriel Pascual | 2014-11-06 13:27:34 +0000 |
commit | bd3648477f9fa1897553405bb803957a140f3dcb (patch) | |
tree | 056e11fe642e6b55757af3e0a681c52c336fe802 /plugins/infra | |
parent | 3f4a173caaa9a16394811894400c910f8ce4da67 (diff) | |
download | org.eclipse.papyrus-bd3648477f9fa1897553405bb803957a140f3dcb.tar.gz org.eclipse.papyrus-bd3648477f9fa1897553405bb803957a140f3dcb.tar.xz org.eclipse.papyrus-bd3648477f9fa1897553405bb803957a140f3dcb.zip |
Bug 413895 - [Properties View] Undo not available when manipulating
models in Properties View
Code & Comments from C. Damus :
The problem is that GMF’s undo/redo global actions stop listening to the
operation history when the active workbench part is not a GMF editor.
Therefore, the property sheet cannot simply reuse the diagram editor’s
actions, but needs to provide its own.
Change-Id: I565af4b1190951115aadae643c90dbc51669ee5d
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Signed-off-by: Gabriel Pascual <gabriel.pascual@all4tec.net>
Diffstat (limited to 'plugins/infra')
3 files changed, 138 insertions, 47 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF index 7ff603bd0fe..c58370eb0f2 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF @@ -1,46 +1,47 @@ -Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.infra.core,
- org.eclipse.papyrus.infra.core.clipboard,
- org.eclipse.papyrus.infra.core.contentoutline,
- org.eclipse.papyrus.infra.core.editor,
- org.eclipse.papyrus.infra.core.editor.reload,
- org.eclipse.papyrus.infra.core.editorsfactory,
- org.eclipse.papyrus.infra.core.extension,
- org.eclipse.papyrus.infra.core.extension.commands,
- org.eclipse.papyrus.infra.core.extension.diagrameditor,
- org.eclipse.papyrus.infra.core.lifecycleevents,
- org.eclipse.papyrus.infra.core.listenerservice,
- org.eclipse.papyrus.infra.core.markers,
- org.eclipse.papyrus.infra.core.modelsetquery,
- org.eclipse.papyrus.infra.core.modelsetquery.impl;x-friends:="org.eclipse.papyrus.uml.resourceloading.profile",
- org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor,
- org.eclipse.papyrus.infra.core.resource,
- org.eclipse.papyrus.infra.core.resource.additional,
- org.eclipse.papyrus.infra.core.resource.sasheditor,
- org.eclipse.papyrus.infra.core.services,
- org.eclipse.papyrus.infra.core.utils
-Require-Bundle: org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.0.1";visibility:=reexport,
- org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="1.0.1";visibility:=reexport,
- org.eclipse.core.runtime,
- org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.emf.edit.ui;bundle-version="2.8.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1",
- org.eclipse.core.resources;bundle-version="3.8.0",
- org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300",
- org.eclipse.gef;bundle-version="3.8.1",
- org.eclipse.emf.ecore.xmi;bundle-version="2.8.0",
- org.eclipse.emf.workspace;bundle-version="1.5.1",
- org.eclipse.papyrus.infra.tools;bundle-version="1.0.1",
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.core.filesystem
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.1.qualifier
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-Activator: org.eclipse.papyrus.infra.core.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.infra.core;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-
+Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.infra.core, + org.eclipse.papyrus.infra.core.clipboard, + org.eclipse.papyrus.infra.core.contentoutline, + org.eclipse.papyrus.infra.core.editor, + org.eclipse.papyrus.infra.core.editor.reload, + org.eclipse.papyrus.infra.core.editorsfactory, + org.eclipse.papyrus.infra.core.extension, + org.eclipse.papyrus.infra.core.extension.commands, + org.eclipse.papyrus.infra.core.extension.diagrameditor, + org.eclipse.papyrus.infra.core.lifecycleevents, + org.eclipse.papyrus.infra.core.listenerservice, + org.eclipse.papyrus.infra.core.markers, + org.eclipse.papyrus.infra.core.modelsetquery, + org.eclipse.papyrus.infra.core.modelsetquery.impl;x-friends:="org.eclipse.papyrus.uml.resourceloading.profile", + org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor, + org.eclipse.papyrus.infra.core.operation, + org.eclipse.papyrus.infra.core.resource, + org.eclipse.papyrus.infra.core.resource.additional, + org.eclipse.papyrus.infra.core.resource.sasheditor, + org.eclipse.papyrus.infra.core.services, + org.eclipse.papyrus.infra.core.utils +Require-Bundle: org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.0.1";visibility:=reexport, + org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="1.0.1";visibility:=reexport, + org.eclipse.core.runtime, + org.eclipse.ui.ide;bundle-version="3.8.0", + org.eclipse.emf.edit.ui;bundle-version="2.8.0", + org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1", + org.eclipse.core.resources;bundle-version="3.8.0", + org.eclipse.emf.transaction;bundle-version="1.4.0", + org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300", + org.eclipse.gef;bundle-version="3.8.1", + org.eclipse.emf.ecore.xmi;bundle-version="2.8.0", + org.eclipse.emf.workspace;bundle-version="1.5.1", + org.eclipse.papyrus.infra.tools;bundle-version="1.0.1", + com.google.guava;bundle-version="11.0.0", + org.eclipse.core.filesystem +Bundle-Vendor: %providerName +Bundle-ActivationPolicy: lazy +Bundle-Version: 1.0.1.qualifier +Bundle-Name: %pluginName +Bundle-Localization: plugin +Bundle-Activator: org.eclipse.papyrus.infra.core.Activator +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.infra.core;singleton:=true +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/MultiDiagramPropertySheetPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/MultiDiagramPropertySheetPage.java index 41592216edf..1056bef8835 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/MultiDiagramPropertySheetPage.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/MultiDiagramPropertySheetPage.java @@ -13,13 +13,20 @@ package org.eclipse.papyrus.infra.core.editor; +import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.papyrus.infra.core.editor.reload.EditorReloadEvent; import org.eclipse.papyrus.infra.core.editor.reload.IEditorReloadListener; +import org.eclipse.papyrus.infra.core.operation.DelegatingUndoContext; +import org.eclipse.papyrus.infra.core.utils.AdapterUtils; +import org.eclipse.ui.IActionBars; import org.eclipse.ui.IPartListener; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.operations.RedoActionHandler; +import org.eclipse.ui.operations.UndoActionHandler; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.views.properties.PropertyShowInContext; @@ -34,6 +41,10 @@ class MultiDiagramPropertySheetPage extends TabbedPropertySheetPage implements I private final CoreMultiDiagramEditor multiDiagramEditor; + private UndoActionHandler undo; + private RedoActionHandler redo; + private DelegatingUndoContext undoContext; + public MultiDiagramPropertySheetPage(CoreMultiDiagramEditor editor) { super(editor); @@ -45,6 +56,13 @@ class MultiDiagramPropertySheetPage extends TabbedPropertySheetPage implements I public void dispose() { IReloadableEditor.Adapter.getAdapter(multiDiagramEditor).removeEditorReloadListener(this); + if (undo != null) { + undo.dispose(); + } + if (redo != null) { + redo.dispose(); + } + super.dispose(); } @@ -53,7 +71,7 @@ class MultiDiagramPropertySheetPage extends TabbedPropertySheetPage implements I Object propertySheet = getSite().getService(IViewPart.class); if (propertySheet instanceof IShowInSource) { ShowInContext context = ((IShowInSource) propertySheet).getShowInContext(); - ; + if (context instanceof PropertyShowInContext) { IWorkbenchPart inputPart = ((PropertyShowInContext) context).getPart(); if (inputPart != null) { @@ -85,5 +103,26 @@ class MultiDiagramPropertySheetPage extends TabbedPropertySheetPage implements I }); } } + + // The editor will have a new undo context (because it will have a new editing domain) + if (undoContext != null) { + undoContext.setDelegate(AdapterUtils.adapt(multiDiagramEditor, IUndoContext.class, null)); + } } + + @Override + public void setActionBars(IActionBars actionBars) { + super.setActionBars(actionBars); + + undoContext = new DelegatingUndoContext(); + undoContext.setDelegate(AdapterUtils.adapt(multiDiagramEditor, IUndoContext.class, null)); + + undo = new UndoActionHandler(multiDiagramEditor.getSite(), undoContext); + redo = new RedoActionHandler(multiDiagramEditor.getSite(), undoContext); + + actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undo); + actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redo); + } + + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/operation/DelegatingUndoContext.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/operation/DelegatingUndoContext.java new file mode 100644 index 00000000000..bb4a632bd2a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/operation/DelegatingUndoContext.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2014 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.papyrus.infra.core.operation; + +import org.eclipse.core.commands.operations.IUndoContext; + +/** + * An undo context that dynamically delegates to another. + * Use this with caution: it is important that the semantics of an undo context + * not change in incompatible ways over time. + */ +public class DelegatingUndoContext implements IUndoContext { + + private IUndoContext delegate; + + /** + * Initializes me. + */ + public DelegatingUndoContext() { + super(); + } + + @Override + public String getLabel() { + return (delegate == null) ? "" : delegate.getLabel(); + } + + @Override + public boolean matches(IUndoContext context) { + return (delegate == null) ? false : delegate.matches(context); + } + + public void setDelegate(IUndoContext delegate) { + this.delegate = delegate; + } + + public IUndoContext getDelegate() { + return delegate; + } +}
\ No newline at end of file |