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

rework of type system service

some evaluator implementation
parent d868d1b7
No related branches found
No related tags found
No related merge requests found
......@@ -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;
package org.fortiss.tooling.kernel.base;
import java.util.HashMap;
import java.util.LinkedList;
......@@ -26,6 +26,7 @@ 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.core.runtime.IStatus;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.interfaces.IEObjectAware;
......@@ -40,13 +41,13 @@ import org.osgi.framework.Bundle;
* @version $Rev$
* @levd.rating RED Rev:
*/
public abstract class EObjectAwareService<T extends IEObjectAware<EObject>> {
public abstract class EObjectAwareServiceBase<T extends IEObjectAware<? extends EObject>> {
/** Stores the class to handler map. */
protected final Map<Class<?>, List<T>> handlerMap = new HashMap<Class<?>, List<T>>();
/** Constructor. */
public EObjectAwareService() {
public EObjectAwareServiceBase() {
setupHandlerMap();
}
......@@ -85,6 +86,14 @@ public abstract class EObjectAwareService<T extends IEObjectAware<EObject>> {
list = new LinkedList<T>();
handlerMap.put(modelElementClass, list);
}
if (useUniqueHandler() && !list.isEmpty()) {
LoggingUtils.log(
ToolingKernelActivator.getDefault(),
"Encountered more than one handler registered with "
+ getExtensionPointName() + "("
+ handler.getClass() + "," + list.get(0).getClass()
+ ")", IStatus.WARNING);
}
list.add(handler);
}
......@@ -97,6 +106,15 @@ public abstract class EObjectAwareService<T extends IEObjectAware<EObject>> {
/** Returns the handler class attribute name. */
protected abstract String getHandlerClassAttribute();
/**
* Returns whether the service requires a unique handler per model element
* class. By default more than one handler can be registered per model
* element class.
*/
protected boolean useUniqueHandler() {
return false;
}
/**
* Returns the attribute name for the model element class. Sub-classes may
* override, but should first consider to use the default value
......
......@@ -18,10 +18,10 @@ $Id$
package org.fortiss.tooling.kernel.interfaces;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.internal.EObjectAwareService;
import org.fortiss.tooling.kernel.base.EObjectAwareServiceBase;
/**
* Abstract interface for {@link EObjectAwareService} base implementation.
* Abstract interface for {@link EObjectAwareServiceBase} base implementation.
*
* @author hoelzlf
* @author $Author$
......
......@@ -20,6 +20,7 @@ package org.fortiss.tooling.kernel.internal;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.interfaces.ICompositionContext;
import org.fortiss.tooling.kernel.interfaces.ICompositor;
import org.fortiss.tooling.kernel.services.ICompositorService;
......@@ -33,7 +34,7 @@ import org.fortiss.tooling.kernel.services.ICompositorService;
* @levd.rating RED Rev:
*/
public final class CompositorService extends
EObjectAwareService<ICompositor<EObject>> implements ICompositorService {
EObjectAwareServiceBase<ICompositor<EObject>> implements ICompositorService {
/** The compositor extension point ID. */
private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelElementCompositor";
......
......@@ -27,6 +27,7 @@ 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.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.interfaces.IEditorBinding;
import org.fortiss.tooling.kernel.internal.editor.BindingEditor;
import org.fortiss.tooling.kernel.internal.editor.ModelElementEditorInput;
......@@ -40,7 +41,7 @@ import org.fortiss.tooling.kernel.services.IEditorService;
* @version $Rev$
* @levd.rating RED Rev:
*/
public class EditorService extends EObjectAwareService<IEditorBinding<EObject>>
public class EditorService extends EObjectAwareServiceBase<IEditorBinding<EObject>>
implements IEditorService {
/** The compositor extension point ID. */
......
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