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

removed trial patches

completed working undo/redo mechanism
fixed global actions update in navigator
parent 33cea36d
No related branches found
No related tags found
No related merge requests found
### Eclipse Workspace Patch 1.0
#P org.fortiss.tooling.kernel
Index: src/org/fortiss/tooling/kernel/internal/compose/ProjectCompositor.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/compose/ProjectCompositor.java (revision 0)
+++ src/org/fortiss/tooling/kernel/internal/compose/ProjectCompositor.java (revision 0)
@@ -0,0 +1,50 @@
+/*--------------------------------------------------------------------------+
+$Id$
+| |
+| Copyright 2011 ForTISS GmbH |
+| |
+| Licensed under the Apache License, Version 2.0 (the "License"); |
+| you may not use this file except in compliance with the License. |
+| You may obtain a copy of the License at |
+| |
+| http://www.apache.org/licenses/LICENSE-2.0 |
+| |
+| Unless required by applicable law or agreed to in writing, software |
+| distributed under the License is distributed on an "AS IS" BASIS, |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and |
+| limitations under the License. |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.kernel.internal.compose;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.emfstore.common.model.Project;
+import org.fortiss.tooling.kernel.interfaces.ICompositionContext;
+import org.fortiss.tooling.kernel.interfaces.ICompositor;
+import org.fortiss.tooling.kernel.model.IProjectRootElement;
+
+/**
+ * {@link ICompositor} implementation for the {@link IProjectRootElement}s.
+ *
+ * @author hoelzlf
+ * @author $Author$
+ * @version $Rev$
+ * @levd.rating RED Rev:
+ */
+public final class ProjectCompositor implements ICompositor<Project> {
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean canCompose(Project container, EObject contained,
+ ICompositionContext context) {
+ return contained instanceof IProjectRootElement;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean compose(Project container, EObject contained,
+ ICompositionContext context) {
+ container.addModelElement(contained);
+ return true;
+ }
+}
Property changes on: src/org/fortiss/tooling/kernel/internal/compose/ProjectCompositor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: svn:keywords
+ Date Author Id Revision HeadURL
Index: META-INF/MANIFEST.MF
===================================================================
--- META-INF/MANIFEST.MF (revision 614)
+++ META-INF/MANIFEST.MF (working copy)
@@ -16,6 +16,7 @@
org.conqat.ide.commons.ui;bundle-version="2.7.0";visibility:=reexport,
org.conqat.ide.commons.gef;bundle-version="2.7.0",
org.eclipse.jdt.ui;bundle-version="3.6.2",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
org.eclipse.emf.emfstore.server;bundle-version="0.7.3",
org.eclipse.emf.emfstore.client;bundle-version="0.7.3",
org.eclipse.emf.emfstore.client.ui;bundle-version="0.7.3"
Index: src/org/fortiss/tooling/kernel/internal/ActionService.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/ActionService.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/ActionService.java (working copy)
@@ -32,6 +32,7 @@
import org.fortiss.tooling.kernel.model.IRemovable;
import org.fortiss.tooling.kernel.services.IActionService;
import org.fortiss.tooling.kernel.services.ICommandStackService;
+import org.fortiss.tooling.kernel.services.INavigatorService;
import org.fortiss.tooling.kernel.util.EObjectSelectionUtils;
/**
@@ -54,8 +55,12 @@
@Override
public void run() {
+ // FIXME (FH): this assumes the navigator is providing the
+ // selection, which might not be what we want!
EObject selectedObject = EObjectSelectionUtils
- .getCurrentSelectionFirstElement();
+ .getFirstElement(INavigatorService.INSTANCE
+ .getCurrentSelection());
+
if (selectedObject != null) {
ICommandStackService.INSTANCE.undo(selectedObject);
}
@@ -63,13 +68,46 @@
@Override
public boolean isEnabled() {
+ // FIXME (FH): this assumes the navigator is providing the
+ // selection, which might not be what we want!
EObject selectedObject = EObjectSelectionUtils
- .getCurrentSelectionFirstElement();
+ .getFirstElement(INavigatorService.INSTANCE
+ .getCurrentSelection());
return selectedObject != null
&& ICommandStackService.INSTANCE.canUndo(selectedObject);
}
};
+ /** The global redo action. */
+ public final IAction globalRedoAction = new Action("Redo", PlatformUI
+ .getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO)) {
+
+ @Override
+ public void run() {
+ // FIXME (FH): this assumes the navigator is providing the
+ // selection, which might not be what we want!
+ EObject selectedObject = EObjectSelectionUtils
+ .getFirstElement(INavigatorService.INSTANCE
+ .getCurrentSelection());
+
+ if (selectedObject != null) {
+ ICommandStackService.INSTANCE.redo(selectedObject);
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ // FIXME (FH): this assumes the navigator is providing the
+ // selection, which might not be what we want!
+ EObject selectedObject = EObjectSelectionUtils
+ .getFirstElement(INavigatorService.INSTANCE
+ .getCurrentSelection());
+ return selectedObject != null
+ && ICommandStackService.INSTANCE.canRedo(selectedObject);
+ }
+ };
+
/** The global delete action. */
public final IAction globalDeleteAction = new Action("Delete", PlatformUI
.getWorkbench().getSharedImages()
@@ -114,6 +152,7 @@
public void addGlobalDefaultActionSectionToMenu(IMenuManager menuManager) {
menuManager.appendToGroup(GROUP_GLOBAL_DEFAULTS, globalDeleteAction);
menuManager.appendToGroup(GROUP_GLOBAL_DEFAULTS, globalUndoAction);
+ menuManager.appendToGroup(GROUP_GLOBAL_DEFAULTS, globalRedoAction);
}
/** {@inheritDoc} */
@@ -136,6 +175,12 @@
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
globalUndoAction);
+ globalRedoAction.setId(ActionFactory.REDO.getId());
+ globalRedoAction.setActionDefinitionId(ActionFactory.REDO
+ .getCommandId());
+ actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),
+ globalRedoAction);
+
actionBars.updateActionBars();
}
@@ -143,5 +188,7 @@
@Override
public void update() {
globalUndoAction.setEnabled(globalUndoAction.isEnabled());
+ globalRedoAction.setEnabled(globalRedoAction.isEnabled());
+
}
}
Index: src/org/fortiss/tooling/kernel/internal/emf/AutoUndoCommandStack.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/emf/AutoUndoCommandStack.java (revision 0)
+++ src/org/fortiss/tooling/kernel/internal/emf/AutoUndoCommandStack.java (revision 0)
@@ -0,0 +1,164 @@
+/*--------------------------------------------------------------------------+
+$Id$
+| |
+| Copyright 2011 ForTISS GmbH |
+| |
+| Licensed under the Apache License, Version 2.0 (the "License"); |
+| you may not use this file except in compliance with the License. |
+| You may obtain a copy of the License at |
+| |
+| http://www.apache.org/licenses/LICENSE-2.0 |
+| |
+| Unless required by applicable law or agreed to in writing, software |
+| distributed under the License is distributed on an "AS IS" BASIS, |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and |
+| limitations under the License. |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.kernel.internal.emf;
+
+import java.util.Map;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.transaction.ExceptionHandler;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalCommandStack;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+/**
+ * This command stack warps a {@link TransactionalEditingDomain} and forwards
+ * all calls to its command stack. However all commands which are executed are
+ * wrapped in an AutoUndoCommand first.
+ *
+ * @author hummelb
+ * @author $Author$
+ * @version $Rev$
+ * @levd.rating YELLOW Hash: 5D53FF5E73D3F0E9DFBD7F3CE61548D5
+ */
+public class AutoUndoCommandStack implements TransactionalCommandStack {
+
+ /** The underlying editing domain. */
+ private final TransactionalEditingDomain editingDomain;
+
+ /** The underlying command stack. */
+ private final TransactionalCommandStack commandStack;
+
+ /** Constructor. */
+ public AutoUndoCommandStack() {
+ this.editingDomain = TransactionalEditingDomain.Factory.INSTANCE
+ .createEditingDomain();
+ commandStack = (TransactionalCommandStack) editingDomain
+ .getCommandStack();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void addCommandStackListener(CommandStackListener listener) {
+ commandStack.addCommandStackListener(listener);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean canRedo() {
+ return commandStack.canRedo();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean canUndo() {
+ return commandStack.canUndo();
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void execute(Command command, Map options)
+ throws InterruptedException, RollbackException {
+ commandStack.execute(
+ new EMFTransactionalCommand(command, editingDomain), options);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void execute(Command command) {
+ commandStack
+ .execute(new EMFTransactionalCommand(command, editingDomain));
+ }
+
+ /** Executes the given {@link Runnable} as a command. */
+ public void execute(final Runnable runner) {
+ execute(new AbstractCommand() {
+
+ @Override
+ public boolean canExecute() {
+ return true;
+ }
+
+ @Override
+ public void execute() {
+ runner.run();
+ }
+
+ @Override
+ public void redo() {
+ // redo is handled automatically
+ }
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void flush() {
+ commandStack.flush();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public ExceptionHandler getExceptionHandler() {
+ return commandStack.getExceptionHandler();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Command getMostRecentCommand() {
+ return commandStack.getMostRecentCommand();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Command getRedoCommand() {
+ return commandStack.getRedoCommand();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Command getUndoCommand() {
+ return commandStack.getUndoCommand();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void redo() {
+ commandStack.redo();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void removeCommandStackListener(CommandStackListener listener) {
+ commandStack.removeCommandStackListener(listener);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setExceptionHandler(ExceptionHandler handler) {
+ commandStack.setExceptionHandler(handler);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void undo() {
+ commandStack.undo();
+ }
+}
Property changes on: src/org/fortiss/tooling/kernel/internal/emf/AutoUndoCommandStack.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: svn:keywords
+ Date Author Id Revision HeadURL
Index: src/org/fortiss/tooling/kernel/internal/properties/PropertiesAdapterFactory.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/properties/PropertiesAdapterFactory.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/properties/PropertiesAdapterFactory.java (working copy)
@@ -19,9 +19,9 @@
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.fortiss.tooling.kernel.services.IPropertiesService;
-import org.fortiss.tooling.kernel.util.ProjectRootElementUtils;
/**
* Adapter factory for tabbed property sheets.
@@ -40,7 +40,7 @@
if (adapterType == ITabbedPropertySheetPageContributor.class
&& adaptableObject instanceof EObject) {
EObject modelElement = (EObject) adaptableObject;
- if (ProjectRootElementUtils.getProjectSpace(modelElement) != null) {
+ if (ModelUtil.getProject(modelElement) != null) {
return new ITabbedPropertySheetPageContributor() {
@Override
Index: plugin.xml
===================================================================
--- plugin.xml (revision 614)
+++ plugin.xml (working copy)
@@ -185,15 +185,15 @@
<extension
point="org.fortiss.tooling.kernel.modelElementHandler">
<modelElementHandler
- handler="org.fortiss.tooling.kernel.internal.handler.ProjectSpaceModelElementHandler"
- modelElementClass="org.eclipse.emf.emfstore.client.model.ProjectSpace">
+ handler="org.fortiss.tooling.kernel.internal.handler.ProjectModelElementHandler"
+ modelElementClass="org.eclipse.emf.emfstore.common.model.Project">
</modelElementHandler>
</extension>
<extension
point="org.fortiss.tooling.kernel.modelElementCompositor">
<modelElementCompositor
- compositor="org.fortiss.tooling.kernel.internal.compose.ProjectSpaceCompositor"
- modelElementClass="org.eclipse.emf.emfstore.client.model.ProjectSpace">
+ compositor="org.fortiss.tooling.kernel.internal.compose.ProjectCompositor"
+ modelElementClass="org.eclipse.emf.emfstore.common.model.Project">
</modelElementCompositor>
</extension>
Index: src/org/fortiss/tooling/kernel/internal/NavigatorService.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/NavigatorService.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/NavigatorService.java (working copy)
@@ -17,6 +17,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.part.ViewPart;
import org.fortiss.tooling.kernel.internal.navigator.NavigatorViewPart;
import org.fortiss.tooling.kernel.services.INavigatorService;
@@ -44,4 +45,11 @@
public ViewPart getNavigatorView() {
return navigatorViewPart;
}
+
+ /** {@inheritDoc} */
+ @Override
+ public ISelection getCurrentSelection() {
+ return navigatorViewPart.getSite().getSelectionProvider()
+ .getSelection();
+ }
}
Index: src/org/fortiss/tooling/kernel/internal/handler/ProjectSpaceModelElementHandler.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/handler/ProjectSpaceModelElementHandler.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/handler/ProjectSpaceModelElementHandler.java (working copy)
@@ -1,71 +0,0 @@
-/*--------------------------------------------------------------------------+
-$Id$
-| |
-| Copyright 2011 ForTISS GmbH |
-| |
-| Licensed under the Apache License, Version 2.0 (the "License"); |
-| you may not use this file except in compliance with the License. |
-| You may obtain a copy of the License at |
-| |
-| http://www.apache.org/licenses/LICENSE-2.0 |
-| |
-| Unless required by applicable law or agreed to in writing, software |
-| distributed under the License is distributed on an "AS IS" BASIS, |
-| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
-| See the License for the specific language governing permissions and |
-| limitations under the License. |
-+--------------------------------------------------------------------------*/
-package org.fortiss.tooling.kernel.internal.handler;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.emfstore.client.model.ProjectSpace;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.fortiss.tooling.kernel.ToolingKernelActivator;
-import org.fortiss.tooling.kernel.base.HandlerBase;
-import org.fortiss.tooling.kernel.interfaces.IHandler;
-import org.fortiss.tooling.kernel.model.IProjectRootElement;
-
-/**
- * {@link IHandler} for {@link ProjectSpace}s.
- *
- * @author hoelzlf
- * @author $Author$
- * @version $Rev$
- * @levd.rating RED Rev:
- */
-public final class ProjectSpaceModelElementHandler extends
- HandlerBase<ProjectSpace> {
-
- /** {@inheritDoc} */
- @Override
- public String getName(ProjectSpace element) {
- return element.getProjectName();
- }
-
- /** {@inheritDoc} */
- @Override
- public String getDescription(ProjectSpace element) {
- return element.getProjectDescription();
- }
-
- /** {@inheritDoc} */
- @Override
- public ImageDescriptor getIconImageDescriptor() {
- return ToolingKernelActivator.getImageDescriptor("icons/project.png");
- }
-
- /** {@inheritDoc} */
- @Override
- public List<EObject> getSubnodes(ProjectSpace element) {
- List<EObject> list = new ArrayList<EObject>();
- for (EObject node : element.getProject().getModelElements()) {
- if (node instanceof IProjectRootElement) {
- list.add(node);
- }
- }
- return list;
- }
-}
Index: src/org/fortiss/tooling/kernel/services/INavigatorService.java
===================================================================
--- src/org/fortiss/tooling/kernel/services/INavigatorService.java (revision 614)
+++ src/org/fortiss/tooling/kernel/services/INavigatorService.java (working copy)
@@ -17,6 +17,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.services;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.part.ViewPart;
import org.fortiss.tooling.kernel.internal.NavigatorService;
@@ -41,4 +42,7 @@
* navigator has not yet been created or has already been disposed.
*/
ViewPart getNavigatorView();
+
+ /** Returns the current naviaator selection. */
+ ISelection getCurrentSelection();
}
Index: src/org/fortiss/tooling/kernel/internal/navigator/NavigatorTreeContentProvider.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/navigator/NavigatorTreeContentProvider.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/navigator/NavigatorTreeContentProvider.java (working copy)
@@ -17,8 +17,13 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal.navigator;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.emfstore.client.model.ProjectSpace;
import org.eclipse.emf.emfstore.client.model.Workspace;
+import org.eclipse.emf.emfstore.common.model.Project;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.fortiss.tooling.kernel.interfaces.IHandler;
@@ -38,7 +43,12 @@
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof Workspace) {
- return ((Workspace) inputElement).getProjectSpaces().toArray();
+ List<Project> result = new ArrayList<Project>();
+ for (ProjectSpace space : ((Workspace) inputElement)
+ .getProjectSpaces()) {
+ result.add(space.getProject());
+ }
+ return result.toArray();
}
return null;
}
Index: src/org/fortiss/tooling/kernel/internal/navigator/NewMenu.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/navigator/NewMenu.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/navigator/NewMenu.java (working copy)
@@ -27,6 +27,7 @@
import org.fortiss.tooling.kernel.services.ICompositorService;
import org.fortiss.tooling.kernel.services.IEditorService;
import org.fortiss.tooling.kernel.services.IModelElementService;
+import org.fortiss.tooling.kernel.services.INavigatorService;
import org.fortiss.tooling.kernel.services.IPrototypeService;
import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype;
import org.fortiss.tooling.kernel.util.EObjectSelectionUtils;
@@ -60,8 +61,11 @@
/** {@inheritDoc} */
@Override
protected IContributionItem[] getContributionItems() {
+ // FIXME (FH): this assumes the navigator is providing the
+ // selection, which might not be what we want!
EObject selectedObject = EObjectSelectionUtils
- .getCurrentSelectionFirstElement();
+ .getFirstElement(INavigatorService.INSTANCE
+ .getCurrentSelection());
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
if (selectedObject != null) {
Index: src/org/fortiss/tooling/kernel/internal/emf/EMFTransactionalCommand.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/emf/EMFTransactionalCommand.java (revision 0)
+++ src/org/fortiss/tooling/kernel/internal/emf/EMFTransactionalCommand.java (revision 0)
@@ -0,0 +1,182 @@
+/*--------------------------------------------------------------------------+
+$Id$
+| |
+| Copyright 2011 ForTISS GmbH |
+| |
+| Licensed under the Apache License, Version 2.0 (the "License"); |
+| you may not use this file except in compliance with the License. |
+| You may obtain a copy of the License at |
+| |
+| http://www.apache.org/licenses/LICENSE-2.0 |
+| |
+| Unless required by applicable law or agreed to in writing, software |
+| distributed under the License is distributed on an "AS IS" BASIS, |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and |
+| limitations under the License. |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.kernel.internal.emf;
+
+import java.util.Collection;
+
+import org.conqat.ide.commons.ui.logging.LoggingUtils;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.Transaction;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
+import org.fortiss.tooling.kernel.ToolingKernelActivator;
+
+/**
+ * This class wraps another EMF command and makes sure that all execute methods
+ * ({@link #execute()}, {@link #undo()}, {@link #redo()}) are executed inside of
+ * a transaction. As a bonus the undo and redo methods are based on the
+ * transaction of the execute call (i.e. are coming for free).
+ *
+ * @author hummelb
+ * @author $Author$
+ * @version $Rev$
+ * @levd.rating YELLOW Hash: 625F16187EE652EBF03196972D41AFE9
+ */
+public class EMFTransactionalCommand implements Command {
+
+ /** The wrapped command. */
+ private final Command inner;
+
+ /** The recording command used. */
+ private final RecordingCommand recordingCommand;
+
+ /** The editing domain. */
+ private final InternalTransactionalEditingDomain editingDomain;
+
+ /** Constructor. */
+ public EMFTransactionalCommand(Command command,
+ TransactionalEditingDomain editingDomain) {
+ inner = command;
+ recordingCommand = new RecordingCommand(editingDomain) {
+ @Override
+ protected void doExecute() {
+ inner.execute();
+ }
+ };
+ this.editingDomain = (InternalTransactionalEditingDomain) editingDomain;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void execute() {
+ runInTransaction(new Runnable() {
+ @Override
+ public void run() {
+ recordingCommand.execute();
+ }
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void redo() {
+ runInTransaction(new Runnable() {
+ @Override
+ public void run() {
+ recordingCommand.redo();
+ }
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void undo() {
+ runInTransaction(new Runnable() {
+ @Override
+ public void run() {
+ recordingCommand.undo();
+ }
+ });
+ }
+
+ /**
+ * Executes the given runnable in a transaction.
+ */
+ private void runInTransaction(Runnable runnable) {
+ Transaction tx = null;
+ try {
+ tx = editingDomain.startTransaction(false, null);
+ runnable.run();
+ } catch (InterruptedException e) {
+ LoggingUtils.error(ToolingKernelActivator.getDefault(),
+ "Had unexpected interruption in command execution!", e);
+ } finally {
+ if (tx != null) {
+ try {
+ tx.commit();
+ } catch (RollbackException e) {
+ // There is nothing we can do about.
+ // Maybe it even was intended, so ignore.
+ }
+ } else {
+ LoggingUtils.log(ToolingKernelActivator.getDefault(),
+ "Was not able to start transaction!", IStatus.ERROR);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean canExecute() {
+ return inner.canExecute();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean canUndo() {
+ return recordingCommand.canUndo();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Collection<?> getAffectedObjects() {
+ return inner.getAffectedObjects();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getDescription() {
+ return inner.getDescription();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getLabel() {
+ return inner.getLabel();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Collection<?> getResult() {
+ return inner.getResult();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Command chain(Command command) {
+ if (command == null) {
+ return this;
+ }
+
+ final CompoundCommand result = new CompoundCommand();
+ result.append(this);
+ result.append(command);
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void dispose() {
+ inner.dispose();
+ recordingCommand.dispose();
+ }
+}
Property changes on: src/org/fortiss/tooling/kernel/internal/emf/EMFTransactionalCommand.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: svn:keywords
+ Date Author Id Revision HeadURL
Index: src/org/fortiss/tooling/kernel/internal/compose/ProjectSpaceCompositor.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/compose/ProjectSpaceCompositor.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/compose/ProjectSpaceCompositor.java (working copy)
@@ -1,50 +0,0 @@
-/*--------------------------------------------------------------------------+
-$Id$
-| |
-| Copyright 2011 ForTISS GmbH |
-| |
-| Licensed under the Apache License, Version 2.0 (the "License"); |
-| you may not use this file except in compliance with the License. |
-| You may obtain a copy of the License at |
-| |
-| http://www.apache.org/licenses/LICENSE-2.0 |
-| |
-| Unless required by applicable law or agreed to in writing, software |
-| distributed under the License is distributed on an "AS IS" BASIS, |
-| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
-| See the License for the specific language governing permissions and |
-| limitations under the License. |
-+--------------------------------------------------------------------------*/
-package org.fortiss.tooling.kernel.internal.compose;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.emfstore.client.model.ProjectSpace;
-import org.fortiss.tooling.kernel.interfaces.ICompositionContext;
-import org.fortiss.tooling.kernel.interfaces.ICompositor;
-import org.fortiss.tooling.kernel.model.IProjectRootElement;
-
-/**
- * {@link ICompositor} implementation for the {@link IProjectRootElement}s.
- *
- * @author hoelzlf
- * @author $Author$
- * @version $Rev$
- * @levd.rating RED Rev:
- */
-public final class ProjectSpaceCompositor implements ICompositor<ProjectSpace> {
-
- /** {@inheritDoc} */
- @Override
- public boolean canCompose(ProjectSpace container, EObject contained,
- ICompositionContext context) {
- return contained instanceof IProjectRootElement;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean compose(ProjectSpace container, EObject contained,
- ICompositionContext context) {
- container.getProject().addModelElement(contained);
- return true;
- }
-}
Index: src/org/fortiss/tooling/kernel/internal/CommandStackService.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/CommandStackService.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/CommandStackService.java (working copy)
@@ -18,9 +18,12 @@
package org.fortiss.tooling.kernel.internal;
import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.emfstore.client.model.Configuration;
import org.eclipse.emf.emfstore.client.model.WorkspaceManager;
+import org.eclipse.emf.emfstore.client.model.changeTracking.commands.CommandObserver;
+import org.eclipse.emf.emfstore.client.model.changeTracking.commands.EMFStoreCommandStack;
import org.eclipse.emf.emfstore.client.model.util.EMFStoreCommand;
import org.fortiss.tooling.kernel.services.ICommandStackService;
@@ -32,7 +35,8 @@
* @version $Rev$
* @levd.rating RED Rev:
*/
-public class CommandStackService implements ICommandStackService {
+public class CommandStackService implements ICommandStackService,
+ CommandObserver {
/** Stores the EMFStore command stack. */
private BasicCommandStack globalCommandStack;
@@ -44,6 +48,10 @@
WorkspaceManager.getInstance().getCurrentWorkspace();
globalCommandStack = (BasicCommandStack) Configuration
.getEditingDomain().getCommandStack();
+ if (globalCommandStack instanceof EMFStoreCommandStack) {
+ ((EMFStoreCommandStack) globalCommandStack)
+ .addCommandStackObserver(this);
+ }
}
/** {@inheritDoc} */
@@ -82,4 +90,22 @@
public void redo(EObject target) {
globalCommandStack.redo();
}
+
+ /** {@inheritDoc} */
+ @Override
+ public void commandStarted(Command command) {
+ System.out.println("Command started.");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void commandCompleted(Command command) {
+ System.out.println("Command comnpleted.");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void commandFailed(Command command, Exception exception) {
+ System.out.println("Command failed.");
+ }
}
Index: src/org/fortiss/tooling/kernel/internal/handler/ProjectModelElementHandler.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/handler/ProjectModelElementHandler.java (revision 0)
+++ src/org/fortiss/tooling/kernel/internal/handler/ProjectModelElementHandler.java (revision 0)
@@ -0,0 +1,72 @@
+/*--------------------------------------------------------------------------+
+$Id$
+| |
+| Copyright 2011 ForTISS GmbH |
+| |
+| Licensed under the Apache License, Version 2.0 (the "License"); |
+| you may not use this file except in compliance with the License. |
+| You may obtain a copy of the License at |
+| |
+| http://www.apache.org/licenses/LICENSE-2.0 |
+| |
+| Unless required by applicable law or agreed to in writing, software |
+| distributed under the License is distributed on an "AS IS" BASIS, |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and |
+| limitations under the License. |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.kernel.internal.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.emfstore.client.model.WorkspaceManager;
+import org.eclipse.emf.emfstore.common.model.Project;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.fortiss.tooling.kernel.ToolingKernelActivator;
+import org.fortiss.tooling.kernel.base.HandlerBase;
+import org.fortiss.tooling.kernel.interfaces.IHandler;
+import org.fortiss.tooling.kernel.model.IProjectRootElement;
+
+/**
+ * {@link IHandler} for {@link Project}s.
+ *
+ * @author hoelzlf
+ * @author $Author$
+ * @version $Rev$
+ * @levd.rating RED Rev:
+ */
+public final class ProjectModelElementHandler extends HandlerBase<Project> {
+
+ /** {@inheritDoc} */
+ @Override
+ public String getName(Project element) {
+ return WorkspaceManager.getProjectSpace(element).getProjectName();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getDescription(Project element) {
+ return WorkspaceManager.getProjectSpace(element)
+ .getProjectDescription();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public ImageDescriptor getIconImageDescriptor() {
+ return ToolingKernelActivator.getImageDescriptor("icons/project.png");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public List<EObject> getSubnodes(Project element) {
+ List<EObject> list = new ArrayList<EObject>();
+ for (EObject node : element.getModelElements()) {
+ if (node instanceof IProjectRootElement) {
+ list.add(node);
+ }
+ }
+ return list;
+ }
+}
Property changes on: src/org/fortiss/tooling/kernel/internal/handler/ProjectModelElementHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: svn:keywords
+ Date Author Id Revision HeadURL
Index: src/org/fortiss/tooling/kernel/internal/EditorService.java
===================================================================
--- src/org/fortiss/tooling/kernel/internal/EditorService.java (revision 614)
+++ src/org/fortiss/tooling/kernel/internal/EditorService.java (working copy)
@@ -67,6 +67,7 @@
@Override
public void openInEditor(EObject element) {
try {
+ // FIXME (FH): only open editor, if at least one bound appear
PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
This diff is collapsed.
This diff is collapsed.
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