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

added simple project configuration editor

added type system configuration selection
parent c4e9fc6f
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,15 @@
uri="http://www.fortiss.org/tooling/kernel">
</package>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
class="org.fortiss.tooling.kernel.internal.editor.BindingEditor"
default="false"
id="org.fortiss.tooling.kernel.internal.editor.BindingEditor"
name="Binding Editor">
</editor>
</extension>
<extension
point="org.eclipse.ui.views">
<view
......
/*--------------------------------------------------------------------------+
$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.base;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
import org.fortiss.tooling.kernel.interfaces.IEditorBinding;
import org.fortiss.tooling.kernel.interfaces.IHandler;
import org.fortiss.tooling.kernel.internal.editor.ModelElementEditorInput;
import org.fortiss.tooling.kernel.services.ICommandStackService;
/**
* Base implementation of model element editors returned by
* {@link IEditorBinding}s.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @levd.rating RED Rev:
*/
public abstract class EditorBase<T extends EObject> extends EditorPart {
/**
* The object shown in this editor. This is valid as soon as
* {@link #init(IEditorSite, IEditorInput)} has been called.
*/
protected T editedObject;
/** The model element handler to be used with the {@link #editedObject}. */
protected IHandler<T> handler;
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
if (!(input instanceof ModelElementEditorInput)) {
throw new PartInitException("Expected input of type "
+ ModelElementEditorInput.class);
}
ModelElementEditorInput meInput = (ModelElementEditorInput) input;
editedObject = (T) meInput.getEditorInput();
if (editedObject == null) {
throw new PartInitException("Missing model element!");
}
handler = (IHandler<T>) meInput.getModelElementHandler();
if (handler == null) {
throw new PartInitException("Missing model element handler!");
}
setInput(input);
setSite(site);
setPartName(handler.getName(editedObject));
setContentDescription(handler.getDescription(editedObject));
}
/** Runs the given {@link Runnable} in the emfStore editing domain. */
protected final void executeCommand(Runnable runner) {
ICommandStackService.INSTANCE.runAsCommand(editedObject, runner);
}
/** {@inheritDoc} */
@Override
public final boolean isDirty() {
return false;
}
/** {@inheritDoc} */
@Override
public final boolean isSaveAsAllowed() {
return false;
}
/** {@inheritDoc} */
@Override
public final void doSave(IProgressMonitor monitor) {
// Saving is handled automatically by emfStore
}
/** {@inheritDoc} */
@Override
public final void doSaveAs() {
// Saving is handled automatically by emfStore
}
}
......@@ -27,6 +27,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
......@@ -40,10 +42,14 @@ 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.util.EObjectSelectionUtils;
import org.unicase.ecp.model.ECPWorkspaceManager;
import org.unicase.ecp.model.NoWorkspaceException;
import org.unicase.ecp.model.workSpaceModel.ECPProject;
......@@ -60,7 +66,7 @@ import org.unicase.ecp.model.workSpaceModel.WorkSpaceModelPackage;
* @levd.rating RED Rev:
*/
public final class NavigatorViewPart extends ViewPart implements
ISelectionListener, ISelectionChangedListener {
ISelectionListener, ISelectionChangedListener, IDoubleClickListener {
/** Stores the TreeViewer. */
private TreeViewer viewer;
......@@ -77,9 +83,6 @@ public final class NavigatorViewPart extends ViewPart implements
/** Stores the menu manager. */
private MenuManager menuManager;
/** Stores the new model element menu. */
private NewMenu newMenu;
/** Constructor. */
public NavigatorViewPart() {
try {
......@@ -172,6 +175,7 @@ public final class NavigatorViewPart extends ViewPart implements
.getLabelDecorator()));
viewer.setContentProvider(new NavigatorTreeContentProvider());
viewer.setInput(workspace);
viewer.addDoubleClickListener(this);
}
createContextMenu();
......@@ -261,4 +265,31 @@ public final class NavigatorViewPart extends ViewPart implements
super.dispose();
}
/** {@inheritDoc} */
@Override
public void doubleClick(DoubleClickEvent event) {
if (event.getSelection() instanceof IStructuredSelection) {
EObject element = EObjectSelectionUtils.getFirstElement(event
.getSelection());
if (element != null) {
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);
}
}
}
......@@ -25,12 +25,12 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CompoundContributionItem;
import org.fortiss.tooling.kernel.interfaces.IPrototypeProvider;
import org.fortiss.tooling.kernel.internal.util.EObjectSelectionUtils;
import org.fortiss.tooling.kernel.services.ICommandStackService;
import org.fortiss.tooling.kernel.services.ICompositorService;
import org.fortiss.tooling.kernel.services.IModelElementService;
import org.fortiss.tooling.kernel.services.IPrototypeService;
import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype;
import org.fortiss.tooling.kernel.util.EObjectSelectionUtils;
/**
* The contributor for the dynamic new menu based on composition.
......
......@@ -15,7 +15,7 @@ $Id$
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal.util;
package org.fortiss.tooling.kernel.util;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
......
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