X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fsharedontology%2Fwizard%2FModelExportPage.java;h=2a9e6f2b4f0ad04c0be6d956dd6325a11629c37b;hb=a7f7fb0c37e4377124ddc3860d8c8d3e39dcd2de;hp=7bdfecd60efb51d994f64f8b7e130bd94669f190;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git 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..2a9e6f2b4 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; @@ -57,6 +59,7 @@ public class ModelExportPage extends WizardPage { List models = Collections.emptyList(); private Button overwrite; + private Button dependencies; protected ModelExportPage(ExportPlan model) { super("Export Model", "Define Export Location", null); @@ -153,6 +156,17 @@ public class ModelExportPage extends WizardPage { } }); + dependencies = new Button(container, SWT.CHECK); + dependencies.setText("&Export dependencies"); + dependencies.setSelection(exportModel.includeDependencies); + GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(dependencies); + dependencies.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + validatePage(); + } + }); + try { initializeData(); } catch (DatabaseException e) { @@ -172,10 +186,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 @@ -244,6 +265,7 @@ public class ModelExportPage extends WizardPage { } exportModel.exportLocation = file; exportModel.overwrite = overwrite.getSelection(); + exportModel.includeDependencies = dependencies.getSelection(); setErrorMessage(null); setMessage("Export selected model to " + exportModel.exportLocation + ".");