]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Search for dependencies in all available bundles. 35/135/1
authorAntti Villberg <antti.villberg@semantum.fi>
Wed, 9 Nov 2016 09:53:19 +0000 (11:53 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Wed, 9 Nov 2016 09:53:19 +0000 (11:53 +0200)
refs #6796

Change-Id: I1e9c34ed5f617c7e872d95a22b45e136de5d643e

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphs.java

index 533c8fa3aace3548d1247d18a9bdf6a26ea7ebae..282c1d07dd6068546768b63adec1cb69b7fd7e6a 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Map;
 import java.util.Set;\r
 \r
 import org.eclipse.core.runtime.FileLocator;\r
-import org.eclipse.core.runtime.Platform;\r
 import org.eclipse.jface.dialogs.MessageDialog;\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
@@ -29,6 +28,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;\r
 import org.eclipse.swt.widgets.Display;\r
 import org.eclipse.swt.widgets.Shell;\r
+import org.osgi.framework.Bundle;\r
 import org.simantics.PlatformException;\r
 import org.simantics.Simantics;\r
 import org.simantics.databoard.Bindings;\r
@@ -71,6 +71,7 @@ import org.simantics.graph.representation.TransferableGraph1;
 import org.simantics.layer0.Layer0;\r
 import org.simantics.ltk.ISource;\r
 import org.simantics.ltk.Problem;\r
+import org.simantics.modeling.ui.Activator;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
 /**\r
@@ -160,29 +161,12 @@ public class CompilePGraphs implements ActionFactory {
                                final Collection<ISource> sources = new ArrayList<ISource>();\r
                                Collection<TransferableGraph1> dependencies = new ArrayList<TransferableGraph1>();\r
 \r
-                       File L0GraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.layer0").getEntry("/graph.tg")), "L0_graph.tg");\r
-                       File L0XGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.layer0x.ontology").getEntry("/graph.tg")), "L0X_graph.tg");\r
-                       File DiagramGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.diagram.ontology").getEntry("/graph.tg")), "DIA_graph.tg");\r
-                       File G2DGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.g2d.ontology").getEntry("/graph.tg")), "G2D_graph.tg");\r
-                       File StructuralGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.structural.ontology").getEntry("/graph.tg")), "ST_graph.tg");\r
-                       File ModelingGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.modeling.ontology").getEntry("/graph.tg")), "MOD_graph.tg");\r
-                       File SimulationGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.simulation.ontology").getEntry("/graph.tg")), "SIMU_graph.tg");\r
-                       File DocumentGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.document.ontology").getEntry("/graph.tg")), "DOC_graph.tg");\r
-                       File SpreadsheetGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.spreadsheet.ontology").getEntry("/graph.tg")), "SHEET_graph.tg");\r
-                       File ProjectGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.project.ontology").getEntry("/graph.tg")), "PROJ_graph.tg");\r
-                       File SelectionViewGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.selectionview.ontology").getEntry("/graph.tg")), "SEL_graph.tg");\r
-                       \r
-                               dependencies.add(GraphCompiler.read(L0GraphFile));\r
-                               dependencies.add(GraphCompiler.read(L0XGraphFile));\r
-                               dependencies.add(GraphCompiler.read(DiagramGraphFile));\r
-                               dependencies.add(GraphCompiler.read(G2DGraphFile));\r
-                               dependencies.add(GraphCompiler.read(StructuralGraphFile));\r
-                               dependencies.add(GraphCompiler.read(ModelingGraphFile));\r
-                               dependencies.add(GraphCompiler.read(SimulationGraphFile));\r
-                               dependencies.add(GraphCompiler.read(DocumentGraphFile));\r
-                               dependencies.add(GraphCompiler.read(SpreadsheetGraphFile));\r
-                               dependencies.add(GraphCompiler.read(ProjectGraphFile));\r
-                               dependencies.add(GraphCompiler.read(SelectionViewGraphFile));\r
+                               for(Bundle b : Activator.getContext().getBundles()) {\r
+                                       URL tg = b.getEntry("/graph.tg");\r
+                                       if(tg == null) continue;\r
+                                       File f = url2file(FileLocator.resolve(tg), b.getSymbolicName());\r
+                                       dependencies.add(GraphCompiler.read(f));\r
+                               }\r
 \r
                                final TransferableGraph1 thisOntology = Simantics.sync(new UniqueRead<TransferableGraph1>() {\r
 \r
@@ -191,7 +175,6 @@ public class CompilePGraphs implements ActionFactory {
                                                        \r
                                                        Layer0 L0 = Layer0.getInstance(graph);\r
                                                        Resource parent = graph.getSingleObject(r, L0.PartOf);\r
-                                                       String name = graph.getRelatedValue(r, L0.HasName, Bindings.STRING);\r
                                                        \r
                                    CopyHandler ch = new DefaultCopyHandler(r) {\r
                                        \r
@@ -282,8 +265,6 @@ public class CompilePGraphs implements ActionFactory {
                                                \r
                                        });\r
                                \r
-\r
-                               \r
                                final StringBuilder errorStringBuilder = new StringBuilder();\r
                                GraphCompilerPreferences prefs = new GraphCompilerPreferences();\r
                                prefs.validate = true;\r
@@ -378,7 +359,6 @@ public class CompilePGraphs implements ActionFactory {
                                \r
                                        final DefaultPasteImportAdvisor advisor = new DefaultPasteImportAdvisor(r);\r
                                        \r
-       //                              final ImportAdvisor advisor = new ImportAdvisor(r, modelName);\r
                                        DefaultPasteHandler.defaultExecute(result.getGraph(), r, advisor);\r
                                        \r
                                                Simantics.sync(new WriteRequest() {\r
@@ -398,9 +378,6 @@ public class CompilePGraphs implements ActionFactory {
                                                \r
                                }\r
                                        \r
-                                       \r
-\r
-                                       \r
                                } catch (Exception e) {\r
                                        Logger.defaultLogError(e);\r
                                }\r