• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 1952

Show
Ignore:
Timestamp:
12/03/07 11:54:52 (12 months ago)
Author:
jmoore
Message:

OmeroPrefs? #800 : Now handling system preferences as well

Files:
1 modified

  • trunk/components/common/src/prefs.java (modified) (7 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/components/common/src/prefs.java

    r1951 r1952  
    1515import java.lang.reflect.InvocationTargetException; 
    1616import java.lang.reflect.Method; 
     17import java.util.Arrays; 
     18import java.util.HashSet; 
    1719import java.util.Properties; 
     20import java.util.Set; 
    1821import java.util.prefs.BackingStoreException; 
    1922import java.util.prefs.Preferences; 
    … …  
    7376     * Cache the root node at start up 
    7477     */ 
    75     private final static Preferences prefs = Preferences.userRoot().node(ROOT); 
     78    private static Preferences prefs = Preferences.userRoot().node(ROOT); 
    7679 
    7780    /** 
    … …  
    128131                "  load_nowarn [FILE...] :  read current profile from a file or standard in", 
    129132                "  set KEY=VALUE         :  set value on current profile", 
     133                "  sys COMMANDS          :  applies commands as above to system preferences", 
    130134                "                                                                  ", 
    131135                "Note: profiles are created on demand. Later properties override earlier ones." }; 
    … …  
    152156    public static String[] print(String[] args) { 
    153157        for (String string : args) { 
    154             System.out.println(string); 
     158            if (string != null) { 
     159                System.out.println(string); 
     160            } 
    155161        } 
    156162        return new String[] {}; 
    … …  
    162168    public static String[] printErr(String[] args) { 
    163169        for (String string : args) { 
    164             System.err.println(string); 
     170            if (string != null) { 
     171                System.err.println(string); 
     172            } 
    165173        } 
    166174        return args; 
    … …  
    216224        } 
    217225 
     226    } 
     227 
     228    /** 
     229     * Replaces the user {@link Preferences} instance with the system 
     230     * {@link Preferences} and continues dispatching. 
     231     */ 
     232    public static String[] sys(String[] args) throws Throwable { 
     233        prefs = Preferences.systemRoot().node(ROOT); 
     234        return dispatch(args); 
    218235    } 
    219236 
    … …  
    288305        args = notNull(args); 
    289306 
     307        String[] keys = _node().keys(); 
    290308        if (args.length == 0) { 
    291             String[] keys = _node().keys(); 
    292309            if (keys.length == 0) { 
    293310                return args; 
    294             } 
    295             return get(keys); 
    296         } 
    297  
     311            } else if (keys.length == 1) { 
     312                return get(args(keys[0], "UNKNOWNKEYJUSTTOFORCELENGTH2")); 
     313            } else { 
     314                return get(keys); 
     315            } 
     316        } else if (args.length == 1) { 
     317            String key = args[0] == null ? "" : args[0]; 
     318            String value = _node().get(key, ""); 
     319            return args(value); 
     320        } 
     321 
     322        Set<String> availableKeys = new HashSet<String>(Arrays.asList(_node() 
     323                .keys())); 
    298324        String[] rv = new String[args.length]; 
    299325        for (int i = 0; i < rv.length; i++) { 
    300326            String key = args[i] == null ? "" : args[i]; 
    301             String value = _node().get(key, ""); 
    302             if (rv.length == 1) { 
    303                 rv[i] = value; 
    304             } else { 
     327            if (availableKeys.contains(key)) { 
     328                String value = _node().get(key, ""); 
    305329                rv[i] = key + "=" + value; 
    306330            } 
    307  
    308331        } 
    309332        return rv; 
     333 
    310334    } 
    311335 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/