Skip to content
Snippets Groups Projects
Commit 84257888 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

more trial with undo/redo actions

parent 7d9984b0
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,9 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal;
import java.util.EventObject;
import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.action.IMenuManager;
......@@ -24,6 +27,8 @@ import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.fortiss.tooling.kernel.interfaces.ITopLevelElementChangeListener;
import org.fortiss.tooling.kernel.interfaces.ITopLevelElementContext;
import org.fortiss.tooling.kernel.model.IRemovable;
import org.fortiss.tooling.kernel.services.ICommandStackService;
import org.fortiss.tooling.kernel.services.IPersistencyService;
......@@ -39,7 +44,8 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils;
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 5DDB14A5557BDA2375928D87F4F4B2BB
*/
public class ActionService implements IActionService {
public class ActionService implements IActionService,
ITopLevelElementChangeListener, CommandStackListener {
/** The group id of the global default action group. */
public static final String GROUP_GLOBAL_DEFAULTS = "globalDefaults";
......@@ -94,6 +100,11 @@ public class ActionService implements IActionService {
}
};
/** Constructor. */
public ActionService() {
}
/** {@inheritDoc} */
@Override
public void addGlobalDefaultActionSectionToMenu(IMenuManager menuManager) {
......@@ -148,4 +159,22 @@ public class ActionService implements IActionService {
globalDeleteAction.setTarget(target);
globalDeleteAction.setEnabled(canDelete);
}
/** {@inheritDoc} */
@Override
public void commandStackChanged(EventObject event) {
refresh();
}
/** {@inheritDoc} */
@Override
public void topLevelElementAdded(ITopLevelElementContext elementContext) {
elementContext.addCommandStackListener(this);
}
/** {@inheritDoc} */
@Override
public void topLevelElementRemoved(ITopLevelElementContext elementContext) {
elementContext.removeCommandStackListener(this);
}
}
......@@ -49,7 +49,6 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils;
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 0DBA8B19BC7741F646B0FECB369E177F
*/
// TODO (FH): move UI parts
public class NavigatorService implements INavigatorService,
ITopLevelElementChangeListener, CommandStackListener {
......
......@@ -20,10 +20,8 @@ package org.fortiss.tooling.kernel.ui.internal.editor;
import org.conqat.lib.commons.assertion.CCSMPre;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.fortiss.tooling.kernel.ui.interfaces.IActionContributingEditor;
import org.fortiss.tooling.kernel.ui.internal.ActionService;
import org.fortiss.tooling.kernel.ui.services.IActionService;
/**
......@@ -50,12 +48,7 @@ public final class BindingContributor extends
public void setActiveEditor(IEditorPart part) {
CCSMPre.isTrue(part instanceof BindingEditor,
"This contributor may only be used for CCTSBindingEditors!");
IActionBars bars = getActionBars();
bars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
((ActionService) IActionService.INSTANCE).globalUndoAction);
bars.setGlobalActionHandler(ActionFactory.REDO.getId(),
((ActionService) IActionService.INSTANCE).globalRedoAction);
bars.updateActionBars();
IActionService.INSTANCE.registerGlobalActions(getActionBars());
super.setActiveEditor(part);
}
......
......@@ -29,8 +29,8 @@ package org.fortiss.tooling.kernel.interfaces;
public interface ITopLevelElementChangeListener {
/** Notifies the listener about the adding of the given element. */
void topLevelElementAdded(ITopLevelElementContext elmentContext);
void topLevelElementAdded(ITopLevelElementContext elementContext);
/** Notifies the listener about the removal of the given element. */
void topLevelElementRemoved(ITopLevelElementContext elmentContext);
void topLevelElementRemoved(ITopLevelElementContext elementContext);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment