X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.xml.sax.ui%2Fsrc%2Forg%2Fsimantics%2Fxml%2Fsax%2Fui%2Fwizard%2FSchemaConversionWizard.java;h=3c27632b6bcccbbe012de1b105568ca6a6cc24e0;hb=fc60d91049c46ee5b6107da4d4c54eada4a9f21c;hp=7512c8adc375cdf78ef1b8ce65051f9ac59319ea;hpb=7fc4b8cf590d204939974dbae460b709112803f0;p=simantics%2Finterop.git diff --git a/org.simantics.xml.sax.ui/src/org/simantics/xml/sax/ui/wizard/SchemaConversionWizard.java b/org.simantics.xml.sax.ui/src/org/simantics/xml/sax/ui/wizard/SchemaConversionWizard.java index 7512c8a..3c27632 100644 --- a/org.simantics.xml.sax.ui/src/org/simantics/xml/sax/ui/wizard/SchemaConversionWizard.java +++ b/org.simantics.xml.sax.ui/src/org/simantics/xml/sax/ui/wizard/SchemaConversionWizard.java @@ -1,11 +1,16 @@ package org.simantics.xml.sax.ui.wizard; import java.io.File; +import java.io.IOException; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; import org.eclipse.ui.IImportWizard; import org.eclipse.ui.IWorkbench; +import org.simantics.xml.sax.ManualSchemaFileImport; import org.simantics.xml.sax.SchemaConverter; public class SchemaConversionWizard extends Wizard implements IImportWizard { @@ -39,15 +44,46 @@ public class SchemaConversionWizard extends Wizard implements IImportWizard { } public void doConversion() throws Exception { - SchemaConverter converter = new SchemaConverter(); - + + File inputFile = new File(inputSelectionPage.getSchemaFilename()); File configurationFile = null; if (inputSelectionPage.getConfigurationFilename() != null) configurationFile = new File(inputSelectionPage.getConfigurationFilename()); File outputPlugin = new File(inputSelectionPage.getPluginFilename()); + + SchemaConverter converter = new SchemaConverter(inputFile,configurationFile,outputPlugin); + converter.setCreateExporter(inputSelectionPage.createExporter); + converter.setCreateImporter(inputSelectionPage.createImporter); + converter.setCreatePGraph(inputSelectionPage.createPGraph); + converter.setFileImport(new ManualSchemaFileImport() { + + String filename; + @Override + public File getFileForLocation(final String location) throws IOException { + if (Display.getCurrent() == null) + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + showDialog(location); + } + }); + else { + showDialog(location); + } + if (filename == null) + return null; + return new File(filename); + } + + protected void showDialog(String location) { + FileDialog dialog = new FileDialog(SchemaConversionWizard.this.getShell(), SWT.OPEN); + dialog.setText("Open schema file for " + location); + filename = dialog.open(); + } + }); - converter.convertSchema(inputFile,configurationFile,outputPlugin); + converter.convert(); schemaCombinationPage.setOutputPlugin(outputPlugin); }