Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2005-11-16 13:52:53 +0000
committerdstadnik2005-11-16 13:52:53 +0000
commit9aad9cef66b1922ddce254558197eed7b957f227 (patch)
tree655434616eb112ab7d110729ecc157b32d5f1a46
parent5590ea5ba79b30c8d6ae7e5f37b820cf7b8c236d (diff)
downloadorg.eclipse.gmf-tooling-9aad9cef66b1922ddce254558197eed7b957f227.tar.gz
org.eclipse.gmf-tooling-9aad9cef66b1922ddce254558197eed7b957f227.tar.xz
org.eclipse.gmf-tooling-9aad9cef66b1922ddce254558197eed7b957f227.zip
[kshaglamdjan] allow to load diadef models from file
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Plugin.java24
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/DiaDefFileSetup.java50
2 files changed, 73 insertions, 1 deletions
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Plugin.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Plugin.java
index 818ee32bb..82b14df9e 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Plugin.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Plugin.java
@@ -1,10 +1,26 @@
+/*
+ * Copyright (c) 2005 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.tests;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
import org.osgi.framework.BundleContext;
-
public class Plugin extends org.eclipse.core.runtime.Plugin {
+
private static Plugin ourInstance;
private BundleContext myContext;
@@ -24,6 +40,12 @@ public class Plugin extends org.eclipse.core.runtime.Plugin {
super.stop(context);
}
+ public static URI createURI(String bundledFileName) throws IOException {
+ URL url = getInstance().getBundle().getEntry(bundledFileName);
+ String filePath = Platform.asLocalURL(url).toExternalForm();
+ return URI.createURI(filePath);
+ }
+
public static Plugin getInstance() {
return ourInstance;
}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/DiaDefFileSetup.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/DiaDefFileSetup.java
new file mode 100644
index 000000000..66a76881d
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/DiaDefFileSetup.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2005 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:
+ * Karen Shaglamdjan (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.tests.setup;
+
+import java.io.IOException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.diadef.Canvas;
+import org.eclipse.gmf.diadef.Connection;
+import org.eclipse.gmf.diadef.Node;
+
+public class DiaDefFileSetup implements DiaDefSource {
+
+ private Canvas myCanvasDef;
+ private Node myNodeDef;
+ private Connection myLinkDef;
+
+ public DiaDefFileSetup init(URI sourceURI) throws IOException {
+ ResourceSet srcResSet = new ResourceSetImpl();
+ Resource srcRes = srcResSet.getResource(sourceURI, true);
+ myCanvasDef = (Canvas) srcRes.getContents().get(0);
+ myNodeDef = (Node) myCanvasDef.getNodes().get(0);
+ myLinkDef = (Connection) myCanvasDef.getLinks().get(0);
+ return this;
+ }
+
+ public final Canvas getCanvasDef() {
+ return myCanvasDef;
+ }
+
+ public final Connection getLinkDef() {
+ return myLinkDef;
+ }
+
+ public final Node getNodeDef() {
+ return myNodeDef;
+ }
+}

Back to the top