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

Fixed the GEF editor actions.

Some cleanup of code => YELLOW.
refs 152
parent bd1fc78b
No related branches found
No related tags found
No related merge requests found
Showing
with 145 additions and 355 deletions
......@@ -10,7 +10,6 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: fortiss
Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.action,
org.fortiss.tooling.base.ui.command,
org.fortiss.tooling.base.ui.compose,
org.fortiss.tooling.base.ui.contentprovider,
......
/*--------------------------------------------------------------------------+
$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.base.ui.action;
import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditDomain;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils;
/**
* GEF editor base implementation.
*
* It provides {@link EditDomain} and thus a {@link CommandStack}.
*
* @author hummel
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 63FF468A2D042586A22495828A0798EF
*/
public abstract class ModelElementsActionBase extends Action {
/** Stores whether the action will modify the model. */
private final boolean modifiesModel;
/** Constructor. */
protected ModelElementsActionBase(String text, String id,
ImageDescriptor image, ImageDescriptor disabledImage,
boolean modifiesModel) {
super(text, image);
setId(id);
setDisabledImageDescriptor(disabledImage);
this.modifiesModel = modifiesModel;
}
/** Returns the Command to be started in the run method. */
protected abstract Command createCommand(Collection<EObject> selection);
/** Returns the selection to be used for this action. */
protected Collection<EObject> getSelection() {
return EObjectSelectionUtils.getCurrentSelectionEObjects();
}
/**
* This method checks if the current selection is non-empty and all elements
* share the same (non-null) context, i.e. are from the same model.
*/
protected boolean isConsistentSelection() {
ITopLevelElement context = null;
for (EObject o : getSelection()) {
ITopLevelElement elementContext = IPersistencyService.INSTANCE
.getTopLevelElementFor(o);
if (context == null) {
context = elementContext;
}
if (elementContext == null || elementContext != context) {
return false;
}
}
return context != null;
}
/** {@inheritDoc} */
@Override
public final void run() {
Collection<EObject> selection = getSelection();
if (selection.isEmpty()) {
return;
}
final Command cmd = createCommand(selection);
if (cmd.canExecute()) {
if (modifiesModel) {
ITopLevelElement context = IPersistencyService.INSTANCE
.getTopLevelElementFor(selection.iterator()
.next());
context.runAsCommand(new Runnable() {
@Override
public void run() {
cmd.execute();
}
});
} else {
cmd.execute();
}
}
}
/** Updates the enablement of this action. */
public void update() {
if (!isConsistentSelection()) {
setEnabled(false);
return;
}
setEnabled(createCommand(getSelection()).canExecute());
}
}
\ No newline at end of file
......@@ -45,12 +45,12 @@ import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.DeleteAction;
import org.eclipse.gef.ui.actions.PrintAction;
import org.eclipse.gef.ui.actions.SelectAllAction;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.gef.ui.actions.UpdateAction;
import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
import org.eclipse.gef.ui.actions.ZoomInAction;
import org.eclipse.gef.ui.actions.ZoomOutAction;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.util.IPropertyChangeListener;
......@@ -69,13 +69,10 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.ToolingBaseUIActivator;
import org.fortiss.tooling.base.ui.action.CopyModelElementsAction;
import org.fortiss.tooling.base.ui.action.CutModelElementsAction;
import org.fortiss.tooling.base.ui.action.ModelElementsActionBase;
import org.fortiss.tooling.base.ui.action.PasteModelElementAction;
import org.fortiss.tooling.base.ui.dnd.ElementCompositionDropTargetListener;
import org.fortiss.tooling.base.ui.editpart.ExtendedLayerRootEditPart;
import org.fortiss.tooling.base.ui.editpart.figure.EVisualStyle;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import org.fortiss.tooling.kernel.ui.service.IEditPartFactoryService;
......@@ -134,8 +131,11 @@ public class GraphicalViewerEditorBase<T extends EObject> extends EditorBase<T>
/** {@inheritDoc} */
@Override
public EObject getSelectedModelElement() {
return EObjectSelectionUtils.getFirstElement(getSite()
.getSelectionProvider().getSelection());
if (getSite().getSelectionProvider() != null) {
return EObjectSelectionUtils.getFirstElement(getSite()
.getSelectionProvider().getSelection());
}
return null;
}
/** Creates the context menu. */
......@@ -347,14 +347,16 @@ public class GraphicalViewerEditorBase<T extends EObject> extends EditorBase<T>
*/
protected void registerEditActions() {
registerSelectionAction(new DeleteAction((IWorkbenchPart) this));
registerSelectionAction(new CopyModelElementsAction());
registerSelectionAction(new CutModelElementsAction());
registerSelectionAction(new PasteModelElementAction());
// TODO (FH): add copy paste actions for GEF
// registerSelectionAction(new CopyModelElementsAction());
// registerSelectionAction(new CutModelElementsAction());
// registerSelectionAction(new PasteModelElementAction());
}
/** Registers and returns the id of the given selection action */
protected final String registerSelectionAction(Action action) {
protected final String registerSelectionAction(SelectionAction action) {
selectionActions.add(registerAction(action));
action.setSelectionProvider(viewer);
return action.getId();
}
......@@ -368,13 +370,13 @@ public class GraphicalViewerEditorBase<T extends EObject> extends EditorBase<T>
/** Updates a list of actions. */
private void updateActions(List<String> actionIds) {
ActionRegistry registry = actionRegistry;
EObject element = getSelectedModelElement();
for (String id : actionIds) {
final IAction action = registry.getAction(id);
IAction action = actionRegistry.getAction(id);
if (action instanceof UpdateAction) {
((UpdateAction) action).update();
} else if (action instanceof ModelElementsActionBase) {
((ModelElementsActionBase) action).update();
} else if (action instanceof EObjectActionBase) {
((EObjectActionBase) action).refresh(element);
}
}
}
......
......@@ -8,11 +8,11 @@
<extension
point="org.eclipse.ui.editors">
<editor
class="org.fortiss.tooling.kernel.ui.internal.editor.BindingEditor"
contributorClass="org.fortiss.tooling.kernel.ui.internal.editor.BindingContributor"
class="org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor"
contributorClass="org.fortiss.tooling.kernel.ui.internal.editor.ActionBarContributor"
default="false"
id="org.fortiss.tooling.kernel.ui.internal.editor.BindingEditor"
name="Binding Editor">
id="org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor"
name="Extendable Model Editor">
</editor>
</extension>
<extension
......
......@@ -49,4 +49,22 @@ public abstract class EObjectActionBase extends Action {
return target;
}
/** Refreshes the action's target and enabled state. */
public final void refresh(EObject element) {
setTarget(element);
if (element == null) {
setEnabled(false);
return;
}
setEnabled(computeEnabled());
}
/**
* Computes the enabled state of the action for the current target, which is
* not <code>null</code> when this method is called. The default
* implementation returns <code>true</code>.
*/
protected boolean computeEnabled() {
return true;
}
}
......@@ -40,7 +40,7 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils;
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: AA768AB233B1896A83B8C734A6C7EB3C
* @ConQAT.Rating YELLOW Hash: 37925CD5EF3C66473FE47771ACF3421A
*/
public class ActionService implements IActionService,
IPersistencyServiceListener, CommandStackListener {
......
......@@ -28,7 +28,7 @@ import org.eclipse.ui.PlatformUI;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.ui.extension.IModelEditorBinding;
import org.fortiss.tooling.kernel.ui.internal.editor.BindingEditor;
import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor;
import org.fortiss.tooling.kernel.ui.internal.editor.ModelElementEditorInput;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
......@@ -76,10 +76,10 @@ public class ModelEditorBindingService extends
.getActiveWorkbenchWindow()
.getActivePage()
.openEditor(new ModelElementEditorInput(element),
BindingEditor.ID);
ExtendableMultiPageEditor.ID);
} catch (final PartInitException e) {
LoggingUtils.error(ToolingKernelActivator.getDefault(),
"Could not open editor with ID " + BindingEditor.ID, e);
"Could not open editor with ID " + ExtendableMultiPageEditor.ID, e);
}
}
......
......@@ -34,7 +34,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 5AF9C7DD4993146F7F9D08D4FA2C7755
* @ConQAT.Rating YELLOW Hash: C813BB34B2E3CB31260E245ED3BDA3D1
*/
public class ModelElementHandlerService extends
EObjectAwareServiceBase<IModelElementHandler<EObject>> implements
......@@ -53,9 +53,7 @@ public class ModelElementHandlerService extends
@Override
public IModelElementHandler<EObject> getModelElementHandler(
EObject modelElement) {
// TODO: Class<? extends EObject> is equivalent to Class<?> -- please
// use the shorter version
Class<? extends EObject> clazz = modelElement.getClass();
Class<?> clazz = modelElement.getClass();
List<IModelElementHandler<EObject>> handlerList = getRegisteredHandlers(clazz);
if (handlerList == null || handlerList.isEmpty()) {
LoggingUtils.error(ToolingKernelActivator.getDefault(), "ERROR: "
......
......@@ -51,7 +51,7 @@ import org.fortiss.tooling.kernel.ui.service.INavigatorService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 64B888719B1AB85A0929FDB73798A97D
* @ConQAT.Rating YELLOW Hash: DD2F69B5A93CC7141A35F54A7DFEE24C
*/
public class NavigatorService implements INavigatorService,
IPersistencyServiceListener, CommandStackListener {
......@@ -139,7 +139,6 @@ public class NavigatorService implements INavigatorService,
return Status.OK_STATUS;
}
}.schedule();
// TODO: does {@link MarkerService} call refresh? which method?
}
/** {@inheritDoc} */
......
/*--------------------------------------------------------------------------+
$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.ui.internal;
import org.fortiss.tooling.kernel.ui.service.IPropertiesService;
/**
* This class implements the {@link IPropertiesService} interface.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 94B90137442EBBDF8F76FF04C1E89F67
*
*/
public class PropertiesService implements IPropertiesService {
// nothing to do yet
}
......@@ -15,19 +15,17 @@ $Id$
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.action;
package org.fortiss.tooling.kernel.ui.internal.actions;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.fortiss.tooling.base.ui.ToolingBaseUIActivator;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.util.CopyPasteUtils;
/**
* Action for copying the current selection.
......@@ -36,45 +34,31 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
* @ConQAT.Rating YELLOW Hash: 0065AC315F6DB535B10BBEE3FA605BB0
*/
public class CopyModelElementsAction extends ModelElementsActionBase {
public class CopyAction extends EObjectActionBase {
/** Constructor. */
public CopyModelElementsAction() {
super("Copy", ActionFactory.COPY.getId(), PlatformUI.getWorkbench()
.getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY), PlatformUI
.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED),
false);
public CopyAction() {
super("Copy", PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
setId(ActionFactory.COPY.getId());
}
/** {@inheritDoc} */
@Override
protected Command createCommand(final Collection<EObject> selection) {
return new AbstractCommand("Copy") {
@Override
public void execute() {
try {
CopyPasteUtils.copyToClipboard(selection);
} catch (IOException e) {
LoggingUtils.error(ToolingBaseUIActivator.getDefault(),
"Had problems during copy operation", e);
}
}
@Override
public void redo() {
// not needed as our transactional command stack
// handles this
}
public void run() {
if (getTarget() == null) {
return;
}
Collection<EObject> targets = new LinkedList<EObject>();
targets.add(getTarget());
CopyPasteUtils.copyToClipboard(targets);
}
@Override
public boolean canExecute() {
return true;
}
};
/** {@inheritDoc} */
@Override
protected boolean computeEnabled() {
return true;
}
}
......@@ -15,20 +15,18 @@ $Id$
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.action;
package org.fortiss.tooling.kernel.ui.internal.actions;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.fortiss.tooling.base.ui.ToolingBaseUIActivator;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.util.CopyPasteUtils;
/**
* Action for cutting the current selection.
......@@ -37,52 +35,33 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
* @ConQAT.Rating YELLOW Hash: 1CE61B5736DE25451F83AE96B807DF78
*/
public class CutModelElementsAction extends ModelElementsActionBase {
public class CutAction extends EObjectActionBase {
/** Constructor. */
public CutModelElementsAction() {
super("Cut", ActionFactory.CUT.getId(), PlatformUI.getWorkbench()
.getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT), PlatformUI
.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true);
public CutAction() {
super("Cut", PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
}
/** {@inheritDoc} */
@Override
protected Command createCommand(final Collection<EObject> selection) {
return new AbstractCommand("Cut") {
public void run() {
ICommandStackService.INSTANCE.runAsCommand(getTarget(), new Runnable() {
@Override
public void execute() {
try {
CopyPasteUtils.copyToClipboard(selection);
for (EObject o : selection) {
IElementCompositorService.INSTANCE.decompose(o);
}
} catch (IOException e) {
LoggingUtils.error(ToolingBaseUIActivator.getDefault(),
"Had problems during cut operation", e);
}
}
@Override
public void redo() {
// not needed as our transactional command stack
// handles this
public void run() {
Collection<EObject> targets = new LinkedList<EObject>();
targets.add(getTarget());
CopyPasteUtils.copyToClipboard(targets);
IElementCompositorService.INSTANCE.decompose(getTarget());
}
});
}
@Override
public boolean canExecute() {
for (EObject o : selection) {
if (!IElementCompositorService.INSTANCE.canDecompose(o)) {
return false;
}
}
return true;
}
};
/** {@inheritDoc} */
@Override
protected boolean computeEnabled() {
return !IElementCompositorService.INSTANCE.canDecompose(getTarget());
}
}
......@@ -40,7 +40,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: C34C3D95AE0D485EC73074D1CC36029D
* @ConQAT.Rating YELLOW Hash: C74B196A8786CBD9D4E86EE9995842A7
*/
public class DeleteAction extends EObjectActionBase {
......@@ -54,16 +54,6 @@ public class DeleteAction extends EObjectActionBase {
setId(ActionFactory.DELETE.getId());
}
/** Refreshes the action's target and enabled state. */
public void refresh(EObject element) {
setTarget(element);
if (element == null) {
setEnabled(false);
return;
}
setEnabled(computeEnabled(element));
}
/** {@inheritDoc} */
@Override
public void run() {
......@@ -115,7 +105,9 @@ public class DeleteAction extends EObjectActionBase {
}
/** Computes enabled state of the delete action. */
private boolean computeEnabled(EObject element) {
@Override
protected boolean computeEnabled() {
EObject element = getTarget();
if (!IPersistencyService.INSTANCE.isTopLevelElement(element)) {
// use composition services for deletion
if (IElementCompositorService.INSTANCE.canDecompose(element)) {
......
......@@ -15,16 +15,14 @@ $Id$
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.action;
package org.fortiss.tooling.kernel.ui.internal.actions;
import java.util.Collection;
import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.util.CopyPasteUtils;
/**
* Action for pasting the current selection.
......@@ -33,40 +31,31 @@ import org.eclipse.ui.actions.ActionFactory;
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
* @ConQAT.Rating YELLOW Hash: E010A996BCC6B73E3D3BB7ABAF393047
*/
public class PasteModelElementAction extends ModelElementsActionBase {
public class PasteAction extends EObjectActionBase {
/** Constructor. */
public PasteModelElementAction() {
super("Paste", ActionFactory.PASTE.getId(), PlatformUI.getWorkbench()
.getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), PlatformUI
.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED),
true);
public PasteAction() {
super("Paste", PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
setId(ActionFactory.PASTE.getId());
}
/** {@inheritDoc} */
@Override
protected Command createCommand(final Collection<EObject> selection) {
return new AbstractCommand("Paste") {
@Override
public void execute() {
CopyPasteUtils.pasteFromClipboard(selection.iterator().next());
}
public void run() {
ICommandStackService.INSTANCE.runAsCommand(getTarget(), new Runnable() {
@Override
public void redo() {
// not needed as our transactional command stack
// handles this
public void run() {
CopyPasteUtils.pasteFromClipboard(getTarget(), null);
}
});
}
@Override
public boolean canExecute() {
return selection.size() == 1;
}
};
/** {@inheritDoc} */
@Override
protected boolean computeEnabled() {
return CopyPasteUtils.canPasteInto(getTarget(), null);
}
}
......@@ -17,7 +17,6 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.actions;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
......@@ -31,7 +30,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: FE20124DCB7DAF4D7AAAC0809FA5B5D2
* @ConQAT.Rating YELLOW Hash: 0B7D56260E20B77F1067D0D6D900E8BA
*/
public class RedoAction extends EObjectActionBase {
......@@ -42,15 +41,10 @@ public class RedoAction extends EObjectActionBase {
setId(ActionFactory.REDO.getId());
}
/** Refreshes the action's target and enabled state. */
public void refresh(EObject element) {
setTarget(element);
if (element == null) {
setEnabled(false);
return;
}
setEnabled(ICommandStackService.INSTANCE.canRedo(element));
/** {@inheritDoc} */
@Override
protected boolean computeEnabled() {
return ICommandStackService.INSTANCE.canRedo(getTarget());
}
/** {@inheritDoc} */
......
......@@ -17,7 +17,6 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.actions;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
......@@ -31,7 +30,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 9562CA97CDD998AB076426AADBD9BB52
* @ConQAT.Rating YELLOW Hash: 7A19147C248ED9C90A307D330E3BD0BB
*/
public class UndoAction extends EObjectActionBase {
......@@ -42,15 +41,10 @@ public class UndoAction extends EObjectActionBase {
setId(ActionFactory.UNDO.getId());
}
/** Refreshes the action's target and enabled state. */
public void refresh(EObject element) {
setTarget(element);
if (element == null) {
setEnabled(false);
return;
}
setEnabled(ICommandStackService.INSTANCE.canUndo(element));
/** {@inheritDoc} */
@Override
protected boolean computeEnabled() {
return ICommandStackService.INSTANCE.canUndo(getTarget());
}
/** {@inheritDoc} */
......
......@@ -24,15 +24,15 @@ import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.fortiss.tooling.kernel.ui.service.IActionService;
/**
* The action bar contributor for the {@link BindingEditor}.
* The action bar contributor for the {@link ExtendableMultiPageEditor}.
*
* @author hummel
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: DD94B05974F477EC8F88B487A0DB7A2D
* @ConQAT.Rating YELLOW Hash: 722291A6CD9154299B4EDAF8C4496BFC
*/
public final class BindingContributor extends
public final class ActionBarContributor extends
MultiPageEditorActionBarContributor {
/** The last editor seen. */
......@@ -45,8 +45,8 @@ public final class BindingContributor extends
*/
@Override
public void setActiveEditor(IEditorPart part) {
Assert.isTrue(part instanceof BindingEditor,
"This contributor may only be used for BindingEditors!");
Assert.isTrue(part instanceof ExtendableMultiPageEditor,
"This contributor may only be used for ExtendableMultiPageEditors!");
IActionService.INSTANCE.registerGlobalActions(getActionBars());
super.setActiveEditor(part);
}
......
......@@ -45,28 +45,25 @@ import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.extension.IModelEditorBinding;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.listener.IBindingEditorPageChangeListener;
import org.fortiss.tooling.kernel.ui.listener.ExtendableMultiPageEditorPageChangeListener;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IPropertiesService;
import org.fortiss.tooling.kernel.ui.util.PropertiesConstantUtils;
/**
* This editor is used for displaying multiple editors provided by editor
* bindings for a given model element.
*
* TODO: the name "Binding" is unintuitive to me. + is there a link to
* IEditorBinding?
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 67AEFFDC48991458A33D3BF44819965E
* @ConQAT.Rating YELLOW Hash: E679E55F39BBC5B00B721E3DF7CC40F3
*/
public class BindingEditor extends MultiPageEditorPart implements
public class ExtendableMultiPageEditor extends MultiPageEditorPart implements
ITabbedPropertySheetPageContributor, CommandStackListener,
ISaveablePart {
/** The editor's ID. */
public static String ID = BindingEditor.class.getName();
public static String ID = ExtendableMultiPageEditor.class.getName();
/**
* The object shown in this editor. This is valid as soon as
......@@ -90,17 +87,17 @@ public class BindingEditor extends MultiPageEditorPart implements
};
/** Stores the binding editor listeners. */
private final Collection<IBindingEditorPageChangeListener> bindingEditorListeners = new IdentityHashSet<IBindingEditorPageChangeListener>();
private final Collection<ExtendableMultiPageEditorPageChangeListener> bindingEditorListeners = new IdentityHashSet<ExtendableMultiPageEditorPageChangeListener>();
/** Adds a page change listener. */
public void addBindingEditorListener(
IBindingEditorPageChangeListener listener) {
ExtendableMultiPageEditorPageChangeListener listener) {
bindingEditorListeners.add(listener);
}
/** Removes a page change listener. */
public void removeBindingEditorListener(
IBindingEditorPageChangeListener listener) {
ExtendableMultiPageEditorPageChangeListener listener) {
bindingEditorListeners.remove(listener);
}
......@@ -109,7 +106,7 @@ public class BindingEditor extends MultiPageEditorPart implements
protected void pageChange(int newPageIndex) {
super.pageChange(newPageIndex);
for (final IBindingEditorPageChangeListener listener : bindingEditorListeners) {
for (final ExtendableMultiPageEditorPageChangeListener listener : bindingEditorListeners) {
listener.pageChanged();
}
}
......@@ -235,7 +232,7 @@ public class BindingEditor extends MultiPageEditorPart implements
*/
@Override
public String getContributorId() {
return IPropertiesService.TABBED_PROPERTY_CONTRIBUTOR_ID;
return PropertiesConstantUtils.TABBED_PROPERTY_CONTRIBUTOR_ID;
}
/**
......
......@@ -21,12 +21,12 @@ import org.eclipse.ui.IActionBars;
/**
* Interface for editors which contribute own actions to the
* {@link BindingContributor}.
* {@link ActionBarContributor}.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: D988E24BA5E310FEE8C71E5F6D462679
* @ConQAT.Rating YELLOW Hash: BA174A950A14B10C5765E0C6F613367F
*/
public interface IActionContributingEditor {
/**
......
......@@ -25,12 +25,12 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
/**
* {@link IEditorInput} used when opening a {@link BindingEditor}.
* {@link IEditorInput} used when opening a {@link ExtendableMultiPageEditor}.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: B446B57CB88D691FC4768698973ABD4E
* @ConQAT.Rating YELLOW Hash: 99BD3D12DC9BCE80935A78E695311746
*/
public final class ModelElementEditorInput implements IEditorInput {
......@@ -81,8 +81,7 @@ public final class ModelElementEditorInput implements IEditorInput {
/** {@inheritDoc} */
@Override
public ImageDescriptor getImageDescriptor() {
// TODO (FH): add image support
return null;
return handler.getIconImageDescriptor();
}
/** {@inheritDoc} */
......
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