Add SCL support for exporting subscription data as CSV
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / ui / CSVExportPlan.java
1 /*******************************************************************************
2  * Copyright (c) 2012 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.charts.ui;
13
14 import java.io.File;
15 import java.util.ArrayDeque;
16 import java.util.Collection;
17 import java.util.Deque;
18 import java.util.HashSet;
19 import java.util.List;
20
21 import org.simantics.Simantics;
22 import org.simantics.db.Resource;
23 import org.simantics.db.management.ISessionContext;
24 import org.simantics.history.csv.ColumnSeparator;
25 import org.simantics.history.csv.DecimalSeparator;
26 import org.simantics.history.csv.ExportInterpolation;
27 import org.simantics.project.IProject;
28
29 /**
30  * @author Antti Villberg
31  */
32 public class CSVExportPlan {
33         
34     // Input
35     ISessionContext sessionContext;
36     IProject        project;
37     Object          selection;
38     Deque<String>   recentLocations;
39
40     // Output
41     Collection<Resource> items = new HashSet<>();
42     File                 exportLocation;
43
44     
45     public double                               startTime;
46     public double                               timeStep;
47     public DecimalSeparator     decimalSeparator;
48     public ColumnSeparator              columnSeparator;
49     public boolean             resample;
50     public ExportInterpolation samplingMode;
51     public int                                  timeDigits;
52     public int                                  floatDigits;
53     public int                                  doubleDigits;
54
55
56     /**
57      * <code>true</code> if the model should be overwritten without a warning.
58      */
59     boolean         overwrite;
60
61     /**
62      * Constructor for SCL support
63      */
64     public CSVExportPlan(double startTime, double timeStep, DecimalSeparator dsep, ColumnSeparator csep, boolean resample, ExportInterpolation mode, int timeDigits, int floatDigits, int doubleDigits) {
65         this.sessionContext = Simantics.getSessionContext();
66         this.recentLocations = new ArrayDeque<>();
67         
68         this.startTime = startTime;
69         this.timeStep = timeStep;
70         this.decimalSeparator = dsep;
71         this.columnSeparator = csep;
72         this.resample = resample;
73         this.samplingMode = mode;
74         this.timeDigits = timeDigits;
75         this.floatDigits = floatDigits;
76         this.doubleDigits = doubleDigits;
77     }
78
79     public void setItems(List<Resource> items) {
80         this.items = items;
81     }
82
83     CSVExportPlan(ISessionContext sessionContext, Deque<String> recentLocations) {
84         this.sessionContext = sessionContext;
85         this.recentLocations = recentLocations;
86     }
87
88 }