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$
package
org.fortiss.tooling.base.ui.compose
;
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.ConnectorBase
;
import
org.fortiss.tooling.base.model.base.EntryConnectorBase
;
...
...
@@ -46,47 +47,41 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/** {@inheritDoc} */
@Override
public
boolean
canConnect
(
S
source
,
T
target
,
HE
parent
,
IConnectionCompositionContext
context
)
{
public
boolean
canConnect
(
S
source
,
T
target
,
HE
parent
,
IConnectionCompositionContext
context
)
{
// Deny creation of feedback connections in internal view
if
(!
allowInternalFeedback
()
&&
context
instanceof
ConnectionDragContext
)
{
ConnectionDragContext
dc
=
(
ConnectionDragContext
)
context
;
if
(!
allowInternalFeedback
()
&&
context
instanceof
ConnectionDragContext
)
{
ConnectionDragContext
dc
=
(
ConnectionDragContext
)
context
;
//
if
(
dc
.
getSource
()
instanceof
FreeConnectorEditPartBase
&&
dc
.
getTarget
()
instanceof
FreeConnectorEditPartBase
)
{
if
(
dc
.
getSource
()
instanceof
FreeConnectorEditPartBase
&&
dc
.
getTarget
()
instanceof
FreeConnectorEditPartBase
)
{
return
false
;
}
}
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
return
checkEntryEntry
((
EntryConnectorBase
)
source
,
(
EntryConnectorBase
)
target
,
null
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
return
checkEntryEntry
((
EntryConnectorBase
)
source
,
(
EntryConnectorBase
)
target
,
null
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
// use swapping here
return
checkExitEntry
((
ExitConnectorBase
)
target
,
(
EntryConnectorBase
)
source
,
null
);
return
checkExitEntry
((
ExitConnectorBase
)
target
,
(
EntryConnectorBase
)
source
,
null
);
}
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
return
checkExitEntry
((
ExitConnectorBase
)
source
,
(
EntryConnectorBase
)
target
,
null
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
return
checkExitExit
((
ExitConnectorBase
)
source
,
(
ExitConnectorBase
)
target
,
null
);
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
return
checkExitEntry
((
ExitConnectorBase
)
source
,
(
EntryConnectorBase
)
target
,
null
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
return
checkExitExit
((
ExitConnectorBase
)
source
,
(
ExitConnectorBase
)
target
,
null
);
}
}
return
false
;
}
/** Checks entry to entry connection. */
private
boolean
checkEntryEntry
(
EntryConnectorBase
source
,
EntryConnectorBase
target
,
EObject
connection
)
{
private
boolean
checkEntryEntry
(
EntryConnectorBase
source
,
EntryConnectorBase
target
,
EObject
connection
)
{
boolean
swapped
=
false
;
// child input to super input => swap input
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
EntryConnectorBase
temp
=
source
;
source
=
target
;
target
=
temp
;
...
...
@@ -94,20 +89,17 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
}
// super input to child input
if
(
swapped
||
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
if
(
swapped
||
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
}
return
false
;
}
/** Checks exit to entry connection. */
private
boolean
checkExitEntry
(
ExitConnectorBase
source
,
EntryConnectorBase
target
,
EObject
connection
)
{
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
()
.
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
private
boolean
checkExitEntry
(
ExitConnectorBase
source
,
EntryConnectorBase
target
,
EObject
connection
)
{
if
(
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
}
return
false
;
}
...
...
@@ -115,18 +107,17 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/**
* Checks exit to exit connection.
*/
private
boolean
checkExitExit
(
ExitConnectorBase
source
,
ExitConnectorBase
target
,
EObject
connection
)
{
private
boolean
checkExitExit
(
ExitConnectorBase
source
,
ExitConnectorBase
target
,
EObject
connection
)
{
boolean
swapped
=
false
;
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
ExitConnectorBase
temp
=
source
;
source
=
target
;
target
=
temp
;
swapped
=
true
;
}
if
(
swapped
||
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
if
(
swapped
||
source
.
eContainer
().
eContainer
()
==
target
.
eContainer
())
{
return
checkSourceOut
(
source
,
connection
)
&&
checkTargetIn
(
target
,
connection
);
}
return
false
;
}
...
...
@@ -137,8 +128,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
private
boolean
checkSourceOut
(
ConnectorBase
source
,
EObject
connection
)
{
// source has no outgoing connection, is already connected, or allows
// multiple connections
return
source
.
getOutgoingLength
()
==
0
||
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
return
source
.
getOutgoingLength
()
==
0
||
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
.
getSource
()
==
source
)
||
allowOneToMany
();
}
...
...
@@ -148,8 +139,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
private
boolean
checkTargetIn
(
ConnectorBase
target
,
EObject
connection
)
{
// target has no incoming connection, is already connected, or allows
// multiple connections.
return
target
.
getIncomingLength
()
==
0
||
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
return
target
.
getIncomingLength
()
==
0
||
(
connection
instanceof
ConnectionSegmentBase
&&
((
ConnectionSegmentBase
)
connection
)
.
getTarget
()
==
target
)
||
allowManyToOne
();
}
...
...
@@ -157,56 +148,50 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
* {@inheritDoc}
*/
@Override
public
boolean
connect
(
S
source
,
T
target
,
HE
parent
,
IConnectionCompositionContext
context
)
{
public
boolean
connect
(
S
source
,
T
target
,
HE
parent
,
IConnectionCompositionContext
context
)
{
ConnectionSegmentBase
conn
=
createConnection
(
source
,
target
,
context
);
// If we are working in a connected model, deal with IDs
ITopLevelElement
modelContext
=
IPersistencyService
.
INSTANCE
.
getTopLevelElementFor
(
source
);
if
(
modelContext
!=
null
)
{
ITopLevelElement
modelContext
=
IPersistencyService
.
INSTANCE
.
getTopLevelElementFor
(
source
);
if
(
modelContext
!=
null
)
{
modelContext
.
prepareIDs
(
conn
);
}
boolean
swap
=
false
;
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
((
HierarchicElementBase
)
source
.
eContainer
())
.
getConnectionsList
().
add
(
conn
);
if
(
source
instanceof
EntryConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
((
HierarchicElementBase
)
source
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
}
else
{
// source.eContainer().eContainer() ==
// target.eContainer()
((
HierarchicElementBase
)
target
.
eContainer
())
.
getConnectionsList
().
add
(
conn
);
((
HierarchicElementBase
)
target
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
swap
=
true
;
}
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
())
.
getConnectionsList
().
add
(
conn
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
())
.
getConnectionsList
().
add
(
conn
);
swap
=
true
;
}
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
())
.
getConnectionsList
().
add
(
conn
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
((
HierarchicElementBase
)
source
.
eContainer
())
.
getConnectionsList
().
add
(
conn
);
}
else
if
(
source
instanceof
ExitConnectorBase
)
{
if
(
target
instanceof
EntryConnectorBase
)
{
((
HierarchicElementBase
)
source
.
eContainer
().
eContainer
()).
getConnectionsList
().
add
(
conn
);
}
else
if
(
target
instanceof
ExitConnectorBase
)
{
if
(
source
.
eContainer
()
==
target
.
eContainer
().
eContainer
())
{
((
HierarchicElementBase
)
source
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
swap
=
true
;
}
else
{
// source.eContainer().eContainer() ==
// target.eContainer()
((
HierarchicElementBase
)
target
.
eContainer
())
.
getConnectionsList
().
add
(
conn
);
((
HierarchicElementBase
)
target
.
eContainer
()).
getConnectionsList
().
add
(
conn
);
}
}
}
if
(
swap
)
{
if
(
swap
)
{
conn
.
setSource
(
target
);
conn
.
setTarget
(
source
);
}
else
{
...
...
@@ -221,8 +206,8 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
* provided to make use of their names when naming the connection. However
* they should not be used for connecting.
*/
protected
abstract
ConnectionSegmentBase
createConnection
(
S
source
,
T
target
,
IConnectionCompositionContext
context
);
protected
abstract
ConnectionSegmentBase
createConnection
(
S
source
,
T
target
,
IConnectionCompositionContext
context
);
/**
* Configures multiple connection behavior for 1-to-many connections. The
...
...
@@ -250,7 +235,7 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/** {@inheritDoc} */
@Override
public
boolean
canDisconnect
(
EObject
connection
)
{
if
(!
canDisconnectSpecific
(
connection
))
{
if
(!
canDisconnectSpecific
(
connection
))
{
return
false
;
}
return
true
;
...
...
@@ -262,12 +247,9 @@ public abstract class ConnectorConnectionCompositorBase<HE extends IHierarchicEl
/** {@inheritDoc} */
@Override
public
boolean
disconnect
(
EObject
connection
)
{
if
(
connection
instanceof
IConnection
)
{
IConnection
conn
=
(
IConnection
)
connection
;
// this order is important !
conn
.
setOwner
(
null
);
conn
.
setSource
(
null
);
conn
.
setTarget
(
null
);
if
(
connection
instanceof
IConnection
)
{
// since an IConnection object contains no element, it can be safe deleted directly.
EcoreUtil
.
delete
(
connection
);
return
true
;
}
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