]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.history/src/org/simantics/history/csv/CSVFormatter.java
Improved Copy Visible Data usability in time series chart editor
[simantics/platform.git] / bundles / org.simantics.history / src / org / simantics / history / csv / CSVFormatter.java
index 6610d17f2456081d73031797f44599f43cf01ffb..6cc7a2a6f09a9bf50e1c7f27eeb74651180e1df2 100644 (file)
@@ -12,9 +12,7 @@
 package org.simantics.history.csv;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
-import java.net.URLDecoder;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.Format;
@@ -85,20 +83,12 @@ public class CSVFormatter {
                i.history = history;
                i.label = label!=null?label:"";
                i.variableReference = variableReference!=null?variableReference:"";
-               i.variableReference = unescape(i.variableReference);
+               i.variableReference = URIs.safeUnescape(i.variableReference);
                i.historyItemId = historyItemId;
                i.unit = unit;
                if ( !items.contains(i) ) items.add( i );
        }
 
-       private static String unescape(String url) {
-               try {
-                       return URLDecoder.decode(url, "UTF-8");
-               } catch (UnsupportedEncodingException e) {
-                       return url;
-               }
-       }
-
        /**
         * Sort items by variableId, label1, label2
         */
@@ -318,7 +308,7 @@ public class CSVFormatter {
                                // Sampling based on given startTime and timeStep
                                if(timeStep > 0) {
 
-                                       // Find the first sample time that contains data 
+                                       // Find the first sample time that contains data if startTime < _from 
                                        double n = Math.max(0, Math.ceil((_from-startTime) / timeStep));
                                        time = startTime + n*timeStep;
 
@@ -597,7 +587,7 @@ public class CSVFormatter {
     private Formatter evaluateFormatter(Format format, DecimalSeparator target) {
         // Probe decimal separator
         String onePointTwo = format.format(1.2);
-        System.out.println("formatted zeroPointOne: " + onePointTwo);
+        //System.out.println("formatted zeroPointOne: " + onePointTwo);
 
         DecimalSeparator formatSeparator;
         if (onePointTwo.indexOf('.') != -1) {