Skip to content
Snippets Groups Projects
Commit 76991867 authored by Christoph Döbber's avatar Christoph Döbber
Browse files

refactorings and cleanups

parent b0064a5e
No related branches found
No related tags found
No related merge requests found
......@@ -49,17 +49,18 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
* 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
System.out.println(contained);
return iterateDecompose(contained, true);
}
/**
* Decomposition ability check that takes care of the whole model subtree.
* Subclasses implement {@link #decompose*****()} instead.
* Decomposition that takes care of the whole model subtree. Subclasses
* implement {@link #decompose*****()} instead.
*/
@SuppressWarnings("javadoc")
@Override
public final boolean decompose(EObject contained) {
return iterateDecompose(contained, false);
......@@ -76,7 +77,6 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
* (non-recursively). Subclasses may override.
*/
protected boolean decomposeSpecific(EObject contained) {
System.out.println("specific: " + contained + " ### " + this);
EcoreUtil.delete(contained);
return true;
}
......@@ -216,8 +216,8 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
}
/**
* Iterates over specifications of given {@link IModelElement} and checks
* for decomposition ability
* Iterates over specifications of given {@link IModelElement} and performs
* decomposition.
*/
private boolean iterateDecomposeSpecifications(IModelElement me) {
ArrayList<IModelElementSpecification> list = new ArrayList<IModelElementSpecification>(
......@@ -232,7 +232,7 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
/**
* Iterates over sub elements of given {@link IHierarchicElementContainer}
* and checks for decomposition ability.
* and performs decomposition.
*/
private boolean iterateDecomposeSubelements(
IHierarchicElementContainer contained) {
......@@ -247,8 +247,8 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
}
/**
* Iterates over list of connections and checks for disconnection ability or
* decomposition ability of sub elements respectively.
* Iterates over list of connections and runs disconnection or decomposition
* of sub elements respectively.
*/
private boolean iterateDecomposeConnections(
EList<IConnection> connectionsList) {
......@@ -263,8 +263,8 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
}
/**
* Iterates over connectors of given {@link IHierarchicElement} and checks
* for decomposition ability.
* Iterates over connectors of given {@link IHierarchicElement} and runs
* decomposition.
*/
private boolean iterateDecomposeConnectors(IHierarchicElement contained) {
ArrayList<IConnector> list = new ArrayList<IConnector>(
......@@ -277,7 +277,10 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
return true;
}
/** Base implementation returns true by default. Subclasses may override. */
/**
* Base implementation returns compositors' decision by default. Subclasses
* may override.
*/
protected boolean canDecomposeSpecification(
IModelElementSpecification element) {
if (element instanceof IHiddenSpecification) {
......@@ -286,18 +289,27 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
return IElementCompositorService.INSTANCE.canDecompose(element);
}
/** Base implementation returns true by default. Subclasses may override. */
protected boolean canDecomposeReference(EObject element) {
/**
* Base implementation yet empty.
*/
protected boolean canDecomposeReference(
@SuppressWarnings("unused") EObject element) {
// TODO implement reference removal
return true;
}
/** Base implementation returns true by default. Subclasses may override. */
/**
* Base implementation returns compositors' decision by default. Subclasses
* may override.
*/
protected boolean canDecomposeSubElement(IHierarchicElement element) {
return IElementCompositorService.INSTANCE.canDecompose(element);
}
/** Base implementation returns true by default. Subclasses may override. */
/**
* Base implementation returns compositors' decision by default. Subclasses
* may override.
*/
protected boolean canDecomposeConnector(IConnector element) {
return IElementCompositorService.INSTANCE.canDecompose(element);
}
......@@ -310,8 +322,11 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
return IConnectionCompositorService.INSTANCE.canDisconnect(conn);
}
/**
* Base implementation returns compositors' decomposition by default and
* invokes EcoreUtil.delete() otherwise. Subclasses may override.
*/
protected boolean decomposeSpecification(IModelElementSpecification element) {
System.out.println("specification: " + element + " ### " + this);
if (IElementCompositorService.INSTANCE.canDecompose(element)) {
return IElementCompositorService.INSTANCE.decompose(element);
}
......@@ -319,13 +334,18 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
return true;
}
protected boolean decomposeReferences(EObject element) {
/** Base implementation yet empty. */
protected boolean decomposeReferences(
@SuppressWarnings("unused") EObject element) {
// TODO implement reference removal
return true;
}
/**
* Base implementation returns compositors' decomposition by default and
* invokes EcoreUtil.delete() otherwise Subclasses may override.
*/
protected boolean decomposeSubelement(IHierarchicElement element) {
System.out.println("subelement: " + element + " ### " + this);
if (IElementCompositorService.INSTANCE.canDecompose(element)) {
return IElementCompositorService.INSTANCE.decompose(element);
}
......@@ -333,12 +353,15 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
return true;
}
/**
* Base implementation returns compositors' decomposition by default and
* invokes EcoreUtil.delete() otherwise Subclasses may override.
*/
protected boolean decomposeConnector(IConnector element) {
ArrayList<IConnection> list = new ArrayList<IConnection>(
element.getIncomingList());
list.addAll(element.getOutgoingList());
for (IConnection conn : list) {
System.out.println("disconnect: " + element + " ### " + this);
if (!IConnectionCompositorService.INSTANCE.disconnect(conn)) {
return false;
}
......@@ -347,8 +370,11 @@ public abstract class HierarchicElementCompositorBase<HE extends IHierarchicElem
return true;
}
/**
* Base implementation returns compositors' decomposition by default and
* invokes EcoreUtil.delete() otherwise Subclasses may override.
*/
protected boolean decomposeConnection(IConnection conn) {
System.out.println("connection: " + conn + " ### " + this);
return IConnectionCompositorService.INSTANCE.disconnect(conn);
}
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.utils;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
/**
* Utils class implementing basic model related functionality for convenience.
*
* @author doebber
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class ModelUtils {
/**
* Wraps model change in transactional command and invokes on model context.
*/
public static void runAsCommand(EObject element, Runnable command) {
ITopLevelElement topLevel = IPersistencyService.INSTANCE
.getTopLevelElementFor(element);
topLevel.runAsCommand(command);
}
}
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