Skip to content
Snippets Groups Projects
Commit 0baf2155 authored by Simon Barner's avatar Simon Barner
Browse files

- Fix last commit: Actually allow one connection from a IHierarchicElement...

- Fix last commit: Actually allow one connection from a IHierarchicElement (node) to a free IConnector
refs 2233
parent 61d748fa
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,29 @@ 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 #canConnectInterally()}).
*/
protected S source;
/**
* Temporary storage of connection source (
* {@link #canConnect(IHierarchicElement, IConnector, IHierarchicElement, IConnectionCompositionContext)}
* must ensure that it is valid in {@link #canConnectInterally()}).
*/
protected T target;
/**
* Helper method to set temporary storage that allows state-based implementation of
* {@link #canConnectInterally()}.
*/
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) {
......@@ -51,12 +74,22 @@ public abstract class HierarchicElementConnectorConnectionCompositorBase<HE exte
ConnectionDragContext dc = (ConnectionDragContext)context;
if(dc.getTarget() instanceof FreeConnectorEditPartBase &&
dc.getSource() instanceof ElementEditPartBase) {
return canConnectInterally();
updateSourceTarget(source, target);
boolean rval = canConnectInterally();
updateSourceTarget(null, null);
return rval;
}
}
return true;
}
/** {@inheritDoc} */
@Override
protected boolean canConnectInterally() {
return target.getIncoming().isEmpty();
}
/** {@inheritDoc} */
@Override
public boolean connect(S source, T target, HE parent, IConnectionCompositionContext context) {
......
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