From b39f9695c428f3b6a31da592a2a019de4abd036d Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Wed, 9 Nov 2016 11:53:19 +0200 Subject: [PATCH] Search for dependencies in all available bundles. refs #6796 Change-Id: I1e9c34ed5f617c7e872d95a22b45e136de5d643e --- .../modeling/ui/actions/CompilePGraphs.java | 39 ++++--------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphs.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphs.java index 533c8fa3a..282c1d07d 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphs.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphs.java @@ -20,7 +20,6 @@ import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; @@ -29,6 +28,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.osgi.framework.Bundle; import org.simantics.PlatformException; import org.simantics.Simantics; import org.simantics.databoard.Bindings; @@ -71,6 +71,7 @@ import org.simantics.graph.representation.TransferableGraph1; import org.simantics.layer0.Layer0; import org.simantics.ltk.ISource; import org.simantics.ltk.Problem; +import org.simantics.modeling.ui.Activator; import org.simantics.utils.datastructures.Pair; /** @@ -160,29 +161,12 @@ public class CompilePGraphs implements ActionFactory { final Collection sources = new ArrayList(); Collection dependencies = new ArrayList(); - File L0GraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.layer0").getEntry("/graph.tg")), "L0_graph.tg"); - File L0XGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.layer0x.ontology").getEntry("/graph.tg")), "L0X_graph.tg"); - File DiagramGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.diagram.ontology").getEntry("/graph.tg")), "DIA_graph.tg"); - File G2DGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.g2d.ontology").getEntry("/graph.tg")), "G2D_graph.tg"); - File StructuralGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.structural.ontology").getEntry("/graph.tg")), "ST_graph.tg"); - File ModelingGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.modeling.ontology").getEntry("/graph.tg")), "MOD_graph.tg"); - File SimulationGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.simulation.ontology").getEntry("/graph.tg")), "SIMU_graph.tg"); - File DocumentGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.document.ontology").getEntry("/graph.tg")), "DOC_graph.tg"); - File SpreadsheetGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.spreadsheet.ontology").getEntry("/graph.tg")), "SHEET_graph.tg"); - File ProjectGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.project.ontology").getEntry("/graph.tg")), "PROJ_graph.tg"); - File SelectionViewGraphFile = url2file(FileLocator.resolve(Platform.getBundle("org.simantics.selectionview.ontology").getEntry("/graph.tg")), "SEL_graph.tg"); - - dependencies.add(GraphCompiler.read(L0GraphFile)); - dependencies.add(GraphCompiler.read(L0XGraphFile)); - dependencies.add(GraphCompiler.read(DiagramGraphFile)); - dependencies.add(GraphCompiler.read(G2DGraphFile)); - dependencies.add(GraphCompiler.read(StructuralGraphFile)); - dependencies.add(GraphCompiler.read(ModelingGraphFile)); - dependencies.add(GraphCompiler.read(SimulationGraphFile)); - dependencies.add(GraphCompiler.read(DocumentGraphFile)); - dependencies.add(GraphCompiler.read(SpreadsheetGraphFile)); - dependencies.add(GraphCompiler.read(ProjectGraphFile)); - dependencies.add(GraphCompiler.read(SelectionViewGraphFile)); + for(Bundle b : Activator.getContext().getBundles()) { + URL tg = b.getEntry("/graph.tg"); + if(tg == null) continue; + File f = url2file(FileLocator.resolve(tg), b.getSymbolicName()); + dependencies.add(GraphCompiler.read(f)); + } final TransferableGraph1 thisOntology = Simantics.sync(new UniqueRead() { @@ -191,7 +175,6 @@ public class CompilePGraphs implements ActionFactory { Layer0 L0 = Layer0.getInstance(graph); Resource parent = graph.getSingleObject(r, L0.PartOf); - String name = graph.getRelatedValue(r, L0.HasName, Bindings.STRING); CopyHandler ch = new DefaultCopyHandler(r) { @@ -282,8 +265,6 @@ public class CompilePGraphs implements ActionFactory { }); - - final StringBuilder errorStringBuilder = new StringBuilder(); GraphCompilerPreferences prefs = new GraphCompilerPreferences(); prefs.validate = true; @@ -378,7 +359,6 @@ public class CompilePGraphs implements ActionFactory { final DefaultPasteImportAdvisor advisor = new DefaultPasteImportAdvisor(r); - // final ImportAdvisor advisor = new ImportAdvisor(r, modelName); DefaultPasteHandler.defaultExecute(result.getGraph(), r, advisor); Simantics.sync(new WriteRequest() { @@ -398,9 +378,6 @@ public class CompilePGraphs implements ActionFactory { } - - - } catch (Exception e) { Logger.defaultLogError(e); } -- 2.43.2