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

reworked kernel services, added base class for extension point driven services

added editor binding extension point and service
parent 791ebaef
No related branches found
No related tags found
No related merge requests found
Showing
with 736 additions and 58 deletions
...@@ -5,8 +5,9 @@ Bundle-SymbolicName: org.fortiss.tooling.kernel;singleton:=true ...@@ -5,8 +5,9 @@ Bundle-SymbolicName: org.fortiss.tooling.kernel;singleton:=true
Bundle-Version: 0.0.1.qualifier Bundle-Version: 0.0.1.qualifier
Bundle-Activator: org.fortiss.tooling.kernel.ToolingKernelActivator Bundle-Activator: org.fortiss.tooling.kernel.ToolingKernelActivator
Bundle-Vendor: fortiss Bundle-Vendor: fortiss
Require-Bundle: org.eclipse.ui;visibility:=reexport, Require-Bundle: org.eclipse.core.runtime;visibility:=reexport,
org.eclipse.core.runtime;visibility:=reexport, org.eclipse.ui;visibility:=reexport,
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.100";visibility:=reexport,
org.eclipse.emf.ecore;bundle-version="2.6.1";visibility:=reexport, org.eclipse.emf.ecore;bundle-version="2.6.1";visibility:=reexport,
org.conqat.ide.commons;bundle-version="2.7.0";visibility:=reexport, org.conqat.ide.commons;bundle-version="2.7.0";visibility:=reexport,
org.conqat.ide.commons.ui;bundle-version="2.7.0";visibility:=reexport, org.conqat.ide.commons.ui;bundle-version="2.7.0";visibility:=reexport,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<extension-point id="modelElementHandler" name="Model Element Handler" schema="schema/modelElementHandler.exsd"/> <extension-point id="modelElementHandler" name="Model Element Handler" schema="schema/modelElementHandler.exsd"/>
<extension-point id="modelPrototypeProvider" name="Model Prototype Provider" schema="schema/modelPrototypeProvider.exsd"/> <extension-point id="modelPrototypeProvider" name="Model Prototype Provider" schema="schema/modelPrototypeProvider.exsd"/>
<extension-point id="modelElementCompositor" name="Model Element Compositor" schema="schema/modelElementCompositor.exsd"/> <extension-point id="modelElementCompositor" name="Model Element Compositor" schema="schema/modelElementCompositor.exsd"/>
<extension-point id="modelEditorBinding" name="Model Element Editor Bindings" schema="schema/modelEditorBinding.exsd"/>
<extension <extension
point="org.eclipse.emf.ecore.generated_package"> point="org.eclipse.emf.ecore.generated_package">
<package <package
......
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.fortiss.tooling.kernel" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.fortiss.tooling.kernel" id="modelEditorBinding" name="Model Element Editor Bindings"/>
</appinfo>
<documentation>
Registers editors for specific model elements.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="modelEditorBinding" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="modelEditorBinding">
<complexType>
<attribute name="modelElementClass" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.eclipse.emf.ecore.EObject"/>
</appinfo>
</annotation>
</attribute>
<attribute name="binding" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.fortiss.tooling.kernel.interfaces.IEditorBinding"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
/*--------------------------------------------------------------------------+
$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.emf.ecore.EObject;
import org.fortiss.tooling.kernel.interfaces.IEditorBinding;
/**
* Abstract class for editor bindings.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @levd.rating RED Rev:
*/
public abstract class EditorBindingBase<T extends EObject> implements
IEditorBinding<EObject>, Comparable<IEditorBinding<EObject>> {
/** {@inheritDoc} */
@Override
public final int compareTo(IEditorBinding<EObject> eb) {
return eb.getPriority() - getPriority();
}
}
...@@ -28,7 +28,7 @@ import org.eclipse.emf.ecore.EObject; ...@@ -28,7 +28,7 @@ import org.eclipse.emf.ecore.EObject;
* @version $Rev$ * @version $Rev$
* @levd.rating RED Rev: * @levd.rating RED Rev:
*/ */
public interface ICompositor<T extends EObject> { public interface ICompositor<T extends EObject> extends IEObjectAware<T> {
/** /**
* Returns whether the given container may include the given contained * Returns whether the given container may include the given contained
* object. * object.
......
/*--------------------------------------------------------------------------+
$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.interfaces;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.internal.EObjectAwareService;
/**
* Abstract interface for {@link EObjectAwareService} base implementation.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @levd.rating RED Rev:
*/
public interface IEObjectAware<T extends EObject> {
// nothing specific is need here
}
/*--------------------------------------------------------------------------+
$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.interfaces;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.IEditorPart;
/**
* Interface for editor bindings.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @levd.rating RED Rev:
*/
public interface IEditorBinding<T extends EObject> extends
IEObjectAware<EObject> {
/** Returns the class of the editor registered by this binding. */
Class<? extends IEditorPart> getEditorClass();
/** Returns the label of the editor. */
String getLabel();
/** Returns the priority of the editor. Higher values have lower priority. */
int getPriority();
}
...@@ -17,21 +17,12 @@ $Id$ ...@@ -17,21 +17,12 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal; package org.fortiss.tooling.kernel.internal;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.conqat.ide.commons.ui.extension.ExtensionPointUtils;
import org.conqat.ide.commons.ui.logging.LoggingUtils;
import org.conqat.lib.commons.reflect.ReflectionUtils;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.interfaces.ICompositionContext; import org.fortiss.tooling.kernel.interfaces.ICompositionContext;
import org.fortiss.tooling.kernel.interfaces.ICompositor; import org.fortiss.tooling.kernel.interfaces.ICompositor;
import org.fortiss.tooling.kernel.services.ICompositorService; import org.fortiss.tooling.kernel.services.ICompositorService;
import org.osgi.framework.Bundle;
/** /**
* This class implements the {@link ICompositorService} interface. * This class implements the {@link ICompositorService} interface.
...@@ -41,7 +32,8 @@ import org.osgi.framework.Bundle; ...@@ -41,7 +32,8 @@ import org.osgi.framework.Bundle;
* @version $Rev$ * @version $Rev$
* @levd.rating RED Rev: * @levd.rating RED Rev:
*/ */
public class CompositorService implements ICompositorService { public final class CompositorService extends
EObjectAwareService<ICompositor<EObject>> implements ICompositorService {
/** The compositor extension point ID. */ /** The compositor extension point ID. */
private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelElementCompositor"; private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelElementCompositor";
...@@ -49,47 +41,8 @@ public class CompositorService implements ICompositorService { ...@@ -49,47 +41,8 @@ public class CompositorService implements ICompositorService {
/** The compositor configuration element name. */ /** The compositor configuration element name. */
private static final String CONFIGURATION_ELEMENT_NAME = "modelElementCompositor"; private static final String CONFIGURATION_ELEMENT_NAME = "modelElementCompositor";
/** Stores the compositors for each model element class. */ /** The compositor attribute name. */
private Map<Class<?>, List<ICompositor<EObject>>> compositorMap; private static final String ATTRIBUTE_NAME = "compositor";
/** Constructor. */
public CompositorService() {
setupCompositorMap();
}
/** Initializes the compositor map from plugin extensions. */
@SuppressWarnings({ "unchecked" })
private void setupCompositorMap() {
compositorMap = new HashMap<Class<?>, List<ICompositor<EObject>>>();
for (IConfigurationElement ce : ExtensionPointUtils
.getConfigurationElements(EXTENSION_POINT_NAME,
CONFIGURATION_ELEMENT_NAME)) {
Bundle bundle = ExtensionPointUtils.getBundle(ce);
try {
Class<?> modelElementClass = ExtensionPointUtils.loadClass(
ce.getAttribute("modelElementClass"), bundle);
Class<?> compositorClass = ExtensionPointUtils.loadClass(
ce.getAttribute("compositor"), bundle);
ICompositor<EObject> compositor = (ICompositor<EObject>) compositorClass
.getConstructor().newInstance();
addCompositor(modelElementClass, compositor);
} catch (Exception ex) {
LoggingUtils.error(ToolingKernelActivator.getDefault(),
ex.getMessage(), ex);
}
}
}
/** Adds the given compositor to the map. */
private void addCompositor(Class<?> modelElementClass,
ICompositor<EObject> compositor) {
List<ICompositor<EObject>> list = compositorMap.get(modelElementClass);
if (list == null) {
list = new LinkedList<ICompositor<EObject>>();
compositorMap.put(modelElementClass, list);
}
list.add(compositor);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
...@@ -112,8 +65,8 @@ public class CompositorService implements ICompositorService { ...@@ -112,8 +65,8 @@ public class CompositorService implements ICompositorService {
*/ */
private ICompositor<EObject> findWorkingCompositor(EObject container, private ICompositor<EObject> findWorkingCompositor(EObject container,
EObject contained, ICompositionContext context) { EObject contained, ICompositionContext context) {
final List<ICompositor<EObject>> list = ReflectionUtils List<ICompositor<EObject>> list = getRegisteredHandlers(container
.performNearestClassLookup(container.getClass(), compositorMap); .getClass());
if (list == null) { if (list == null) {
return null; return null;
} }
...@@ -124,4 +77,22 @@ public class CompositorService implements ICompositorService { ...@@ -124,4 +77,22 @@ public class CompositorService implements ICompositorService {
} }
return null; return null;
} }
/** {@inheritDoc} */
@Override
protected String getExtensionPointName() {
return EXTENSION_POINT_NAME;
}
/** {@inheritDoc} */
@Override
protected String getConfigurationElementName() {
return CONFIGURATION_ELEMENT_NAME;
}
/** {@inheritDoc} */
@Override
protected String getHandlerClassAttribute() {
return ATTRIBUTE_NAME;
}
} }
/*--------------------------------------------------------------------------+
$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;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.conqat.ide.commons.ui.extension.ExtensionPointUtils;
import org.conqat.ide.commons.ui.logging.LoggingUtils;
import org.conqat.lib.commons.reflect.ReflectionUtils;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.interfaces.IEObjectAware;
import org.osgi.framework.Bundle;
/**
* Service base implementation, which supports handler registration with
* {@link EObject} relation.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @levd.rating RED Rev:
*/
public abstract class EObjectAwareService<T extends IEObjectAware<EObject>> {
/** Stores the class to handler map. */
protected final Map<Class<?>, List<T>> handlerMap = new HashMap<Class<?>, List<T>>();
/** Constructor. */
public EObjectAwareService() {
setupHandlerMap();
}
/** Returns the list of registered handlers for the given class. */
public List<T> getRegisteredHandlers(Class<?> modelElementClass) {
return ReflectionUtils.performNearestClassLookup(modelElementClass,
handlerMap);
}
/** Initializes the handler map from plugin extensions. */
@SuppressWarnings({ "unchecked" })
private void setupHandlerMap() {
for (IConfigurationElement ce : ExtensionPointUtils
.getConfigurationElements(getExtensionPointName(),
getConfigurationElementName())) {
Bundle bundle = ExtensionPointUtils.getBundle(ce);
try {
Class<?> modelElementClass = ExtensionPointUtils.loadClass(
ce.getAttribute(getModelElementClassAttribute()),
bundle);
Class<?> handlerClass = ExtensionPointUtils.loadClass(
ce.getAttribute(getHandlerClassAttribute()), bundle);
T handler = (T) handlerClass.getConstructor().newInstance();
addHandler(modelElementClass, handler);
} catch (Exception ex) {
LoggingUtils.error(ToolingKernelActivator.getDefault(),
ex.getMessage(), ex);
}
}
}
/** Adds the given compositor to the map. */
private void addHandler(Class<?> modelElementClass, T handler) {
List<T> list = handlerMap.get(modelElementClass);
if (list == null) {
list = new LinkedList<T>();
handlerMap.put(modelElementClass, list);
}
list.add(handler);
}
/** Returns the extension point name. */
protected abstract String getExtensionPointName();
/** Returns the configuration element name. */
protected abstract String getConfigurationElementName();
/** Returns the handler class attribute name. */
protected abstract String getHandlerClassAttribute();
/**
* Returns the attribute name for the model element class. Sub-classes may
* override, but should first consider to use the default value
* <i>modelElementClass</i> in the extension point definition.
*/
protected String getModelElementClassAttribute() {
return "modelElementClass";
}
}
...@@ -17,6 +17,12 @@ $Id$ ...@@ -17,6 +17,12 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal; package org.fortiss.tooling.kernel.internal;
import java.util.Collections;
import java.util.List;
import org.conqat.lib.commons.collections.CollectionUtils;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.base.EditorBindingBase;
import org.fortiss.tooling.kernel.services.IEditorService; import org.fortiss.tooling.kernel.services.IEditorService;
/** /**
...@@ -27,6 +33,54 @@ import org.fortiss.tooling.kernel.services.IEditorService; ...@@ -27,6 +33,54 @@ import org.fortiss.tooling.kernel.services.IEditorService;
* @version $Rev$ * @version $Rev$
* @levd.rating RED Rev: * @levd.rating RED Rev:
*/ */
public class EditorService implements IEditorService { public class EditorService extends
EObjectAwareService<EditorBindingBase<EObject>> implements
IEditorService {
/** The compositor extension point ID. */
private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelEditorBinding";
/** The compositor configuration element name. */
private static final String CONFIGURATION_ELEMENT_NAME = "modelEditorBinding";
/** The compositor attribute name. */
private static final String ATTRIBUTE_NAME = "binding";
/** Constructor. */
public EditorService() {
super();
// sort editor bindings by priority.
for (Class<?> clazz : handlerMap.keySet()) {
Collections.sort(handlerMap.get(clazz));
}
}
/** {@inheritDoc} */
@Override
public List<EditorBindingBase<EObject>> getBindings(EObject element) {
List<EditorBindingBase<EObject>> bindings = getRegisteredHandlers(element
.getClass());
if (bindings == null) {
bindings = CollectionUtils.emptyList();
}
return bindings;
}
/** {@inheritDoc} */
@Override
protected String getExtensionPointName() {
return EXTENSION_POINT_NAME;
}
/** {@inheritDoc} */
@Override
protected String getConfigurationElementName() {
return CONFIGURATION_ELEMENT_NAME;
}
/** {@inheritDoc} */
@Override
protected String getHandlerClassAttribute() {
return ATTRIBUTE_NAME;
}
} }
/*-----------------------------------------------------------------------+
| edu.tum.cs.ccts.model.base
| |
$Id$
| |
| Copyright (c) 2004-2008 Technische Universitaet Muenchen |
| |
| Technische Universitaet Muenchen ######### ########## |
| Institut fuer Informatik - Lehrstuhl IV ## ## ## ## ## |
| Prof. Dr. Manfred Broy ## ## ## ## ## |
| Boltzmannstr. 3 ## ## ## ## ## |
| 85748 Garching bei Muenchen ## ## ## ## ## |
| Germany ## ###### ## ## |
+-----------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal.editor;
import org.conqat.ide.commons.ui.logging.LoggingUtils;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.base.EditorBindingBase;
import org.fortiss.tooling.kernel.interfaces.IHandler;
import org.fortiss.tooling.kernel.services.IEditorService;
/**
* This editor is used for displaying multiple editors provided by editor
* bindings for a given model element.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @levd.rating YELLOW Hash: 5BCA3453180427D26544F7CF84AFDB4B
*/
public class BindingEditor extends MultiPageEditorPart implements
ITabbedPropertySheetPageContributor {
/** The editor's ID. */
public static String ID = BindingEditor.class.getName();
// TODO (FH): change this
/** The tabbed property sheet contributor ID. */
public static final String TABBED_PROPERTY_CONTRIBUTOR_ID = "edu.tum.cs.ccts.model.base.properties.Contributor";
/**
* The object shown in this editor. This is valid as soon as
* {@link #init(IEditorSite, IEditorInput)} has been called.
*/
protected EObject editedObject;
/** The model element handler to be used with the {@link #editedObject}. */
protected IHandler<EObject> handler;
/**
* The adapter used for learning about changes in the {@link #editedObject}.
*/
private final Adapter editedObjectChangeAdapter = new AdapterImpl() {
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification msg) {
editedObjectChanged();
}
};
/**
* This is called whenever something about the currently edited object
* changes. This is used to update the part name and to close the editor if
* the object is removed.
*/
protected void editedObjectChanged() {
setPartName(handler.getName(editedObject));
setContentDescription(handler.getDescription(editedObject));
if (editedObject.eContainer() == null) {
getSite().getPage().closeEditor(this, false);
}
}
/** {@inheritDoc} */
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
if (!(input instanceof ModelElementEditorInput)) {
throw new PartInitException(
"BindingEditor initialized with wrong editor input object.");
}
super.init(site, input);
ModelElementEditorInput meInput = ((ModelElementEditorInput) input);
editedObject = meInput.getEditorInput();
if (editedObject == null) {
throw new PartInitException("Missing model element!");
}
handler = meInput.getModelElementHandler();
if (handler == null) {
throw new PartInitException("Missing model element handler!");
}
setPartName(handler.getName(editedObject));
setContentDescription(handler.getDescription(editedObject));
setTitleImage(handler.getIcon());
editedObject.eAdapters().add(editedObjectChangeAdapter);
}
/** {@inheritDoc} */
@Override
protected void createPages() {
int pageIndex = 0;
for (EditorBindingBase<EObject> editorBinding : IEditorService.INSTANCE
.getBindings(editedObject)) {
try {
IEditorPart editorPart = editorBinding.getEditorClass()
.newInstance();
addPage(editorPart, getEditorInput());
setPageText(pageIndex++, editorBinding.getLabel());
} catch (Exception ex) {
LoggingUtils.error(ToolingKernelActivator.getDefault(),
"Editor instantiation failed.", ex);
}
}
}
/** {@inheritDoc} */
@Override
public void doSave(IProgressMonitor monitor) {
// Saving is handled automatically by emfStore
}
/** {@inheritDoc} */
@Override
public void doSaveAs() {
// Saving is handled automatically by emfStore
}
/** {@inheritDoc} */
@Override
public void dispose() {
editedObject.eAdapters().remove(editedObjectChangeAdapter);
super.dispose();
}
/** {@inheritDoc} */
@Override
public boolean isDirty() {
// editors for emfStore objects are never dirty
return false;
}
/** {@inheritDoc} */
@Override
public boolean isSaveAsAllowed() {
return false;
}
/** {@inheritDoc} */
@Override
public boolean isSaveOnCloseNeeded() {
return false;
}
/**
* {@inheritDoc}
*/
@Override
public String getContributorId() {
return TABBED_PROPERTY_CONTRIBUTOR_ID;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
if (adapter == IPropertySheetPage.class) {
return new TabbedPropertySheetPage(this);
}
return super.getAdapter(adapter);
}
/**
* TODO: COMMENT ME
*/
public void gotoMarker(IMarker marker) {
// TODO (FH): implement marker goto
}
}
/*--------------------------------------------------------------------------+
$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.editor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
import org.fortiss.tooling.kernel.interfaces.IHandler;
import org.fortiss.tooling.kernel.services.IModelElementService;
/**
* {@link IEditorInput} used when opening a {@link BindingEditor}.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @levd.rating RED Rev:
*/
public final class ModelElementEditorInput implements IEditorInput {
/** The editor input {@link EObject}. */
private final EObject modelElement;
/** Stores the model element handler. */
private final IHandler<EObject> handler;
/** Constructor. */
public ModelElementEditorInput(EObject modelElement) {
this.modelElement = modelElement;
this.handler = IModelElementService.INSTANCE
.getModelElementHandler(modelElement);
}
/** Returns the editor input {@link EObject}. */
public EObject getEditorInput() {
return modelElement;
}
/** Returns the model element handler. */
public IHandler<EObject> getModelElementHandler() {
return handler;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
return obj instanceof ModelElementEditorInput
&& ((ModelElementEditorInput) obj).getEditorInput().equals(
modelElement);
}
/** {@inheritDoc} */
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
return null;
}
/** {@inheritDoc} */
@Override
public boolean exists() {
return modelElement.eContainer() != null;
}
/** {@inheritDoc} */
@Override
public ImageDescriptor getImageDescriptor() {
// TODO (FH): add image support
return null;
}
/** {@inheritDoc} */
@Override
public String getName() {
return handler.getName(modelElement);
}
/** {@inheritDoc} */
@Override
public IPersistableElement getPersistable() {
return null;
}
/** {@inheritDoc} */
@Override
public String getToolTipText() {
return handler.getDescription(modelElement);
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return super.hashCode();
}
}
...@@ -17,6 +17,10 @@ $Id$ ...@@ -17,6 +17,10 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.services; package org.fortiss.tooling.kernel.services;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.base.EditorBindingBase;
import org.fortiss.tooling.kernel.internal.EditorService; import org.fortiss.tooling.kernel.internal.EditorService;
/** /**
...@@ -32,5 +36,6 @@ public interface IEditorService { ...@@ -32,5 +36,6 @@ public interface IEditorService {
/** Returns the singleton instance of the service. */ /** Returns the singleton instance of the service. */
public static final IEditorService INSTANCE = new EditorService(); public static final IEditorService INSTANCE = new EditorService();
// TODO (FH): define /** Returns registered editor bindings for the given {@link EObject}. */
List<EditorBindingBase<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