Add SCL support for exporting subscription data as CSV
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / ui / CSVExportPlan.java
index 1c88b3556b6f00870cfc4a51f64efd27a23e9574..762fcd95a0456ff168e2515544b52697e90f00bb 100644 (file)
@@ -1,63 +1,88 @@
-/*******************************************************************************\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.Collection;\r
-import java.util.Deque;\r
-import java.util.HashSet;\r
-\r
-import org.simantics.db.common.NamedResource;\r
-import org.simantics.db.management.ISessionContext;\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.project.IProject;\r
-\r
-/**\r
- * @author Antti Villberg\r
- */\r
-public class CSVExportPlan {\r
-       \r
-    // Input\r
-    ISessionContext sessionContext;\r
-    IProject        project;\r
-    Object          selection;\r
-    Deque<String>   recentLocations;\r
-\r
-    // Output\r
-    Collection<NamedResource>   models = new HashSet<NamedResource>();\r
-    File            exportLocation;\r
-\r
-    \r
-    double                             startTime;\r
-    double                             timeStep;\r
-    DecimalSeparator   decimalSeparator;\r
-    ColumnSeparator            columnSeparator;\r
-    boolean             resample;\r
-    ExportInterpolation samplingMode;\r
-    int                                        timeDigits;\r
-    int                                        floatDigits;\r
-    int                                        doubleDigits;\r
-\r
-\r
-    /**\r
-     * <code>true</code> if the model should be overwritten without a warning.\r
-     */\r
-    boolean         overwrite;\r
-\r
-    CSVExportPlan(ISessionContext sessionContext, Deque<String> recentLocations) {\r
-        this.sessionContext = sessionContext;\r
-        this.recentLocations = recentLocations;\r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2012 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.charts.ui;
+
+import java.io.File;
+import java.util.ArrayDeque;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.List;
+
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.history.csv.ColumnSeparator;
+import org.simantics.history.csv.DecimalSeparator;
+import org.simantics.history.csv.ExportInterpolation;
+import org.simantics.project.IProject;
+
+/**
+ * @author Antti Villberg
+ */
+public class CSVExportPlan {
+       
+    // Input
+    ISessionContext sessionContext;
+    IProject        project;
+    Object          selection;
+    Deque<String>   recentLocations;
+
+    // Output
+    Collection<Resource> items = new HashSet<>();
+    File                 exportLocation;
+
+    
+    public double                              startTime;
+    public double                              timeStep;
+    public DecimalSeparator    decimalSeparator;
+    public ColumnSeparator             columnSeparator;
+    public boolean             resample;
+    public ExportInterpolation samplingMode;
+    public int                                 timeDigits;
+    public int                                 floatDigits;
+    public int                                 doubleDigits;
+
+
+    /**
+     * <code>true</code> if the model should be overwritten without a warning.
+     */
+    boolean         overwrite;
+
+    /**
+     * Constructor for SCL support
+     */
+    public CSVExportPlan(double startTime, double timeStep, DecimalSeparator dsep, ColumnSeparator csep, boolean resample, ExportInterpolation mode, int timeDigits, int floatDigits, int doubleDigits) {
+        this.sessionContext = Simantics.getSessionContext();
+        this.recentLocations = new ArrayDeque<>();
+        
+        this.startTime = startTime;
+        this.timeStep = timeStep;
+        this.decimalSeparator = dsep;
+        this.columnSeparator = csep;
+        this.resample = resample;
+        this.samplingMode = mode;
+        this.timeDigits = timeDigits;
+        this.floatDigits = floatDigits;
+        this.doubleDigits = doubleDigits;
+    }
+
+    public void setItems(List<Resource> items) {
+        this.items = items;
+    }
+
+    CSVExportPlan(ISessionContext sessionContext, Deque<String> recentLocations) {
+        this.sessionContext = sessionContext;
+        this.recentLocations = recentLocations;
+    }
+
 }
\ No newline at end of file