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

reworked open editor code

added open after new menu composition
parent 65d47866
No related branches found
No related tags found
No related merge requests found
......@@ -21,9 +21,15 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.conqat.ide.commons.ui.logging.LoggingUtils;
import org.conqat.lib.commons.collections.CollectionUtils;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.interfaces.IEditorBinding;
import org.fortiss.tooling.kernel.internal.editor.BindingEditor;
import org.fortiss.tooling.kernel.internal.editor.ModelElementEditorInput;
import org.fortiss.tooling.kernel.services.IEditorService;
/**
......@@ -56,6 +62,22 @@ public class EditorService extends EObjectAwareService<IEditorBinding<EObject>>
}
}
/** {@inheritDoc} */
@Override
public void openInEditor(EObject element) {
try {
PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.openEditor(new ModelElementEditorInput(element),
BindingEditor.ID);
} catch (final PartInitException e) {
LoggingUtils.error(ToolingKernelActivator.getDefault(),
"Could not open editor with ID " + BindingEditor.ID, e);
}
}
/** {@inheritDoc} */
@Override
public List<IEditorBinding<EObject>> getBindings(EObject element) {
......
......@@ -42,13 +42,11 @@ import org.eclipse.ui.IDecoratorManager;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.UIJob;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.internal.editor.BindingEditor;
import org.fortiss.tooling.kernel.internal.editor.ModelElementEditorInput;
import org.fortiss.tooling.kernel.services.IEditorService;
import org.fortiss.tooling.kernel.util.EObjectSelectionUtils;
import org.unicase.ecp.model.ECPWorkspaceManager;
import org.unicase.ecp.model.NoWorkspaceException;
......@@ -273,23 +271,8 @@ public final class NavigatorViewPart extends ViewPart implements
EObject element = EObjectSelectionUtils.getFirstElement(event
.getSelection());
if (element != null) {
openInEditor(element);
IEditorService.INSTANCE.openInEditor(element);
}
}
}
/** Opens an editor for the given element. */
private void openInEditor(EObject element) {
try {
PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.openEditor(new ModelElementEditorInput(element),
BindingEditor.ID);
} catch (final PartInitException e) {
LoggingUtils.error(ToolingKernelActivator.getDefault(),
"Could not open editor with ID " + BindingEditor.ID, e);
}
}
}
......@@ -27,6 +27,7 @@ import org.eclipse.ui.actions.CompoundContributionItem;
import org.fortiss.tooling.kernel.interfaces.IPrototypeProvider;
import org.fortiss.tooling.kernel.services.ICommandStackService;
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.IPrototypeService;
import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype;
......@@ -107,7 +108,7 @@ public class NewMenu extends CompoundContributionItem {
EObject newObject = prototype.getPrototypeCopy();
if (ICompositorService.INSTANCE.compose(container,
newObject, null)) {
// TODO (FH): open editor
IEditorService.INSTANCE.openInEditor(newObject);
}
}
});
......
......@@ -36,6 +36,9 @@ public interface IEditorService {
/** Returns the singleton instance of the service. */
public static final IEditorService INSTANCE = new EditorService();
/** Opens an editor for the given element. */
void openInEditor(EObject element);
/** Returns registered editor bindings for the given {@link EObject}. */
List<IEditorBinding<EObject>> getBindings(EObject element);
}
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