diff --git a/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/ActorDescriptor.java b/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/ActorDescriptor.java index fa1ec4cf..62a8d4eb 100644 --- a/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/ActorDescriptor.java +++ b/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/ActorDescriptor.java @@ -20,5 +20,9 @@ public void addPort(PortDescriptor port) { ports.add(port); } + + public List getPorts() { + return ports; + } } diff --git a/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/TqCLLibraryProvider.java b/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/TqCLLibraryProvider.java index 7c3c1ccf..77ecb85f 100644 --- a/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/TqCLLibraryProvider.java +++ b/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/TqCLLibraryProvider.java @@ -27,7 +27,7 @@ public interface TqCLLibraryProvider { public List getPortTypes(String library) throws TqCLLibraryException; - public List getActorPorts(String actor) throws TqCLLibraryException; + public List getActorPorts(String actor) throws TqCLLibraryException; public List getActorParameters(String actor) throws TqCLLibraryException; diff --git a/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/impl/TcQLLibraryProviderProxy.java b/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/impl/TcQLLibraryProviderProxy.java index 82b5f967..9426f73c 100644 --- a/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/impl/TcQLLibraryProviderProxy.java +++ b/org.eclipse.triquetrum.commands.api/src/main/java/org/eclipse/triquetrum/commands/api/services/impl/TcQLLibraryProviderProxy.java @@ -21,6 +21,7 @@ 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; @@ -61,7 +62,7 @@ public List getPortTypes(String library) throws TqCLLibraryException { } @Override - public List getActorPorts(String actor) throws TqCLLibraryException { + public List getActorPorts(String actor) throws TqCLLibraryException { for (TqCLLibraryProvider provider : libraryProviders.values()) { boolean hasElement = provider.hasElement(actor); if (hasElement) { diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/TqclUiModule.java b/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/TqclUiModule.java new file mode 100644 index 00000000..112271cd --- /dev/null +++ b/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/TqclUiModule.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * 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.ui; + +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * Use this class to register components to be used within the Eclipse IDE. + */ +public class TqclUiModule extends AbstractTqclUiModule { + + public TqclUiModule(AbstractUIPlugin plugin) { + super(plugin); + } +} diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/TqclUiModule.xtend b/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/TqclUiModule.xtend deleted file mode 100644 index f5efcc03..00000000 --- a/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/TqclUiModule.xtend +++ /dev/null @@ -1,13 +0,0 @@ -/* - * generated by Xtext 2.10.0 - */ -package org.eclipse.triquetrum.commands.ui - -import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor - -/** - * Use this class to register components to be used within the Eclipse IDE. - */ -@FinalFieldsConstructor -class TqclUiModule extends AbstractTqclUiModule { -} diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/contentassist/TqclProposalProvider.java b/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/contentassist/TqclProposalProvider.java index 0718d842..fd3fc01a 100644 --- a/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/contentassist/TqclProposalProvider.java +++ b/org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/contentassist/TqclProposalProvider.java @@ -30,15 +30,20 @@ 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.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.TriquetrumScript; import org.eclipse.triquetrum.commands.validation.TqCLUtils; import org.eclipse.xtext.Assignment; +import org.eclipse.xtext.EcoreUtil2; +import org.eclipse.xtext.RuleCall; import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext; import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor; @@ -147,6 +152,33 @@ public void completeInsert_Name(EObject model, Assignment assignment, ContentAss } } + @Override + public void completeConnectionPort_Port(EObject model, Assignment assignment, ContentAssistContext context, + ICompletionProposalAcceptor acceptor) { + // TODO Auto-generated method stub + super.completeConnectionPort_Port(model, assignment, context, acceptor); + if (model instanceof ConnectionPort) { + ConnectionPort connectionPort = (ConnectionPort) model; + Insert actor = connectionPort.getActor(); + String actorClass = actor.getEntityClass(); + try { + List actorPorts = TqCLServices.getInstance().getTqclLibraryProvider() + .getActorPorts(TqCLUtils.cleanEntityName(actorClass)); + for (PortDescriptor portDescriptor : actorPorts) { + ICompletionProposal completionProposal = createCompletionProposal(portDescriptor.getDisplayName(), + context); + acceptor.accept(completionProposal); + } + + } catch (TqCLLibraryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + } + @Override public void completeInsert_Parameters(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/.TqclUiModule.xtendbin b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/.TqclUiModule.xtendbin deleted file mode 100644 index 41267d0b..00000000 Binary files a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/.TqclUiModule.xtendbin and /dev/null differ diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/TqclUiModule.java b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/TqclUiModule.java deleted file mode 100644 index f40abdd5..00000000 --- a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/TqclUiModule.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * generated by Xtext 2.10.0 - */ -package org.eclipse.triquetrum.commands.ui; - -import org.eclipse.triquetrum.commands.ui.AbstractTqclUiModule; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor; - -/** - * Use this class to register components to be used within the Eclipse IDE. - */ -@FinalFieldsConstructor -@SuppressWarnings("all") -public class TqclUiModule extends AbstractTqclUiModule { - public TqclUiModule(final AbstractUIPlugin plugin) { - super(plugin); - } -} diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclDescriptionLabelProvider.xtendbin b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclDescriptionLabelProvider.xtendbin index 0eb0a8ed..0b5a8b3b 100644 Binary files a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclDescriptionLabelProvider.xtendbin and b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclDescriptionLabelProvider.xtendbin differ diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclLabelProvider.xtendbin b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclLabelProvider.xtendbin index ec7d4e47..2eb1c0cc 100644 Binary files a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclLabelProvider.xtendbin and b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclLabelProvider.xtendbin differ diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/outline/.TqclOutlineTreeProvider.xtendbin b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/outline/.TqclOutlineTreeProvider.xtendbin index 578a8878..cf703c49 100644 Binary files a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/outline/.TqclOutlineTreeProvider.xtendbin and b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/outline/.TqclOutlineTreeProvider.xtendbin differ diff --git a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/quickfix/.TqclQuickfixProvider.xtendbin b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/quickfix/.TqclQuickfixProvider.xtendbin index 6d9b856f..573a5aa2 100644 Binary files a/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/quickfix/.TqclQuickfixProvider.xtendbin and b/org.eclipse.triquetrum.commands.xtext.ui/src/main/xtend-gen/org/eclipse/triquetrum/commands/ui/quickfix/.TqclQuickfixProvider.xtendbin differ diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/AbstractTqclRuntimeModule.java b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/AbstractTqclRuntimeModule.java index b7f4e71f..d7df0703 100644 --- a/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/AbstractTqclRuntimeModule.java +++ b/org.eclipse.triquetrum.commands.xtext/src/main/java-gen/org/eclipse/triquetrum/commands/AbstractTqclRuntimeModule.java @@ -200,4 +200,6 @@ public Class bindIGenerator2() { return TqclGenerator.class; } + + } 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 index 529a1107..b1ee122b 100644 --- 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 @@ -23,6 +23,7 @@ Workflow { component = XtextGenerator { cleaner = { enabled = true + } configuration = { @@ -116,6 +117,8 @@ Workflow { generateXtendStub = false } + generateXtendStubs = false + contentAssist= { generateStub=true 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..e351099b --- /dev/null +++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclRuntimeModule.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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; + +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 bindIQualifiedNameProvider() { + return org.eclipse.triquetrum.commands.scoping.TqclQualifiedNameProvider.class; + } +} diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclRuntimeModule.xtend b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclRuntimeModule.xtend deleted file mode 100644 index 0ffcc113..00000000 --- a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclRuntimeModule.xtend +++ /dev/null @@ -1,11 +0,0 @@ -/* - * generated by Xtext 2.10.0 - */ -package org.eclipse.triquetrum.commands - - -/** - * Use this class to register components to be used at runtime / without the Equinox extension registry. - */ -class TqclRuntimeModule extends AbstractTqclRuntimeModule { -} 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..0fb52c01 --- /dev/null +++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclStandaloneSetup.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * 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; + + +/** + * 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/TqclStandaloneSetup.xtend b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclStandaloneSetup.xtend deleted file mode 100644 index 3034945f..00000000 --- a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/TqclStandaloneSetup.xtend +++ /dev/null @@ -1,15 +0,0 @@ -/* - * generated by Xtext 2.10.0 - */ -package org.eclipse.triquetrum.commands - - -/** - * Initialization support for running Xtext languages without Equinox extension registry. - */ -class TqclStandaloneSetup extends TqclStandaloneSetupGenerated { - - def static void doSetup() { - new TqclStandaloneSetup().createInjectorAndDoEMFRegistration() - } -} 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..0a8c9d9d --- /dev/null +++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/scoping/TqclQualifiedNameProvider.java @@ -0,0 +1,28 @@ +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 index 85afc0cb..bd3f4591 100644 --- 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 @@ -13,14 +13,23 @@ */ package org.eclipse.triquetrum.commands.scoping; +import java.util.ArrayList; +import java.util.function.Consumer; + 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.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. @@ -33,14 +42,28 @@ public class TqclScopeProvider extends AbstractTqclScopeProvider { @Override public IScope getScope(EObject context, EReference reference) { if (context instanceof Connect && reference == TqclPackage.Literals.CONNECTION_PORT__ACTOR) { - Connect connect = (Connect) context; // 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 = EcoreUtil2.getRootContainer(context); Iterable candidates = EcoreUtil2.getAllContentsOfType(rootElement, Insert.class); // Create IEObjectDescriptions and puts them into an IScope instance - return Scopes.scopeFor(candidates); +// + Predicate predicate = 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; + } + }; + IScope scope = Scopes.scopeFor(candidates); + + return new FilteringScope(scope,predicate); } return super.getScope(context, reference); @@ -48,4 +71,5 @@ public IScope getScope(EObject context, EReference reference) { + } 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 index 9b5784d9..61e52f16 100644 --- 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 @@ -29,4 +29,9 @@ public static String cleanParameterName(String id) { return null; } + public static String createEditorEntityName(String entityName) { + return entityName.contains(" ") ? ("\"" + entityName + "\"") : entityName; + + } + } diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.TqclRuntimeModule.xtendbin b/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.TqclRuntimeModule.xtendbin deleted file mode 100644 index dde83426..00000000 Binary files a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.TqclRuntimeModule.xtendbin and /dev/null differ diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.TqclStandaloneSetup.xtendbin b/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.TqclStandaloneSetup.xtendbin deleted file mode 100644 index 45c2a1b0..00000000 Binary files a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/.TqclStandaloneSetup.xtendbin and /dev/null differ diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/TqclRuntimeModule.java b/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/TqclRuntimeModule.java deleted file mode 100644 index d0930e29..00000000 --- a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/TqclRuntimeModule.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * generated by Xtext 2.10.0 - */ -package org.eclipse.triquetrum.commands; - -import org.eclipse.triquetrum.commands.AbstractTqclRuntimeModule; - -/** - * Use this class to register components to be used at runtime / without the Equinox extension registry. - */ -@SuppressWarnings("all") -public class TqclRuntimeModule extends AbstractTqclRuntimeModule { -} diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/TqclStandaloneSetup.java b/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/TqclStandaloneSetup.java deleted file mode 100644 index 7c0e5cb5..00000000 --- a/org.eclipse.triquetrum.commands.xtext/src/main/xtend-gen/org/eclipse/triquetrum/commands/TqclStandaloneSetup.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * generated by Xtext 2.10.0 - */ -package org.eclipse.triquetrum.commands; - -import org.eclipse.triquetrum.commands.TqclStandaloneSetupGenerated; - -/** - * Initialization support for running Xtext languages without Equinox extension registry. - */ -@SuppressWarnings("all") -public class TqclStandaloneSetup extends TqclStandaloneSetupGenerated { - public static void doSetup() { - TqclStandaloneSetup _tqclStandaloneSetup = new TqclStandaloneSetup(); - _tqclStandaloneSetup.createInjectorAndDoEMFRegistration(); - } -} 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 index c5d1a3af..08102a18 100644 --- 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 @@ -16,6 +16,7 @@ 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; @@ -26,6 +27,7 @@ import ptolemy.actor.CompositeActor; import ptolemy.data.expr.Parameter; import ptolemy.kernel.Entity; +import ptolemy.kernel.Port; import ptolemy.kernel.util.Attribute; public class TriquetrumLibraryProvider implements TqCLLibraryProvider { @@ -47,48 +49,56 @@ private void init() { for (IExtension extension : extensions) { IConfigurationElement[] configurationElements = extension.getConfigurationElements(); for (IConfigurationElement group : configurationElements) { - String groupName = group.getAttribute("displayName"); - - IConfigurationElement[] children = group.getChildren(); - for (IConfigurationElement element : children) { - 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); - default: - break; - } - } else { - // TODO: manage errors - } - - } + fillElementsFromGroup(group); } } 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; + 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(); @@ -102,6 +112,7 @@ private void fillParameters(EntityDescriptor 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"); @@ -126,6 +137,20 @@ private void fillParameters(EntityDescriptor entityDescriptor) { } } + public void fillPorts(ActorDescriptor actorDescriptor, Entity entity) { + List portList = entity.portList(); + for (Object object : portList) { + if (object instanceof Port) { + Port port = (Port) object; + PortDescriptor portDescriptor = new PortDescriptor(TRIQUETRUM_LIBRARY_NAME, port.getName(), port.getClassName(), null); + actorDescriptor.addPort(portDescriptor); + } + else{ + System.out.println(""); + } + } + } + @Override public List getActors(String library) throws TqCLLibraryException { init(); @@ -152,9 +177,8 @@ public List getPortTypes(String library) throws TqCLLibraryException { } @Override - public List getActorPorts(String actor) throws TqCLLibraryException { - // TODO Auto-generated method stub - return null; + public List getActorPorts(String actor) throws TqCLLibraryException { + return actors.get(actor).getPorts(); } @Override @@ -172,8 +196,7 @@ public Set getLibraryNames() { @Override public boolean hasElement(String element) { - // TODO Auto-generated method stub - return false; + return actors.containsKey(element)||directors.containsKey(element)||parameters.containsKey(element); } @Override 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