From 398e2513205da705403e75176623bca25d9476ee Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Tue, 28 Jun 2011 09:48:26 +0000 Subject: [PATCH] refactoring of connection compositor service channel creation works on the model level, but not yet on the UI level --- .../trunk/META-INF/MANIFEST.MF | 4 +- .../base/ui/command/ConnectionCommand.java | 6 +- ...archicElementConnectionCompositorBase.java | 24 +++---- .../tooling/base/ui/dnd/DragContext.java | 4 +- .../editor/gef/GraphicalViewerEditorBase.java | 2 + org.fortiss.tooling.kernel/trunk/plugin.xml | 2 +- ... => modelElementConnectionCompositor.exsd} | 10 +-- .../kernel/base/EObjectAware2ServiceBase.java | 67 +++++++++++++++---- ...ava => IConnectionCompositionContext.java} | 6 +- ...nector.java => IConnectionCompositor.java} | 8 +-- ....java => ConnectionCompositorService.java} | 37 +++++----- ...java => IConnectionCompositorService.java} | 14 ++-- 12 files changed, 116 insertions(+), 68 deletions(-) rename org.fortiss.tooling.kernel/trunk/schema/{modelElementConnector.exsd => modelElementConnectionCompositor.exsd} (91%) rename org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/{IConnectionContext.java => IConnectionCompositionContext.java} (88%) rename org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/{IConnector.java => IConnectionCompositor.java} (91%) rename org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/{ConnectorService.java => ConnectionCompositorService.java} (69%) rename org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/{IConnectorService.java => IConnectionCompositorService.java} (83%) diff --git a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF index 4d375a182..bf0b5a29e 100644 --- a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF @@ -12,6 +12,7 @@ Bundle-Vendor: fortiss Export-Package: org.fortiss.tooling.base.ui, org.fortiss.tooling.base.ui.action, org.fortiss.tooling.base.ui.command, + org.fortiss.tooling.base.ui.compose, org.fortiss.tooling.base.ui.dnd, org.fortiss.tooling.base.ui.editor, org.fortiss.tooling.base.ui.editor.gef, @@ -22,4 +23,5 @@ Export-Package: org.fortiss.tooling.base.ui, org.fortiss.tooling.base.ui.editpart.policy, org.fortiss.tooling.base.ui.layout, org.fortiss.tooling.base.ui.layout.constants, - org.fortiss.tooling.base.ui.layout.util + org.fortiss.tooling.base.ui.layout.util, + org.fortiss.tooling.base.ui.preferences diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ConnectionCommand.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ConnectionCommand.java index 51f70594e..7c2d094e8 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ConnectionCommand.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ConnectionCommand.java @@ -23,7 +23,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.commands.Command; import org.fortiss.tooling.base.ui.dnd.DragContext; import org.fortiss.tooling.base.ui.editpart.policy.ConnectionGraphicalNodeEditPolicy; -import org.fortiss.tooling.kernel.services.IConnectorService; +import org.fortiss.tooling.kernel.services.IConnectionCompositorService; /** * This command is used by {@link ConnectionGraphicalNodeEditPolicy} to @@ -62,7 +62,7 @@ public class ConnectionCommand extends Command { } if (context.getSource().getModel() instanceof EObject && context.getTarget().getModel() instanceof EObject) { - return IConnectorService.INSTANCE.canConnect((EObject) context + return IConnectionCompositorService.INSTANCE.canConnect((EObject) context .getSource().getModel(), (EObject) context.getTarget() .getModel(), connection, context); } @@ -72,7 +72,7 @@ public class ConnectionCommand extends Command { /** {@inheritDoc} */ @Override public void execute() { - IConnectorService.INSTANCE.connect((EObject) context.getSource() + IConnectionCompositorService.INSTANCE.connect((EObject) context.getSource() .getModel(), (EObject) context.getTarget().getModel(), connection, context); } diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java index 32a79b01f..3f25e0791 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java @@ -25,7 +25,7 @@ import org.fortiss.tooling.base.model.element.IHierarchicElement; import org.fortiss.tooling.base.ui.dnd.DragContext; import org.fortiss.tooling.base.ui.dnd.DropContext; import org.fortiss.tooling.base.ui.editpart.RootEditPartBase; -import org.fortiss.tooling.kernel.interfaces.IConnectionContext; +import org.fortiss.tooling.kernel.interfaces.IConnectionCompositionContext; import org.fortiss.tooling.kernel.services.ICompositorService; /** @@ -36,13 +36,13 @@ import org.fortiss.tooling.kernel.services.ICompositorService; * Sub-classes must implement: * <UL> * <LI> - * {@link #createConnection(IHierarchicElement, IHierarchicElement, IConnectionContext)} + * {@link #createConnection(IHierarchicElement, IHierarchicElement, IConnectionCompositionContext)} * <LI> - * {@link #createSourceConnector(IHierarchicElement, IHierarchicElement, IConnectionContext)} + * {@link #createSourceConnector(IHierarchicElement, IHierarchicElement, IConnectionCompositionContext)} * <LI> - * {@link #createTargetConnector(IHierarchicElement, IHierarchicElement, IConnectionContext)} + * {@link #createTargetConnector(IHierarchicElement, IHierarchicElement, IConnectionCompositionContext)} * <LI> - * {@link #getParent(IHierarchicElement, IHierarchicElement, IConnectionContext)} + * {@link #getParent(IHierarchicElement, IHierarchicElement, IConnectionCompositionContext)} * </UL> * These methods are called in order to create specific model elements. * @@ -57,7 +57,7 @@ import org.fortiss.tooling.kernel.services.ICompositorService; * @ConQAT.Rating RED Hash: */ public abstract class HierarchicElementConnectionCompositorBase<HE extends IHierarchicElement, S extends IHierarchicElement, T extends IHierarchicElement> - implements org.fortiss.tooling.kernel.interfaces.IConnector<S, T> { + implements org.fortiss.tooling.kernel.interfaces.IConnectionCompositor<S, T> { /** * Determines whether connectors of the component may be connected @@ -69,28 +69,28 @@ public abstract class HierarchicElementConnectionCompositorBase<HE extends IHier /** Creates the application specific {@link IConnection} model element. */ protected abstract IConnection createConnection(S source, T target, - IConnectionContext context); + IConnectionCompositionContext context); /** * Creates the application specific source {@link IConnector} model element. */ protected abstract IConnector createSourceConnector(S source, T target, - IConnectionContext context); + IConnectionCompositionContext context); /** * Creates the application specific target {@link IConnector} model element. */ protected abstract IConnector createTargetConnector(S source, T target, - IConnectionContext context); + IConnectionCompositionContext context); /** Returns the parent model element used to compose the connection. */ protected abstract HE getParent(S source, T target, - IConnectionContext context); + IConnectionCompositionContext context); /** {@inheritDoc} */ @Override public boolean canConnect(S source, T target, EObject connection, - IConnectionContext context) { + IConnectionCompositionContext context) { if (context instanceof DragContext) { DragContext dc = (DragContext) context; // Is an internal feedback connection allowed? @@ -106,7 +106,7 @@ public abstract class HierarchicElementConnectionCompositorBase<HE extends IHier /** {@inheritDoc} */ @Override public void connect(S source, T target, EObject conn, - IConnectionContext context) { + IConnectionCompositionContext context) { // create application specific connection IConnection connection = createConnection(source, target, context); diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DragContext.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DragContext.java index 9b7dfb120..e4779545a 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DragContext.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DragContext.java @@ -19,7 +19,7 @@ package org.fortiss.tooling.base.ui.dnd; import org.eclipse.draw2d.geometry.Point; import org.eclipse.gef.EditPart; -import org.fortiss.tooling.kernel.interfaces.IConnectionContext; +import org.fortiss.tooling.kernel.interfaces.IConnectionCompositionContext; /** * A {@link DragContext} stores information obtained from user's drag gesture, @@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.interfaces.IConnectionContext; * @version $Rev$ * @ConQAT.Rating YELLOW Hash: 61FB58030A2C456B296353EEC89181DD */ -public class DragContext implements IConnectionContext { +public class DragContext implements IConnectionCompositionContext { /** Source edit part. */ private final EditPart source; diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/gef/GraphicalViewerEditorBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/gef/GraphicalViewerEditorBase.java index 6a0dbd045..641304b2a 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/gef/GraphicalViewerEditorBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/gef/GraphicalViewerEditorBase.java @@ -250,11 +250,13 @@ public class GraphicalViewerEditorBase<T extends EObject> extends EditorBase<T> ZoomManager.FIT_HEIGHT }); /** Registers global actions (including zoom action). */ + @Override public void registerGlobalActions(IActionBars bars) { bars.getToolBarManager().add(zoomContribution); } /** Unregisters global actions (including zoom action). */ + @Override public void unregisterGlobalActions(IActionBars bars) { bars.getToolBarManager().remove(zoomContribution); } diff --git a/org.fortiss.tooling.kernel/trunk/plugin.xml b/org.fortiss.tooling.kernel/trunk/plugin.xml index 9dd64404d..ec578c5ad 100644 --- a/org.fortiss.tooling.kernel/trunk/plugin.xml +++ b/org.fortiss.tooling.kernel/trunk/plugin.xml @@ -3,10 +3,10 @@ <plugin> <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="modelElementConnector" name="Model Element Connector" schema="schema/modelElementConnector.exsd"/> <extension-point id="modelStorageProvider" name="Model Storage Provider" schema="schema/modelStorageProvider.exsd"/> <extension-point id="modelConstraintChecker" name="Model Constraint Checker" schema="schema/modelConstraintChecker.exsd"/> <extension-point id="eclipseResourceStorageLocationProvider" name="Eclipse Resource Storage Location Provider" schema="schema/eclipseResourceStorageLocationProvider.exsd"/> + <extension-point id="modelElementConnectionCompositor" name="Model Element Connection Compositor" schema="schema/modelElementConnectionCompositor.exsd"/> <extension point="org.eclipse.emf.ecore.generated_package"> <package diff --git a/org.fortiss.tooling.kernel/trunk/schema/modelElementConnector.exsd b/org.fortiss.tooling.kernel/trunk/schema/modelElementConnectionCompositor.exsd similarity index 91% rename from org.fortiss.tooling.kernel/trunk/schema/modelElementConnector.exsd rename to org.fortiss.tooling.kernel/trunk/schema/modelElementConnectionCompositor.exsd index fb1927fde..99c545dd0 100644 --- a/org.fortiss.tooling.kernel/trunk/schema/modelElementConnector.exsd +++ b/org.fortiss.tooling.kernel/trunk/schema/modelElementConnectionCompositor.exsd @@ -20,7 +20,7 @@ </annotation> <complexType> <sequence> - <element ref="connector" minOccurs="1" maxOccurs="unbounded"/> + <element ref="modelElementConnectionCompositor" minOccurs="1" maxOccurs="unbounded"/> </sequence> <attribute name="point" type="string" use="required"> <annotation> @@ -49,13 +49,13 @@ </complexType> </element> - <element name="connector"> + <element name="modelElementConnectionCompositor"> <complexType> <sequence> - <element ref="source" minOccurs="1" maxOccurs="unbounded"/> - <element ref="target" minOccurs="1" maxOccurs="unbounded"/> + <element ref="source"/> + <element ref="target"/> </sequence> - <attribute name="connector" type="string" use="required"> + <attribute name="modelElementConnectionCompositor" type="string" use="required"> <annotation> <documentation> The connector class registered. diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectAware2ServiceBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectAware2ServiceBase.java index 80a78184a..8a841ff5e 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectAware2ServiceBase.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectAware2ServiceBase.java @@ -28,13 +28,39 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.interfaces.IEObjectAware2; +import org.fortiss.tooling.kernel.internal.ConnectionCompositorService; import org.fortiss.tooling.kernel.util.ExtensionPointUtils; import org.fortiss.tooling.kernel.util.LoggingUtils; import org.osgi.framework.Bundle; /** - * Service base implementation, which supports handler registration with two - * related {@link EObject} classes. + * Service base implementation, which supports handler registration with a set + * of source and a set of target classes. + * + * <p> + * Sub-classes must implement: + * <UL> + * <LI>{@link #getExtensionPointName()} to provide the extension point ID, + * <LI>{@link #getConfigurationElementName()} to provide the configuration + * element ID, + * <LI>{@link #getHandlerClassAttribute()} to provide the attribute of the + * handler class. + * </UL> + * + * <p> + * Sub-classes may override: + * <UL> + * <LI>{@link #getSourceAttribute()} to provide a source attribute ID, + * <LI>{@link #getTargetAttribute()} to provide a target attribute ID, + * <LI>{@link #getModelElementClassConfigurationElement()} to provide a element + * class configuration element, + * <LI>{@link #getModelElementClassAttribute()} to provide a element class + * attribute. + * </UL> + * + * An example implementation of a service based on this class is given by + * {@link ConnectionCompositorService}. The corresponding extension point schema + * is defined in <code>schema/modelElementConnectionCompositor.exsd</code>. * * @author hoelzlf * @author $Author$ @@ -81,6 +107,15 @@ public abstract class EObjectAware2ServiceBase<T extends IEObjectAware2<? extend return "target"; } + /** + * Returns the configuration element 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 getModelElementClassConfigurationElement() { + return "modelElementClass"; + } + /** * Returns the attribute name for the model element class. Sub-classes may * override, but should first consider to use the default value @@ -138,25 +173,33 @@ public abstract class EObjectAware2ServiceBase<T extends IEObjectAware2<? extend List<Class<?>> sources = new ArrayList<Class<?>>(); List<Class<?>> targets = new ArrayList<Class<?>>(); - for (final IConfigurationElement child : ce.getChildren()) { + for (IConfigurationElement child : ce.getChildren()) { if (child.getName().equals(getSourceAttribute())) { - sources.add(ExtensionPointUtils.loadClass( - child.getAttribute(getModelElementClassAttribute()), - bundle)); + addRegisteredClasses(child, sources, bundle); } else if (child.getName().equals(getTargetAttribute())) { - targets.add(ExtensionPointUtils.loadClass( - child.getAttribute(getModelElementClassAttribute()), - bundle)); + addRegisteredClasses(child, targets, bundle); } } - for (final Class<?> source : sources) { - for (final Class<?> destination : targets) { - addHandler(source, destination, handler); + for (Class<?> source : sources) { + for (Class<?> target : targets) { + addHandler(source, target, handler); } } } + /** Adds all registered classes to the given list. */ + private void addRegisteredClasses(IConfigurationElement element, + List<Class<? extends Object>> list, Bundle bundle) + throws ClassNotFoundException { + for (IConfigurationElement ce : element + .getChildren(getModelElementClassConfigurationElement())) { + Class<?> modelElementClass = ExtensionPointUtils.loadClass( + ce.getAttribute(getModelElementClassAttribute()), bundle); + list.add(modelElementClass); + } + } + /** Adds the given handler to the map. */ private void addHandler(Class<?> sourceElementClass, Class<?> targetElementClass, T handler) { diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionContext.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionCompositionContext.java similarity index 88% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionContext.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionCompositionContext.java index 2307ca601..11b4cc91f 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionContext.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionCompositionContext.java @@ -19,8 +19,8 @@ $Id$ package org.fortiss.tooling.kernel.interfaces; /** - * An {@link IConnectionContext} provides additional information like drag point - * positions to an {@link IConnector}. + * An {@link IConnectionCompositionContext} provides additional information like drag point + * positions to an {@link IConnectionCompositor}. * * @FloH: what is a "drag point position"? * @@ -29,6 +29,6 @@ package org.fortiss.tooling.kernel.interfaces; * @version $Rev$ * @ConQAT.Rating YELLOW Hash: BE7A6E2BC307F4A6894607896C09D3E8 */ -public interface IConnectionContext { +public interface IConnectionCompositionContext { // this is just a marker interface } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnector.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionCompositor.java similarity index 91% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnector.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionCompositor.java index bd85c2325..4861cc423 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnector.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IConnectionCompositor.java @@ -30,7 +30,7 @@ import org.eclipse.emf.ecore.EObject; * @version $Rev$ * @ConQAT.Rating YELLOW Hash: 3AF8EF4B6F61B768A17A63A6FF51CB2B */ -public interface IConnector<S extends EObject, T extends EObject> extends +public interface IConnectionCompositor<S extends EObject, T extends EObject> extends IEObjectAware2<S, T> { /** * Returns whether a connection between the source and the destination is @@ -39,12 +39,12 @@ public interface IConnector<S extends EObject, T extends EObject> extends * in case of a reconnect. */ boolean canConnect(S source, T destination, EObject connection, - IConnectionContext context); + IConnectionCompositionContext context); /** * Actually connects the given source and destination. This will only be * called if - * {@link #canConnect(EObject, EObject, EObject, IConnectionContext)} + * {@link #canConnect(EObject, EObject, EObject, IConnectionCompositionContext)} * returned true. * * @param source @@ -60,5 +60,5 @@ public interface IConnector<S extends EObject, T extends EObject> extends * context information for the connection. May be null. */ void connect(S source, T destination, EObject connection, - IConnectionContext context); + IConnectionCompositionContext context); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConnectorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConnectionCompositorService.java similarity index 69% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConnectorService.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConnectionCompositorService.java index 8e3bee5bf..9234ce3fd 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConnectorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConnectionCompositorService.java @@ -21,58 +21,59 @@ import java.util.List; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.base.EObjectAware2ServiceBase; -import org.fortiss.tooling.kernel.interfaces.IConnectionContext; -import org.fortiss.tooling.kernel.interfaces.IConnector; -import org.fortiss.tooling.kernel.services.IConnectorService; +import org.fortiss.tooling.kernel.interfaces.IConnectionCompositionContext; +import org.fortiss.tooling.kernel.interfaces.IConnectionCompositor; +import org.fortiss.tooling.kernel.services.IConnectionCompositorService; /** - * This class implements the {@link IConnectorService} interface. + * This class implements the {@link IConnectionCompositorService} interface. * * @author hoelzl * @author $Author$ * @version $Rev$ * @ConQAT.Rating YELLOW Hash: E4E7A3B42928271F17D36BABCB6BEF58 */ -public class ConnectorService extends - EObjectAware2ServiceBase<IConnector<EObject, EObject>> implements - IConnectorService { +public class ConnectionCompositorService extends + EObjectAware2ServiceBase<IConnectionCompositor<EObject, EObject>> + implements IConnectionCompositorService { /** The connector extension point ID. */ - private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelElementConnector"; + private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelElementConnectionCompositor"; /** The connector configuration element name. */ - private static final String CONFIGURATION_ELEMENT_NAME = "modelElementConnector"; + private static final String CONFIGURATION_ELEMENT_NAME = "modelElementConnectionCompositor"; /** The connector attribute name. */ - private static final String ATTRIBUTE_NAME = "connector"; + private static final String ATTRIBUTE_NAME = "modelElementConnectionCompositor"; /** {@inheritDoc} */ @Override public boolean canConnect(EObject source, EObject destination, - EObject connection, IConnectionContext context) { + EObject connection, IConnectionCompositionContext context) { return findWorkingConnector(source, destination, connection, context) != null; } /** {@inheritDoc} */ @Override public void connect(EObject source, EObject destination, - EObject connection, IConnectionContext context) { + EObject connection, IConnectionCompositionContext context) { findWorkingConnector(source, destination, connection, context).connect( source, destination, connection, context); } /** - * Returns the first {@link IConnector} which can connect the given elements - * (or <code>null</code>n if no such connector exists). + * Returns the first {@link IConnectionCompositor} which can connect the + * given elements (or <code>null</code>n if no such connector exists). */ - private IConnector<EObject, EObject> findWorkingConnector(EObject source, - EObject target, EObject connection, IConnectionContext context) { - List<IConnector<EObject, EObject>> list = getRegisteredHandlers( + private IConnectionCompositor<EObject, EObject> findWorkingConnector( + EObject source, EObject target, EObject connection, + IConnectionCompositionContext context) { + List<IConnectionCompositor<EObject, EObject>> list = getRegisteredHandlers( source.getClass(), target.getClass()); if (list == null) { return null; } - for (IConnector<EObject, EObject> connector : list) { + for (IConnectionCompositor<EObject, EObject> connector : list) { if (connector.canConnect(source, target, connection, context)) { return connector; } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IConnectorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IConnectionCompositorService.java similarity index 83% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IConnectorService.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IConnectionCompositorService.java index aba44eb14..595a2cff9 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IConnectorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IConnectionCompositorService.java @@ -18,8 +18,8 @@ $Id$ package org.fortiss.tooling.kernel.services; import org.eclipse.emf.ecore.EObject; -import org.fortiss.tooling.kernel.interfaces.IConnectionContext; -import org.fortiss.tooling.kernel.internal.ConnectorService; +import org.fortiss.tooling.kernel.interfaces.IConnectionCompositionContext; +import org.fortiss.tooling.kernel.internal.ConnectionCompositorService; /** * The connector service provides registration and access to model element @@ -30,10 +30,10 @@ import org.fortiss.tooling.kernel.internal.ConnectorService; * @version $Rev$ * @ConQAT.Rating YELLOW Hash: 0D2545C48EFB0383922CBB05BB469585 */ -public interface IConnectorService { +public interface IConnectionCompositorService { /** Returns the singleton instance of the service. */ - public static final IConnectorService INSTANCE = new ConnectorService(); + public static final IConnectionCompositorService INSTANCE = new ConnectionCompositorService(); /** * Returns whether a connection between the source and the destination is @@ -41,12 +41,12 @@ public interface IConnectorService { * also may be null. */ public boolean canConnect(EObject source, EObject destination, - EObject connection, IConnectionContext context); + EObject connection, IConnectionCompositionContext context); /** * Actually connects the given source and destination. This will only be * called if - * {@link #canConnect(EObject, EObject, EObject, IConnectionContext)} + * {@link #canConnect(EObject, EObject, EObject, IConnectionCompositionContext)} * returned true. * * @param source @@ -62,5 +62,5 @@ public interface IConnectorService { * context information for the connection. May be null. */ public void connect(EObject source, EObject destination, - EObject connection, IConnectionContext context); + EObject connection, IConnectionCompositionContext context); } -- GitLab