Example usage for java.util.prefs Preferences put

List of usage examples for java.util.prefs Preferences put

Introduction

In this page you can find the example usage for java.util.prefs Preferences put.

Prototype

public abstract void put(String key, String value);

Source Link

Document

Associates the specified value with the specified key in this preference node.

Usage

From source file:au.org.ala.delta.editor.EditorPreferences.java

public static void setImportFileFilter(String filter) {
    Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class);
    if (prefs != null) {
        prefs.put(IMPORT_FILE_FILTER_KEY, filter);
    }//from w w  w . jav  a  2 s .c o m
}

From source file:au.org.ala.delta.editor.EditorPreferences.java

public static void setEditorAdvanceMode(EditorAdvanceMode mode) {
    Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class);
    if (prefs != null) {
        prefs.put(ADVANCE_MODE_KEY, mode.toString());
    }/*w  w w .ja  va 2  s. c  o m*/
}

From source file:au.org.ala.delta.editor.EditorPreferences.java

public static void setPreferredLookAndFeel(String lookAndFeelName) {
    Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class);
    if (prefs != null) {
        prefs.put(LOOK_AND_FEEL_KEY, lookAndFeelName);
    }//from   w ww . ja  va2 s.  c  o m
}

From source file:au.org.ala.delta.editor.EditorPreferences.java

public static void setPreferredFont(Font font) {
    Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class);
    if (prefs != null) {
        prefs.put(FONT_KEY, font.getFontName() + "-" + font.getStyle() + "-" + font.getSize());
    }//from w  w w.j  a v  a2 s.co m
}

From source file:de.tbuchloh.kiskis.gui.common.Application.java

/**
 * @param prefs//from  w ww . j ava  2s  .co  m
 *            is the location to store the program information
 * @param list
 *            is a list of Program objects
 */
public static void storePrograms(final Preferences prefs, final Collection list) {
    Preferences n = prefs.node(Settings.K_URL_ALLPROGS_NODE);
    try {
        n.removeNode();
    } catch (final BackingStoreException e) {
        throw new Error(e);
    }

    n = prefs.node(Settings.K_URL_ALLPROGS_NODE);
    int cnt = 0;
    for (final Iterator i = list.iterator(); i.hasNext();) {
        final Program p = (Program) i.next();
        final Preferences child = n.node(String.valueOf(cnt++));
        child.put(Settings.K_URL_PROG_PREFIX, p.getUrlRegex());
        child.put(Settings.K_URL_PROG_CMD, p.getCommand());
        LOG.debug("storing " + p); //$NON-NLS-1$
    }
    try {
        n.flush();
    } catch (final BackingStoreException e1) {
        throw new Error(e1);
    }
}

From source file:com.vaadin.tools.ReportUsage.java

private static String loadFirstLaunch() {
    Preferences prefs = Preferences.userNodeForPackage(CheckForUpdates.class);

    String firstLaunch = prefs.get(FIRST_LAUNCH, null);
    if (firstLaunch == null) {
        long currentTimeMillis = System.currentTimeMillis();
        firstLaunch = Long.toHexString(currentTimeMillis);
        prefs.put(FIRST_LAUNCH, firstLaunch);
    }//from w ww  . ja  va  2 s  .c  o m
    return firstLaunch;

}

From source file:PrefsUtil.java

/**
 * Puts a list into the preferences starting with "0" then "1"
 *//*w w w  .j a  v  a 2  s.  c o m*/
public static void putList(Preferences preferences, List list) {
    if (preferences == null) {
        throw new IllegalArgumentException("Preferences not set.");
    }
    //System.out.println( "LIST=" + list );
    for (int index = 0; list != null && index < list.size(); index++) {
        Object value = list.get(index);
        preferences.put("" + index, value == null ? null : value.toString());
    }
}

From source file:PrefsUtil.java

/**
 * Puts a list into the preferences./*  w w w . j  a va2  s .  c o  m*/
 */
public static void putMap(Preferences preferences, Map map) {
    if (preferences == null) {
        throw new IllegalArgumentException("Preferences not set.");
    }

    for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
        Map.Entry entry = (Map.Entry) iter.next();
        Object value = entry.getValue();
        preferences.put(entry.getKey().toString(), value == null ? null : value.toString());
    }
}

From source file:org.pentaho.reporting.ui.datasources.jdbc.connection.JdbcConnectionDefinitionManager.java

private static void put(final Preferences node, final String key, final String value) {
    if (value == null) {
        node.remove(key);/*from   w ww  .  j a  v a  2  s .c  o  m*/
    } else {
        node.put(key, value);
    }

}

From source file:de.maklerpoint.office.Tags.Tags.java

/**
 * /*from   w  ww  .j  av  a  2  s .c om*/
 * @param tag 
 */
public static void addTag(TagObj tag) {
    Preferences prefs = Preferences.userRoot().node(Tags.class.getName());
    String taglist = prefs.get("tagListe", "Standard,ffentlich,Wichtig,Dienstlich,Persnlich");

    String[] result = taglist.split(",");

    if (result == null) {
        return;
    }

    String[] clean = (String[]) ArrayUtils.add(result, tag.getName());
    prefs.put("tagListe", ArrayStringTools.arrayToString(clean, ","));

    prefs.put("tag" + tag.getName(), tag.getTagColor() + "," + tag.getFontColor());

    InitializeTags.loadTags();
}