Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
2153ffa9
Commit
2153ffa9
authored
12 years ago
by
Dongyue Mou
Browse files
Options
Downloads
Patches
Plain Diff
improved refinement testing
parent
64754cec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/ConnectorConnectionCompositorBase.java
+60
-78
60 additions, 78 deletions
...ng/base/ui/compose/ConnectorConnectionCompositorBase.java
with
60 additions
and
78 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/ConnectorConnectionCompositorBase.java
+
60
−
78
View file @
2153ffa9
...
@@ -18,6 +18,7 @@ $Id$
...
@@ -18,6 +18,7 @@ $Id$
package
org.fortiss.tooling.base.ui.compose
;
package
org.fortiss.tooling.base.ui.compose
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.emf.ecore.util.EcoreUtil
;
import
org.fortiss.tooling.base.model.base.ConnectionSegmentBase
;
import
org.fortiss.tooling.base.model.base.ConnectionSegmentBase
;
import
org.fortiss.tooling.base.model.base.ConnectorBase
;
import
org.fortiss.tooling.base.model.base.ConnectorBase
;
import
org.fortiss.tooling.base.model.base.EntryConnectorBase
;
import
org.fortiss.tooling.base.model.base.EntryConnectorBase
;
...
@@ -46,47 +47,41 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -46,47 +47,41 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
@Override
public
boolean
canConnect
(
S
source
,
T
target
,
HE
parent
,
public
boolean
canConnect
(
S
source
,
T
target
,
HE
parent
,
IConnectionCompositionContext
context
)
{
IConnectionCompositionContext
context
)
{
// Deny creation of feedback connections in internal view
// Deny creation of feedback connections in internal view
if
(!
allowInternalFeedback
()
if
(!
allowInternalFeedback
()
&&
context
instanceof
ConnectionDragContext
)
{
&&
context
instanceof
ConnectionDragContext
)
{
ConnectionDragContext
dc
=
(
ConnectionDragContext
)
context
;
ConnectionDragContext
dc
=
(
ConnectionDragContext
)
context
;
//
//
if
(
dc
.
getSource
()
instanceof
FreeConnectorEditPartBase
if
(
dc
.
getSource
()
instanceof
FreeConnectorEditPartBase
&&
&&
dc
.
getTarget
()
instanceof
FreeConnectorEditPartBase
)
{
dc
.
getTarget
()
instanceof
FreeConnectorEditPartBase
)
{
return
false
;
return
false
;
}
}
}
}
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
return
checkEntryEntry
((
EntryConnectorBase
)
source
,
return
checkEntryEntry
((
EntryConnectorBase
)
source
,
(
EntryConnectorBase
)
target
,
null
);
(
EntryConnectorBase
)
target
,
null
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
// use swapping here
// use swapping here
return
checkExitEntry
((
ExitConnectorBase
)
target
,
return
checkExitEntry
((
ExitConnectorBase
)
target
,
(
EntryConnectorBase
)
source
,
null
);
(
EntryConnectorBase
)
source
,
null
);
}
}
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
return
checkExitEntry
((
ExitConnectorBase
)
source
,
return
checkExitEntry
((
ExitConnectorBase
)
source
,
(
EntryConnectorBase
)
target
,
null
);
(
EntryConnectorBase
)
target
,
null
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
return
checkExitExit
((
ExitConnectorBase
)
source
,
(
ExitConnectorBase
)
target
,
null
);
return
checkExitExit
((
ExitConnectorBase
)
source
,
(
ExitConnectorBase
)
target
,
null
);
}
}
}
}
return
false
;
return
false
;
}
}
/** Checks entry to entry connection. */
/** Checks entry to entry connection. */
private
boolean
checkEntryEntry
(
EntryConnectorBase
source
,
private
boolean
checkEntryEntry
(
EntryConnectorBase
source
,
EntryConnectorBase
target
,
EntryConnectorBase
target
,
EObject
connection
)
{
EObject
connection
)
{
boolean
swapped
=
false
;
boolean
swapped
=
false
;
// child input to super input => swap input
// child input to super input => swap input
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
EntryConnectorBase
temp
=
source
;
EntryConnectorBase
temp
=
source
;
source
=
target
;
source
=
target
;
target
=
temp
;
target
=
temp
;
...
@@ -94,20 +89,17 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -94,20 +89,17 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
}
}
// super input to child input
// super input to child input
if
(
swapped
||
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
if
(
swapped
||
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
&&
checkTargetIn
(
target
,
connection
);
}
}
return
false
;
return
false
;
}
}
/** Checks exit to entry connection. */
/** Checks exit to entry connection. */
private
boolean
checkExitEntry
(
ExitConnectorBase
source
,
private
boolean
checkExitEntry
(
ExitConnectorBase
source
,
EntryConnectorBase
target
,
EntryConnectorBase
target
,
EObject
connection
)
{
EObject
connection
)
{
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
()
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
.
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
}
}
return
false
;
return
false
;
}
}
...
@@ -115,18 +107,17 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -115,18 +107,17 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/**
/**
* Checks exit to exit connection.
* Checks exit to exit connection.
*/
*/
private
boolean
checkExitExit
(
ExitConnectorBase
source
,
private
boolean
checkExitExit
(
ExitConnectorBase
source
,
ExitConnectorBase
target
,
ExitConnectorBase
target
,
EObject
connection
)
{
EObject
connection
)
{
boolean
swapped
=
false
;
boolean
swapped
=
false
;
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
ExitConnectorBase
temp
=
source
;
ExitConnectorBase
temp
=
source
;
source
=
target
;
source
=
target
;
target
=
temp
;
target
=
temp
;
swapped
=
true
;
swapped
=
true
;
}
}
if
(
swapped
||
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
if
(
swapped
||
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
&&
checkTargetIn
(
target
,
connection
);
}
}
return
false
;
return
false
;
}
}
...
@@ -137,8 +128,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -137,8 +128,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
private
boolean
checkSourceOut
(
ConnectorBase
source
,
EObject
connection
)
{
private
boolean
checkSourceOut
(
ConnectorBase
source
,
EObject
connection
)
{
// source has no outgoing connection, is already connected, or allows
// source has no outgoing connection, is already connected, or allows
// multiple connections
// multiple connections
return
source
.
getOutgoingLength
()
==
0
return
source
.
getOutgoingLength
()
==
0
||
||
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
.
getSource
()
==
source
)
||
allowOneToMany
();
.
getSource
()
==
source
)
||
allowOneToMany
();
}
}
...
@@ -148,8 +139,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -148,8 +139,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
private
boolean
checkTargetIn
(
ConnectorBase
target
,
EObject
connection
)
{
private
boolean
checkTargetIn
(
ConnectorBase
target
,
EObject
connection
)
{
// target has no incoming connection, is already connected, or allows
// target has no incoming connection, is already connected, or allows
// multiple connections.
// multiple connections.
return
target
.
getIncomingLength
()
==
0
return
target
.
getIncomingLength
()
==
0
||
||
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
.
getTarget
()
==
target
)
||
allowManyToOne
();
.
getTarget
()
==
target
)
||
allowManyToOne
();
}
}
...
@@ -157,56 +148,50 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -157,56 +148,50 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
* {@inheritDoc}
* {@inheritDoc}
*/
*/
@Override
@Override
public
boolean
connect
(
S
source
,
T
target
,
HE
parent
,
public
boolean
connect
(
S
source
,
T
target
,
HE
parent
,
IConnectionCompositionContext
context
)
{
IConnectionCompositionContext
context
)
{
ConnectionSegmentBase
conn
=
createConnection
(
source
,
target
,
context
);
ConnectionSegmentBase
conn
=
createConnection
(
source
,
target
,
context
);
// If we are working in a connected model, deal with IDs
// If we are working in a connected model, deal with IDs
ITopLevelElement
modelContext
=
IPersistencyService
.
INSTANCE
ITopLevelElement
modelContext
=
IPersistencyService
.
INSTANCE
.
getTopLevelElementFor
(
source
);
.
getTopLevelElementFor
(
source
);
if
(
modelContext
!=
null
)
{
if
(
modelContext
!=
null
)
{
modelContext
.
prepareIDs
(
conn
);
modelContext
.
prepareIDs
(
conn
);
}
}
boolean
swap
=
false
;
boolean
swap
=
false
;
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
((
HierarchicElementBase
)
source
.
eContainer
())
((
HierarchicElementBase
)
source
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
.
getConnectionsList
().
add
(
conn
);
}
else
{
}
else
{
// source.eContainer().eContainer() ==
// source.eContainer().eContainer() ==
// target.eContainer()
// target.eContainer()
((
HierarchicElementBase
)
target
.
eContainer
())
((
HierarchicElementBase
)
target
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
.
getConnectionsList
().
add
(
conn
);
swap
=
true
;
swap
=
true
;
}
}
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
())
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
())
.
getConnectionsList
().
add
(
.
getConnectionsList
().
add
(
conn
);
conn
);
swap
=
true
;
swap
=
true
;
}
}
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
())
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
()).
getConnectionsList
().
add
(
.
getConnectionsList
().
add
(
conn
);
conn
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
((
HierarchicElementBase
)
source
.
eContainer
())
((
HierarchicElementBase
)
source
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
.
getConnectionsList
().
add
(
conn
);
swap
=
true
;
swap
=
true
;
}
else
{
}
else
{
// source.eContainer().eContainer() ==
// source.eContainer().eContainer() ==
// target.eContainer()
// target.eContainer()
((
HierarchicElementBase
)
target
.
eContainer
())
((
HierarchicElementBase
)
target
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
.
getConnectionsList
().
add
(
conn
);
}
}
}
}
}
}
if
(
swap
)
{
if
(
swap
)
{
conn
.
setSource
(
target
);
conn
.
setSource
(
target
);
conn
.
setTarget
(
source
);
conn
.
setTarget
(
source
);
}
else
{
}
else
{
...
@@ -221,8 +206,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -221,8 +206,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
* provided to make use of their names when naming the connection. However
* provided to make use of their names when naming the connection. However
* they should not be used for connecting.
* they should not be used for connecting.
*/
*/
protected
abstract
ConnectionSegmentBase
createConnection
(
S
source
,
protected
abstract
ConnectionSegmentBase
createConnection
(
S
source
,
T
target
,
T
target
,
IConnectionCompositionContext
context
);
IConnectionCompositionContext
context
);
/**
/**
* Configures multiple connection behavior for 1-to-many connections. The
* Configures multiple connection behavior for 1-to-many connections. The
...
@@ -250,7 +235,7 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -250,7 +235,7 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
@Override
public
boolean
canDisconnect
(
EObject
connection
)
{
public
boolean
canDisconnect
(
EObject
connection
)
{
if
(!
canDisconnectSpecific
(
connection
))
{
if
(!
canDisconnectSpecific
(
connection
))
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -262,12 +247,9 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
...
@@ -262,12 +247,9 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
@Override
public
boolean
disconnect
(
EObject
connection
)
{
public
boolean
disconnect
(
EObject
connection
)
{
if
(
connection
instanceof
IConnection
)
{
if
(
connection
instanceof
IConnection
)
{
IConnection
conn
=
(
IConnection
)
connection
;
// since an IConnection object contains no element, it can be safe deleted directly.
// this order is important !
EcoreUtil
.
delete
(
connection
);
conn
.
setOwner
(
null
);
conn
.
setSource
(
null
);
conn
.
setTarget
(
null
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment