X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.team.ui%2Fsrc%2Forg%2Fsimantics%2Fteam%2Fui%2FPreferences.java;h=b8dafbacd42a8136576463a5324d9b1f8fd4ed7c;hb=4aba159170fc72d39c2f930ea224aa71f4cdc2e7;hp=d587d1b6074719f514cad73e42d74ab327a59227;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.team.ui/src/org/simantics/team/ui/Preferences.java b/bundles/org.simantics.team.ui/src/org/simantics/team/ui/Preferences.java index d587d1b60..b8dafbacd 100644 --- a/bundles/org.simantics.team.ui/src/org/simantics/team/ui/Preferences.java +++ b/bundles/org.simantics.team.ui/src/org/simantics/team/ui/Preferences.java @@ -1,49 +1,49 @@ -package org.simantics.team.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; - -public final class Preferences { - public static final String CURRENT_TEAM_FOLDER = "CURRENT_TEAM_FOLDER"; - public static final String RECENT_TEAM_FOLDERS = "RECENT_TEAM_FOLDERS"; - 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(); - } - } - } - -} +package org.simantics.team.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; + +public final class Preferences { + public static final String CURRENT_TEAM_FOLDER = "CURRENT_TEAM_FOLDER"; + public static final String RECENT_TEAM_FOLDERS = "RECENT_TEAM_FOLDERS"; + 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(); + } + } + } + +}