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

unde/redo actions finally work

some clean up
parent 84257888
No related branches found
No related tags found
No related merge requests found
......@@ -37,12 +37,9 @@ import org.eclipse.swt.widgets.Control;
* @version $Rev$
* @ConQAT.Rating RED Hash: 95D1650431DCD178D61C00A971F6810C
*/
// TODO (FH): move to UI
public final class DataBindingUtils {
/**
* Decoration key for edit feedback.
*/
/** Decoration key for edit feedback. */
public static final String DECORATION_KEY = ControlDecoration.class
.getName();
......
......@@ -20,6 +20,7 @@ package org.fortiss.tooling.kernel.ui.util;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
......@@ -32,9 +33,8 @@ import org.eclipse.ui.PlatformUI;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 03051CAAB0FB1E7D6A6BA510002D2C58
* @ConQAT.Rating YELLOW Hash: C89BCA60DC06B35E1946C57DD21D8769
*/
// TODO (FH): move to UI
public final class EObjectSelectionUtils {
/**
......@@ -54,7 +54,8 @@ public final class EObjectSelectionUtils {
/**
* Returns the first selected EObject or <code>null</code> if no EObject is
* selected.
* selected. If the selection implements {@link IAdaptable}, it is asked to
* adapt to {@link EObject}.
*/
public static EObject getFirstElement(ISelection selection) {
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
......@@ -62,6 +63,11 @@ public final class EObjectSelectionUtils {
return (EObject) ((IStructuredSelection) selection)
.getFirstElement();
}
if (((IStructuredSelection) selection).getFirstElement() instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) ((IStructuredSelection) selection)
.getFirstElement();
return (EObject) adaptable.getAdapter(EObject.class);
}
}
return null;
}
......
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