X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fwizard%2FModelExportWizardPage.java;h=0146ff347b20365b0658a238f57b3d792099acf5;hb=refs%2Fchanges%2F28%2F3328%2F1;hp=95e384b7e93b7fd4ada18a820e7c8101f9816ef2;hpb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/wizard/ModelExportWizardPage.java b/org.simantics.g3d/src/org/simantics/g3d/wizard/ModelExportWizardPage.java index 95e384b7..0146ff34 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/wizard/ModelExportWizardPage.java +++ b/org.simantics.g3d/src/org/simantics/g3d/wizard/ModelExportWizardPage.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ package org.simantics.g3d.wizard; import java.io.File; @@ -89,99 +100,99 @@ public abstract class ModelExportWizardPage extends Wiza } if (exportToFile) { - new Label(container, SWT.NONE).setText("&Target file:"); - exportLocation = new CCombo(container, SWT.BORDER); - { - exportLocation.setText(""); - GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(exportLocation); - exportLocation.addModifyListener(new ModifyListener(){ - @Override - public void modifyText(ModifyEvent e) { - validatePage(); - } - }); - } - Button browseFileButton = new Button(container, SWT.PUSH); - { - browseFileButton.setText("Browse..."); - browseFileButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); - browseFileButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - dialog.setText("Choose Export Target File"); - dialog.setFilterExtensions(getFilterExtensions()); - dialog.setFilterNames(getFilterNames()); - String loc = exportLocation.getText(); - dialog.setFilterPath(loc); - String file = dialog.open(); - if (file == null) - return; - exportLocation.setText(file); - validatePage(); - } - }); - } + new Label(container, SWT.NONE).setText("&Target file:"); + exportLocation = new CCombo(container, SWT.BORDER); + { + exportLocation.setText(""); + GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(exportLocation); + exportLocation.addModifyListener(new ModifyListener(){ + @Override + public void modifyText(ModifyEvent e) { + validatePage(); + } + }); + } + Button browseFileButton = new Button(container, SWT.PUSH); + { + browseFileButton.setText("Browse..."); + browseFileButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); + browseFileButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + dialog.setText("Choose Export Target File"); + dialog.setFilterExtensions(getFilterExtensions()); + dialog.setFilterNames(getFilterNames()); + String loc = exportLocation.getText(); + dialog.setFilterPath(loc); + String file = dialog.open(); + if (file == null) + return; + exportLocation.setText(file); + validatePage(); + } + }); + } - + - + } else { - new Label(container, SWT.NONE).setText("&Target folder:"); - exportLocation = new CCombo(container, SWT.BORDER); - { - exportLocation.setText(""); - GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(exportLocation); - exportLocation.addModifyListener(new ModifyListener(){ - @Override - public void modifyText(ModifyEvent e) { - validatePage(); - } - }); - } - Button browseFileButton = new Button(container, SWT.PUSH); - { - browseFileButton.setText("Browse..."); - browseFileButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); - browseFileButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE); - dialog.setText("Choose Export Target Folder"); - String loc = exportLocation.getText(); - dialog.setFilterPath(loc); - String file = dialog.open(); - if (file == null) - return; - exportLocation.setText(file); - validatePage(); - } - }); - } + new Label(container, SWT.NONE).setText("&Target folder:"); + exportLocation = new CCombo(container, SWT.BORDER); + { + exportLocation.setText(""); + GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(exportLocation); + exportLocation.addModifyListener(new ModifyListener(){ + @Override + public void modifyText(ModifyEvent e) { + validatePage(); + } + }); + } + Button browseFileButton = new Button(container, SWT.PUSH); + { + browseFileButton.setText("Browse..."); + browseFileButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); + browseFileButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE); + dialog.setText("Choose Export Target Folder"); + String loc = exportLocation.getText(); + dialog.setFilterPath(loc); + String file = dialog.open(); + if (file == null) + return; + exportLocation.setText(file); + validatePage(); + } + }); + } } - Label horizRule = new Label(container, SWT.BORDER); - GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 0).grab(true, false).span(3, 1).applyTo(horizRule); + Label horizRule = new Label(container, SWT.BORDER); + GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 0).grab(true, false).span(3, 1).applyTo(horizRule); - overwrite = new Button(container, SWT.CHECK); - overwrite.setText("&Overwrite existing files without warning"); - overwrite.setSelection(exportData.isOverwrite()); - GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(overwrite); - overwrite.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - validatePage(); - } - }); + overwrite = new Button(container, SWT.CHECK); + overwrite.setText("&Overwrite existing files without warning"); + overwrite.setSelection(exportData.isOverwrite()); + GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(overwrite); + overwrite.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + validatePage(); + } + }); - try { - initializeData(); - } catch (DatabaseException e) { - e.printStackTrace(); - } + try { + initializeData(); + } catch (DatabaseException e) { + e.printStackTrace(); + } - setControl(container); - validatePage(); + setControl(container); + validatePage(); } @@ -189,42 +200,42 @@ public abstract class ModelExportWizardPage extends Wiza protected void initializeData() throws DatabaseException { - final Resource selection = ResourceAdaptionUtils.toSingleResource(exportData.getSelection()); + final Resource selection = ResourceAdaptionUtils.toSingleResource(exportData.getSelection()); - Simantics.getSessionContext().getSession().syncRequest( - new ReadRequest() { - @Override - public void run(ReadGraph graph) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - models = getSupportedModels(graph, Simantics.getProject().get()); - } - }); + Simantics.getSessionContext().getSession().syncRequest( + new ReadRequest() { + @Override + public void run(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + models = getSupportedModels(graph, Simantics.getProject().get()); + } + }); - Collections.sort(models); + Collections.sort(models); - // Populate combo boxes - int i = 0; - boolean selected = false; - for (NamedResource s : models) { - model.add(s.getName()); - model.setData(String.valueOf(i), s); - if (s.getResource().equals(selection)) { - model.select(i); - selected = true; - } - ++i; - } - if (!selected && i > 0) - model.select(0); - - if (model.getSelectionIndex() >= 0) { - exportData.setModel((NamedResource)model.getData(Integer.toString(model.getSelectionIndex()))); - } - for (String path : exportData.getRecentLocations()) { - exportLocation.add(path); - } - if (exportLocation.getItemCount() > 0) - exportLocation.select(0); + // Populate combo boxes + int i = 0; + boolean selected = false; + for (NamedResource s : models) { + model.add(s.getName()); + model.setData(String.valueOf(i), s); + if (s.getResource().equals(selection)) { + model.select(i); + selected = true; + } + ++i; + } + if (!selected && i > 0) + model.select(0); + + if (model.getSelectionIndex() >= 0) { + exportData.setModel((NamedResource)model.getData(Integer.toString(model.getSelectionIndex()))); + } + for (String path : exportData.getRecentLocations()) { + exportLocation.add(path); + } + if (exportLocation.getItemCount() > 0) + exportLocation.select(0); }