Commit ce4afcae authored by Martti Käärik's avatar Martti Käärik
Browse files

Direct editing of names and creation tools for configuration elements.

Change-Id: Ia951ede1f1339d033828fc6e71deef94976091b2
parent 30f48370
Loading
Loading
Loading
Loading
+174 −46

File changed.

Preview size limit exceeded, changes collapsed.

+31 −0
Original line number Diff line number Diff line
@@ -6,15 +6,18 @@ import java.util.List;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.etsi.mts.tdl.Action;
import org.etsi.mts.tdl.Behaviour;
import org.etsi.mts.tdl.BehaviourDescription;
import org.etsi.mts.tdl.ComponentInstance;
import org.etsi.mts.tdl.ComponentType;
import org.etsi.mts.tdl.DataInstance;
import org.etsi.mts.tdl.DataType;
import org.etsi.mts.tdl.Element;
import org.etsi.mts.tdl.ElementImport;
import org.etsi.mts.tdl.Function;
import org.etsi.mts.tdl.GateType;
import org.etsi.mts.tdl.Package;
import org.etsi.mts.tdl.SimpleDataInstance;
import org.etsi.mts.tdl.Target;
@@ -26,6 +29,10 @@ import org.etsi.mts.tdl.tdlPackage;

public class ModelHelper {
	
	public EObject owner(EObject element) {
		return element.eContainer();
	}

	public TestDescription getTestDescription(EObject behaviourContent) {
		EObject c = behaviourContent;
		while (c != null) {
@@ -36,6 +43,18 @@ public class ModelHelper {
		return null;
	}
	
	public ComponentInstance getContainingTestComponent(DDiagramElement configurationDiagramElement) {
		while (configurationDiagramElement != null) {
			EObject t = configurationDiagramElement.getTarget();
			if (t instanceof ComponentInstance)
				return (ComponentInstance) t;
			if (!(configurationDiagramElement.eContainer() instanceof DDiagramElement))
				return null;
			configurationDiagramElement = (DDiagramElement) configurationDiagramElement.eContainer();
		}
		return null;
	}
	
	public TestConfiguration getTestConfiguration(EObject behaviourContent) {
		TestDescription td = getTestDescription(behaviourContent);
		return td != null ? td.getTestConfiguration() : null;
@@ -56,10 +75,22 @@ public class ModelHelper {
		return (List<Action>) getOf(context, tdlPackage.eINSTANCE.getAction());
	}

	public List<DataType> getDataTypes(EObject context) {
		return (List<DataType>) getOf(context, tdlPackage.eINSTANCE.getDataType());
	}

	public List<DataInstance> getDataInstances(EObject context) {
		return (List<DataInstance>) getOf(context, tdlPackage.eINSTANCE.getDataInstance());
	}

	public List<ComponentType> getComponentTypes(EObject context) {
		return (List<ComponentType>) getOf(context, tdlPackage.eINSTANCE.getComponentType());
	}

	public List<GateType> getGateTypes(EObject context) {
		return (List<GateType>) getOf(context, tdlPackage.eINSTANCE.getGateType());
	}

	public List<Variable> getVariables(EObject context) {
		List<Variable> vars = new LinkedList<Variable>();
		TestDescription td = getTestDescription(context);