forked from eclipse-archived/triquetrum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eclipse-archived#190 Completed interpreter to run application
- Loading branch information
Showing
17 changed files
with
459 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...de/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLPtolemyLaunchShortcut.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.eclipse.triquetrum.commands.xtext.ide; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.debug.ui.ILaunchShortcut; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.triquetrum.commands.interpreter.TqclInterpreter; | ||
import org.eclipse.triquetrum.workflow.WorkflowExecutionService; | ||
import org.eclipse.triquetrum.workflow.WorkflowExecutionService.StartMode; | ||
import org.eclipse.triquetrum.workflow.editor.TriqEditorPlugin; | ||
import org.eclipse.ui.IEditorInput; | ||
import org.eclipse.ui.IEditorPart; | ||
import org.eclipse.ui.console.ConsolePlugin; | ||
import org.eclipse.ui.console.IConsole; | ||
import org.eclipse.ui.console.IConsoleManager; | ||
import org.eclipse.ui.console.MessageConsole; | ||
import org.eclipse.ui.console.MessageConsoleStream; | ||
|
||
import ptolemy.actor.CompositeActor; | ||
|
||
public class TqCLPtolemyLaunchShortcut implements ILaunchShortcut { | ||
|
||
@Override | ||
public void launch(ISelection selection, String mode) { | ||
Object firstElement = ((IStructuredSelection) selection).getFirstElement(); | ||
if (firstElement instanceof IFile) { | ||
try { | ||
IFile file = (IFile) firstElement; | ||
java.net.URI rawLocationURI = file.getRawLocationURI(); | ||
|
||
IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); | ||
MessageConsole messageConsole = new MessageConsole(file.getName(), "TqCL", null, false); | ||
consoleManager.addConsoles(new IConsole[] { messageConsole }); | ||
MessageConsoleStream newMessageStream = messageConsole.newMessageStream(); | ||
// newMessageStream | ||
|
||
TqclInterpreter interpreter = new TqclInterpreter(); | ||
CompositeActor model = (CompositeActor) interpreter.interpret(file.getName(), file.getContents(), | ||
file.getParent().getLocationURI(), CompositeActor.class); | ||
|
||
String moml = model.exportMoML(); | ||
|
||
System.out.println(moml); | ||
|
||
//workflow service could be exposed by a different plugin; not workflow editor | ||
WorkflowExecutionService executionService = TriqEditorPlugin.getDefault().getWorkflowExecutionService(); | ||
executionService.start(StartMode.RUN, model, null, null, null); | ||
|
||
} catch (CoreException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void launch(IEditorPart editor, String mode) { | ||
// TODO Auto-generated method stub | ||
IEditorInput firstElement = editor.getEditorInput(); | ||
if (firstElement instanceof IFile) { | ||
IFile file = (IFile) firstElement; | ||
|
||
} | ||
} | ||
|
||
} |
Binary file modified
BIN
+0 Bytes
(100%)
....tests/src/test/xtend-gen/org/eclipse/triquetrum/commands/tests/.TqclParsingTest.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...nd-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclDescriptionLabelProvider.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...rc/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclLabelProvider.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...in/xtend-gen/org/eclipse/triquetrum/commands/ui/outline/.TqclOutlineTreeProvider.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...main/xtend-gen/org/eclipse/triquetrum/commands/ui/quickfix/.TqclQuickfixProvider.xtendbin
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
org.eclipse.triquetrum.workflow.editor/OSGI-INF/PtolemyModelBuilderService.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.triquetrum.workflow.editor.PtolemyModelBuilderService"> | ||
<implementation class="org.eclipse.triquetrum.workflow.editor.PtolemyModelBuilderService"/> | ||
<service> | ||
<provide interface="org.eclipse.triquetrum.commands.api.services.ModelBuilderService"/> | ||
</service> | ||
</scr:component> |
178 changes: 178 additions & 0 deletions
178
...itor/src/main/java/org/eclipse/triquetrum/workflow/editor/PtolemyModelBuilderService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CompositeEntity, ComponentEntity<?>> { | ||
|
||
@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<String, String> 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<String, String> 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<String, String> 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<String, String> 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; | ||
} | ||
|
||
} |
Oops, something went wrong.