Skip to content
Snippets Groups Projects
Commit 35eb86a6 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

fix

refs 2285
parent e9731644
No related branches found
No related tags found
No related merge requests found
......@@ -34,12 +34,11 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
/**
* Base class for all connection compositors.
* TODO(VA) Issue #2285
*
* @author igna
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: A9318C58BA40BCECFFCD7EC46CD9F991
* @ConQAT.Rating YELLOW Hash: 67DAA9F7139C677C66E42620BB11908B
*/
abstract class ConnectionCompositorBase<HE extends IHierarchicElement, S extends EObject, T extends EObject>
implements IConnectionCompositor<HE, S, T> {
......@@ -113,10 +112,12 @@ abstract class ConnectionCompositorBase<HE extends IHierarchicElement, S extends
* Determines whether connectors of the component may be connected
* internally. The default value is <code>false</code>.
*
* {@link #canConnectInternally()} allows to state if we support internal connections. By
* {@link #canConnectInternally} allows to state if we support internal
* connections. By
* default connectors of the parent element cannot be connected in internal view of the element.
*/
protected boolean canConnectInternally() {
@SuppressWarnings("unused")
protected boolean canConnectInternally(S source, T target) {
return false;
}
......
......@@ -33,7 +33,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author igna
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: D16AFB6CA4BD3168AD05A546E09CFD06
* @ConQAT.Rating YELLOW Hash: 604DDA87FE41F470428147389A781BB0
*/
public abstract class ConnectorHierarchicElementConnectionCompositorBase<HE extends IHierarchicElement, S extends IConnector, T extends IHierarchicElement>
extends ConnectionCompositorBase<HE, S, T> {
......@@ -45,7 +45,7 @@ public abstract class ConnectorHierarchicElementConnectionCompositorBase<HE exte
ConnectionDragContext dc = (ConnectionDragContext)context;
if(dc.getSource() instanceof FreeConnectorEditPartBase &&
dc.getTarget() instanceof RootEditPart) {
return canConnectInternally();
return canConnectInternally(source, target);
}
}
return true;
......@@ -61,31 +61,15 @@ public abstract class ConnectorHierarchicElementConnectionCompositorBase<HE exte
@Override
public boolean connect(S source, T target, HE parent, IConnectionCompositionContext context) {
ITopLevelElement topElement = IPersistencyService.INSTANCE.getTopLevelElementFor(parent);
IConnector targetConnector = null;
if(sameParent(target, source)) {
if(source instanceof EntryConnectorBase) {
targetConnector = createEntryConnector();
} else {
targetConnector = createExitConnector();
}
} else {
if(source instanceof EntryConnectorBase) {
targetConnector = createExitConnector();
} else {
targetConnector = createEntryConnector();
}
}
avoidDuplicateConnectorName(target, targetConnector);
boolean isSrcEntry = source instanceof EntryConnectorBase;
isSrcEntry = sameParent(target, source) ? isSrcEntry : !isSrcEntry;
IConnector conn = isSrcEntry ? createEntryConnector() : createExitConnector();
avoidDuplicateConnectorName(target, conn);
if(topElement != null) {
topElement.prepareIDs(targetConnector);
topElement.prepareIDs(conn);
}
createNewTargetDropContext(target, context, targetConnector);
createConnection(source, targetConnector, parent, topElement);
createNewTargetDropContext(target, context, conn);
createConnection(source, conn, parent, topElement);
return true;
}
}
......@@ -26,25 +26,18 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
/**
* Base implementation for supporting direct connection of two {@link IHierarchicElement}s.
*
* Sub-classes may implement {@link #canConnectInternally()} to support internal connections. By
* default connectors of the parent element cannot be connected in internal view of the element.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 24C6F5B1888DF3221318E27D49C64503
* @ConQAT.Rating YELLOW Hash: 09D5C8054487253D2E3C784F9609FAB8
*/
public abstract class HierarchicElementConnectionCompositorBase<HE extends IHierarchicElement, S extends IHierarchicElement, T extends IHierarchicElement>
extends ConnectionCompositorBase<HE, S, T> {
/**
* Creates the application specific source {@link IConnector} model element.
*/
/** Creates the application specific source {@link IConnector} model element. */
protected abstract IConnector createEntryConnector();
/**
* Creates the application specific target {@link IConnector} model element.
*/
/** Creates the application specific target {@link IConnector} model element. */
protected abstract IConnector createExitConnector();
/** {@inheritDoc} */
......@@ -58,10 +51,8 @@ public abstract class HierarchicElementConnectionCompositorBase<HE extends IHier
public boolean connect(S source, T target, HE parent, IConnectionCompositionContext context) {
IConnector sourceConnector = createEntryConnector();
avoidDuplicateConnectorName(source, sourceConnector);
IConnector targetConnector = createExitConnector();
avoidDuplicateConnectorName(target, targetConnector);
ITopLevelElement topElement = IPersistencyService.INSTANCE.getTopLevelElementFor(parent);
if(topElement != null) {
topElement.prepareIDs(sourceConnector);
......@@ -69,7 +60,6 @@ public abstract class HierarchicElementConnectionCompositorBase<HE extends IHier
}
createNewSourceDropContext(source, context, sourceConnector);
createNewTargetDropContext(target, context, targetConnector);
createConnection(targetConnector, sourceConnector, parent, topElement);
return true;
}
......
......@@ -33,7 +33,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author igna
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: CBB58A89C546E50B601EDEF3C8FA6F0C
* @ConQAT.Rating YELLOW Hash: B497F76A177D396698CCBB513FEDA8A1
*/
public abstract class HierarchicElementConnectorConnectionCompositorBase<HE extends IHierarchicElement, S extends IHierarchicElement, T extends IConnector>
extends ConnectionCompositorBase<HE, S, T> {
......@@ -44,38 +44,6 @@ public abstract class HierarchicElementConnectorConnectionCompositorBase<HE exte
/** Creates the application specific target {@link IConnector} model element. */
protected abstract IConnector createExitConnector();
/**
* Temporary storage of connection source (
* {@link #canConnect(IHierarchicElement, IConnector, IHierarchicElement, IConnectionCompositionContext)}
* must ensure that it is valid in {@link #canConnectInternally()}).
*
* TODO (see #2234): Avoid this by refactoring the compositor interface to allow state based
* implementation.
*/
protected S source;
/**
* Temporary storage of connection source (
* {@link #canConnect(IHierarchicElement, IConnector, IHierarchicElement, IConnectionCompositionContext)}
* must ensure that it is valid in {@link #canConnectInternally()}).
*
* TODO (see #2234): Avoid this by refactoring the compositor interface to allow state based
* implementation.
*/
protected T target;
/**
* Helper method to set temporary storage that allows state-based implementation of
* {@link #canConnectInternally()}.
*
* TODO (see #2234): Avoid this by refactoring the compositor interface to allow state based
* implementation.
*/
protected void updateSourceTarget(S source, T target) {
this.source = source;
this.target = target;
}
/** {@inheritDoc} */
@Override
public boolean canConnect(S source, T target, HE parent, IConnectionCompositionContext context) {
......@@ -83,11 +51,7 @@ public abstract class HierarchicElementConnectorConnectionCompositorBase<HE exte
ConnectionDragContext dc = (ConnectionDragContext)context;
if(dc.getTarget() instanceof FreeConnectorEditPartBase &&
dc.getSource() instanceof ElementEditPartBase) {
updateSourceTarget(source, target);
boolean rval = canConnectInternally();
updateSourceTarget(null, null);
return rval;
return canConnectInternally(source, target);
}
}
return true;
......@@ -95,7 +59,7 @@ public abstract class HierarchicElementConnectorConnectionCompositorBase<HE exte
/** {@inheritDoc} */
@Override
protected boolean canConnectInternally() {
protected boolean canConnectInternally(S source, T target) {
return target.getIncoming().isEmpty();
}
......@@ -103,30 +67,15 @@ public abstract class HierarchicElementConnectorConnectionCompositorBase<HE exte
@Override
public boolean connect(S source, T target, HE parent, IConnectionCompositionContext context) {
ITopLevelElement topElement = IPersistencyService.INSTANCE.getTopLevelElementFor(parent);
IConnector sourceConnector = null;
if(sameParent(source, target)) {
if(target instanceof EntryConnectorBase) {
sourceConnector = createEntryConnector();
} else {
sourceConnector = createExitConnector();
}
} else {
if(target instanceof EntryConnectorBase) {
sourceConnector = createExitConnector();
} else {
sourceConnector = createEntryConnector();
}
}
avoidDuplicateConnectorName(source, sourceConnector);
boolean isTargetEntry = target instanceof EntryConnectorBase;
isTargetEntry = sameParent(source, target) ? isTargetEntry : !isTargetEntry;
IConnector conn = isTargetEntry ? createEntryConnector() : createExitConnector();
avoidDuplicateConnectorName(source, conn);
if(topElement != null) {
topElement.prepareIDs(sourceConnector);
topElement.prepareIDs(conn);
}
createNewSourceDropContext(source, context, sourceConnector);
createConnection(sourceConnector, target, parent, topElement);
createNewSourceDropContext(source, context, conn);
createConnection(conn, target, parent, topElement);
return true;
}
}
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