1 package org.simantics.team.ui;
3 import java.util.Deque;
4 import java.util.Iterator;
5 import java.util.LinkedList;
7 import java.util.TreeSet;
9 import org.eclipse.ui.IMemento;
10 import org.simantics.utils.ui.workbench.StringMemento;
12 public final class Preferences {
13 public static final String CURRENT_TEAM_FOLDER = "CURRENT_TEAM_FOLDER";
14 public static final String RECENT_TEAM_FOLDERS = "RECENT_TEAM_FOLDERS";
15 private static final String TAG_PATH = "path";
16 private static final String ATTR_NAME = "name";
17 public static Deque<String> decodePaths(String recentPathsPref) {
18 Deque<String> result = new LinkedList<String>();
20 StringMemento sm = new StringMemento(recentPathsPref);
21 for (IMemento m : sm.getChildren(TAG_PATH)) {
22 String name = m.getString(ATTR_NAME);
23 if (name != null && !name.isEmpty())
26 } catch (IllegalArgumentException e) {
30 public static String encodePaths(Deque<String> recentPaths) {
31 StringMemento sm = new StringMemento();
32 for (String path : recentPaths) {
33 IMemento m = sm.createChild(TAG_PATH);
34 m.putString(ATTR_NAME, path);
38 public static <T> void removeDuplicates(Iterable<String> iter) {
40 Set<String> dups = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
41 for (Iterator<String> it = iter.iterator(); it.hasNext();) {
42 String path = it.next();
43 if (!dups.add(path)) {