List of usage examples for java.util.prefs Preferences get
public abstract String get(String key, String def);
From source file:net.bican.wordpress.configuration.PreferencesConfiguration.java
/** * @param cl Calling class/*from w w w . j a v a 2 s.c om*/ */ public PreferencesConfiguration(Class<?> cl) { try { Preferences p = Preferences.userNodeForPackage(cl); for (String preference : p.keys()) { this.addProperty(preference, p.get(preference, null)); } } catch (BackingStoreException e) { // then we end up with an empty set of preferences, no big deal } }
From source file:org.pdfsam.module.PreferencesUsageDataStore.java
public void incrementUsageFor(String moduleId) { Preferences node = Preferences.userRoot().node(USAGE_PATH).node(moduleId); String json = node.get(MODULE_USAGE_KEY, ""); try {// w w w . j av a 2s .c om if (isNotBlank(json)) { node.put(MODULE_USAGE_KEY, JSON.std.asString(JSON.std.beanFrom(ModuleUsage.class, json).inc())); } else { node.put(MODULE_USAGE_KEY, JSON.std.asString(ModuleUsage.fistUsage(moduleId))); } LOG.trace("Usage incremented for module {}", moduleId); } catch (IOException e) { LOG.error("Unable to increment modules usage statistics", e); } finally { incrementTotalUsage(); } }
From source file:verdandi.ui.action.ImportPluginAction.java
/** * Ask the import file from the user/*from ww w .ja va 2 s . co m*/ */ private File getFile() { File res = null; Preferences prefs = Preferences.userNodeForPackage(getClass()); File importDir = new File(prefs.get(KEY_CWD, System.getProperty("user.home"))); JFileChooser chooser = new JFileChooser(importDir); chooser.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { return f.getName().toLowerCase().endsWith(".jar") || f.isDirectory(); } @Override public String getDescription() { return RC.getString("pluginimportaction.filechooser.jarfilter.description"); } }); chooser.setDialogTitle(RC.getString("pluginimportaction.filechooser.title")); chooser.setMultiSelectionEnabled(false); if (chooser.showOpenDialog(parent) != JFileChooser.APPROVE_OPTION) { LOG.debug("User cancelled"); return null; } res = chooser.getSelectedFile(); prefs.put("import.dir", res.getParent()); try { prefs.flush(); } catch (BackingStoreException e) { LOG.error("Cannot write export file preference", e); } return res; }
From source file:codeswarm.ui.MainView.java
/** * initializes the Dialog and sets the dialog-values according to the * user's preferences (the last values entered). * @param args java arguments passed to the main method. The first parameter * will be passed to {@link code_swarm}. It specifies the config-file. */// ww w . j av a 2 s. c o m public MainView(String[] args) { this.args = args; initComponents(); this.getRootPane().setDefaultButton(goButton); Preferences p = Preferences.userNodeForPackage(MainView.class); String username = p.get("username", ""); userName.setText(username); String url = p.get("repositoryURL", "http://"); repositoryURL.setText(url); }
From source file:de.fhg.igd.mapviewer.server.tiles.CustomTileMapServerConfiguration.java
/** * Load the configuration's properties/*ww w. j a v a 2 s . c o m*/ * * @param node the preference node */ protected void loadProperties(Preferences node) { setUrlPattern(node.get(URL_PATTERN, null)); setZoomLevel(node.getInt(ZOOM_LEVELS, DEFAULT_ZOOM_LEVELS)); setAttributionText(node.get(ATTRIBUTION, null)); }
From source file:de.fhg.igd.mapviewer.server.wms.WMSConfiguration.java
/** * Load the configuration's properties//ww w.jav a 2 s . c o m * * @param node the preference node */ protected void loadProperties(Preferences node) { setBaseUrl(node.get(BASE_URL, null)); setPreferredEpsg(node.getInt(PREFERRED_EPSG, DEFAULT_PREFERRED_EPSG)); setLayers(node.get(LAYERS, "")); //$NON-NLS-1$ }
From source file:net.straylightlabs.tivolibre.DecoderApp.java
private String loadMak() { Preferences prefs = getPrefs(); return prefs.get(PREF_MAK, null); }
From source file:abfab3d.param.editor.URIEditor.java
public URIEditor(Parameter param) { super(param); m_textField = new TextField(EDITOR_SIZE); Object val = m_param.getValue(); String sval = ""; if (val != null) { sval = val.toString(); }// w w w . j a v a 2 s. c om m_textField.setText(sval); m_textField.addActionListener(this); m_open = new JButton("Open"); m_open.setToolTipText("Open File"); panel = new JPanel(new FlowLayout()); panel.add(m_open); panel.add(m_textField); String user_dir = System.getProperty("user.dir"); Preferences prefs = Preferences.userNodeForPackage(URIEditor.class); String last_dir = prefs.get(LASTDIR_PROPERTY, null); String dir; if (last_dir != null) dir = last_dir; else dir = user_dir; fc = new JFileChooser(dir); m_open.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int returnVal = fc.showDialog(parent, "Open File"); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String dir = file.getPath(); int idx = dir.lastIndexOf(File.separator); if (idx > 0) { dir = dir.substring(0, idx); Preferences prefs = Preferences.userNodeForPackage(URIEditor.class); prefs.put(LASTDIR_PROPERTY, dir); } m_param.setValue(file.getAbsolutePath()); informParamChangedListeners(); } } }); }
From source file:org.pentaho.di.core.util.StringListPluginProperty.java
/** * {@inheritDoc}//ww w . jav a 2 s .co m * * @see at.aschauer.commons.pentaho.plugin.PluginProperty#readFromPreferences(java.util.prefs.Preferences) */ public void readFromPreferences(final Preferences node) { final String stringValue = node.get(this.getKey(), asString(this.getValue())); this.setValue(fromString(stringValue)); }
From source file:ch.astina.hesperid.installer.web.services.InstallationManager.java
public String getApplicationHomeDirectoryPath() { Preferences prefs = Preferences.userNodeForPackage(InstallationManager.class); String installDir = prefs.get(HOME_DIRECTORY, null); return installDir; }