aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2009-03-11 14:44:30 -0400
committeratikhomirov2009-03-11 14:44:30 -0400
commit39ffdaba5a670a3444cad59302b45206c1a7f3a3 (patch)
tree2414c3a9544ac10d95aeb327f398060f4585beab
parente87f7acffe8a66446e03e2529de7e0c15d8c6049 (diff)
downloadorg.eclipse.gmf-tooling-39ffdaba5a670a3444cad59302b45206c1a7f3a3.zip
org.eclipse.gmf-tooling-39ffdaba5a670a3444cad59302b45206c1a7f3a3.tar.gz
org.eclipse.gmf-tooling-39ffdaba5a670a3444cad59302b45206c1a7f3a3.tar.xz
[259583] employ real m2m transformations - utility to replace InnerClassViewmapProducer, way to invoke xpand templates during qvto
-rw-r--r--plugins/org.eclipse.gmf.codegen/plugin.xml6
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.qvtlib/org/eclipse/gmf/internal/codegen/util/XpandFacadeAccess.java54
2 files changed, 60 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/plugin.xml b/plugins/org.eclipse.gmf.codegen/plugin.xml
index c0e85a5..d27927a 100644
--- a/plugins/org.eclipse.gmf.codegen/plugin.xml
+++ b/plugins/org.eclipse.gmf.codegen/plugin.xml
@@ -122,5 +122,11 @@
<metamodel nsURI="http://www.eclipse.org/emf/2002/GenModel"/>
</library>
</unit>
+ <unit
+ description="Access to GMF Xpand templates through QVTO"
+ name="XpandFacade"
+ namespace="xpt">
+ <library class="org.eclipse.gmf.internal.codegen.util.XpandFacadeAccess"/>
+ </unit>
</extension>
</plugin>
diff --git a/plugins/org.eclipse.gmf.codegen/templates.qvtlib/org/eclipse/gmf/internal/codegen/util/XpandFacadeAccess.java b/plugins/org.eclipse.gmf.codegen/templates.qvtlib/org/eclipse/gmf/internal/codegen/util/XpandFacadeAccess.java
new file mode 100644
index 0000000..9e119c7
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.qvtlib/org/eclipse/gmf/internal/codegen/util/XpandFacadeAccess.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2009 Borland Software Corporation
+ *
+ * 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:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.internal.codegen.util;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.gmf.internal.xpand.BufferOutput;
+import org.eclipse.gmf.internal.xpand.XpandFacade;
+import org.eclipse.gmf.internal.xpand.model.Scope;
+import org.eclipse.gmf.internal.xpand.util.BundleResourceManager;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
+
+/**
+ * @author artem
+ */
+public class XpandFacadeAccess {
+
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public String xpand(Object self, String templateName, List<String> templateRoots) {
+ StringBuilder result = new StringBuilder();
+ ArrayList<URL> urls = new ArrayList<URL>(templateRoots.size());
+ for (String s : templateRoots) {
+ try {
+ urls.add(new URL(s));
+ } catch (MalformedURLException ex) {
+ ILog l = Platform.getLog(Platform.getBundle("org.eclipse.gmf.codegen")); //$NON-NLS-1$
+ l.log(new Status(Status.ERROR, l.getBundle().getSymbolicName(), ex.getClass().getSimpleName(), ex));
+ }
+ }
+ BundleResourceManager rm = new BundleResourceManager(urls.toArray(new URL[urls.size()]));
+ try {
+ new XpandFacade(new Scope(rm, null, new BufferOutput(result))).evaluate(templateName, self, null);
+ } catch (Exception ex) {
+ return ex.toString();
+ }
+ return result.toString();
+ }
+}