X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.charts%2Fsrc%2Forg%2Fsimantics%2Fcharts%2Fui%2FCSVExportPreferences.java;h=60831fe7006e2d6da9e4ebe3354e872a036afaa3;hp=8a34434251f93326a8c171d1144f5c0be262b6ce;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/ui/CSVExportPreferences.java b/bundles/org.simantics.charts/src/org/simantics/charts/ui/CSVExportPreferences.java index 8a3443425..60831fe70 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/ui/CSVExportPreferences.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/ui/CSVExportPreferences.java @@ -1,68 +1,68 @@ -/******************************************************************************* - * 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.util.Deque; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Set; -import java.util.TreeSet; - -import org.eclipse.ui.IMemento; -import org.simantics.utils.ui.workbench.StringMemento; - -/** - * @author Antti Villberg - */ -public final class CSVExportPreferences { - - public static final String RECENT_LOCATIONS = "RECENT_CSV_EXPORT_LOCATIONS"; - public static final String EXPORT_OVERWRITE = "CSV_EXPORT_OVERWRITE"; - - private static final String TAG_PATH = "path"; - private static final String ATTR_NAME = "name"; - - public static Deque decodePaths(String recentPathsPref) { - Deque result = new LinkedList(); - try { - StringMemento sm = new StringMemento(recentPathsPref); - for (IMemento m : sm.getChildren(TAG_PATH)) { - String name = m.getString(ATTR_NAME); - if (name != null && !name.isEmpty()) - result.add(name); - } - } catch (IllegalArgumentException e) { - } - return result; - } - - public static String encodePaths(Deque recentPaths) { - StringMemento sm = new StringMemento(); - for (String path : recentPaths) { - IMemento m = sm.createChild(TAG_PATH); - m.putString(ATTR_NAME, path); - } - return sm.toString(); - } - - public static void removeDuplicates(Iterable iter) { - // Remove duplicates - Set dups = new TreeSet(String.CASE_INSENSITIVE_ORDER); - for (Iterator it = iter.iterator(); it.hasNext();) { - String path = it.next(); - if (!dups.add(path)) { - it.remove(); - } - } - } - -} +/******************************************************************************* + * 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.util.Deque; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.ui.IMemento; +import org.simantics.utils.ui.workbench.StringMemento; + +/** + * @author Antti Villberg + */ +public final class CSVExportPreferences { + + public static final String RECENT_LOCATIONS = "RECENT_CSV_EXPORT_LOCATIONS"; + public static final String EXPORT_OVERWRITE = "CSV_EXPORT_OVERWRITE"; + + private static final String TAG_PATH = "path"; + private static final String ATTR_NAME = "name"; + + public static Deque decodePaths(String recentPathsPref) { + Deque result = new LinkedList(); + try { + StringMemento sm = new StringMemento(recentPathsPref); + for (IMemento m : sm.getChildren(TAG_PATH)) { + String name = m.getString(ATTR_NAME); + if (name != null && !name.isEmpty()) + result.add(name); + } + } catch (IllegalArgumentException e) { + } + return result; + } + + public static String encodePaths(Deque recentPaths) { + StringMemento sm = new StringMemento(); + for (String path : recentPaths) { + IMemento m = sm.createChild(TAG_PATH); + m.putString(ATTR_NAME, path); + } + return sm.toString(); + } + + public static void removeDuplicates(Iterable iter) { + // Remove duplicates + Set dups = new TreeSet(String.CASE_INSENSITIVE_ORDER); + for (Iterator it = iter.iterator(); it.hasNext();) { + String path = it.next(); + if (!dups.add(path)) { + it.remove(); + } + } + } + +}