From a05128401422cae82e1bc4acb0c20d3809cfe361 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Mon, 9 Oct 2017 23:14:39 +0300 Subject: [PATCH] (refs #7535) Allow only selecting models in the model export Change-Id: I5bf76ab83e9556b9eed580bee3f68dadcdc5f0f0 --- .../ui/sharedontology/wizard/ModelExportPage.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelExportPage.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelExportPage.java index 7bdfecd60..8dc11477e 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelExportPage.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelExportPage.java @@ -35,6 +35,7 @@ import org.eclipse.swt.widgets.Label; import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.request.IndexRoot; import org.simantics.db.common.request.UniqueRead; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.SelectionHints; @@ -42,6 +43,7 @@ import org.simantics.db.layer0.util.DraftStatusBean; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingUtils; import org.simantics.modeling.ModelingUtils.LibraryInfo; +import org.simantics.simulation.ontology.SimulationResource; import org.simantics.utils.strings.AlphanumComparator; import org.simantics.utils.ui.ISelectionUtils; @@ -172,10 +174,17 @@ public class ModelExportPage extends WizardPage { public List perform(ReadGraph graph) throws DatabaseException { List result = new ArrayList<>(); Layer0 L0 = Layer0.getInstance(graph); + SimulationResource SIMU = SimulationResource.getInstance(graph); for (Resource r : selected) { - String name = graph.getRelatedValue(r, L0.HasName, Bindings.STRING); - DraftStatusBean draft = ModelingUtils.getDependencyDraftStatus(graph, r); - result.add(new LibraryInfo(name, r, draft)); + Resource model = r; + if(!graph.isInstanceOf(model, SIMU.Model)) { + model = graph.syncRequest(new IndexRoot(r)); + if(!graph.isInstanceOf(model, SIMU.Model)) + continue; + } + String name = graph.getRelatedValue(model, L0.HasName, Bindings.STRING); + DraftStatusBean draft = ModelingUtils.getDependencyDraftStatus(graph, model); + result.add(new LibraryInfo(name, model, draft)); } Collections.sort(result, new Comparator() { @Override -- 2.47.0