diff options
author | atikhomirov | 2008-10-31 13:27:00 +0000 |
---|---|---|
committer | atikhomirov | 2008-10-31 13:27:00 +0000 |
commit | e0ae3dd14fd99f751edb594b0219a4e6cae3d099 (patch) | |
tree | 842e4ff93a232a74d14dbe04fed1a777c3ed46ee | |
parent | 9b713c2399790f7bf26bf29ff59f33fefb0c77d9 (diff) | |
download | org.eclipse.gmf-tooling-e0ae3dd14fd99f751edb594b0219a4e6cae3d099.tar.gz org.eclipse.gmf-tooling-e0ae3dd14fd99f751edb594b0219a4e6cae3d099.tar.xz org.eclipse.gmf-tooling-e0ae3dd14fd99f751edb594b0219a4e6cae3d099.zip |
[251588] Ant integration for GMF-Xpand - inputURI working
-rw-r--r-- | plugins/org.eclipse.gmf.xpand.ant/src-ant/org/eclipse/gmf/internal/xpand/ant/InvokeTemplateTask.java | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/plugins/org.eclipse.gmf.xpand.ant/src-ant/org/eclipse/gmf/internal/xpand/ant/InvokeTemplateTask.java b/plugins/org.eclipse.gmf.xpand.ant/src-ant/org/eclipse/gmf/internal/xpand/ant/InvokeTemplateTask.java index a64027c96..2c2339f78 100644 --- a/plugins/org.eclipse.gmf.xpand.ant/src-ant/org/eclipse/gmf/internal/xpand/ant/InvokeTemplateTask.java +++ b/plugins/org.eclipse.gmf.xpand.ant/src-ant/org/eclipse/gmf/internal/xpand/ant/InvokeTemplateTask.java @@ -21,6 +21,10 @@ import java.util.StringTokenizer; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; /** * <p>... xmlns:xpt=<em>"eclipse.org/gmf/2008/xpand"</em>... @@ -32,21 +36,23 @@ import org.eclipse.core.runtime.IProgressMonitor; public class InvokeTemplateTask extends Task { private String myTemplateName; - private Object myTemplateTarget; + private String myInputURI; private String[] myTemplateRoots; private String myOutFile; private XpandFacade myFacade; + private Object myInputObject; + private ResourceSetImpl myResourceSet; public void setName(String name) { myTemplateName = name; } public void setBareInput(String input) { - myTemplateTarget = input; + myInputObject = input; } public void setInputURI(String uri) { - myTemplateTarget = uri; + myInputURI = uri; } public void setOutFile(String uri) { @@ -77,7 +83,7 @@ public class InvokeTemplateTask extends Task { XpandFacade xf = createExecFacade(); String result = xf.xpand(myTemplateName, getTemplateTarget(), getTemplateArguments()); if (myOutFile == null) { - System.err.println("ITT:" + result); + System.err.println(result); } else { try { File f = getProject().resolveFile(myOutFile); @@ -94,7 +100,7 @@ public class InvokeTemplateTask extends Task { if (myTemplateName == null) { throw new BuildException("Template name is missing", getLocation()); } - if (myTemplateTarget == null) { + if (myInputURI == null && myInputObject == null) { throw new BuildException("Target object is missing", getLocation()); } if (myFacade == null && (myTemplateRoots == null || myTemplateRoots.length == 0)) { @@ -103,13 +109,20 @@ public class InvokeTemplateTask extends Task { } protected Object getTemplateTarget() { - return myTemplateTarget; + if (myInputURI != null) { + return getResourceSet().getEObject(URI.createURI(myInputURI), true); + } + return myInputObject; } protected Object[] getTemplateArguments() { return null; } + protected void setInputObject(Object input) { + myInputObject = input; + } + protected void setFacade(XpandFacade xf) { myFacade = xf; } @@ -134,4 +147,12 @@ public class InvokeTemplateTask extends Task { throw new BuildException(ex, getLocation()); } } + + protected ResourceSet getResourceSet() { + if (myResourceSet == null) { + myResourceSet = new ResourceSetImpl(); + myResourceSet.getURIConverter().getURIMap().putAll(EcorePlugin.computePlatformURIMap()); + } + return myResourceSet; + } } |