--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.charts.ui;\r
+\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.eclipse.core.runtime.preferences.InstanceScope;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.preference.IPreferenceStore;\r
+import org.eclipse.jface.wizard.WizardPage;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.CCombo;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.eclipse.swt.widgets.Text;\r
+import org.eclipse.ui.preferences.ScopedPreferenceStore;\r
+import org.simantics.NameLabelUtil;\r
+import org.simantics.Simantics;\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.parser.StringEscapeUtils;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.NamedResource;\r
+import org.simantics.db.common.request.IsParent;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.history.csv.ColumnSeparator;\r
+import org.simantics.history.csv.DecimalSeparator;\r
+import org.simantics.history.csv.ExportInterpolation;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.modeling.preferences.CSVPreferences;\r
+import org.simantics.modeling.ui.modelBrowser2.label.SubscriptionItemLabelRule;\r
+import org.simantics.utils.datastructures.Arrays;\r
+import org.simantics.utils.datastructures.Pair;\r
+import org.simantics.utils.strings.AlphanumComparator;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+\r
+/**\r
+ * @author Antti Villberg\r
+ */\r
+public class CSVExportPage extends WizardPage {\r
+\r
+ CSVExportPlan exportModel;\r
+ CCombo model;\r
+ Table item;\r
+ Button selectAllItems;\r
+ SelectionAdapter selectAllItemsListener;\r
+ CCombo exportLocation;\r
+\r
+ CCombo decimalSeparator;\r
+ CCombo columnSeparator;\r
+ CCombo sampling;\r
+ Text timeStep;\r
+ Text startTime;\r
+ Text timeStamps;\r
+ CCombo samplingMode;\r
+ Text singlePrecision;\r
+ Text doublePrecision;\r
+\r
+ Group resampling;\r
+\r
+ Collection<Resource> initialSelection;\r
+\r
+ List<Pair<NamedResource,List<NamedResource>>> models = new ArrayList<>();\r
+\r
+ private Button overwrite;\r
+\r
+ ModifyListener m = (e) -> validatePage();\r
+\r
+ SelectionListener s = new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ validatePage();\r
+ }\r
+ };\r
+\r
+ protected CSVExportPage(CSVExportPlan model) {\r
+ super("Export CSV Data", "Define Export Properties", null);\r
+ this.exportModel = model;\r
+ }\r
+\r
+ @Override\r
+ public void createControl(Composite parent) {\r
+ Composite container = new Composite(parent, SWT.NONE);\r
+ GridLayoutFactory.swtDefaults().spacing(20, 10).numColumns(3).applyTo(container);\r
+ new Label(container, SWT.NONE).setText("Select a model:");\r
+ model = new CCombo(container, SWT.BORDER);\r
+ {\r
+ model.setEditable(false);\r
+ model.setText("");\r
+ model.setToolTipText("Selects the Model To Export From");\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(model);\r
+ }\r
+\r
+ new Label(container, SWT.NONE).setText("Exported items:");\r
+ item = new Table(container, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);\r
+ {\r
+ item.setToolTipText("Selects the Subscription Items");\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).hint(SWT.DEFAULT, 105).applyTo(item);\r
+ }\r
+ item.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ if (e.detail == SWT.CHECK) {\r
+ TableItem[] selected = item.getSelection();\r
+ TableItem it = (TableItem) e.item;\r
+ boolean checkedWasSelected = Arrays.contains(selected, it);\r
+ if (checkedWasSelected) {\r
+ boolean check = it.getChecked();\r
+ for (TableItem i : selected)\r
+ i.setChecked(check);\r
+ }\r
+ int checked = countCheckedItems(item);\r
+ int totalItems = item.getItemCount();\r
+ updateSelectAll(checked > 0, checked < totalItems, false);\r
+ validatePage();\r
+ }\r
+ }\r
+ });\r
+ new Label(container, 0);\r
+ selectAllItems = new Button(container, SWT.CHECK);\r
+ {\r
+ selectAllItems.setText("&Select All");\r
+ selectAllItems.setToolTipText("Select/Deselect All Listed Subscription Items");\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(selectAllItems);\r
+ }\r
+ selectAllItemsListener = new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ boolean select = selectAllItems.getSelection();\r
+ updateSelectAll(select, false, false);\r
+ item.setRedraw(false);\r
+ for (TableItem it : item.getItems())\r
+ it.setChecked(select);\r
+ item.setRedraw(true);\r
+\r
+ validatePage();\r
+ }\r
+ };\r
+ selectAllItems.addSelectionListener(selectAllItemsListener);\r
+\r
+ new Label(container, SWT.NONE).setText("&Output file:");\r
+ exportLocation = new CCombo(container, SWT.BORDER);\r
+ {\r
+ exportLocation.setText("");\r
+ GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(exportLocation);\r
+ exportLocation.addModifyListener(m);\r
+ }\r
+ Button browseFileButton = new Button(container, SWT.PUSH);\r
+ {\r
+ browseFileButton.setText("Browse...");\r
+ browseFileButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
+ browseFileButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);\r
+ dialog.setText("Choose Output File");\r
+ dialog.setFilterPath(new File(exportLocation.getText()).getParent());\r
+ dialog.setFilterExtensions(new String[] { "*.csv" });\r
+ dialog.setFilterNames(new String[] { "Comma separated values (*.csv)" });\r
+ dialog.setOverwrite(false);\r
+ String file = dialog.open();\r
+ if (file == null)\r
+ return;\r
+ exportLocation.setText(file);\r
+ validatePage();\r
+ }\r
+ });\r
+ }\r
+\r
+ \r
+ Label horizRule = new Label(container, SWT.BORDER);\r
+ GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 0).grab(true, false).span(3, 1).applyTo(horizRule);\r
+\r
+ new Label(container, SWT.NONE).setText("&Decimal separator:");\r
+ decimalSeparator = new CCombo(container, SWT.READ_ONLY | SWT.BORDER);\r
+ for(DecimalSeparator s : DecimalSeparator.values())\r
+ decimalSeparator.add(s.label);\r
+ decimalSeparator.select(0);\r
+ decimalSeparator.addSelectionListener(s);\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(decimalSeparator);\r
+\r
+ new Label(container, SWT.NONE).setText("&Column separator:");\r
+ columnSeparator = new CCombo(container, SWT.READ_ONLY | SWT.BORDER);\r
+ for(ColumnSeparator s : ColumnSeparator.values())\r
+ columnSeparator.add(s.label);\r
+ columnSeparator.select(0);\r
+ columnSeparator.addSelectionListener(s);\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(columnSeparator);\r
+\r
+ new Label(container, SWT.NONE).setText("Sampling:");\r
+ sampling = new CCombo(container, SWT.READ_ONLY | SWT.BORDER);\r
+ sampling.add("Recorded samples");\r
+ sampling.add("Resampled");\r
+ sampling.select(0);\r
+ sampling.addSelectionListener(s);\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(sampling);\r
+\r
+ resampling = new Group(container, SWT.NONE);\r
+ resampling.setText("Resampling settings (not used with recorded samples)");\r
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(resampling);\r
+ GridLayoutFactory.swtDefaults().numColumns(3).applyTo(resampling);\r
+\r
+ new Label(resampling, SWT.NONE).setText("&Start time:");\r
+ startTime = new Text(resampling, SWT.BORDER);\r
+ startTime.addModifyListener(m);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(startTime);\r
+ new Label(resampling, SWT.NONE).setText(" seconds");\r
+\r
+ new Label(resampling, SWT.NONE).setText("&Time step:");\r
+ timeStep = new Text(resampling, SWT.BORDER);\r
+ timeStep.addModifyListener(m);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(timeStep);\r
+ new Label(resampling, SWT.NONE).setText(" seconds");\r
+ \r
+ new Label(resampling, SWT.NONE).setText("Sampling mode:");\r
+ samplingMode = new CCombo(resampling, SWT.READ_ONLY | SWT.BORDER);\r
+ samplingMode.add("Linear interpolation");\r
+ samplingMode.add("Previous sample");\r
+ samplingMode.select(0);\r
+ samplingMode.addSelectionListener(s);\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2,1).applyTo(samplingMode);\r
+\r
+ Group digits = new Group(container, SWT.NONE);\r
+ digits.setText("Significant digits");\r
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(digits);\r
+ GridLayoutFactory.swtDefaults().numColumns(2).applyTo(digits);\r
+\r
+ new Label(digits, SWT.NONE).setText("&Time stamps:");\r
+ timeStamps = new Text(digits, SWT.BORDER);\r
+ timeStamps.addModifyListener(m);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(timeStamps);\r
+ \r
+ new Label(digits, SWT.NONE).setText("&Single precision floating point:");\r
+ singlePrecision = new Text(digits, SWT.BORDER);\r
+ singlePrecision.addModifyListener(m);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(singlePrecision);\r
+\r
+ new Label(digits, SWT.NONE).setText("&Double precision floating point:");\r
+ doublePrecision = new Text(digits, SWT.BORDER);\r
+ doublePrecision.addModifyListener(m);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(doublePrecision);\r
+\r
+ overwrite = new Button(container, SWT.CHECK);\r
+ overwrite.setText("&Overwrite existing files without warning");\r
+ overwrite.setSelection(exportModel.overwrite);\r
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(overwrite);\r
+ overwrite.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ validatePage();\r
+ }\r
+ });\r
+\r
+ try {\r
+ initializeData();\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ model.addSelectionListener(s);\r
+\r
+ setControl(container);\r
+ validatePage();\r
+ \r
+ }\r
+\r
+ void updateSelectAll(boolean checked, boolean gray, boolean notify) {\r
+ if (checked) {\r
+ selectAllItems.setText("Select None");\r
+ } else {\r
+ selectAllItems.setText("Select All");\r
+ }\r
+ if (!notify)\r
+ selectAllItems.removeSelectionListener(selectAllItemsListener);\r
+ selectAllItems.setGrayed(checked && gray);\r
+ selectAllItems.setSelection(checked);\r
+ if (!notify)\r
+ selectAllItems.addSelectionListener(selectAllItemsListener);\r
+ }\r
+\r
+ protected int countCheckedItems(Table table) {\r
+ int ret = 0;\r
+ for (TableItem item : table.getItems())\r
+ ret += item.getChecked() ? 1 : 0;\r
+ return ret;\r
+ }\r
+\r
+ private void initializeData() throws DatabaseException {\r
+\r
+ // Write preferences to formatter\r
+ IPreferenceStore csvnode = new ScopedPreferenceStore( InstanceScope.INSTANCE, CSVPreferences.P_NODE );\r
+ \r
+ Double startTime = csvnode.getDouble(CSVPreferences.P_CSV_START_TIME);\r
+ Double timeStep = csvnode.getDouble(CSVPreferences.P_CSV_TIME_STEP);\r
+ String decimalSeparator = csvnode.getString(CSVPreferences.P_CSV_DECIMAL_SEPARATOR);\r
+ String columnSeparator = StringEscapeUtils.unescape( csvnode.getString(CSVPreferences.P_CSV_COLUMN_SEPARATOR) );\r
+ Boolean resample = csvnode.getBoolean(CSVPreferences.P_CSV_RESAMPLE);\r
+ String samplingModePreference = csvnode.getString(CSVPreferences.P_CSV_SAMPLING_MODE);\r
+ int timeDigits = csvnode.getInt(CSVPreferences.P_CSV_TIME_DIGITS);\r
+ int floatDigits = csvnode.getInt(CSVPreferences.P_CSV_FLOAT_DIGITS);\r
+ int doubleDigits = csvnode.getInt(CSVPreferences.P_CSV_DOUBLE_DIGITS);\r
+ \r
+ initialSelection = ISelectionUtils.getPossibleKeys(exportModel.selection, SelectionHints.KEY_MAIN, Resource.class);\r
+\r
+ models = exportModel.sessionContext.getSession().syncRequest(new UniqueRead<List<Pair<NamedResource,List<NamedResource>>>>() {\r
+\r
+ @Override\r
+ public List<Pair<NamedResource,List<NamedResource>>> perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ ModelingResources MOD = ModelingResources.getInstance(graph);\r
+ List<Pair<NamedResource,List<NamedResource>>> result = new ArrayList<>();\r
+ for(Resource model : graph.syncRequest(new org.simantics.db.layer0.request.ProjectModels(Simantics.getProjectResource()))) {\r
+ String name = graph.getPossibleRelatedValue(model, L0.HasName, Bindings.STRING);\r
+ if(name == null) continue;\r
+ name = NameLabelUtil.modalName(graph, model);\r
+ List<NamedResource> subs = new ArrayList<>();\r
+ for(Resource item : ModelingUtils.searchByType(graph, model, MOD.Subscription_Item)) {\r
+ String subscriptionLabel = null;\r
+ Resource subscription = graph.getPossibleObject(item, L0.PartOf);\r
+ if(subscription != null) {\r
+ subscriptionLabel = graph.getPossibleRelatedValue(subscription, L0.HasLabel, Bindings.STRING);\r
+ }\r
+ SubscriptionItemLabelRule rule = new SubscriptionItemLabelRule();\r
+ Map<String,String> map = rule.getLabel(graph, item); \r
+ String label = map.get(ColumnKeys.SINGLE);\r
+ if(label == null) continue;\r
+ if(subscriptionLabel != null) label = subscriptionLabel + "/" + label;\r
+ subs.add(new NamedResource(label, item));\r
+ }\r
+ subs.sort((o1,o2) -> AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(o1.getName(), o2.getName()));\r
+ result.add(new Pair<>(new NamedResource(name, model), subs));\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ });\r
+ \r
+ Set<NamedResource> selected = exportModel.sessionContext.getSession().syncRequest(new UniqueRead<Set<NamedResource>>() {\r
+\r
+ @Override\r
+ public Set<NamedResource> perform(ReadGraph graph) throws DatabaseException {\r
+\r
+ if(initialSelection == null) return Collections.emptySet();\r
+\r
+ HashSet<NamedResource> result = new HashSet<>();\r
+ \r
+ for(Pair<NamedResource,List<NamedResource>> p : models) {\r
+ for(NamedResource nr : p.second) {\r
+ for(Resource i : initialSelection) {\r
+ if(graph.syncRequest(new IsParent(i, nr.getResource()))) result.add(nr);\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ });\r
+ \r
+\r
+ for(int i=0;i<models.size();i++) {\r
+ \r
+ Pair<NamedResource,List<NamedResource>> p = models.get(i);\r
+ model.add(p.first.getName());\r
+\r
+ boolean hasInitial = false;\r
+ for(NamedResource nr : p.second) {\r
+ if(selected.contains(nr)) hasInitial = true;\r
+ }\r
+ if(hasInitial) {\r
+ model.select(i);\r
+ item.removeAll();\r
+ exportModel.models.clear();\r
+ int index = 0;\r
+ int firstIndex = 0;\r
+ for(NamedResource nr : p.second) {\r
+ TableItem ti = new TableItem(item, SWT.NONE);\r
+ ti.setText(nr.getName());\r
+ ti.setData(nr);\r
+ if(selected.contains(nr)) {\r
+ exportModel.models.add(nr);\r
+ ti.setChecked(true);\r
+ if(firstIndex == 0) firstIndex = index;\r
+ }\r
+ index++;\r
+ }\r
+ item.setTopIndex(firstIndex);\r
+ item.setData(p.first);\r
+ }\r
+ \r
+ }\r
+ \r
+ this.decimalSeparator.select(DecimalSeparator.fromPreference(decimalSeparator).ordinal());\r
+ this.columnSeparator.select(ColumnSeparator.fromPreference(columnSeparator).ordinal());\r
+ \r
+ if(resample) {\r
+ this.sampling.select(1);\r
+ } else {\r
+ this.sampling.select(0);\r
+ }\r
+ \r
+ this.samplingMode.select(ExportInterpolation.fromPreference(samplingModePreference).index());\r
+ \r
+ this.startTime.setText("" + startTime);\r
+ this.timeStep.setText("" + timeStep);\r
+ this.timeStamps.setText("" + timeDigits);\r
+ this.singlePrecision.setText("" + floatDigits);\r
+ this.doublePrecision.setText("" + doubleDigits);\r
+ \r
+ for (String path : exportModel.recentLocations) {\r
+ exportLocation.add(path);\r
+ }\r
+ if (exportLocation.getItemCount() > 0)\r
+ exportLocation.select(0);\r
+ \r
+ }\r
+\r
+ Integer validInteger(String s) {\r
+ try {\r
+ return Integer.parseInt(s);\r
+ } catch (NumberFormatException e) {\r
+ return null;\r
+ }\r
+ }\r
+\r
+ Double validDouble(String s) {\r
+ try {\r
+ return Double.parseDouble(s);\r
+ } catch (NumberFormatException e) {\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ Pair<NamedResource,List<NamedResource>> getModel(String name) {\r
+ for(Pair<NamedResource,List<NamedResource>> data : models) {\r
+ if(data.first.getName().equals(name)) return data;\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ void validatePage() {\r
+\r
+ boolean resample = sampling.getText().equals("Resampled"); \r
+ \r
+ if(resample) {\r
+ resampling.setText("Resampling settings");\r
+ timeStep.setEnabled(true);\r
+ startTime.setEnabled(true);\r
+ samplingMode.setEnabled(true);\r
+ } else {\r
+ resampling.setText("Resampling settings (not used with recorded samples)");\r
+ timeStep.setEnabled(false);\r
+ startTime.setEnabled(false);\r
+ samplingMode.setEnabled(false);\r
+ }\r
+ \r
+ String selectedModel = model.getText();\r
+ Pair<NamedResource,List<NamedResource>> p = getModel(selectedModel);\r
+ if(p != null) {\r
+ \r
+ HashSet<NamedResource> checked = new HashSet<>();\r
+ \r
+ NamedResource existing = (NamedResource)item.getData();\r
+ if(!p.first.equals(existing)) {\r
+ \r
+ item.removeAll();\r
+ for(NamedResource nr : p.second) {\r
+ TableItem ti = new TableItem(item, SWT.NONE);\r
+ ti.setText(nr.getName());\r
+ ti.setData(nr);\r
+ }\r
+ item.setData(p.first);\r
+ \r
+ }\r
+ \r
+ for(TableItem ti : item.getItems()) {\r
+ if(ti.getChecked()) checked.add((NamedResource)ti.getData());\r
+ }\r
+ \r
+ exportModel.models = checked;\r
+ \r
+ }\r
+\r
+ Double validStartTime = validDouble(startTime.getText());\r
+ Double validStepSize = validDouble(timeStep.getText());\r
+\r
+ if(resample) {\r
+ \r
+ if(validStartTime == null) {\r
+ setErrorMessage("Start time must be a number.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+ \r
+ if(validStepSize == null) {\r
+ setErrorMessage("Step size must be a number.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+ if(validStepSize <= 0) {\r
+ setErrorMessage("Step size must be greater than 0.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+\r
+ } else {\r
+ \r
+ if(exportModel.models.size() > 1) {\r
+ setErrorMessage("Recorded samples can only be exported for a single subscription item.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+\r
+ }\r
+ \r
+ if(item.getItemCount() == 0) {\r
+ setErrorMessage("No subscription items in selected model.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+ \r
+ if (exportModel.models.isEmpty()) {\r
+ setErrorMessage("No items selected for export.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+ \r
+ String exportLoc = exportLocation.getText();\r
+ if (exportLoc.isEmpty()) {\r
+ setErrorMessage("Select output file.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+ File file = new File(exportLoc);\r
+ if (file.isDirectory()) {\r
+ setErrorMessage("The output file is a directory.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+ File parent = file.getParentFile();\r
+ if (parent == null || !parent.isDirectory()) {\r
+ setErrorMessage("The output directory does not exist.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+\r
+ exportModel.columnSeparator = ColumnSeparator.fromIndex(columnSeparator.getSelectionIndex());\r
+ exportModel.decimalSeparator = DecimalSeparator.fromIndex(decimalSeparator.getSelectionIndex());\r
+ if (exportModel.columnSeparator.preference.equals(exportModel.decimalSeparator.preference)) {\r
+ setErrorMessage("Decimal and column separator cannot be the same character.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+\r
+ Integer validTimeDigits = validInteger(timeStamps.getText());\r
+\r
+ if(validTimeDigits == null) {\r
+ setErrorMessage("Time stamps needs to be an integer number.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+\r
+ Integer validSinglePrecision = validInteger(singlePrecision.getText());\r
+ if(validSinglePrecision == null) {\r
+ setErrorMessage("Single precision needs to be an integer number.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+\r
+ Integer validDoublePrecision = validInteger(doublePrecision.getText());\r
+ if(validDoublePrecision == null) {\r
+ setErrorMessage("Double precision needs to be an integer number.");\r
+ setPageComplete(false);\r
+ return;\r
+ }\r
+\r
+ exportModel.exportLocation = file;\r
+ exportModel.overwrite = overwrite.getSelection();\r
+\r
+ exportModel.startTime = validStartTime;\r
+ exportModel.timeStep = validStepSize;\r
+\r
+ exportModel.resample = sampling.getSelectionIndex() == 1;\r
+ exportModel.samplingMode = ExportInterpolation.fromIndex(samplingMode.getSelectionIndex());\r
+ \r
+ exportModel.timeDigits = validTimeDigits;\r
+ exportModel.floatDigits = validSinglePrecision;\r
+ exportModel.doubleDigits = validDoublePrecision;\r
+ \r
+ setErrorMessage(null);\r
+ setMessage("Press Finish to export subscription data.");\r
+ setPageComplete(true);\r
+ \r
+ }\r
+\r
+}\r