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
f79d2b44
Commit
f79d2b44
authored
13 years ago
by
Florian Hölzl
Browse files
Options
Downloads
Patches
Plain Diff
canDecompose is not recursive (decompose is)
refs 133
parent
76991867
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/trunk/src/org/fortiss/tooling/base/decompose/HierarchicElementCompositorBase.java
+20
-180
20 additions, 180 deletions
...oling/base/decompose/HierarchicElementCompositorBase.java
with
20 additions
and
180 deletions
org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/decompose/HierarchicElementCompositorBase.java
+
20
−
180
View file @
f79d2b44
...
...
@@ -24,7 +24,6 @@ import org.eclipse.emf.ecore.EObject;
import
org.eclipse.emf.ecore.util.EcoreUtil
;
import
org.fortiss.tooling.base.model.element.IConnection
;
import
org.fortiss.tooling.base.model.element.IConnector
;
import
org.fortiss.tooling.base.model.element.IHiddenSpecification
;
import
org.fortiss.tooling.base.model.element.IHierarchicElement
;
import
org.fortiss.tooling.base.model.element.IHierarchicElementContainer
;
import
org.fortiss.tooling.base.model.element.IModelElement
;
...
...
@@ -45,17 +44,6 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
public
abstract
class
HierarchicElementCompositorBase
<
HE
extends
IHierarchicElementContainer
>
implements
IElementCompositor
<
HE
>
{
/**
* Decomposition ability check that takes care of the whole model subtree.
* Subclasses implement {@link #canDecompose*****()} instead.
*/
@SuppressWarnings
(
"javadoc"
)
@Override
public
final
boolean
canDecompose
(
EObject
contained
)
{
// TODO remove
return
iterateDecompose
(
contained
,
true
);
}
/**
* Decomposition that takes care of the whole model subtree. Subclasses
* implement {@link #decompose*****()} instead.
...
...
@@ -63,15 +51,9 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
@SuppressWarnings
(
"javadoc"
)
@Override
public
final
boolean
decompose
(
EObject
contained
)
{
return
iterateDecompose
(
contained
,
false
);
return
iterateDecompose
(
contained
);
}
/**
* Returns whether the compositor is able to decompose the given model
* element
*/
protected
abstract
boolean
canDecomposeSpecific
(
EObject
contained
);
/**
* Base implementation for element removal using EcoreUtil.delete
* (non-recursively). Subclasses may override.
...
...
@@ -82,137 +64,40 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
}
/** recursive traversion of all model elements in subtree */
private
boolean
iterateDecompose
(
EObject
contained
,
boolean
can
)
{
if
(!
canDecomposeSpecific
(
contained
))
{
return
false
;
}
if
(
can
)
{
if
(
contained
instanceof
IModelElement
)
{
if
(!
iterateCanDecomposeSpecifications
((
IModelElement
)
contained
))
{
return
false
;
}
// TODO CD: handle references
}
if
(
contained
instanceof
IHierarchicElementContainer
)
{
if
(!
iterateCanDecomposeSubelements
((
IHierarchicElementContainer
)
contained
))
{
return
false
;
}
}
if
(
contained
instanceof
IHierarchicElement
)
{
IHierarchicElement
he
=
(
IHierarchicElement
)
contained
;
if
(!
iterateCanDecomposeConnections
(
he
.
getConnectionsList
()))
{
return
false
;
}
if
(!
iterateCanDecomposeConnectors
((
IHierarchicElement
)
contained
))
{
return
false
;
}
}
if
(
contained
instanceof
IConnector
)
{
IConnector
connector
=
(
IConnector
)
contained
;
if
(!
iterateCanDecomposeConnections
(
connector
.
getIncomingList
()))
{
return
false
;
}
if
(!
iterateCanDecomposeConnections
(
connector
.
getOutgoingList
()))
{
return
false
;
}
}
}
else
{
if
(
contained
instanceof
IModelElement
)
{
if
(!
iterateDecomposeSpecifications
((
IModelElement
)
contained
))
{
return
false
;
}
// TODO CD: handle references
}
if
(
contained
instanceof
IHierarchicElementContainer
)
{
if
(!
iterateDecomposeSubelements
((
IHierarchicElementContainer
)
contained
))
{
return
false
;
}
}
if
(
contained
instanceof
IHierarchicElement
)
{
IHierarchicElement
he
=
(
IHierarchicElement
)
contained
;
if
(!
iterateDecomposeConnections
(
he
.
getConnectionsList
()))
{
return
false
;
}
if
(!
iterateDecomposeConnectors
((
IHierarchicElement
)
contained
))
{
return
false
;
}
}
if
(
contained
instanceof
IConnector
)
{
IConnector
connector
=
(
IConnector
)
contained
;
if
(!
iterateDecomposeConnections
(
connector
.
getIncomingList
()))
{
return
false
;
}
if
(!
iterateDecomposeConnections
(
connector
.
getOutgoingList
()))
{
return
false
;
}
private
boolean
iterateDecompose
(
EObject
contained
)
{
if
(
contained
instanceof
IModelElement
)
{
if
(!
iterateDecomposeSpecifications
((
IModelElement
)
contained
))
{
return
false
;
}
return
decomposeSpecific
(
contained
);
// TODO CD: handle references
}
return
true
;
}
/**
* Iterates over specifications of given {@link IModelElement} and checks
* for decomposition ability
*/
private
boolean
iterateCanDecomposeSpecifications
(
IModelElement
me
)
{
for
(
IModelElementSpecification
spec
:
me
.
getSpecificationsList
())
{
if
(!
canDecomposeSpecification
(
spec
))
{
if
(
contained
instanceof
IHierarchicElementContainer
)
{
if
(!
iterateDecomposeSubelements
((
IHierarchicElementContainer
)
contained
))
{
return
false
;
}
}
return
true
;
}
if
(
contained
instanceof
IHierarchicElement
)
{
IHierarchicElement
he
=
(
IHierarchicElement
)
contained
;
/**
* Iterates over sub elements of given {@link IHierarchicElementContainer}
* and checks for decomposition ability.
*/
private
boolean
iterateCanDecomposeSubelements
(
IHierarchicElementContainer
contained
)
{
for
(
IHierarchicElement
subelement
:
contained
.
getContainedElementsList
())
{
if
(!
canDecomposeSubElement
(
subelement
))
{
if
(!
iterateDecomposeConnections
(
he
.
getConnectionsList
()))
{
return
false
;
}
}
return
true
;
}
/**
* Iterates over list of connections and checks for disconnection ability or
* decomposition ability of sub elements respectively.
*/
private
boolean
iterateCanDecomposeConnections
(
EList
<
IConnection
>
connectionsList
)
{
for
(
IConnection
conn
:
connectionsList
)
{
if
(!
canDecomposeConnection
(
conn
))
{
if
(!
iterateDecomposeConnectors
((
IHierarchicElement
)
contained
))
{
return
false
;
}
}
return
true
;
}
/**
* Iterates over connectors of given {@link IHierarchicElement} and checks
* for decomposition ability.
*/
private
boolean
iterateCanDecomposeConnectors
(
IHierarchicElement
contained
)
{
for
(
IConnector
c
:
contained
.
getConnectorsList
())
{
if
(!
can
DecomposeConnect
or
(
c
))
{
}
if
(
contained
instanceof
IConnector
)
{
IConnector
connector
=
(
IConnector
)
contained
;
if
(!
iterateDecomposeConnections
(
connector
.
getIncomingList
()))
{
return
false
;
}
if
(!
iterate
DecomposeConnect
ions
(
connector
.
getOutgoingList
()
))
{
return
false
;
}
}
return
true
;
return
decomposeSpecific
(
contained
)
;
}
/**
...
...
@@ -277,51 +162,6 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
return
true
;
}
/**
* Base implementation returns compositors' decision by default. Subclasses
* may override.
*/
protected
boolean
canDecomposeSpecification
(
IModelElementSpecification
element
)
{
if
(
element
instanceof
IHiddenSpecification
)
{
return
true
;
}
return
IElementCompositorService
.
INSTANCE
.
canDecompose
(
element
);
}
/**
* Base implementation yet empty.
*/
protected
boolean
canDecomposeReference
(
@SuppressWarnings
(
"unused"
)
EObject
element
)
{
// TODO implement reference removal
return
true
;
}
/**
* Base implementation returns compositors' decision by default. Subclasses
* may override.
*/
protected
boolean
canDecomposeSubElement
(
IHierarchicElement
element
)
{
return
IElementCompositorService
.
INSTANCE
.
canDecompose
(
element
);
}
/**
* Base implementation returns compositors' decision by default. Subclasses
* may override.
*/
protected
boolean
canDecomposeConnector
(
IConnector
element
)
{
return
IElementCompositorService
.
INSTANCE
.
canDecompose
(
element
);
}
/**
* Base implementation returns compositors' decision by default. Subclasses
* may override.
*/
protected
boolean
canDecomposeConnection
(
IConnection
conn
)
{
return
IConnectionCompositorService
.
INSTANCE
.
canDisconnect
(
conn
);
}
/**
* Base implementation returns compositors' decomposition by default and
* invokes EcoreUtil.delete() otherwise. Subclasses may override.
...
...
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