(Parameter.class, this, TqclPackage.INSERT__PARAMETERS);
+ }
+ return parameters;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.INSERT__PARAMETERS:
+ return ((InternalEList>)getParameters()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.INSERT__CATEGORY:
+ return getCategory();
+ case TqclPackage.INSERT__ENTITY_CLASS:
+ return getEntityClass();
+ case TqclPackage.INSERT__NAME:
+ return getName();
+ case TqclPackage.INSERT__PARAMETERS:
+ return getParameters();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.INSERT__CATEGORY:
+ setCategory((Category)newValue);
+ return;
+ case TqclPackage.INSERT__ENTITY_CLASS:
+ setEntityClass((String)newValue);
+ return;
+ case TqclPackage.INSERT__NAME:
+ setName((String)newValue);
+ return;
+ case TqclPackage.INSERT__PARAMETERS:
+ getParameters().clear();
+ getParameters().addAll((Collection extends Parameter>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.INSERT__CATEGORY:
+ setCategory(CATEGORY_EDEFAULT);
+ return;
+ case TqclPackage.INSERT__ENTITY_CLASS:
+ setEntityClass(ENTITY_CLASS_EDEFAULT);
+ return;
+ case TqclPackage.INSERT__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ case TqclPackage.INSERT__PARAMETERS:
+ getParameters().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.INSERT__CATEGORY:
+ return category != CATEGORY_EDEFAULT;
+ case TqclPackage.INSERT__ENTITY_CLASS:
+ return ENTITY_CLASS_EDEFAULT == null ? entityClass != null : !ENTITY_CLASS_EDEFAULT.equals(entityClass);
+ case TqclPackage.INSERT__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case TqclPackage.INSERT__PARAMETERS:
+ return parameters != null && !parameters.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String toString()
+ {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (category: ");
+ result.append(category);
+ result.append(", entityClass: ");
+ result.append(entityClass);
+ result.append(", name: ");
+ result.append(name);
+ result.append(')');
+ return result.toString();
+ }
+
+} //InsertImpl
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/LibraryImpl.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/LibraryImpl.java
new file mode 100644
index 00000000..8c0525f4
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/LibraryImpl.java
@@ -0,0 +1,189 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+
+import org.eclipse.triquetrum.commands.tqcl.Library;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+
+/**
+ *
+ * An implementation of the model object 'Library'.
+ *
+ *
+ * The following features are implemented:
+ *
+ *
+ * - {@link org.eclipse.triquetrum.commands.tqcl.impl.LibraryImpl#getName Name}
+ *
+ *
+ * @generated
+ */
+public class LibraryImpl extends MinimalEObjectImpl.Container implements Library
+{
+ /**
+ * The default value of the '{@link #getName() Name}' attribute.
+ *
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() Name}' attribute.
+ *
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected LibraryImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass()
+ {
+ return TqclPackage.Literals.LIBRARY;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setName(String newName)
+ {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TqclPackage.LIBRARY__NAME, oldName, name));
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.LIBRARY__NAME:
+ return getName();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.LIBRARY__NAME:
+ setName((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.LIBRARY__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.LIBRARY__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String toString()
+ {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: ");
+ result.append(name);
+ result.append(')');
+ return result.toString();
+ }
+
+} //LibraryImpl
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/ParameterImpl.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/ParameterImpl.java
new file mode 100644
index 00000000..5bc1333a
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/ParameterImpl.java
@@ -0,0 +1,245 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+
+import org.eclipse.triquetrum.commands.tqcl.Parameter;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+
+/**
+ *
+ * An implementation of the model object 'Parameter'.
+ *
+ *
+ * The following features are implemented:
+ *
+ *
+ * - {@link org.eclipse.triquetrum.commands.tqcl.impl.ParameterImpl#getId Id}
+ * - {@link org.eclipse.triquetrum.commands.tqcl.impl.ParameterImpl#getValue Value}
+ *
+ *
+ * @generated
+ */
+public class ParameterImpl extends MinimalEObjectImpl.Container implements Parameter
+{
+ /**
+ * The default value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected static final String ID_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected String id = ID_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getValue() Value}' attribute.
+ *
+ *
+ * @see #getValue()
+ * @generated
+ * @ordered
+ */
+ protected static final String VALUE_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getValue() Value}' attribute.
+ *
+ *
+ * @see #getValue()
+ * @generated
+ * @ordered
+ */
+ protected String value = VALUE_EDEFAULT;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected ParameterImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass()
+ {
+ return TqclPackage.Literals.PARAMETER;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setId(String newId)
+ {
+ String oldId = id;
+ id = newId;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TqclPackage.PARAMETER__ID, oldId, id));
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setValue(String newValue)
+ {
+ String oldValue = value;
+ value = newValue;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TqclPackage.PARAMETER__VALUE, oldValue, value));
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.PARAMETER__ID:
+ return getId();
+ case TqclPackage.PARAMETER__VALUE:
+ return getValue();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.PARAMETER__ID:
+ setId((String)newValue);
+ return;
+ case TqclPackage.PARAMETER__VALUE:
+ setValue((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.PARAMETER__ID:
+ setId(ID_EDEFAULT);
+ return;
+ case TqclPackage.PARAMETER__VALUE:
+ setValue(VALUE_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.PARAMETER__ID:
+ return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
+ case TqclPackage.PARAMETER__VALUE:
+ return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String toString()
+ {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (id: ");
+ result.append(id);
+ result.append(", value: ");
+ result.append(value);
+ result.append(')');
+ return result.toString();
+ }
+
+} //ParameterImpl
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/SetImpl.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/SetImpl.java
new file mode 100644
index 00000000..cbf39c56
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/SetImpl.java
@@ -0,0 +1,205 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+
+import org.eclipse.triquetrum.commands.tqcl.Parameter;
+import org.eclipse.triquetrum.commands.tqcl.Set;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+
+/**
+ *
+ * An implementation of the model object 'Set'.
+ *
+ *
+ * The following features are implemented:
+ *
+ *
+ * - {@link org.eclipse.triquetrum.commands.tqcl.impl.SetImpl#getParam Param}
+ *
+ *
+ * @generated
+ */
+public class SetImpl extends CommandImpl implements Set
+{
+ /**
+ * The cached value of the '{@link #getParam() Param}' containment reference.
+ *
+ *
+ * @see #getParam()
+ * @generated
+ * @ordered
+ */
+ protected Parameter param;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected SetImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass()
+ {
+ return TqclPackage.Literals.SET;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Parameter getParam()
+ {
+ return param;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public NotificationChain basicSetParam(Parameter newParam, NotificationChain msgs)
+ {
+ Parameter oldParam = param;
+ param = newParam;
+ if (eNotificationRequired())
+ {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TqclPackage.SET__PARAM, oldParam, newParam);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setParam(Parameter newParam)
+ {
+ if (newParam != param)
+ {
+ NotificationChain msgs = null;
+ if (param != null)
+ msgs = ((InternalEObject)param).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TqclPackage.SET__PARAM, null, msgs);
+ if (newParam != null)
+ msgs = ((InternalEObject)newParam).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TqclPackage.SET__PARAM, null, msgs);
+ msgs = basicSetParam(newParam, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TqclPackage.SET__PARAM, newParam, newParam));
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.SET__PARAM:
+ return basicSetParam(null, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.SET__PARAM:
+ return getParam();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.SET__PARAM:
+ setParam((Parameter)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.SET__PARAM:
+ setParam((Parameter)null);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.SET__PARAM:
+ return param != null;
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //SetImpl
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TqclFactoryImpl.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TqclFactoryImpl.java
new file mode 100644
index 00000000..124ae4c7
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TqclFactoryImpl.java
@@ -0,0 +1,295 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.impl;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+import org.eclipse.triquetrum.commands.tqcl.*;
+
+/**
+ *
+ * An implementation of the model Factory.
+ *
+ * @generated
+ */
+public class TqclFactoryImpl extends EFactoryImpl implements TqclFactory
+{
+ /**
+ * Creates the default factory implementation.
+ *
+ *
+ * @generated
+ */
+ public static TqclFactory init()
+ {
+ try
+ {
+ TqclFactory theTqclFactory = (TqclFactory)EPackage.Registry.INSTANCE.getEFactory(TqclPackage.eNS_URI);
+ if (theTqclFactory != null)
+ {
+ return theTqclFactory;
+ }
+ }
+ catch (Exception exception)
+ {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new TqclFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ *
+ *
+ * @generated
+ */
+ public TqclFactoryImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass)
+ {
+ switch (eClass.getClassifierID())
+ {
+ case TqclPackage.TRIQUETRUM_SCRIPT: return createTriquetrumScript();
+ case TqclPackage.COMPOSITE_COMMAND: return createCompositeCommand();
+ case TqclPackage.COMMAND: return createCommand();
+ case TqclPackage.INCLUDE: return createInclude();
+ case TqclPackage.LIBRARY: return createLibrary();
+ case TqclPackage.INSERT: return createInsert();
+ case TqclPackage.SET: return createSet();
+ case TqclPackage.CONNECT: return createConnect();
+ case TqclPackage.CONNECTION_PORT: return createConnectionPort();
+ case TqclPackage.GO: return createGo();
+ case TqclPackage.PARAMETER: return createParameter();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object createFromString(EDataType eDataType, String initialValue)
+ {
+ switch (eDataType.getClassifierID())
+ {
+ case TqclPackage.CATEGORY:
+ return createCategoryFromString(eDataType, initialValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String convertToString(EDataType eDataType, Object instanceValue)
+ {
+ switch (eDataType.getClassifierID())
+ {
+ case TqclPackage.CATEGORY:
+ return convertCategoryToString(eDataType, instanceValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public TriquetrumScript createTriquetrumScript()
+ {
+ TriquetrumScriptImpl triquetrumScript = new TriquetrumScriptImpl();
+ return triquetrumScript;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public CompositeCommand createCompositeCommand()
+ {
+ CompositeCommandImpl compositeCommand = new CompositeCommandImpl();
+ return compositeCommand;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Command createCommand()
+ {
+ CommandImpl command = new CommandImpl();
+ return command;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Include createInclude()
+ {
+ IncludeImpl include = new IncludeImpl();
+ return include;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Library createLibrary()
+ {
+ LibraryImpl library = new LibraryImpl();
+ return library;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Insert createInsert()
+ {
+ InsertImpl insert = new InsertImpl();
+ return insert;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Set createSet()
+ {
+ SetImpl set = new SetImpl();
+ return set;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Connect createConnect()
+ {
+ ConnectImpl connect = new ConnectImpl();
+ return connect;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public ConnectionPort createConnectionPort()
+ {
+ ConnectionPortImpl connectionPort = new ConnectionPortImpl();
+ return connectionPort;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Go createGo()
+ {
+ GoImpl go = new GoImpl();
+ return go;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Parameter createParameter()
+ {
+ ParameterImpl parameter = new ParameterImpl();
+ return parameter;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public Category createCategoryFromString(EDataType eDataType, String initialValue)
+ {
+ Category result = Category.get(initialValue);
+ if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
+ return result;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String convertCategoryToString(EDataType eDataType, Object instanceValue)
+ {
+ return instanceValue == null ? null : instanceValue.toString();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public TqclPackage getTqclPackage()
+ {
+ return (TqclPackage)getEPackage();
+ }
+
+ /**
+ *
+ *
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static TqclPackage getPackage()
+ {
+ return TqclPackage.eINSTANCE;
+ }
+
+} //TqclFactoryImpl
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TqclPackageImpl.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TqclPackageImpl.java
new file mode 100644
index 00000000..ea6cdef2
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TqclPackageImpl.java
@@ -0,0 +1,680 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.impl;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+import org.eclipse.triquetrum.commands.tqcl.Category;
+import org.eclipse.triquetrum.commands.tqcl.Command;
+import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
+import org.eclipse.triquetrum.commands.tqcl.Connect;
+import org.eclipse.triquetrum.commands.tqcl.ConnectionPort;
+import org.eclipse.triquetrum.commands.tqcl.Go;
+import org.eclipse.triquetrum.commands.tqcl.Include;
+import org.eclipse.triquetrum.commands.tqcl.Insert;
+import org.eclipse.triquetrum.commands.tqcl.Library;
+import org.eclipse.triquetrum.commands.tqcl.Parameter;
+import org.eclipse.triquetrum.commands.tqcl.Set;
+import org.eclipse.triquetrum.commands.tqcl.TqclFactory;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+import org.eclipse.triquetrum.commands.tqcl.TriquetrumScript;
+
+/**
+ *
+ * An implementation of the model Package.
+ *
+ * @generated
+ */
+public class TqclPackageImpl extends EPackageImpl implements TqclPackage
+{
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass triquetrumScriptEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass compositeCommandEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass commandEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass includeEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass libraryEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass insertEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass setEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass connectEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass connectionPortEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass goEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass parameterEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EEnum categoryEEnum = null;
+
+ /**
+ * Creates an instance of the model Package, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ *
+ *
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.triquetrum.commands.tqcl.TqclPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private TqclPackageImpl()
+ {
+ super(eNS_URI, TqclFactory.eINSTANCE);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the Package for this model, and for any others upon which it depends.
+ *
+ *
This method is used to initialize {@link TqclPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ *
+ *
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static TqclPackage init()
+ {
+ if (isInited) return (TqclPackage)EPackage.Registry.INSTANCE.getEPackage(TqclPackage.eNS_URI);
+
+ // Obtain or create and register package
+ TqclPackageImpl theTqclPackage = (TqclPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof TqclPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new TqclPackageImpl());
+
+ isInited = true;
+
+ // Create package meta-data objects
+ theTqclPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theTqclPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theTqclPackage.freeze();
+
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(TqclPackage.eNS_URI, theTqclPackage);
+ return theTqclPackage;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getTriquetrumScript()
+ {
+ return triquetrumScriptEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getTriquetrumScript_Libraries()
+ {
+ return (EReference)triquetrumScriptEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getTriquetrumScript_Commands()
+ {
+ return (EReference)triquetrumScriptEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getCompositeCommand()
+ {
+ return compositeCommandEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getCompositeCommand_Start()
+ {
+ return (EReference)compositeCommandEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getCompositeCommand_Commands()
+ {
+ return (EReference)compositeCommandEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getCompositeCommand_End()
+ {
+ return (EReference)compositeCommandEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getCommand()
+ {
+ return commandEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getInclude()
+ {
+ return includeEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getInclude_Filename()
+ {
+ return (EAttribute)includeEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getLibrary()
+ {
+ return libraryEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getLibrary_Name()
+ {
+ return (EAttribute)libraryEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getInsert()
+ {
+ return insertEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getInsert_Category()
+ {
+ return (EAttribute)insertEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getInsert_EntityClass()
+ {
+ return (EAttribute)insertEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getInsert_Name()
+ {
+ return (EAttribute)insertEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getInsert_Parameters()
+ {
+ return (EReference)insertEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getSet()
+ {
+ return setEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getSet_Param()
+ {
+ return (EReference)setEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getConnect()
+ {
+ return connectEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getConnect_From()
+ {
+ return (EReference)connectEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getConnect_To()
+ {
+ return (EReference)connectEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getConnectionPort()
+ {
+ return connectionPortEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getConnectionPort_Actor()
+ {
+ return (EReference)connectionPortEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getConnectionPort_Port()
+ {
+ return (EAttribute)connectionPortEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getGo()
+ {
+ return goEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getGo_Direction()
+ {
+ return (EAttribute)goEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getGo_Actor()
+ {
+ return (EReference)goEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getParameter()
+ {
+ return parameterEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getParameter_Id()
+ {
+ return (EAttribute)parameterEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EAttribute getParameter_Value()
+ {
+ return (EAttribute)parameterEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EEnum getCategory()
+ {
+ return categoryEEnum;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public TqclFactory getTqclFactory()
+ {
+ return (TqclFactory)getEFactoryInstance();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ *
+ *
+ * @generated
+ */
+ public void createPackageContents()
+ {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ triquetrumScriptEClass = createEClass(TRIQUETRUM_SCRIPT);
+ createEReference(triquetrumScriptEClass, TRIQUETRUM_SCRIPT__LIBRARIES);
+ createEReference(triquetrumScriptEClass, TRIQUETRUM_SCRIPT__COMMANDS);
+
+ compositeCommandEClass = createEClass(COMPOSITE_COMMAND);
+ createEReference(compositeCommandEClass, COMPOSITE_COMMAND__START);
+ createEReference(compositeCommandEClass, COMPOSITE_COMMAND__COMMANDS);
+ createEReference(compositeCommandEClass, COMPOSITE_COMMAND__END);
+
+ commandEClass = createEClass(COMMAND);
+
+ includeEClass = createEClass(INCLUDE);
+ createEAttribute(includeEClass, INCLUDE__FILENAME);
+
+ libraryEClass = createEClass(LIBRARY);
+ createEAttribute(libraryEClass, LIBRARY__NAME);
+
+ insertEClass = createEClass(INSERT);
+ createEAttribute(insertEClass, INSERT__CATEGORY);
+ createEAttribute(insertEClass, INSERT__ENTITY_CLASS);
+ createEAttribute(insertEClass, INSERT__NAME);
+ createEReference(insertEClass, INSERT__PARAMETERS);
+
+ setEClass = createEClass(SET);
+ createEReference(setEClass, SET__PARAM);
+
+ connectEClass = createEClass(CONNECT);
+ createEReference(connectEClass, CONNECT__FROM);
+ createEReference(connectEClass, CONNECT__TO);
+
+ connectionPortEClass = createEClass(CONNECTION_PORT);
+ createEReference(connectionPortEClass, CONNECTION_PORT__ACTOR);
+ createEAttribute(connectionPortEClass, CONNECTION_PORT__PORT);
+
+ goEClass = createEClass(GO);
+ createEAttribute(goEClass, GO__DIRECTION);
+ createEReference(goEClass, GO__ACTOR);
+
+ parameterEClass = createEClass(PARAMETER);
+ createEAttribute(parameterEClass, PARAMETER__ID);
+ createEAttribute(parameterEClass, PARAMETER__VALUE);
+
+ // Create enums
+ categoryEEnum = createEEnum(CATEGORY);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ *
+ *
+ * @generated
+ */
+ public void initializePackageContents()
+ {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+ compositeCommandEClass.getESuperTypes().add(this.getCommand());
+ includeEClass.getESuperTypes().add(this.getCommand());
+ insertEClass.getESuperTypes().add(this.getCommand());
+ setEClass.getESuperTypes().add(this.getCommand());
+ connectEClass.getESuperTypes().add(this.getCommand());
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(triquetrumScriptEClass, TriquetrumScript.class, "TriquetrumScript", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getTriquetrumScript_Libraries(), this.getLibrary(), null, "libraries", null, 0, -1, TriquetrumScript.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getTriquetrumScript_Commands(), this.getCommand(), null, "commands", null, 0, -1, TriquetrumScript.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(compositeCommandEClass, CompositeCommand.class, "CompositeCommand", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getCompositeCommand_Start(), this.getGo(), null, "start", null, 0, 1, CompositeCommand.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getCompositeCommand_Commands(), this.getCommand(), null, "commands", null, 0, -1, CompositeCommand.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getCompositeCommand_End(), this.getGo(), null, "end", null, 0, 1, CompositeCommand.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(commandEClass, Command.class, "Command", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+
+ initEClass(includeEClass, Include.class, "Include", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getInclude_Filename(), ecorePackage.getEString(), "filename", null, 0, 1, Include.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(libraryEClass, Library.class, "Library", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getLibrary_Name(), ecorePackage.getEString(), "name", null, 0, 1, Library.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(insertEClass, Insert.class, "Insert", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getInsert_Category(), this.getCategory(), "category", null, 0, 1, Insert.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getInsert_EntityClass(), ecorePackage.getEString(), "entityClass", null, 0, 1, Insert.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getInsert_Name(), ecorePackage.getEString(), "name", null, 0, 1, Insert.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getInsert_Parameters(), this.getParameter(), null, "parameters", null, 0, -1, Insert.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(setEClass, Set.class, "Set", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getSet_Param(), this.getParameter(), null, "param", null, 0, 1, Set.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(connectEClass, Connect.class, "Connect", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getConnect_From(), this.getConnectionPort(), null, "from", null, 0, -1, Connect.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getConnect_To(), this.getConnectionPort(), null, "to", null, 0, -1, Connect.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(connectionPortEClass, ConnectionPort.class, "ConnectionPort", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getConnectionPort_Actor(), this.getInsert(), null, "actor", null, 0, 1, ConnectionPort.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getConnectionPort_Port(), ecorePackage.getEString(), "port", null, 0, 1, ConnectionPort.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(goEClass, Go.class, "Go", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getGo_Direction(), ecorePackage.getEString(), "direction", null, 0, 1, Go.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getGo_Actor(), this.getInsert(), null, "actor", null, 0, 1, Go.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(parameterEClass, Parameter.class, "Parameter", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getParameter_Id(), ecorePackage.getEString(), "id", null, 0, 1, Parameter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getParameter_Value(), ecorePackage.getEString(), "value", null, 0, 1, Parameter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ // Initialize enums and add enum literals
+ initEEnum(categoryEEnum, Category.class, "Category");
+ addEEnumLiteral(categoryEEnum, Category.ACTOR);
+ addEEnumLiteral(categoryEEnum, Category.PARAMETER);
+ addEEnumLiteral(categoryEEnum, Category.PORT);
+ addEEnumLiteral(categoryEEnum, Category.DIRECTOR);
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} //TqclPackageImpl
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TriquetrumScriptImpl.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TriquetrumScriptImpl.java
new file mode 100644
index 00000000..a805ca0d
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/impl/TriquetrumScriptImpl.java
@@ -0,0 +1,218 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.impl;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+import org.eclipse.triquetrum.commands.tqcl.Command;
+import org.eclipse.triquetrum.commands.tqcl.Library;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+import org.eclipse.triquetrum.commands.tqcl.TriquetrumScript;
+
+/**
+ *
+ * An implementation of the model object 'Triquetrum Script'.
+ *
+ *
+ * The following features are implemented:
+ *
+ *
+ * - {@link org.eclipse.triquetrum.commands.tqcl.impl.TriquetrumScriptImpl#getLibraries Libraries}
+ * - {@link org.eclipse.triquetrum.commands.tqcl.impl.TriquetrumScriptImpl#getCommands Commands}
+ *
+ *
+ * @generated
+ */
+public class TriquetrumScriptImpl extends MinimalEObjectImpl.Container implements TriquetrumScript
+{
+ /**
+ * The cached value of the '{@link #getLibraries() Libraries}' containment reference list.
+ *
+ *
+ * @see #getLibraries()
+ * @generated
+ * @ordered
+ */
+ protected EList libraries;
+
+ /**
+ * The cached value of the '{@link #getCommands() Commands}' containment reference list.
+ *
+ *
+ * @see #getCommands()
+ * @generated
+ * @ordered
+ */
+ protected EList commands;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected TriquetrumScriptImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass()
+ {
+ return TqclPackage.Literals.TRIQUETRUM_SCRIPT;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EList getLibraries()
+ {
+ if (libraries == null)
+ {
+ libraries = new EObjectContainmentEList(Library.class, this, TqclPackage.TRIQUETRUM_SCRIPT__LIBRARIES);
+ }
+ return libraries;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EList getCommands()
+ {
+ if (commands == null)
+ {
+ commands = new EObjectContainmentEList(Command.class, this, TqclPackage.TRIQUETRUM_SCRIPT__COMMANDS);
+ }
+ return commands;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.TRIQUETRUM_SCRIPT__LIBRARIES:
+ return ((InternalEList>)getLibraries()).basicRemove(otherEnd, msgs);
+ case TqclPackage.TRIQUETRUM_SCRIPT__COMMANDS:
+ return ((InternalEList>)getCommands()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.TRIQUETRUM_SCRIPT__LIBRARIES:
+ return getLibraries();
+ case TqclPackage.TRIQUETRUM_SCRIPT__COMMANDS:
+ return getCommands();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.TRIQUETRUM_SCRIPT__LIBRARIES:
+ getLibraries().clear();
+ getLibraries().addAll((Collection extends Library>)newValue);
+ return;
+ case TqclPackage.TRIQUETRUM_SCRIPT__COMMANDS:
+ getCommands().clear();
+ getCommands().addAll((Collection extends Command>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.TRIQUETRUM_SCRIPT__LIBRARIES:
+ getLibraries().clear();
+ return;
+ case TqclPackage.TRIQUETRUM_SCRIPT__COMMANDS:
+ getCommands().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case TqclPackage.TRIQUETRUM_SCRIPT__LIBRARIES:
+ return libraries != null && !libraries.isEmpty();
+ case TqclPackage.TRIQUETRUM_SCRIPT__COMMANDS:
+ return commands != null && !commands.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //TriquetrumScriptImpl
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/util/TqclAdapterFactory.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/util/TqclAdapterFactory.java
new file mode 100644
index 00000000..003f941b
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/util/TqclAdapterFactory.java
@@ -0,0 +1,344 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.util;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.triquetrum.commands.tqcl.*;
+
+/**
+ *
+ * The Adapter Factory for the model.
+ * It provides an adapter createXXX
method for each class of the model.
+ *
+ * @see org.eclipse.triquetrum.commands.tqcl.TqclPackage
+ * @generated
+ */
+public class TqclAdapterFactory extends AdapterFactoryImpl
+{
+ /**
+ * The cached model package.
+ *
+ *
+ * @generated
+ */
+ protected static TqclPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ *
+ *
+ * @generated
+ */
+ public TqclAdapterFactory()
+ {
+ if (modelPackage == null)
+ {
+ modelPackage = TqclPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ *
+ * This implementation returns true
if the object is either the model's package or is an instance object of the model.
+ *
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object)
+ {
+ if (object == modelPackage)
+ {
+ return true;
+ }
+ if (object instanceof EObject)
+ {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the createXXX
methods.
+ *
+ *
+ * @generated
+ */
+ protected TqclSwitch modelSwitch =
+ new TqclSwitch()
+ {
+ @Override
+ public Adapter caseTriquetrumScript(TriquetrumScript object)
+ {
+ return createTriquetrumScriptAdapter();
+ }
+ @Override
+ public Adapter caseCompositeCommand(CompositeCommand object)
+ {
+ return createCompositeCommandAdapter();
+ }
+ @Override
+ public Adapter caseCommand(Command object)
+ {
+ return createCommandAdapter();
+ }
+ @Override
+ public Adapter caseInclude(Include object)
+ {
+ return createIncludeAdapter();
+ }
+ @Override
+ public Adapter caseLibrary(Library object)
+ {
+ return createLibraryAdapter();
+ }
+ @Override
+ public Adapter caseInsert(Insert object)
+ {
+ return createInsertAdapter();
+ }
+ @Override
+ public Adapter caseSet(Set object)
+ {
+ return createSetAdapter();
+ }
+ @Override
+ public Adapter caseConnect(Connect object)
+ {
+ return createConnectAdapter();
+ }
+ @Override
+ public Adapter caseConnectionPort(ConnectionPort object)
+ {
+ return createConnectionPortAdapter();
+ }
+ @Override
+ public Adapter caseGo(Go object)
+ {
+ return createGoAdapter();
+ }
+ @Override
+ public Adapter caseParameter(Parameter object)
+ {
+ return createParameterAdapter();
+ }
+ @Override
+ public Adapter defaultCase(EObject object)
+ {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the target
.
+ *
+ *
+ * @param target the object to adapt.
+ * @return the adapter for the target
.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target)
+ {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.TriquetrumScript Triquetrum Script}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.TriquetrumScript
+ * @generated
+ */
+ public Adapter createTriquetrumScriptAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.CompositeCommand Composite Command}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.CompositeCommand
+ * @generated
+ */
+ public Adapter createCompositeCommandAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Command Command}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Command
+ * @generated
+ */
+ public Adapter createCommandAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Include Include}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Include
+ * @generated
+ */
+ public Adapter createIncludeAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Library Library}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Library
+ * @generated
+ */
+ public Adapter createLibraryAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Insert Insert}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Insert
+ * @generated
+ */
+ public Adapter createInsertAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Set Set}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Set
+ * @generated
+ */
+ public Adapter createSetAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Connect Connect}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Connect
+ * @generated
+ */
+ public Adapter createConnectAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.ConnectionPort Connection Port}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.ConnectionPort
+ * @generated
+ */
+ public Adapter createConnectionPortAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Go Go}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Go
+ * @generated
+ */
+ public Adapter createGoAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.triquetrum.commands.tqcl.Parameter Parameter}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.eclipse.triquetrum.commands.tqcl.Parameter
+ * @generated
+ */
+ public Adapter createParameterAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ *
+ * This default implementation returns null.
+ *
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter()
+ {
+ return null;
+ }
+
+} //TqclAdapterFactory
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/util/TqclSwitch.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/util/TqclSwitch.java
new file mode 100644
index 00000000..1a61a44e
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/tqcl/util/TqclSwitch.java
@@ -0,0 +1,366 @@
+/**
+ * ******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ * *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ * ******************************************************************************
+ */
+package org.eclipse.triquetrum.commands.tqcl.util;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.util.Switch;
+
+import org.eclipse.triquetrum.commands.tqcl.*;
+
+/**
+ *
+ * The Switch for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the caseXXX
method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ *
+ * @see org.eclipse.triquetrum.commands.tqcl.TqclPackage
+ * @generated
+ */
+public class TqclSwitch extends Switch
+{
+ /**
+ * The cached model package
+ *
+ *
+ * @generated
+ */
+ protected static TqclPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ *
+ *
+ * @generated
+ */
+ public TqclSwitch()
+ {
+ if (modelPackage == null)
+ {
+ modelPackage = TqclPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Checks whether this is a switch for the given package.
+ *
+ *
+ * @param ePackage the package in question.
+ * @return whether this is a switch for the given package.
+ * @generated
+ */
+ @Override
+ protected boolean isSwitchFor(EPackage ePackage)
+ {
+ return ePackage == modelPackage;
+ }
+
+ /**
+ * Calls caseXXX
for each class of the model until one returns a non null result; it yields that result.
+ *
+ *
+ * @return the first non-null result returned by a caseXXX
call.
+ * @generated
+ */
+ @Override
+ protected T doSwitch(int classifierID, EObject theEObject)
+ {
+ switch (classifierID)
+ {
+ case TqclPackage.TRIQUETRUM_SCRIPT:
+ {
+ TriquetrumScript triquetrumScript = (TriquetrumScript)theEObject;
+ T result = caseTriquetrumScript(triquetrumScript);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.COMPOSITE_COMMAND:
+ {
+ CompositeCommand compositeCommand = (CompositeCommand)theEObject;
+ T result = caseCompositeCommand(compositeCommand);
+ if (result == null) result = caseCommand(compositeCommand);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.COMMAND:
+ {
+ Command command = (Command)theEObject;
+ T result = caseCommand(command);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.INCLUDE:
+ {
+ Include include = (Include)theEObject;
+ T result = caseInclude(include);
+ if (result == null) result = caseCommand(include);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.LIBRARY:
+ {
+ Library library = (Library)theEObject;
+ T result = caseLibrary(library);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.INSERT:
+ {
+ Insert insert = (Insert)theEObject;
+ T result = caseInsert(insert);
+ if (result == null) result = caseCommand(insert);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.SET:
+ {
+ Set set = (Set)theEObject;
+ T result = caseSet(set);
+ if (result == null) result = caseCommand(set);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.CONNECT:
+ {
+ Connect connect = (Connect)theEObject;
+ T result = caseConnect(connect);
+ if (result == null) result = caseCommand(connect);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.CONNECTION_PORT:
+ {
+ ConnectionPort connectionPort = (ConnectionPort)theEObject;
+ T result = caseConnectionPort(connectionPort);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.GO:
+ {
+ Go go = (Go)theEObject;
+ T result = caseGo(go);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TqclPackage.PARAMETER:
+ {
+ Parameter parameter = (Parameter)theEObject;
+ T result = caseParameter(parameter);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ default: return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Triquetrum Script'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Triquetrum Script'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseTriquetrumScript(TriquetrumScript object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Composite Command'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Composite Command'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseCompositeCommand(CompositeCommand object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Command'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Command'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseCommand(Command object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Include'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Include'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseInclude(Include object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Library'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Library'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseLibrary(Library object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Insert'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Insert'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseInsert(Insert object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Set'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Set'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseSet(Set object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Connect'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Connect'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseConnect(Connect object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Connection Port'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Connection Port'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseConnectionPort(ConnectionPort object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Go'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Go'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseGo(Go object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Parameter'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Parameter'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseParameter(Parameter object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'EObject'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'EObject'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ @Override
+ public T defaultCase(EObject object)
+ {
+ return null;
+ }
+
+} //TqclSwitch
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/validation/AbstractTqclValidator.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/validation/AbstractTqclValidator.java
new file mode 100644
index 00000000..d435aef1
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/validation/AbstractTqclValidator.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext 2.10.0
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.validation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.xtext.validation.AbstractDeclarativeValidator;
+
+public abstract class AbstractTqclValidator extends AbstractDeclarativeValidator {
+
+ @Override
+ protected List getEPackages() {
+ List result = new ArrayList();
+ result.add(org.eclipse.triquetrum.commands.tqcl.TqclPackage.eINSTANCE);
+ return result;
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/GenerateTqcl.mwe2 b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/GenerateTqcl.mwe2
new file mode 100644
index 00000000..b1ee122b
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/GenerateTqcl.mwe2
@@ -0,0 +1,132 @@
+module org.eclipse.triquetrum.commands.GenerateTqcl
+
+import org.eclipse.xtext.xtext.generator.*
+import org.eclipse.xtext.xtext.generator.model.project.*
+
+var rootPath = ".."
+var basename = "org.eclipse.triquetrum.commands.xtext"
+
+Workflow {
+
+// component = org.eclipse.emf.mwe.utils.DirectoryCleaner
+// {
+// directory = ""
+// }
+
+ bean = org.eclipse.emf.mwe.utils.StandaloneSetup
+ {
+ platformUri = "${rootPath}"
+ scanClassPath = true
+ registerGeneratedEPackage = "org.eclipse.triquetrum.workflow.model.TriqPackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.triquetrum.workflow.model/model/triquetrum.genmodel"
+ }
+ component = XtextGenerator {
+ cleaner = {
+ enabled = true
+
+ }
+
+ configuration = {
+ project = StandardProjectConfig {
+ baseName = "${basename}"
+ rootPath = rootPath
+ runtimeTest = {
+ name ="${basename}.tests"
+ enabled = true
+ src = "../${basename}.tests/src/test/java"
+ srcGen = "../${basename}.tests/src/test/java-gen"
+ }
+ runtime = {
+ src = "src/main/java"
+ srcGen = "src/main/java-gen"
+ }
+ eclipsePlugin = {
+ name ="${basename}.ui"
+ enabled = true
+ src = "../${basename}.ui/src/main/java"
+ srcGen = "../${basename}.ui/src/main/java-gen"
+ }
+
+ eclipsePluginTest = {
+ name ="${basename}.ui.tests"
+ enabled = false
+ src = "../${basename}.ui.tests/src/test/java"
+ srcGen = "../${basename}.ui.tests/src/test/java-gen"
+ }
+ genericIde = {
+ enabled = true
+ name ="${basename}.ide"
+ src = "../${basename}.ide/src/main/java"
+ srcGen = "../${basename}.ide/src/main/java-gen"
+ }
+
+ createEclipseMetaData = true
+
+
+ }
+
+ code = {
+ encoding = "UTF-8"
+ fileHeader = "/*******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * generated by Xtext \${version}
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/"
+ }
+ }
+
+
+
+ language = StandardLanguage {
+ name = "org.eclipse.triquetrum.commands.Tqcl"
+ fileExtensions = "tqcl"
+ emfGenerator = {
+ javaModelDirectory = "org.eclipse.triquetrum.commands.xtext/src/main/java-gen"
+
+ }
+
+ referencedResource ="platform:/resource/org.eclipse.triquetrum.workflow.model/model/triquetrum.genmodel"
+
+
+
+ generator = generator.GeneratorFragment2 {
+ generateStub = true
+ generateXtendStub = false
+ }
+
+ serializer = {
+ generateStub = true
+ generateXtendStub = false
+ }
+
+ validator = {
+ // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
+ generateStub = true
+ generateXtendStub = false
+ }
+
+ scopeProvider = {
+ generateStub = true
+ generateXtendStub = false
+ }
+
+ generateXtendStubs = false
+
+ contentAssist=
+ {
+ generateStub=true
+ generateXtendStub=false
+ }
+
+
+
+ }
+ }
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/Tqcl.xtext b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/Tqcl.xtext
new file mode 100644
index 00000000..1e1a509a
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/Tqcl.xtext
@@ -0,0 +1,91 @@
+grammar org.eclipse.triquetrum.commands.Tqcl with org.eclipse.xtext.common.Terminals
+
+generate tqcl "http://www.eclipse.org/triquetrum/commands/Tqcl"
+
+TriquetrumScript:
+ libraries+=Library*
+ commands+=Command*
+;
+
+CompositeCommand:
+ start = GoInto commands+=Command* (end = (GoOut|GoTop))
+;
+
+SimpleCommand returns Command:
+ (Insert|Connect|Set|Include)";"
+;
+
+Command returns Command:
+ SimpleCommand|CompositeCommand
+;
+
+
+
+Include:
+ "include" filename=STRING ";"
+;
+
+Library:
+ "library" name=ID ";"
+;
+
+
+Insert:
+ "insert" (category=Category)? entityClass=ENTITY_CLASS 'as' name=STRING ("with" parameters+=(Parameter) ("," parameters+=Parameter)*)? ;
+
+Set:
+ "set" param = Parameter
+;
+
+Connect:
+ "connect" from+=ConnectionPort(',' from+=ConnectionPort)* "to" to+=ConnectionPort(',' to+=ConnectionPort)*;
+
+ConnectionPort:
+ actor=[Insert] '.' port=NamedObj;
+
+GoInto returns Go:
+ "go" direction="into" actor = [Insert]
+;
+
+
+GoOut returns Go:
+ "go" direction="out"
+;
+
+GoTop returns Go:
+ "go" direction="top"
+;
+
+enum Category:
+ actor | parameter | port | director;
+
+Parameter:
+ id=Parameter_id "=" value=STRING;
+
+Parameter_id:
+ PARAMETER_NAME|STRING
+;
+
+terminal PARAMETER_NAME:
+ '$'('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
+;
+
+NamedObj:
+ (ID | STRING)
+ ;
+
+terminal ENTITY_CLASS:
+ ('<'->'>')
+;
+
+
+//terminal fragment ESCAPED_CHAR:
+// '\\' ('n'|'t'|'r'|'\\');
+
+//terminal ENTITY_INSTANCE_NAME: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|ESCAPED_CHAR)*;
+
+
+
+
+
+
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclRuntimeModule.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclRuntimeModule.java
new file mode 100644
index 00000000..29535b3a
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclRuntimeModule.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands;
+
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+
+/**
+ * Use this class to register components to be used at runtime / without the Equinox extension registry.
+ */
+public class TqclRuntimeModule extends AbstractTqclRuntimeModule {
+
+ @Override
+ public Class extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
+ return org.eclipse.triquetrum.commands.scoping.TqclQualifiedNameProvider.class;
+ }
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclStandaloneSetup.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclStandaloneSetup.java
new file mode 100644
index 00000000..15c686bc
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclStandaloneSetup.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands;
+
+
+/**
+ * Initialization support for running Xtext languages without Equinox extension registry.
+ */
+public class TqclStandaloneSetup extends TqclStandaloneSetupGenerated {
+
+ public static void doSetup() {
+ new TqclStandaloneSetup().createInjectorAndDoEMFRegistration();
+ }
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/generator/TqclGenerator.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/generator/TqclGenerator.java
new file mode 100644
index 00000000..380f3ed5
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/generator/TqclGenerator.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/*
+ * generated by Xtext 2.10.0
+ */
+package org.eclipse.triquetrum.commands.generator;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.generator.AbstractGenerator;
+import org.eclipse.xtext.generator.IFileSystemAccess2;
+import org.eclipse.xtext.generator.IGeneratorContext;
+
+/**
+ * Generates code from your model files on save.
+ *
+ * See
+ * https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
+ */
+public class TqclGenerator extends AbstractGenerator {
+
+ @Override
+ public void doGenerate(Resource arg0, IFileSystemAccess2 arg1, IGeneratorContext arg2) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/CompositeCommandInterpreterComponent.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/CompositeCommandInterpreterComponent.java
new file mode 100644
index 00000000..2c5416c6
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/CompositeCommandInterpreterComponent.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.tqcl.Command;
+import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
+import org.eclipse.triquetrum.commands.tqcl.Go;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+
+/**
+ * Interpreter component for {@link CompositeCommand}
+ * @author rtotaro
+ */
+public class CompositeCommandInterpreterComponent implements TqclInterpreterComponent {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void interpret(EObject element, InterpretContext context) {
+ if (element instanceof CompositeCommand) {
+ CompositeCommand compositeCommand = (CompositeCommand) element;
+ context.getInterpreter().interpret(compositeCommand.getStart(),context);
+ for (Command command : compositeCommand.getCommands()) {
+ context.getInterpreter().interpret(command,context);
+ }
+ Go end = compositeCommand.getEnd();
+ if(end!=null)
+ {
+ context.getInterpreter().interpret(end,context);
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
+ */
+ @Override
+ public List intepretedEClasses() {
+ return Arrays.asList(TqclPackage.Literals.COMPOSITE_COMMAND);
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/ConnectInterpreterComponent.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/ConnectInterpreterComponent.java
new file mode 100644
index 00000000..cf8303aa
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/ConnectInterpreterComponent.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
+import org.eclipse.triquetrum.commands.tqcl.Connect;
+import org.eclipse.triquetrum.commands.tqcl.ConnectionPort;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+
+/**
+ * Interpreter component for {@link Connect}
+ * @author rtotaro
+ */
+public class ConnectInterpreterComponent implements TqclInterpreterComponent {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
+ */
+ @Override
+ public void interpret(EObject element, InterpretContext context) {
+ if (element instanceof Connect) {
+ Connect connect = (Connect) element;
+ EList from = connect.getFrom();
+ EList to = connect.getTo();
+ for (ConnectionPort connectionPortFrom : from) {
+ for (ConnectionPort connectionPortTo : to) {
+ context.getModelBuilderService().connect(context.getCurrentActor(),createPortPath(connectionPortFrom),createPortPath(connectionPortTo));
+ }
+ }
+
+ }
+
+ }
+
+ /**
+ * @param port
+ * @return
+ */
+ private String createPortPath(ConnectionPort port) {
+ return port.getActor().getName()+"."+port.getPort();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
+ */
+ @Override
+ public List intepretedEClasses() {
+ return Arrays.asList(TqclPackage.Literals.CONNECT);
+ }
+
+}
+
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/GoInterpreterComponent.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/GoInterpreterComponent.java
new file mode 100644
index 00000000..cb38bce8
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/GoInterpreterComponent.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
+import org.eclipse.triquetrum.commands.tqcl.Go;
+import org.eclipse.triquetrum.commands.tqcl.Insert;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+
+/**
+ * Interpreter component for {@link Go}
+ * @author rtotaro
+ */
+public class GoInterpreterComponent implements TqclInterpreterComponent {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void interpret(EObject element, InterpretContext context) {
+ if (element instanceof Go) {
+ Go go = (Go) element;
+ String direction = go.getDirection();
+
+ switch (direction) {
+ case "into":
+ Insert actor = go.getActor();
+ String name = actor.getName();
+ context.setCurrentActor(context.getModelBuilderService().getChild(context.getCurrentActor(),name));
+ break;
+ case "out":
+ context.setCurrentActor(context.getModelBuilderService().getParent(context.getCurrentActor()));
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
+ */
+ @Override
+ public List intepretedEClasses() {
+ return Arrays.asList(TqclPackage.Literals.GO);
+ }
+
+}
+
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java
new file mode 100644
index 00000000..16c0cd14
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.api.services.TcQLException;
+import org.eclipse.triquetrum.commands.tqcl.Category;
+import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
+import org.eclipse.triquetrum.commands.tqcl.Insert;
+import org.eclipse.triquetrum.commands.tqcl.Parameter;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+import org.eclipse.triquetrum.commands.validation.TqCLUtils;
+
+/**
+ * Interpreter component for {@link Insert}
+ * @author rtotaro
+ */
+public class InsertInterpreterComponent implements TqclInterpreterComponent {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void interpret(EObject element, InterpretContext context) {
+ if (element instanceof Insert) {
+ Insert insert = (Insert) element;
+ Category category = insert.getCategory();
+ String entityClass = TqCLUtils.cleanEntityClassName(insert.getEntityClass());
+ String name = insert.getName();
+ Map params = extractParameterMap(insert);
+ switch (category) {
+ case ACTOR:
+ context.getModelBuilderService().insertActor(context.getCurrentActor(), name, entityClass, params);
+ break;
+ case DIRECTOR:
+ context.getModelBuilderService().insertDirector(context.getCurrentActor(), name, entityClass, params);
+ break;
+ case PARAMETER:
+ context.getModelBuilderService().insertParameter(context.getCurrentActor(), name, entityClass, params);
+ break;
+ case PORT:
+ context.getModelBuilderService().insertPort(context.getCurrentActor(), name, entityClass, params);
+ break;
+ }
+
+ }
+ }
+
+ private Map extractParameterMap(Insert insert) {
+ Map params = new HashMap<>();
+ for (Parameter parameter : insert.getParameters()) {
+ params.put(TqCLUtils.cleanParameterName(parameter.getId()), parameter.getValue());
+ }
+ return params;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
+ */
+ @Override
+ public List intepretedEClasses() {
+ return Arrays.asList(TqclPackage.Literals.INSERT);
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InterpretContext.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InterpretContext.java
new file mode 100644
index 00000000..ca9f5e86
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InterpretContext.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import org.eclipse.triquetrum.commands.api.services.ModelBuilderService;
+
+
+/**
+ * Object that contains the result of interpretation
+ *
+ * @author rtotaro
+ *
+ * @param class used to represent the composite actor
+ * @param class used to represent the simple actor
+ */
+public class InterpretContext {
+
+ private ModelBuilderService modelBuilderService;
+
+ private TqclInterpreter interpreter;
+
+ private CompositeActor model;
+
+ private Actor currentActor;
+
+ /**
+ * @param interpreter is used by interpreter component
+ * @param model root of the model to interpret
+ * @param modelBuilderService is used to build the model
+ */
+ public InterpretContext(TqclInterpreter interpreter,CompositeActor model,ModelBuilderService modelBuilderService) {
+ super();
+ this.interpreter = interpreter;
+ this.model = model;
+ this.currentActor = (Actor) model;
+ this.modelBuilderService = modelBuilderService;
+ }
+
+ public TqclInterpreter getInterpreter() {
+ return interpreter;
+ }
+
+ public ModelBuilderService getModelBuilderService() {
+ return modelBuilderService;
+ }
+ public CompositeActor getModel() {
+ return model;
+ }
+
+ public Actor getCurrentActor() {
+ return currentActor;
+ }
+
+ /**
+ * Is used to set the current level in the actor hierarchy
+ * Could be also a simple actor for adding ports or parameters
+ * @param currentActor
+ */
+ public void setCurrentActor(Actor currentActor) {
+ this.currentActor = currentActor;
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java
new file mode 100644
index 00000000..d4ec7ab8
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.triquetrum.commands.TqclStandaloneSetup;
+import org.eclipse.triquetrum.commands.api.TqCLServices;
+import org.eclipse.triquetrum.commands.api.services.ModelBuilderService;
+import org.eclipse.xtext.linking.lazy.LazyLinkingResource;
+import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.parser.IParseResult;
+import org.eclipse.xtext.resource.IResourceFactory;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.util.CancelIndicator;
+import org.eclipse.xtext.validation.IConcreteSyntaxDiagnosticProvider.IConcreteSyntaxDiagnostic;
+import org.eclipse.xtext.validation.IConcreteSyntaxValidator.IDiagnosticAcceptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Injector;
+
+import ptolemy.util.StringUtilities;
+
+/**
+ * The TqCL interpreter, the type of the result is related to the {@link ModelBuilderService} set in the {@link InterpretContext}
+ * @author rtotaro
+ *
+ * @param class used to represent the composite actor
+ * @param class used to represent the simple acto
+ */
+public class TqclInterpreter {
+
+ private static Map components = new HashMap<>();
+ private final static Logger LOGGER = LoggerFactory.getLogger(TqclInterpreter.class);
+
+ static
+ {
+ addComponent(new TriquetrumScriptInterpreterComponent());
+ addComponent(new InsertInterpreterComponent());
+ addComponent(new GoInterpreterComponent());
+ addComponent(new CompositeCommandInterpreterComponent());
+ addComponent(new ConnectInterpreterComponent());
+ }
+
+
+
+ private static void addComponent(TqclInterpreterComponent component){
+ for (EClass eClass : component.intepretedEClasses()) {
+ components.put(eClass, component);
+ }
+ }
+
+ /**
+ * Interpreter the TqCL script
+ *
+ * @param modelName the name of the result model
+ * @param script to interpret
+ * @param uri parent directory of the script
+ * @param modelClass result class, is used to select the right {@link ModelBuilderService}
+ * @return
+ */
+ public CompositeActor interpret(String modelName,InputStream script, java.net.URI uri,Class> modelClass) {
+ try {
+ Injector injector = new TqclStandaloneSetup().createInjectorAndDoEMFRegistration();
+ IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
+
+ XtextResource resource = (XtextResource) resourceFactory.createResource(URI.createURI(uri.getPath()+"/"+modelName));
+ resource.load(script, null);
+ IParseResult parseResult = resource.getParseResult();
+
+ if(parseResult.hasSyntaxErrors()){
+ Iterable syntaxErrors = parseResult.getSyntaxErrors();
+ //TODO: log them
+ }
+
+ if (resource instanceof LazyLinkingResource) {
+ LazyLinkingResource lazyLinkingResource = (LazyLinkingResource) resource;
+ lazyLinkingResource.resolveLazyCrossReferences(CancelIndicator.NullImpl);
+ }
+ else
+ {
+ EcoreUtil.resolveAll(resource);
+ }
+ EObject root = parseResult.getRootASTElement();
+
+ resource.getConcreteSyntaxValidator().validateRecursive(root, new IDiagnosticAcceptor()
+ {
+ @Override
+ public void accept(IConcreteSyntaxDiagnostic arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ }, Collections.EMPTY_MAP);
+
+ ModelBuilderService modelBuilderService = TqCLServices.getInstance().getModelBuilderService(modelClass);
+ CompositeActor model = modelBuilderService.createNewModel(StringUtils.removeEnd(modelName, ".tqcl"), uri.toString());
+
+ interpret(root, new InterpretContext(this,model,modelBuilderService));
+
+ return model;
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ void interpret(EObject element, InterpretContext context)
+ {
+ components.get(element.eClass()).interpret(element, context);
+ }
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreterComponent.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreterComponent.java
new file mode 100644
index 00000000..fec368f7
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreterComponent.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Interface implements by interpreter components. Each component interpret one
+ * or more syntax structure
+ *
+ * @author rtotaro
+ *
+ */
+public interface TqclInterpreterComponent {
+
+ /**
+ * Interpret the element adding result to the context
+ *
+ * @param element
+ * @param context
+ */
+ @SuppressWarnings("rawtypes")
+ void interpret(EObject element, InterpretContext context);
+
+ /**
+ * Interpreted EClasses, this information is used to choose which component
+ * call during interpretation. An EClass can be interpreted by only one
+ * component
+ *
+ * @return the list of interpreted classes
+ */
+ List intepretedEClasses();
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TriquetrumScriptInterpreterComponent.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TriquetrumScriptInterpreterComponent.java
new file mode 100644
index 00000000..783652e8
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TriquetrumScriptInterpreterComponent.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.interpreter;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.tqcl.Command;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+import org.eclipse.triquetrum.commands.tqcl.TriquetrumScript;
+
+/**
+ * Interpreter component for {@link TriquetrumScript}
+ * @author rtotaro
+ *
+ */
+public class TriquetrumScriptInterpreterComponent implements TqclInterpreterComponent {
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void interpret(EObject element, InterpretContext context) {
+ if (element instanceof TriquetrumScript) {
+ TriquetrumScript script = (TriquetrumScript) element;
+ EList commands = script.getCommands();
+
+ for (Command command : commands) {
+ context.getInterpreter().interpret(command, context);
+ }
+ }
+ }
+
+ @Override
+ public List intepretedEClasses() {
+ return Arrays.asList(TqclPackage.Literals.TRIQUETRUM_SCRIPT);
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/scoping/TqclQualifiedNameProvider.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/scoping/TqclQualifiedNameProvider.java
new file mode 100644
index 00000000..45040acc
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/scoping/TqclQualifiedNameProvider.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.scoping;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.tqcl.Insert;
+import org.eclipse.triquetrum.commands.validation.TqCLUtils;
+import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+
+public class TqclQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {
+
+ @Override
+ public QualifiedName apply(EObject eObject) {
+// if (eObject instanceof Insert) {
+// return getFullyQualifiedName(eObject);
+// }
+ return super.apply(eObject);
+ }
+
+ @Override
+ public QualifiedName getFullyQualifiedName(EObject eObject) {
+// if (eObject instanceof Insert) {
+// Insert insert = (Insert) eObject;
+// return QualifiedName.create(TqCLUtils.cleanEntityName(insert.getName()));
+// }
+ return super.getFullyQualifiedName(eObject);
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/scoping/TqclScopeProvider.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/scoping/TqclScopeProvider.java
new file mode 100644
index 00000000..92cbdf01
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/scoping/TqclScopeProvider.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/*
+ * generated by Xtext 2.10.0
+ */
+package org.eclipse.triquetrum.commands.scoping;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.triquetrum.commands.tqcl.Category;
+import org.eclipse.triquetrum.commands.tqcl.Connect;
+import org.eclipse.triquetrum.commands.tqcl.Go;
+import org.eclipse.triquetrum.commands.tqcl.Insert;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.scoping.IScope;
+import org.eclipse.xtext.scoping.Scopes;
+import org.eclipse.xtext.scoping.impl.FilteringScope;
+
+import com.google.common.base.Predicate;
+
+/**
+ * This class contains custom scoping description.
+ *
+ * See
+ * https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping
+ * on how and when to use it.
+ */
+public class TqclScopeProvider extends AbstractTqclScopeProvider {
+
+ private Predicate actorInsertPredicate = new Predicate() {
+
+ @Override
+ public boolean apply(IEObjectDescription objectDescription) {
+ EObject eObjectOrProxy = objectDescription.getEObjectOrProxy();
+ if (eObjectOrProxy instanceof Insert) {
+ Insert insert = (Insert) eObjectOrProxy;
+ return Category.ACTOR.equals(insert.getCategory());
+ }
+ return false;
+ }
+ };
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xtext.scoping.impl.DelegatingScopeProvider#getScope(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EReference)
+ */
+ @Override
+ public IScope getScope(EObject context, EReference reference) {
+ if (context instanceof Go && reference == TqclPackage.Literals.GO__ACTOR) {
+ EObject eContainer = context.eContainer().eContainer();
+ Iterable candidates = EcoreUtil2.getAllContentsOfType(eContainer, Insert.class);
+ IScope scope = Scopes.scopeFor(candidates);
+ return new FilteringScope(scope, actorInsertPredicate);
+ }
+ if (context instanceof Connect && reference == TqclPackage.Literals.CONNECTION_PORT__ACTOR) {
+ // Collect a list of candidates by going through the model
+ // EcoreUtil2 provides useful functionality to do that
+ // For example searching for all elements within the root Object's
+ // tree
+ EObject rootElement = context.eContainer();
+ Iterable candidates = EcoreUtil2.getAllContentsOfType(rootElement, Insert.class);
+ // Create IEObjectDescriptions and puts them into an IScope instance
+ IScope scope = Scopes.scopeFor(candidates);
+ return new FilteringScope(scope, actorInsertPredicate);
+
+ }
+ return super.getScope(context, reference);
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/serializer/TqclSemanticSequencer.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/serializer/TqclSemanticSequencer.java
new file mode 100644
index 00000000..e2d37c3d
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/serializer/TqclSemanticSequencer.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/*
+ * generated by Xtext 2.10.0
+ */
+package org.eclipse.triquetrum.commands.serializer;
+
+
+public class TqclSemanticSequencer extends AbstractTqclSemanticSequencer {
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/serializer/TqclSyntacticSequencer.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/serializer/TqclSyntacticSequencer.java
new file mode 100644
index 00000000..379d7d12
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/serializer/TqclSyntacticSequencer.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/*
+ * generated by Xtext 2.10.0
+ */
+package org.eclipse.triquetrum.commands.serializer;
+
+
+public class TqclSyntacticSequencer extends AbstractTqclSyntacticSequencer {
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/validation/TqCLUtils.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/validation/TqCLUtils.java
new file mode 100644
index 00000000..5c31db67
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/validation/TqCLUtils.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.triquetrum.commands.validation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.api.TqCLServices;
+import org.eclipse.triquetrum.commands.api.services.PortDescriptor;
+import org.eclipse.triquetrum.commands.api.services.TqCLLibraryException;
+import org.eclipse.triquetrum.commands.tqcl.Category;
+import org.eclipse.triquetrum.commands.tqcl.Command;
+import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
+import org.eclipse.triquetrum.commands.tqcl.Insert;
+import org.eclipse.triquetrum.commands.tqcl.Parameter;
+import org.eclipse.xtext.EcoreUtil2;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
+/**
+ * Utils class to clean qualified name used in tqcl and create valid name for ptolemy models
+ * @author rtotaro
+ *
+ */
+public class TqCLUtils {
+
+ public static String cleanEntityName(String entityClass) {
+ return entityClass.substring(1, entityClass.lastIndexOf('>'));
+ }
+
+ public static Category getCategory(Insert insert) {
+ Category category = insert.getCategory();
+ if (category == null) {
+ category = Category.ACTOR;
+ }
+ return category;
+ }
+
+ public static String cleanParameterName(String id) {
+
+ if (id.startsWith("$")) {
+ return id.substring(1);
+ } else if (id.startsWith("\"")) {
+ return id.substring(1, id.lastIndexOf('"'));
+ }
+
+ // TODO : throw exception???
+ return null;
+ }
+
+ public static String createEditorEntityName(String entityName) {
+ return entityName.contains(" ") ? ("\"" + entityName + "\"") : entityName;
+
+ }
+
+ public static String getParameterValueByName(Insert insert, String parameterName) {
+ EList parameters = insert.getParameters();
+ for (Parameter parameter : parameters) {
+ if (parameterName.equals(cleanParameterName(parameter.getId()))) {
+ return parameter.getValue();
+ }
+ }
+
+ return null;
+ }
+
+ public static List getActorInsertPorts(Insert actor,final boolean input,final boolean output) {
+ String actorClass = actor.getEntityClass();
+ List actorPorts = new ArrayList<>();
+ try {
+ List candidateLibraryPorts = TqCLServices.getInstance().getTqclLibraryProvider()
+ .getActorPorts(TqCLUtils.cleanEntityName(actorClass));
+
+ actorPorts.addAll(Collections2.filter(candidateLibraryPorts,new Predicate() {
+ @Override
+ public boolean apply(PortDescriptor candidatePort) {
+ return (candidatePort.isInput()&&input)||(candidatePort.isOutput()&&output);
+ }
+ }));
+
+ fillDeclaredPorts(actor, actorPorts,input,output);
+
+
+ } catch (TqCLLibraryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return actorPorts;
+ }
+
+ private static void fillDeclaredPorts(Insert actor, List actorPorts, boolean input, boolean output) {
+ EObject actorContainer = actor.eContainer();
+ List compositeCommands = EcoreUtil2.getAllContentsOfType(actorContainer,
+ CompositeCommand.class);
+ Collection filteredCompositeCommand = Collections2.filter(compositeCommands,
+ new Predicate() {
+ @Override
+ public boolean apply(CompositeCommand compositeCommand) {
+ return compositeCommand.getStart().getActor().getName().equals(actor.getName());
+ }
+ });
+
+ for (CompositeCommand compositeCommand : filteredCompositeCommand) {
+ EList commands = compositeCommand.getCommands();
+ for (Command command : commands) {
+ if (command instanceof Insert) {
+ Insert insert = (Insert) command;
+ if (Category.PORT.equals(insert.getCategory())) {
+ Boolean inputPort = Boolean.parseBoolean(TqCLUtils.getParameterValueByName(insert, "input"));
+ Boolean outputPort = Boolean.parseBoolean(TqCLUtils.getParameterValueByName(insert, "output"));
+
+ if ((input && inputPort) || (output && outputPort)) {
+ actorPorts.add(new PortDescriptor("script", insert.getName(),
+ TqCLUtils.cleanEntityName(insert.getEntityClass()), null,inputPort,outputPort));
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ public static String cleanEntityClassName(String entityClass) {
+ return entityClass.substring(1, entityClass.lastIndexOf('>'));
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/validation/TqclValidator.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/validation/TqclValidator.java
new file mode 100644
index 00000000..d66339c6
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/validation/TqclValidator.java
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/*
+ * generated by Xtext 2.10.0
+ */
+package org.eclipse.triquetrum.commands.validation;
+
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.triquetrum.commands.api.TqCLServices;
+import org.eclipse.triquetrum.commands.api.services.EntityDescriptor;
+import org.eclipse.triquetrum.commands.api.services.ParameterDescriptor;
+import org.eclipse.triquetrum.commands.api.services.PortDescriptor;
+import org.eclipse.triquetrum.commands.api.services.TqCLLibraryException;
+import org.eclipse.triquetrum.commands.api.services.TqCLLibraryProvider;
+import org.eclipse.triquetrum.commands.tqcl.Category;
+import org.eclipse.triquetrum.commands.tqcl.Connect;
+import org.eclipse.triquetrum.commands.tqcl.ConnectionPort;
+import org.eclipse.triquetrum.commands.tqcl.Insert;
+import org.eclipse.triquetrum.commands.tqcl.Library;
+import org.eclipse.triquetrum.commands.tqcl.Parameter;
+import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.validation.Check;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+
+/**
+ * This class contains custom validation rules.
+ *
+ * See
+ * https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
+ */
+public class TqclValidator extends AbstractTqclValidator {
+
+ public static final String INVALID_ENTITY_CLASS = "invalidEntityClass";
+
+ public static final String INVALID_LIBRARY = "invalidLibrary";
+
+ public static final String INVALID_PARAMETER = "invalidParameter";
+
+ public static final String DUPLICATED_ENTITY_NAME = "duplicatedEntityName";
+
+ public static final String INVALID_PORT_NAME = "invalidPortName";
+
+ /**
+ * Check that the library is supported by a {@link TqCLLibraryProvider}
+ * @param library
+ */
+ @Check
+ public void checkLibrary(Library library) {
+ String name = library.getName();
+ Set libraryNames = TqCLServices.getInstance().getTqclLibraryProvider().getLibraryNames();
+ if (!libraryNames.contains(name)) {
+ warning("Invalid Library Name", TqclPackage.Literals.LIBRARY__NAME, INVALID_LIBRARY);
+ }
+ }
+
+ /**
+ * Check that entity exists in the imported libraries
+ * @param library
+ */
+ @Check
+ public void checkEntityInLibrary(Insert insert) {
+ String entityClass = TqCLUtils.cleanEntityClassName(insert.getEntityClass());
+ List libraries = EcoreUtil2.getAllContentsOfType(EcoreUtil2.getRootContainer(insert), Library.class);
+ for (Library library : libraries) {
+ String libraryName = library.getName();
+ TqCLLibraryProvider tqclLibraryProvider = TqCLServices.getInstance().getTqclLibraryProvider();
+ if (tqclLibraryProvider.hasElementInLibrary(entityClass, libraryName, insert.getCategory().getName())) {
+ return;
+ }
+
+ }
+ String message = MessageFormat.format("Entity class {0} not found in imported library", entityClass);
+ error(message, TqclPackage.Literals.INSERT__ENTITY_CLASS, INVALID_ENTITY_CLASS);
+ }
+
+ /**
+ * Check that the name used for model element is an unique identifier
+ * @param insert
+ */
+ @Check
+ public void checkNameUnique(Insert insert) {
+ String name = insert.getName();
+ EObject rootContainer = EcoreUtil2.getRootContainer(insert);
+ TreeIterator eAllContents = rootContainer.eAllContents();
+ while (eAllContents.hasNext()) {
+ EObject eObject = (EObject) eAllContents.next();
+ if (eObject instanceof Insert) {
+ Insert otherInsert = (Insert) eObject;
+ if (otherInsert != insert) {
+ if (otherInsert.getName().equals(name)) {
+ error("Duplicated entity name", TqclPackage.Literals.INSERT__NAME, DUPLICATED_ENTITY_NAME);
+ }
+ }
+
+ }
+ }
+ }
+
+ /**
+ * Check that the ports to connect already exist in the model
+ * @param connectionPort
+ */
+ @Check
+ public void checkConnectionPortName(ConnectionPort connectionPort) {
+ String featureName = connectionPort.eContainmentFeature().getName();
+ if(featureName.equals(TqclPackage.Literals.CONNECT__FROM.getName()))
+ {
+ checkPortName(connectionPort,false,true);
+
+ }
+ if(featureName.equals(TqclPackage.Literals.CONNECT__TO.getName()))
+ {
+ checkPortName(connectionPort,true,false);
+ }
+
+ }
+
+ private void checkPortName(ConnectionPort connectionPort,boolean input,boolean output) {
+ List actorInsertPorts = TqCLUtils.getActorInsertPorts(connectionPort.getActor(), input,
+ output);
+ Collection portNames = Collections2.transform(actorInsertPorts,
+ new Function() {
+ @Override
+ public String apply(PortDescriptor portDescriptor) {
+ return portDescriptor.getDisplayName();
+ }
+ });
+
+ String portToCheck = connectionPort.getPort();
+ if (!portNames.contains(portToCheck)) {
+ if(input)
+ {
+ error("Invalid input port name", TqclPackage.Literals.CONNECTION_PORT__PORT, INVALID_PORT_NAME);
+ }
+ else if(output)
+ {
+ error("Invalid output port name", TqclPackage.Literals.CONNECTION_PORT__PORT, INVALID_PORT_NAME);
+ }
+ else
+ {
+ error("Invalidport name", TqclPackage.Literals.CONNECTION_PORT__PORT, INVALID_PORT_NAME);
+ }
+ }
+ }
+
+ /**
+ * Check that the used parameter exists for the inserted actor
+ * @param insert
+ */
+ @Check
+ public void checkEntityParameters(Insert insert) {
+ TqCLLibraryProvider tqclLibraryProvider = TqCLServices.getInstance().getTqclLibraryProvider();
+ EList eContents = insert.eContainer().eContents();
+ for (EObject eObject : eContents) {
+ if (eObject instanceof Library) {
+ Library library = (Library) eObject;
+ try {
+ Category category = TqCLUtils.getCategory(insert);
+ String entityClass = insert.getEntityClass();
+ EntityDescriptor entityDescriptor = null;
+ switch (category) {
+ case ACTOR:
+ entityDescriptor = tqclLibraryProvider.getActor(TqCLUtils.cleanEntityName(entityClass));
+ break;
+ case DIRECTOR:
+ entityDescriptor = tqclLibraryProvider.getDirector(TqCLUtils.cleanEntityName(entityClass));
+ break;
+ case PARAMETER:
+ entityDescriptor = tqclLibraryProvider.getParameterType(TqCLUtils.cleanEntityName(entityClass));
+ break;
+
+ default:
+ break;
+ }
+
+ if (entityDescriptor != null) {
+ List parameters = entityDescriptor.getParameters();
+ EList tqclParameters = insert.getParameters();
+ for (Parameter tqclParameter : tqclParameters) {
+ boolean found = false;
+ for (ParameterDescriptor parameterDescriptor : parameters) {
+ if (parameterDescriptor.getDisplayName()
+ .equals(TqCLUtils.cleanParameterName(tqclParameter.getId()))) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ String message = MessageFormat.format("Invalid parameter name {0} for actor {1}",
+ tqclParameter.getId(), entityDescriptor.getClazz());
+ error(message, tqclParameter, TqclPackage.Literals.PARAMETER__ID, INVALID_PARAMETER);
+ }
+ }
+ }
+ } catch (TqCLLibraryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.gitignore b/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.gitignore
new file mode 100644
index 00000000..8d5e73b3
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.gitignore
@@ -0,0 +1,6 @@
+/.TqclRuntimeModule.java._trace
+/.TqclStandaloneSetup.java._trace
+/.TqclRuntimeModule.xtendbin
+/.TqclStandaloneSetup.xtendbin
+/TqclRuntimeModule.java
+/TqclStandaloneSetup.java
diff --git a/org.eclipse.triquetrum.commands.xtext/src/test/java-gen/org/eclipse/triquetrum/commands/tests/TqclInjectorProvider.java b/org.eclipse.triquetrum.commands.xtext/src/test/java-gen/org/eclipse/triquetrum/commands/tests/TqclInjectorProvider.java
new file mode 100644
index 00000000..f46cf301
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/test/java-gen/org/eclipse/triquetrum/commands/tests/TqclInjectorProvider.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Totaro Rodolfo
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rodolfo Totaro - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/*
+ * generated by Xtext 2.10.0
+ */
+package org.eclipse.triquetrum.commands.tests;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import org.eclipse.triquetrum.commands.TqclRuntimeModule;
+import org.eclipse.triquetrum.commands.TqclStandaloneSetup;
+import org.eclipse.xtext.junit4.GlobalRegistries;
+import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
+import org.eclipse.xtext.junit4.IInjectorProvider;
+import org.eclipse.xtext.junit4.IRegistryConfigurator;
+
+public class TqclInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
+
+ protected GlobalStateMemento stateBeforeInjectorCreation;
+ protected GlobalStateMemento stateAfterInjectorCreation;
+ protected Injector injector;
+
+ static {
+ GlobalRegistries.initializeDefaults();
+ }
+
+ @Override
+ public Injector getInjector() {
+ if (injector == null) {
+ stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
+ this.injector = internalCreateInjector();
+ stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
+ }
+ return injector;
+ }
+
+ protected Injector internalCreateInjector() {
+ return new TqclStandaloneSetup() {
+ @Override
+ public Injector createInjector() {
+ return Guice.createInjector(createRuntimeModule());
+ }
+ }.createInjectorAndDoEMFRegistration();
+ }
+
+ protected TqclRuntimeModule createRuntimeModule() {
+ // make it work also with Maven/Tycho and OSGI
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672
+ return new TqclRuntimeModule() {
+ @Override
+ public ClassLoader bindClassLoaderToInstance() {
+ return TqclInjectorProvider.class
+ .getClassLoader();
+ }
+ };
+ }
+
+ @Override
+ public void restoreRegistry() {
+ stateBeforeInjectorCreation.restoreGlobalState();
+ }
+
+ @Override
+ public void setupRegistry() {
+ getInjector();
+ stateAfterInjectorCreation.restoreGlobalState();
+ }
+}
diff --git a/org.eclipse.triquetrum.commands.xtext/src/test/java/org/eclipse/triquetrum/commands/tests/TqclParsingTest.xtend b/org.eclipse.triquetrum.commands.xtext/src/test/java/org/eclipse/triquetrum/commands/tests/TqclParsingTest.xtend
new file mode 100644
index 00000000..ba58d1f1
--- /dev/null
+++ b/org.eclipse.triquetrum.commands.xtext/src/test/java/org/eclipse/triquetrum/commands/tests/TqclParsingTest.xtend
@@ -0,0 +1,30 @@
+/*
+ * generated by Xtext 2.10.0
+ */
+package org.eclipse.triquetrum.commands.tests
+
+import com.google.inject.Inject
+import org.eclipse.triquetrum.commands.tqcl.TriquetrumScript
+import org.eclipse.xtext.junit4.InjectWith
+import org.eclipse.xtext.junit4.XtextRunner
+import org.eclipse.xtext.junit4.util.ParseHelper
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(XtextRunner)
+@InjectWith(TqclInjectorProvider)
+class TqclParsingTest{
+
+ @Inject
+ ParseHelper parseHelper
+
+ @Test
+ def void loadModel() {
+ val result = parseHelper.parse('''
+ Hello Xtext!
+ ''')
+ Assert.assertNotNull(result)
+ }
+
+}
diff --git a/org.eclipse.triquetrum.logging.dvp/src/main/resources/log4j.properties b/org.eclipse.triquetrum.logging.dvp/src/main/resources/log4j.properties
index 30533356..f836a6fb 100644
--- a/org.eclipse.triquetrum.logging.dvp/src/main/resources/log4j.properties
+++ b/org.eclipse.triquetrum.logging.dvp/src/main/resources/log4j.properties
@@ -8,7 +8,7 @@
# Contributors:
# Erwin De Ley - initial API and implementation and/or initial documentation
###############################################################################
-log4j.rootLogger=INFO,CONSOLE
+log4j.rootLogger=DEBUG,CONSOLE
#log4j.logger.org.eclipse.triquetrum.workflow.editor = ALL
log4j.logger.org.eclipse.triquetrum.processing.service = ALL
diff --git a/org.eclipse.triquetrum.processing.actor/.DS_Store b/org.eclipse.triquetrum.processing.actor/.DS_Store
new file mode 100644
index 00000000..5008ddfc
Binary files /dev/null and b/org.eclipse.triquetrum.processing.actor/.DS_Store differ
diff --git a/org.eclipse.triquetrum.target.platform/org.eclipse.triquetrum.commands.xtext.platform.target b/org.eclipse.triquetrum.target.platform/org.eclipse.triquetrum.commands.xtext.platform.target
new file mode 100644
index 00000000..c6275355
--- /dev/null
+++ b/org.eclipse.triquetrum.target.platform/org.eclipse.triquetrum.commands.xtext.platform.target
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.triquetrum.workflow.editor/META-INF/MANIFEST.MF b/org.eclipse.triquetrum.workflow.editor/META-INF/MANIFEST.MF
index 9907c888..925267bf 100644
--- a/org.eclipse.triquetrum.workflow.editor/META-INF/MANIFEST.MF
+++ b/org.eclipse.triquetrum.workflow.editor/META-INF/MANIFEST.MF
@@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.graphiti;bundle-version="0.12.0",
org.eclipse.core.commands;bundle-version="3.7.0",
org.eclipse.core.resources;bundle-version="3.10.0",
org.eclipse.core.runtime;bundle-version="3.11.0",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.6.100"
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.6.100",
+ org.eclipse.triquetrum.commands.api
Import-Package: org.apache.batik.bridge;version="1.6.0",
org.apache.batik.css.engine;version="1.6.0",
org.apache.batik.dom;version="1.6.1",
@@ -106,7 +107,8 @@ Import-Package: org.apache.batik.bridge;version="1.6.0",
ptolemy.vergil.icon;version="11.0.0",
ptolemy.vergil.kernel.attributes;version="11.0.0"
Bundle-Activator: org.eclipse.triquetrum.workflow.editor.TriqEditorPlugin
-Service-Component: OSGI-INF/colorRendererService.xml,
- OSGI-INF/attributesRendererService.xml
+Service-Component: OSGI-INF/colorRendererService.xml,OSGI-INF/attributesRendererService.xml,OSGI-INF/librariesProvider.xml,
+ OSGI-INF/ModelBuilderService.xml,OSGI-INF/PtolemyModelBuilderService.xml
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.triquetrum.workflow.editor.palette.spi
+Export-Package: org.eclipse.triquetrum.workflow.editor,
+ org.eclipse.triquetrum.workflow.editor.features
diff --git a/org.eclipse.triquetrum.workflow.editor/OSGI-INF/ModelBuilderService.xml b/org.eclipse.triquetrum.workflow.editor/OSGI-INF/ModelBuilderService.xml
new file mode 100644
index 00000000..5557c47a
--- /dev/null
+++ b/org.eclipse.triquetrum.workflow.editor/OSGI-INF/ModelBuilderService.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/org.eclipse.triquetrum.workflow.editor/OSGI-INF/PtolemyModelBuilderService.xml b/org.eclipse.triquetrum.workflow.editor/OSGI-INF/PtolemyModelBuilderService.xml
new file mode 100644
index 00000000..caafff1e
--- /dev/null
+++ b/org.eclipse.triquetrum.workflow.editor/OSGI-INF/PtolemyModelBuilderService.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/org.eclipse.triquetrum.workflow.editor/OSGI-INF/librariesProvider.xml b/org.eclipse.triquetrum.workflow.editor/OSGI-INF/librariesProvider.xml
new file mode 100644
index 00000000..c1642491
--- /dev/null
+++ b/org.eclipse.triquetrum.workflow.editor/OSGI-INF/librariesProvider.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/org.eclipse.triquetrum.workflow.editor/build.properties b/org.eclipse.triquetrum.workflow.editor/build.properties
index 42cb575b..54042ee1 100644
--- a/org.eclipse.triquetrum.workflow.editor/build.properties
+++ b/org.eclipse.triquetrum.workflow.editor/build.properties
@@ -1,15 +1,3 @@
-###############################################################################
-# Copyright (c) 2015, 2016 iSencia Belgium NV.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Erwin De Ley - initial API and implementation and/or initial documentation
-###############################################################################
-source.. = src/main/java/,\
- src/main/resources/
output.. = target/classes/
bin.includes = META-INF/,\
.,\
@@ -23,7 +11,9 @@ bin.includes = META-INF/,\
about.properties,\
eclipse32.png,\
schema/,\
- build.properties
+ build.properties,\
+ OSGI-INF/librariesProvider.xml,\
+ OSGI-INF/ModelBuilderService.xml
src.includes = src/,\
schema/,\
plugin_customization.ini,\
@@ -37,3 +27,5 @@ src.includes = src/,\
about.html,\
OSGI-INF/,\
META-INF/
+source.. = src/main/java/,\
+ src/main/resources/
diff --git a/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/PtolemyModelBuilderService.java b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/PtolemyModelBuilderService.java
new file mode 100644
index 00000000..3d900e9c
--- /dev/null
+++ b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/PtolemyModelBuilderService.java
@@ -0,0 +1,178 @@
+package org.eclipse.triquetrum.workflow.editor;
+
+import java.util.Map;
+
+import org.eclipse.triquetrum.commands.api.services.ModelBuilderService;
+import org.eclipse.triquetrum.workflow.model.util.PtolemyUtil;
+import org.osgi.framework.Version;
+import org.ptolemy.commons.ThreeDigitVersionSpecification;
+import org.ptolemy.commons.VersionSpecification;
+
+import ptolemy.actor.CompositeActor;
+import ptolemy.actor.Director;
+import ptolemy.actor.IOPort;
+import ptolemy.actor.IORelation;
+import ptolemy.actor.TypedCompositeActor;
+import ptolemy.actor.TypedIORelation;
+import ptolemy.data.expr.Parameter;
+import ptolemy.kernel.ComponentEntity;
+import ptolemy.kernel.ComponentRelation;
+import ptolemy.kernel.CompositeEntity;
+import ptolemy.kernel.Entity;
+import ptolemy.kernel.Port;
+import ptolemy.kernel.Relation;
+import ptolemy.kernel.util.Attribute;
+import ptolemy.kernel.util.IllegalActionException;
+import ptolemy.kernel.util.NameDuplicationException;
+
+public class PtolemyModelBuilderService implements ModelBuilderService> {
+
+ @Override
+ public Class> getSupportedModelClass() {
+ return CompositeActor.class;
+ }
+
+ @Override
+ public CompositeEntity createNewModel(String modelName, String folderPath) {
+ return new TypedCompositeActor();
+ }
+
+ private VersionSpecification getVersion() {
+ Version bundleVersion = TriqEditorPlugin.getDefault().getBundle().getVersion();
+ VersionSpecification providerVersion = new ThreeDigitVersionSpecification(bundleVersion.getMajor(),
+ bundleVersion.getMinor(), bundleVersion.getMicro(), bundleVersion.getQualifier());
+ return providerVersion;
+ }
+
+ @Override
+ public boolean insertActor(CompositeEntity parent, String actorName, String actorclass,
+ Map parameters) {
+ try {
+ Entity> actor = PtolemyUtil._createEntity(parent, actorclass, /*getVersion()*/null, actorName);
+ for (String paramKey : parameters.keySet()) {
+ Attribute attribute = actor.getAttribute(paramKey);
+ if (attribute instanceof Parameter) {
+ Parameter param = (Parameter) attribute;
+ param.setExpression(parameters.get(paramKey));
+ param.propagateValue();
+ }
+ }
+// parent.entityList().add(actor);
+ return true;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean insertDirector(CompositeEntity actor, String directorName, String entityClass,
+ Map params) {
+ try {
+ Attribute attribute = PtolemyUtil._createAttribute(actor, entityClass, directorName);
+ if (attribute instanceof Director) {
+ for (String paramKey : params.keySet()) {
+ Attribute directorAttribute = attribute.getAttribute(paramKey);
+ if (directorAttribute instanceof Parameter) {
+ Parameter param = (Parameter) directorAttribute;
+ param.setExpression(params.get(paramKey));
+ param.propagateValue();
+ }
+ }
+ return true;
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean insertPort(ComponentEntity> actor, String portName, String entityClass,
+ Map params) {
+ try {
+ Port port = PtolemyUtil._createPort(actor, entityClass, portName);
+
+ if (port instanceof IOPort) {
+ IOPort ioPort = (IOPort) port;
+ if(params.containsKey("input") && Boolean.parseBoolean(params.get("input")))
+ {
+ ioPort.setInput(true);
+ }
+ if(params.containsKey("output") && Boolean.parseBoolean(params.get("output")))
+ {
+ ioPort.setOutput(true);
+ }
+ if(params.containsKey("multi") && Boolean.parseBoolean(params.get("multi")))
+ {
+ ioPort.setMultiport(true);
+ }
+
+ }
+
+ return true;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean insertParameter(ComponentEntity> actor, String parameterName, String entityClass,
+ Map params) {
+ try {
+ Attribute attribute = PtolemyUtil._createAttribute(actor, entityClass, parameterName);
+ if (attribute instanceof Parameter) {
+ Parameter param = (Parameter) attribute;
+ param.setExpression(params.get("expression"));
+ return true;
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public CompositeEntity getParent(ComponentEntity> actor) {
+ return (CompositeEntity) actor.getContainer();
+ }
+
+ @Override
+ public ComponentEntity> getChild(CompositeEntity parent, String name) {
+ return parent.getEntity(name);
+ }
+
+ @Override
+ public boolean connect(CompositeEntity currentActor, String from, String to) {
+ int size = currentActor.relationList().size();
+ try {
+
+ ComponentRelation relation = currentActor.newRelation("_R" + (size + 1));
+
+ String[] splitFrom = from.split("\\.");
+ String actorFrom = splitFrom[0];
+ String portFrom = splitFrom[1];
+
+ String[] splitTo = to.split("\\.");
+ String actorTo = splitTo[0];
+ String portTo = splitTo[1];
+
+ Port outputport = currentActor.getEntity(actorFrom).getPort(portFrom);
+ Port inputPort = currentActor.getEntity(actorTo).getPort(portTo);
+
+ inputPort.link(relation);
+ outputport.link(relation);
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
diff --git a/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/TriquetrumLibraryProvider.java b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/TriquetrumLibraryProvider.java
new file mode 100644
index 00000000..07417335
--- /dev/null
+++ b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/TriquetrumLibraryProvider.java
@@ -0,0 +1,276 @@
+package org.eclipse.triquetrum.workflow.editor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.triquetrum.commands.api.services.ActorDescriptor;
+import org.eclipse.triquetrum.commands.api.services.DirectorDescriptor;
+import org.eclipse.triquetrum.commands.api.services.EntityDescriptor;
+import org.eclipse.triquetrum.commands.api.services.ParameterDescriptor;
+import org.eclipse.triquetrum.commands.api.services.PortDescriptor;
+import org.eclipse.triquetrum.commands.api.services.TqCLLibraryException;
+import org.eclipse.triquetrum.commands.api.services.TqCLLibraryProvider;
+import org.eclipse.triquetrum.workflow.model.util.PtolemyUtil;
+import org.osgi.framework.Version;
+import org.ptolemy.commons.ThreeDigitVersionSpecification;
+import org.ptolemy.commons.VersionSpecification;
+
+import ptolemy.actor.CompositeActor;
+import ptolemy.actor.IOPort;
+import ptolemy.actor.TypedIOPort;
+import ptolemy.data.expr.Parameter;
+import ptolemy.kernel.Entity;
+import ptolemy.kernel.Port;
+import ptolemy.kernel.util.Attribute;
+
+public class TriquetrumLibraryProvider implements TqCLLibraryProvider {
+
+ private static final String TRIQUETRUM_LIBRARY_NAME = "Triquetrum";
+ private Map actors = new HashMap<>();
+ private Map directors = new HashMap<>();
+ private Map parameters = new HashMap<>();
+ private Map ports = new HashMap<>();
+
+ private boolean initialized = false;
+
+ private void init() {
+ if (initialized) {
+ return;
+ }
+ IExtensionPoint extPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint(TriqFeatureProvider.PALETTE_CONTRIBUTION_EXTENSION_ID);
+ IExtension[] extensions = extPoint.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement group : configurationElements) {
+ fillElementsFromGroup(group);
+ }
+ }
+
+ PortDescriptor port = new PortDescriptor(TRIQUETRUM_LIBRARY_NAME, "port", TypedIOPort.class.getName(), null,true,true);
+ ParameterDescriptor inputParameter = new ParameterDescriptor(TRIQUETRUM_LIBRARY_NAME, "input", Parameter.class.getName(), null);
+ inputParameter.setDefaultValue("false");
+ port.addParameter(inputParameter);
+
+ ParameterDescriptor outputParameter = new ParameterDescriptor(TRIQUETRUM_LIBRARY_NAME, "output", Parameter.class.getName(), null);
+ outputParameter.setDefaultValue("false");
+ port.addParameter(outputParameter);
+
+ ParameterDescriptor multiParameter = new ParameterDescriptor(TRIQUETRUM_LIBRARY_NAME, "multi", Parameter.class.getName(), null);
+ multiParameter.setDefaultValue("false");
+ port.addParameter(multiParameter);
+
+ ports.put(TypedIOPort.class.getName(),
+ port);
+
+ initialized = true;
+ }
+
+ public void fillElementsFromGroup(IConfigurationElement group) {
+ String groupName = group.getAttribute("displayName");
+
+ IConfigurationElement[] children = group.getChildren();
+ for (IConfigurationElement element : children) {
+ if (element.getName().equals("entry")) {
+ String clazz = element.getAttribute("class");
+ String displayName = element.getAttribute("displayName");
+ String icon = element.getAttribute("icon");
+ String type = element.getAttribute("type");
+ if (type != null) {
+ BoCategory boCategory = BoCategory.valueOf(type);
+ switch (boCategory) {
+ case Actor:
+ ActorDescriptor actorDescriptor = new ActorDescriptor(TRIQUETRUM_LIBRARY_NAME, displayName,
+ clazz, icon);
+ fillParameters(actorDescriptor);
+ actors.put(actorDescriptor.getClazz(), actorDescriptor);
+ break;
+ case Director:
+ DirectorDescriptor directorDescriptor = new DirectorDescriptor(TRIQUETRUM_LIBRARY_NAME,
+ displayName, clazz, icon);
+ fillParameters(directorDescriptor);
+ directors.put(directorDescriptor.getClazz(), directorDescriptor);
+ break;
+ case Parameter:
+ ParameterDescriptor parameterDescriptor = new ParameterDescriptor(TRIQUETRUM_LIBRARY_NAME,
+ displayName, clazz, icon);
+ fillParameters(parameterDescriptor);
+ parameters.put(parameterDescriptor.getClazz(), parameterDescriptor);
+ break;
+ case Port:
+// PortDescriptor port = new PortDescriptor(TRIQUETRUM_LIBRARY_NAME, "input", clazz, null);
+// ports.put(clazz, port);
+ break;
+ default:
+ System.out.println("unsupported category " + boCategory.name());
+ break;
+ }
+ }
+ } else if (element.getName().equals("group")) {
+ fillElementsFromGroup(element);
+ }
+
+ }
+ }
+
+ private void fillParameters(EntityDescriptor entityDescriptor) {
+ CompositeActor ptolemyModel = new CompositeActor();
+
+ Version bundleVersion = TriqEditorPlugin.getDefault().getBundle().getVersion();
+ VersionSpecification providerVersion = new ThreeDigitVersionSpecification(bundleVersion.getMajor(),
+ bundleVersion.getMinor(), bundleVersion.getMicro(), bundleVersion.getQualifier());
+ try {
+ List paramList = new ArrayList<>();
+ if (entityDescriptor instanceof ActorDescriptor) {
+ ActorDescriptor actorDescriptor = (ActorDescriptor) entityDescriptor;
+ Entity> entity = PtolemyUtil._createEntity(ptolemyModel, actorDescriptor.getClazz(), providerVersion,
+ "parameterfilling");
+ paramList = entity.attributeList(Parameter.class);
+ fillPorts(actorDescriptor, entity);
+ } else {
+ Attribute attribute = PtolemyUtil._createAttribute(ptolemyModel, entityDescriptor.getClazz(),
+ "parameterfilling");
+ paramList = attribute.attributeList(Parameter.class);
+ }
+ for (Parameter ptolemyParameter : paramList) {
+ ParameterDescriptor parameter = new ParameterDescriptor(TRIQUETRUM_LIBRARY_NAME,
+ ptolemyParameter.getName(), ptolemyParameter.getClassName(), null);
+ parameter.setDefaultValue(ptolemyParameter.getDefaultExpression());
+ entityDescriptor.addParameter(parameter);
+ }
+ if (entityDescriptor instanceof ParameterDescriptor) {
+ ParameterDescriptor parameter = new ParameterDescriptor(TRIQUETRUM_LIBRARY_NAME, "expression",
+ String.class.getName(), null);
+ entityDescriptor.addParameter(parameter);
+ }
+ } catch (
+
+ Exception e) {
+ // LOG
+ e.printStackTrace();
+ }
+ }
+
+ public void fillPorts(ActorDescriptor actorDescriptor, Entity> entity) {
+ List> portList = entity.portList();
+ for (Object object : portList) {
+ if (object instanceof IOPort) {
+ IOPort port = (IOPort) object;
+ PortDescriptor portDescriptor = new PortDescriptor(TRIQUETRUM_LIBRARY_NAME, port.getName(),
+ port.getClassName(), null,port.isInput(),port.isOutput());
+ actorDescriptor.addPort(portDescriptor);
+ } else {
+ System.out.println("");
+ }
+ }
+ }
+
+ @Override
+ public List getActors(String library) throws TqCLLibraryException {
+ init();
+ return new ArrayList<>(actors.values());
+ }
+
+ @Override
+ public List getDirectors(String library) throws TqCLLibraryException {
+ init();
+ return new ArrayList<>(directors.values());
+ }
+
+ @Override
+ public List getParameterTypes(String library) throws TqCLLibraryException {
+
+ init();
+ return new ArrayList<>(parameters.values());
+ }
+
+ @Override
+ public List getPortTypes(String library) throws TqCLLibraryException {
+ init();
+ return new ArrayList<>(ports.values());
+ }
+
+ @Override
+ public List getActorPorts(String actor) throws TqCLLibraryException {
+ init();
+ return actors.get(actor).getPorts();
+ }
+
+ @Override
+ public List getActorParameters(String actor) throws TqCLLibraryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set getLibraryNames() {
+ HashSet libraries = new HashSet();
+ libraries.add(TRIQUETRUM_LIBRARY_NAME);
+ return libraries;
+ }
+
+ @Override
+ public boolean hasElement(String element) {
+ return actors.containsKey(element) || directors.containsKey(element) || parameters.containsKey(element);
+ }
+
+ @Override
+ public ActorDescriptor getActor(String library, String actorClass) throws TqCLLibraryException {
+ if (getLibraryNames().contains(library)) {
+ return actors.get(actorClass);
+ }
+ return null;
+ }
+
+ @Override
+ public ActorDescriptor getActor(String actorClass) throws TqCLLibraryException {
+ return actors.get(actorClass);
+ }
+
+ @Override
+ public DirectorDescriptor getDirector(String directorClass) throws TqCLLibraryException {
+ return directors.get(directorClass);
+ }
+
+ @Override
+ public boolean hasElementInLibrary(String element, String library, String category) {
+ init();
+ if (getLibraryNames().contains(library)) {
+ BoCategory boCategory = BoCategory.valueOf(StringUtils.capitalize(category));
+ switch (boCategory) {
+ case Actor:
+ return actors.containsKey(element);
+ case Director:
+ return directors.containsKey(element);
+ case Parameter:
+ return parameters.containsKey(element);
+ case Port:
+ return ports.containsKey(element);
+ // TODO: remove default when switch is completed
+ default:
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public ParameterDescriptor getParameterType(String parameterClass) {
+ return parameters.get(parameterClass);
+ }
+
+ @Override
+ public PortDescriptor getPortType(String portClass) throws TqCLLibraryException {
+ return ports.get(portClass);
+ }
+
+}
diff --git a/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/TriquetrumModelBuilderService.java b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/TriquetrumModelBuilderService.java
new file mode 100644
index 00000000..ce309975
--- /dev/null
+++ b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/TriquetrumModelBuilderService.java
@@ -0,0 +1,295 @@
+package org.eclipse.triquetrum.workflow.editor;
+
+import java.net.URI;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.graphiti.features.ICreateFeature;
+import org.eclipse.graphiti.features.context.impl.AddContext;
+import org.eclipse.graphiti.features.context.impl.CreateConnectionContext;
+import org.eclipse.graphiti.features.context.impl.CreateContext;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.triquetrum.commands.api.services.ModelBuilderService;
+import org.eclipse.triquetrum.workflow.editor.features.ConnectionCreateFeature;
+import org.eclipse.triquetrum.workflow.editor.features.ModelElementCreateFeature;
+import org.eclipse.triquetrum.workflow.editor.wizard.WizardUtils;
+import org.eclipse.triquetrum.workflow.model.Actor;
+import org.eclipse.triquetrum.workflow.model.CompositeActor;
+import org.eclipse.triquetrum.workflow.model.CompositeEntity;
+import org.eclipse.triquetrum.workflow.model.Entity;
+import org.eclipse.triquetrum.workflow.model.TriqFactory;
+import org.eclipse.ui.PartInitException;
+import org.osgi.framework.Version;
+import org.ptolemy.commons.ThreeDigitVersionSpecification;
+import org.ptolemy.commons.VersionSpecification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TriquetrumModelBuilderService implements ModelBuilderService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TriquetrumModelBuilderService.class);
+ private Diagram diagram;
+ private TriqDiagramEditor editor;
+
+ @Override
+ public Class getSupportedModelClass() {
+ return CompositeActor.class;
+ }
+
+ @Override
+ public CompositeActor createNewModel(String modelName, String folderPath) {
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ URI locationURI = root.getLocationURI();
+ if (folderPath.startsWith(locationURI.toString())) {
+ String relativePath = StringUtils.removeStart(folderPath, locationURI.toString());
+ IResource modelContainer = root.findMember(relativePath);
+ IProject project = null;
+ if (modelContainer instanceof IProject) {
+ project = (IProject) modelContainer;
+ modelContainer = null;
+ } else {
+ project = modelContainer.getProject();
+ }
+ diagram = WizardUtils.createDiagramAndFile("Triquetrum workflow", modelName, project,
+ (IFolder) modelContainer);
+
+ CompositeActor model = TriqFactory.eINSTANCE.createCompositeActor();
+ model.setName(diagram.getName());
+ model.buildWrappedObject();
+ diagram.eResource().getContents().add(model);
+ try {
+ editor = WizardUtils.openDiagramInEditor(diagram);
+ TransactionalEditingDomain editingDomain = editor.getDiagramBehavior().getEditingDomain();
+ editingDomain.getCommandStack().execute(new AbstractCommand("Create model","Model Builder creting new model") {
+
+ {
+ isExecutable=true;
+ isPrepared = true;
+ }
+
+ @Override
+ public void redo() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execute() {
+ getFeatureProvider().link(diagram, model);
+ }
+ });
+
+
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else {
+ // TODO exception to manage
+ throw new RuntimeException("file not in workspace");
+ }
+ return (CompositeActor) Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement(diagram);
+ }
+
+ private VersionSpecification getVersion() {
+ Version bundleVersion = TriqEditorPlugin.getDefault().getBundle().getVersion();
+ VersionSpecification providerVersion = new ThreeDigitVersionSpecification(bundleVersion.getMajor(),
+ bundleVersion.getMinor(), bundleVersion.getMicro(), bundleVersion.getQualifier());
+ return providerVersion;
+ }
+
+ private EObject createElement(String entityClass) {
+ TriqFeatureProvider triqFeatureProvider = getFeatureProvider();
+
+ ICreateFeature[] createFeatures = triqFeatureProvider.getCreateFeatures();
+ for (ICreateFeature iCreateFeature : createFeatures) {
+ if (iCreateFeature instanceof ModelElementCreateFeature) {
+ ModelElementCreateFeature modelElementCreateFeature = (ModelElementCreateFeature) iCreateFeature;
+
+ if (modelElementCreateFeature.getWrappedClass().equals(entityClass)) {
+ CreateContext createContext = new CreateContext();
+ createContext.setTargetContainer(triqFeatureProvider.getDiagramTypeProvider().getDiagram());
+
+ editor.getDiagramBehavior().executeFeature(modelElementCreateFeature,createContext);
+
+ EObject businessObjectForLinkedPictogramElement = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement(diagram);
+ return businessObjectForLinkedPictogramElement;
+
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public TriqFeatureProvider getFeatureProvider() {
+ TriqFeatureProvider triqFeatureProvider = (TriqFeatureProvider) editor.getDiagramTypeProvider()
+ .getFeatureProvider();
+ return triqFeatureProvider;
+ }
+
+ @Override
+ public boolean insertActor(CompositeEntity parent, String actorName, String actorclass,
+ Map parameters) {
+
+ LOGGER.debug(MessageFormat.format("Creating actor {0} of type {1} with parameters {2}", actorName, actorclass,
+ parameters.toString()));
+ try {
+
+ TransactionalEditingDomain editingDomain = editor.getDiagramBehavior().getEditingDomain();
+ Actor actor = TriqFactory.eINSTANCE.createActor();
+ Map modelParameters = new HashMap<>();
+ for (org.eclipse.triquetrum.workflow.model.Parameter parameter : actor.getParameters()) {
+ modelParameters.put(parameter.getName(), parameter);
+ }
+ EStructuralFeature eStructuralFeatureName = actor.eClass().getEStructuralFeature("name");
+ editingDomain.getCommandStack()
+ .execute(new SetCommand(editingDomain, actor, eStructuralFeatureName, actorName));
+
+ for (Entry parameter : parameters.entrySet()) {
+ String paramName = parameter.getKey();
+ org.eclipse.triquetrum.workflow.model.Parameter parameterToSet = modelParameters.get(paramName);
+ EStructuralFeature eStructuralFeatureExpression = parameterToSet.eClass()
+ .getEStructuralFeature("expression");
+ editingDomain.getCommandStack().execute(new SetCommand(editingDomain, parameterToSet,
+ eStructuralFeatureExpression, parameter.getValue()));
+ }
+
+
+ AddContext context = new AddContext();
+ context.setNewObject(actor);
+ getFeatureProvider().getAddFeature(context);
+
+
+
+
+// EObject businessObjectForLinkedPictogramElement = parent;
+
+
+// AddContext context = new AddContext();
+// context.setNewObject(TriqFactory);
+// getFeatureProvider().getAddFeature(context)
+
+// EObject businessObjectForLinkedPictogramElement = createElement(actorclass);
+//
+// if (businessObjectForLinkedPictogramElement instanceof CompositeActor) {
+// CompositeActor mainActor = (CompositeActor) businessObjectForLinkedPictogramElement;
+// org.eclipse.triquetrum.workflow.model.NamedObj child = mainActor
+// .getChild(((CompositeActor) businessObjectForLinkedPictogramElement).getName());
+// TransactionalEditingDomain editingDomain = editor.getDiagramBehavior().getEditingDomain();
+// if (child instanceof Actor) {
+// Actor actor = (Actor) child;
+// Map modelParameters = new HashMap<>();
+// for (org.eclipse.triquetrum.workflow.model.Parameter parameter : actor.getParameters()) {
+// modelParameters.put(parameter.getName(), parameter);
+// }
+// EStructuralFeature eStructuralFeatureName = actor.eClass().getEStructuralFeature("name");
+// editingDomain.getCommandStack()
+// .execute(new SetCommand(editingDomain, actor, eStructuralFeatureName, actorName));
+//
+// for (Entry parameter : parameters.entrySet()) {
+// String paramName = parameter.getKey();
+// org.eclipse.triquetrum.workflow.model.Parameter parameterToSet = modelParameters.get(paramName);
+// EStructuralFeature eStructuralFeatureExpression = parameterToSet.eClass()
+// .getEStructuralFeature("expression");
+// editingDomain.getCommandStack().execute(new SetCommand(editingDomain, parameterToSet,
+// eStructuralFeatureExpression, parameter.getValue()));
+// }
+// }
+// }
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean insertDirector(CompositeEntity actor, String directorName, String entityClass,
+ Map params) {
+ LOGGER.debug(MessageFormat.format("Creating director {0} of type {1} with parameters {2}", directorName,
+ entityClass, params.toString()));
+ return false;
+ }
+
+ @Override
+ public boolean insertPort(Entity actor, String portName, String entityClass, Map params) {
+ LOGGER.debug(MessageFormat.format("Creating port {0} of type {1} with parameters {2}", portName, entityClass,
+ params.toString()));
+ return false;
+ }
+
+ @Override
+ public boolean insertParameter(Entity actor, String parameterName, String entityClass, Map params) {
+ LOGGER.debug(MessageFormat.format("Creating parameter {0} of type {1} with parameters {2}", parameterName,
+ entityClass, params.toString()));
+ return false;
+ }
+
+ @Override
+ public CompositeEntity getParent(Entity actor) {
+ LOGGER.debug("go to parent");
+ return (CompositeEntity) actor.getContainer();
+ }
+
+ @Override
+ public Entity getChild(CompositeEntity parent,String name) {
+ // TODO Auto-generated method stub
+ LOGGER.debug("go into child " + name);
+ return (Entity) parent.getChild(name);
+ }
+
+ @Override
+ public boolean connect(CompositeEntity currentActor, String from, String to) {
+ LOGGER.debug(MessageFormat.format("Connecting {0} to {1}", from, to));
+
+ ConnectionCreateFeature feature = new ConnectionCreateFeature(getFeatureProvider());
+ CreateConnectionContext createContext = new CreateConnectionContext();
+ EList children = currentActor.eContents();
+
+// for (Shape shape : children) {
+// EList anchors = shape.getAnchors();
+// for (Anchor anchor : anchors) {
+// EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(anchor);
+// if (bo instanceof Port) {
+// Port port = (Port) bo;
+// String fullName = port.getFullName();
+// if(fullName.endsWith(from))
+// {
+// createContext.setSourceAnchor(anchor);
+// }
+// if(fullName.endsWith(to))
+// {
+// createContext.setTargetAnchor(anchor);
+// }
+// }
+// }
+// }
+
+ editor.getDiagramBehavior().executeFeature(feature, createContext);
+ return false;
+ }
+
+}
diff --git a/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/wizard/WizardUtils.java b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/wizard/WizardUtils.java
index 2a1e1442..c047b47d 100644
--- a/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/wizard/WizardUtils.java
+++ b/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/wizard/WizardUtils.java
@@ -34,6 +34,7 @@
import org.eclipse.triquetrum.workflow.editor.TriqDiagramEditor;
import org.eclipse.triquetrum.workflow.editor.util.FileService;
import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
@@ -92,7 +93,7 @@ public static Diagram createDiagramAndFile(final String diagramTypeId, final Str
return diagram;
}
- public static void openDiagramInEditor(Diagram diagram) throws PartInitException {
+ public static TriqDiagramEditor openDiagramInEditor(Diagram diagram) throws PartInitException {
String editorID = TriqDiagramEditor.EDITOR_ID;
String diagramTypeProviderId = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(diagram.getDiagramTypeId());
String namingConventionID = diagramTypeProviderId + ".editor"; //$NON-NLS-1$
@@ -105,7 +106,7 @@ public static void openDiagramInEditor(Diagram diagram) throws PartInitException
String providerId = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(diagram.getDiagramTypeId());
DiagramEditorInput editorInput = new DiagramEditorInput(EcoreUtil.getURI(diagram), providerId);
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput, editorID);
+ return (TriqDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput, editorID);
}
/**
diff --git a/org.eclipse.triquetrum.workflow.model/.DS_Store b/org.eclipse.triquetrum.workflow.model/.DS_Store
new file mode 100644
index 00000000..b85d7272
Binary files /dev/null and b/org.eclipse.triquetrum.workflow.model/.DS_Store differ
diff --git a/target/classes/org/eclipse/triquetrum/commands/api/.gitignore b/target/classes/org/eclipse/triquetrum/commands/api/.gitignore
new file mode 100644
index 00000000..81ebf4e6
--- /dev/null
+++ b/target/classes/org/eclipse/triquetrum/commands/api/.gitignore
@@ -0,0 +1 @@
+/TqCLCommandServices.class
diff --git a/target/classes/org/eclipse/triquetrum/commands/api/TqCLCommandServices.class b/target/classes/org/eclipse/triquetrum/commands/api/TqCLCommandServices.class
new file mode 100644
index 00000000..32e8c716
Binary files /dev/null and b/target/classes/org/eclipse/triquetrum/commands/api/TqCLCommandServices.class differ