Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml24
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPageBookView.java329
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPropertySheetPage.java93
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/UndoRedoActionProvider.java169
4 files changed, 464 insertions, 151 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
index 212afac9ee0..5fb47fd1cfc 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
@@ -28,6 +28,14 @@
<!--We add a drag assistant in order support drag and drop between Model Explorer and Table Editor or other View/editors -->
<dragAssistant class="org.eclipse.papyrus.views.modelexplorer.dnd.EObjectDragAdapterAssistant" viewerId="org.eclipse.papyrus.views.modelexplorer.modelexplorer">
</dragAssistant>
+ <viewerActionBinding
+ viewerId="org.eclipse.papyrus.views.modelexplorer.modelexplorer">
+ <includes>
+ <actionExtension
+ pattern="org.eclipse.papyrus.views.modelexplorer.actionprovider.*">
+ </actionExtension>
+ </includes>
+ </viewerActionBinding>
</extension>
<extension point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent activeByDefault="false" contentProvider="org.eclipse.papyrus.infra.emf.providers.MoDiscoContentProvider" id="org.eclipse.papyrus.views.modelexplorer.navigatorContent" labelProvider="org.eclipse.jface.viewers.LabelProvider" name="Model Contents" priority="lowest">
@@ -43,7 +51,7 @@
</triggerPoints>
<possibleChildren>
<or>
- <instanceof value="org.eclipse.gmf.runtime.notation.impl.DiagramImpl">
+ <instanceof value="org.eclipse.gmf.runtime.notation.Diagram">
</instanceof>
<adapt type="org.eclipse.emf.ecore.EObject"/>
</or>
@@ -86,6 +94,20 @@
</dropAssistant>
</navigatorContent>
+ <actionProvider
+ class="org.eclipse.papyrus.views.modelexplorer.actionprovider.UndoRedoActionProvider"
+ id="org.eclipse.papyrus.views.modelexplorer.actionprovider.UndoRedoActionProvider">
+ <enablement>
+ <or>
+ <adapt
+ type="org.eclipse.emf.ecore.EObject">
+ </adapt>
+ <instanceof
+ value="org.eclipse.emf.ecore.EObject">
+ </instanceof>
+ </or>
+ </enablement>
+ </actionProvider>
</extension>
<!--
<extension
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPageBookView.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPageBookView.java
index a38698ecded..5fa29922d98 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPageBookView.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPageBookView.java
@@ -1,150 +1,179 @@
-/*****************************************************************************
- * Copyright (c) 2010, 2014 LIFL, 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:
- * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
- * Ansgar Radermacher (CEA) ansgar.radermacher@cea.fr - Added support for IGotoMarker
- * Christian W. Damus (CEA) - bug 434635
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.views.modelexplorer;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EValidator;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.MultiViewPageBookView;
-import org.eclipse.papyrus.views.modelexplorer.sorting.DefaultTreeViewerSorting;
-import org.eclipse.papyrus.views.modelexplorer.sorting.ITreeViewerSorting;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-import com.google.common.collect.Lists;
-
-
-/**
- * A Page Book containing one {@link ModelExplorerView} for each opened Papyrus Editor.
- *
- * @author cedric dumoulin
- *
- */
-public class ModelExplorerPageBookView extends MultiViewPageBookView implements IGotoMarker, ITabbedPropertySheetPageContributor {
-
- /** ID of the view, as given in the plugin.xml file */
- public static final String VIEW_ID = "org.eclipse.papyrus.views.modelexplorer.modelexplorer"; //$NON-NLS-1$
-
- private final SharedModelExplorerState state = new SharedModelExplorerState();
-
- @Override
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
-
- if (memento != null) {
- state.load(memento);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected PageRec doCreatePage(IWorkbenchPart part) {
-
- // part is of type IMultiDiagramEditor (because of isImportant() )
-
- ModelExplorerPage page = new ModelExplorerPage();
- page.setSharedState(state);
-
- // Init the page, and so the View
- initPage(page, part);
- page.createControl(getPageBook());
- return new PageRec(part, page);
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-
- if (IPropertySheetPage.class == adapter) {
- // Do not test if tabbedPropertySheetPage is null before calling new
- // this is managed by Eclipse which only call current method when necessary
- return new TabbedPropertySheetPage(this);
- }
-
- if (adapter == ITreeViewerSorting.class) {
- return new DefaultTreeViewerSorting() {
-
- @Override
- public void setSorted(boolean sorted) {
- // Update the shared state
- if (state != null) {
- state.setAlphaSorted(sorted);
- }
- }
-
- @Override
- public boolean isSorted() {
- return state != null && state.isAlphaSorted();
- }
- };
- }
-
- return super.getAdapter(adapter);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getContributorId() {
- // return Activator.PLUGIN_ID;
- return "TreeOutlinePage"; //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- */
- public void gotoMarker(IMarker marker) {
- String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
- if (uriAttribute != null) {
- URI uri = URI.createURI(uriAttribute);
- IViewPart viewPart = getActiveView();
- if (viewPart instanceof ModelExplorerView) {
- ModelExplorerView modelExplorerView = (ModelExplorerView) viewPart;
- EditingDomain domain = modelExplorerView.getEditingDomain();
- EObject eObject = domain.getResourceSet().getEObject(uri, false);
- if (eObject != null) {
- CommonViewer treeViewer = ((ModelExplorerView) viewPart).getCommonViewer();
- // The common viewer is in fact a tree viewer
- // bug enhancement: use function in ModelExplorerView instead of findElementForEObject
- ModelExplorerView.reveal(Lists.newArrayList(eObject), treeViewer);
- }
- }
- }
- }
-
- @Override
- public void saveState(IMemento memento) {
- state.save(memento);
-
- super.saveState(memento);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 LIFL, 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:
+ * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Ansgar Radermacher (CEA) ansgar.radermacher@cea.fr - Added support for IGotoMarker
+ * Christian W. Damus (CEA) - bug 434635
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 431117
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.MultiViewPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.sorting.DefaultTreeViewerSorting;
+import org.eclipse.papyrus.views.modelexplorer.sorting.ITreeViewerSorting;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+
+import com.google.common.collect.Lists;
+
+
+/**
+ * A Page Book containing one {@link ModelExplorerView} for each opened Papyrus Editor.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class ModelExplorerPageBookView extends MultiViewPageBookView implements IGotoMarker, ITabbedPropertySheetPageContributor {
+
+ /** ID of the view, as given in the plugin.xml file */
+ public static final String VIEW_ID = "org.eclipse.papyrus.views.modelexplorer.modelexplorer"; //$NON-NLS-1$
+
+ private final SharedModelExplorerState state = new SharedModelExplorerState();
+
+ /** The property sheet pages. */
+ private List<IPropertySheetPage> propertiesSheetPages = new LinkedList<IPropertySheetPage>();
+
+ @Override
+ public void init(IViewSite site, IMemento memento) throws PartInitException {
+ super.init(site, memento);
+
+ if (memento != null) {
+ state.load(memento);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+
+ // part is of type IMultiDiagramEditor (because of isImportant() )
+
+ ModelExplorerPage page = new ModelExplorerPage();
+ page.setSharedState(state);
+
+ // Init the page, and so the View
+ initPage(page, part);
+ page.createControl(getPageBook());
+ return new PageRec(part, page);
+ }
+
+ /**
+ * Retrieves the {@link IPropertySheetPage} that his Model Explorer uses.
+ *
+ * @return
+ */
+ private IPropertySheetPage getPropertySheetPage() {
+ IPropertySheetPage propertySheetPage = new ModelExplorerPropertySheetPage(this);
+ propertiesSheetPages.add(propertySheetPage);
+ return propertySheetPage;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+
+ if (IPropertySheetPage.class == adapter) {
+ // Do not test if tabbedPropertySheetPage is null before calling new
+ // this is managed by Eclipse which only call current method when necessary
+ return getPropertySheetPage();
+ }
+
+ if (adapter == ITreeViewerSorting.class) {
+ return new DefaultTreeViewerSorting() {
+
+ @Override
+ public void setSorted(boolean sorted) {
+ // Update the shared state
+ if (state != null) {
+ state.setAlphaSorted(sorted);
+ }
+ }
+
+ @Override
+ public boolean isSorted() {
+ return state != null && state.isAlphaSorted();
+ }
+ };
+ }
+
+ return super.getAdapter(adapter);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getContributorId() {
+ // return Activator.PLUGIN_ID;
+ return "TreeOutlinePage"; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void gotoMarker(IMarker marker) {
+ String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
+ if (uriAttribute != null) {
+ URI uri = URI.createURI(uriAttribute);
+ IViewPart viewPart = getActiveView();
+ if (viewPart instanceof ModelExplorerView) {
+ ModelExplorerView modelExplorerView = (ModelExplorerView) viewPart;
+ EditingDomain domain = modelExplorerView.getEditingDomain();
+ EObject eObject = domain.getResourceSet().getEObject(uri, false);
+ if (eObject != null) {
+ CommonViewer treeViewer = ((ModelExplorerView) viewPart).getCommonViewer();
+ // The common viewer is in fact a tree viewer
+ // bug enhancement: use function in ModelExplorerView instead of findElementForEObject
+ ModelExplorerView.reveal(Lists.newArrayList(eObject), treeViewer);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void saveState(IMemento memento) {
+ state.save(memento);
+
+ super.saveState(memento);
+ }
+
+ /**
+ * @see org.eclipse.ui.part.PageBookView#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ for (IPropertySheetPage page : propertiesSheetPages) {
+ page.dispose();
+ }
+ propertiesSheetPages.clear();
+ super.dispose();
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPropertySheetPage.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPropertySheetPage.java
new file mode 100644
index 00000000000..2913aefe76b
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerPropertySheetPage.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+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.actions.ActionFactory;
+import org.eclipse.ui.operations.RedoActionHandler;
+import org.eclipse.ui.operations.UndoActionHandler;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * Specific PropertySheetPage for Model Explorer view to contribute to Undo/Redo Edit menu.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+class ModelExplorerPropertySheetPage extends TabbedPropertySheetPage {
+
+ /** The undo. */
+ private UndoActionHandler undo = null;
+
+ /** The redo. */
+ private RedoActionHandler redo = null;
+
+ /** The undo context. */
+ private DelegatingUndoContext undoContext = null;
+
+ /**
+ * Constructor.
+ *
+ * @param tabbedPropertySheetPageContributor
+ * the tabbed property sheet page contributor
+ */
+ public ModelExplorerPropertySheetPage(ITabbedPropertySheetPageContributor tabbedPropertySheetPageContributor) {
+ super(tabbedPropertySheetPageContributor);
+ }
+
+ /**
+ * @see org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage#setActionBars(org.eclipse.ui.IActionBars)
+ *
+ * @param actionBars
+ */
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+
+ undoContext = new DelegatingUndoContext();
+ undoContext.setDelegate(AdapterUtils.adapt(getSite().getPage().getActivePart(), IUndoContext.class, null));
+
+ undo = new UndoActionHandler(getSite().getPage().getActivePart().getSite(), undoContext);
+ redo = new RedoActionHandler(getSite().getPage().getActivePart().getSite(), undoContext);
+
+ actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undo);
+ actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redo);
+ }
+
+ /**
+ * @see org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+
+ if (undo != null) {
+ undo.dispose();
+ }
+ if (redo != null) {
+ redo.dispose();
+ }
+
+ super.dispose();
+ }
+
+
+
+
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/UndoRedoActionProvider.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/UndoRedoActionProvider.java
new file mode 100644
index 00000000000..8d70cf8f5c4
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/actionprovider/UndoRedoActionProvider.java
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.actionprovider;
+
+import java.util.EventObject;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.operations.OperationHistoryActionHandler;
+import org.eclipse.ui.operations.RedoActionHandler;
+import org.eclipse.ui.operations.UndoActionHandler;
+
+/**
+ * Action Provider to provide Redo/Undo action trough workbench menu.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+public class UndoRedoActionProvider extends AbstractCommonActionProvider implements CommandStackListener {
+
+
+ /** The undo action. */
+ IAction undoAction = null;
+
+ /** The redo action. */
+ private IAction redoAction = null;
+
+ /** Listened command stack. */
+ private CommandStack commandStack;
+
+
+ /**
+ * Instantiates a new undo redo action provider.
+ */
+ public UndoRedoActionProvider() {
+ super();
+
+
+ }
+
+ /**
+ * Gets the command stack.
+ *
+ * @return the command stack
+ */
+ private CommandStack getCommandStack() {
+
+ if (commandStack == null) {
+ CommonNavigator navigator = getCommonNavigator();
+
+ if (navigator instanceof IEditingDomainProvider) {
+ EditingDomain editingDomain = ((IEditingDomainProvider) navigator).getEditingDomain();
+ commandStack = editingDomain.getCommandStack();
+ }
+
+ }
+
+ return commandStack;
+ }
+
+ /**
+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+ *
+ * @param aSite
+ */
+ @Override
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+
+ ICommonViewerSite viewSite = aSite.getViewSite();
+ if (viewSite instanceof ICommonViewerWorkbenchSite) {
+ IWorkbenchPartSite partSite = ((ICommonViewerWorkbenchSite) viewSite).getSite();
+ undoAction = new UndoActionHandler(partSite, getUndoContext());
+ redoAction = new RedoActionHandler(partSite, getUndoContext());
+ }
+
+ getCommandStack().addCommandStackListener(this);
+
+ }
+
+ /**
+ * Gets the undo context.
+ *
+ * @return the undo context
+ */
+ private IUndoContext getUndoContext() {
+ IUndoContext context = null;
+
+ CommonNavigator navigator = getCommonNavigator();
+ if (navigator instanceof IAdaptable) {
+
+ // Get undo context from navigator
+ context = (IUndoContext) navigator.getAdapter(IUndoContext.class);
+ }
+
+ return context;
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+ *
+ * @param actionBars
+ */
+ @Override
+ public void fillActionBars(IActionBars actionBars) {
+
+ actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
+ actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
+ }
+
+ /**
+ * <p>
+ * Synchronise handlers after a Command stack's change.
+ * </p>
+ *
+ * @see org.eclipse.emf.common.command.CommandStackListener#commandStackChanged(java.util.EventObject)
+ *
+ * @param event
+ */
+ public void commandStackChanged(EventObject event) {
+
+ // Refresh Undo handler after Command stack state has changed
+ if (undoAction instanceof OperationHistoryActionHandler) {
+ ((OperationHistoryActionHandler) undoAction).update();
+ }
+
+ // Refresh Redo handler after Command stack state has changed
+ if (redoAction instanceof OperationHistoryActionHandler) {
+ ((OperationHistoryActionHandler) redoAction).update();
+ }
+
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.ActionGroup#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+
+ // Detach listener of command stack
+ getCommandStack().removeCommandStackListener(this);
+
+ super.dispose();
+ }
+}

Back to the top