Refine search
public void mouseClicked (MouseEvent evt) { java.awt.Color color = JColorChooser.showDialog(null, "Choose a background color", EffectUtil.fromString(prefs.get("background", "000000"))); if (color == null) return; renderingBackgroundColor = new Color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1); backgroundColorLabel.setIcon(getColorIcon(color)); prefs.put("background", EffectUtil.toString(color)); } });
public static boolean getMatchPortionOnly() { return prefs.getBoolean(PREF_MATCH_PORTION_ONLY, DEFAULT_MATCH_PORTION_ONLY); } public static void setMatchPortionOnly(boolean matchPortionOnly) { prefs.putBoolean(PREF_MATCH_PORTION_ONLY, matchPortionOnly); }
public static int getHistorySize() { return prefs.getInt(PREF_HISTORY_SIZE, DEFAULT_HISTORY_SIZE); } public static void setHistorySize(int historySize) { prefs.putInt(PREF_HISTORY_SIZE, historySize); }
// Retrieve the user preference node for the package com.mycompany Preferences prefs = Preferences.userNodeForPackage(com.mycompany.MyClass.class); // Preference key name final String PREF_NAME = "name_of_preference"; // Set the value of the preference String newValue = "a string"; prefs.put(PREF_NAME, newValue); // Get the value of the preference; // default value is returned if the preference does not exist String defaultValue = "default string"; String propertyValue = prefs.get(PREF_NAME, defaultValue); // "a string"
/** * Set the header width. This is the default value to use for {@link #margin} for next {@link * Log4JFormatter} to be created. * * @param margin the size of the margin to set. */ static void setHeaderWidth(final int margin) { Preferences.userNodeForPackage(Log4JFormatter.class).putInt("logging.header", margin); }
public static boolean isAdmin(){ Preferences prefs = Preferences.systemRoot(); try{ prefs.put("foo", "bar"); // SecurityException on Windows prefs.remove("foo"); prefs.flush(); // BackingStoreException on Linux return true; }catch(Exception e){ return false; } }
Preferences prefs = Preferences.userRoot().node(preferencesKey); prefs.clear(); prefs.putInt("I_" + key, (Integer) val); } else if (val instanceof Float) { prefs.putFloat("F_" + key, (Float) val); } else if (val instanceof String) { prefs.put("S_" + key, (String) val); } else if (val instanceof Boolean) { prefs.putBoolean("B_" + key, (Boolean) val); prefs.sync();
Preferences prefs = Preferences.userRoot().node(preferencesKey); String[] keys = prefs.keys(); if (keys != null) { for (String key : keys) { put(key.substring(2), prefs.getInt(key, (Integer) 0)); break; case 'F': put(key.substring(2), prefs.getFloat(key, (Float) 0f)); break; case 'S': put(key.substring(2), prefs.get(key, (String) null)); break; case 'B': put(key.substring(2), prefs.getBoolean(key, (Boolean) false)); break; default: put(key, prefs.getInt(key, (Integer) defaultValue)); } else if (defaultValue instanceof String) { put(key, prefs.get(key, (String) defaultValue)); } else if (defaultValue instanceof Boolean) { put(key, prefs.getBoolean(key, (Boolean) defaultValue));
@Test public void testPreferencesPlaceholderConfigurerWithPathInPlaceholder() { factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class) .addPropertyValue("name", "${mypath/myName}") .addPropertyValue("age", "${myAge}") .addPropertyValue("touchy", "${myotherpath/myTouchy}") .getBeanDefinition()); PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer(); Properties props = new Properties(); props.put("myAge", "99"); ppc.setProperties(props); ppc.setSystemTreePath("mySystemPath"); ppc.setUserTreePath("myUserPath"); Preferences.systemRoot().node("mySystemPath").node("mypath").put("myName", "myNameValue"); Preferences.systemRoot().node("mySystemPath/myotherpath").put("myTouchy", "myTouchyValue"); Preferences.userRoot().node("myUserPath/myotherpath").put("myTouchy", "myOtherTouchyValue"); ppc.afterPropertiesSet(); ppc.postProcessBeanFactory(factory); TestBean tb = (TestBean) factory.getBean("tb"); assertEquals("myNameValue", tb.getName()); assertEquals(99, tb.getAge()); assertEquals("myOtherTouchyValue", tb.getTouchy()); Preferences.userRoot().node("myUserPath/myotherpath").remove("myTouchy"); Preferences.systemRoot().node("mySystemPath/myotherpath").remove("myTouchy"); Preferences.systemRoot().node("mySystemPath/mypath").remove("myName"); }
Preferences prefs = Preferences.userRoot().node(getClass().getName()); JFileChooser chooser = new JFileChooser(prefs.get(LAST_USED_FOLDER, new File(".").getAbsolutePath())); int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { // do something prefs.put(LAST_USED_FOLDER, chooser.getSelectedFile().getParent()); }
findWindowPosition = new WindowPosition(); try { Preferences prefs = Preferences.userNodeForPackage(ConfigSaver.class); if (!prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName()) .equals(decompilerSettings.getLanguage().getName())) prefs.put(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName()); prefs.getBoolean(FLATTEN_SWITCH_BLOCKS_ID, decompilerSettings.getFlattenSwitchBlocks())); decompilerSettings.setForceExplicitImports( prefs.getBoolean(FORCE_EXPLICIT_IMPORTS_ID, decompilerSettings.getForceExplicitImports())); decompilerSettings.setShowSyntheticMembers( prefs.getBoolean(SHOW_SYNTHETIC_MEMBERS_ID, decompilerSettings.getShowSyntheticMembers())); decompilerSettings.setExcludeNestedTypes( prefs.getBoolean(EXCLUDE_NESTED_TYPES_ID, decompilerSettings.getExcludeNestedTypes())); decompilerSettings.setForceExplicitTypeArguments(prefs.getBoolean(FORCE_EXPLICIT_TYPE_ARGUMENTS_ID, decompilerSettings.getForceExplicitTypeArguments())); decompilerSettings.setRetainRedundantCasts( prefs.getBoolean(RETAIN_REDUNDANT_CASTS_ID, decompilerSettings.getRetainRedundantCasts())); decompilerSettings.setIncludeErrorDiagnostics( prefs.getBoolean(INCLUDE_ERROR_DIAGNOSTICS_ID, decompilerSettings.getIncludeErrorDiagnostics())); decompilerSettings.setLanguage( findLanguageByName(prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName()))); decompilerSettings.setUnicodeOutputEnabled(prefs.getBoolean(UNICODE_REPLACE_ENABLED_ID, false));
final Arguments arguments = new Arguments(args); final PrintWriter out = arguments.out; final Preferences prefs = Preferences.userNodeForPackage(NADCONTransform.class); prefs.remove(GRID_LOCATION); } else { prefs.put(GRID_LOCATION, args[0]); final String location = prefs.get(GRID_LOCATION, DEFAULT_GRID_LOCATION); out.println( "Usage: java org.geotools.referencing.operation.transform.NADCONTransform "
@Override public void validate() throws IllegalStateException { Preferences prefs = NbPreferences.root().node("laf"); if (!prefs.getBoolean("darcula.installed", false)) { prefs.put("laf", DarculaLaf.class.getName()); SWITCH_EDITOR_COLORS = true; } prefs.putBoolean("darcula.installed", true); // to make LAF available in Tools > Options > Appearance > Look and Feel UIManager.installLookAndFeel(new UIManager.LookAndFeelInfo(DarculaLaf.NAME, DarculaLaf.class.getName())); UIManager.put("Nb.DarculaLFCustoms", new DarculaLFCustoms()); }
private LuytenPreferences loadLuytenPreferences(Preferences prefs) throws Exception { LuytenPreferences newLuytenPrefs = new LuytenPreferences(); for (Field field : LuytenPreferences.class.getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers())) continue; field.setAccessible(true); String prefId = field.getName(); Object defaultVal = field.get(newLuytenPrefs); if (field.getType() == String.class) { String defaultStr = (String) (defaultVal == null ? "" : defaultVal); field.set(newLuytenPrefs, prefs.get(prefId, defaultStr)); } else if (field.getType() == Boolean.class || field.getType() == boolean.class) { Boolean defaultBool = (Boolean) (defaultVal == null ? new Boolean(false) : defaultVal); field.setBoolean(newLuytenPrefs, prefs.getBoolean(prefId, defaultBool)); } else if (field.getType() == Integer.class || field.getType() == int.class) { Integer defaultInt = (Integer) (defaultVal == null ? new Integer(0) : defaultVal); field.setInt(newLuytenPrefs, prefs.getInt(prefId, defaultInt)); } } return newLuytenPrefs; }
void load() { Preferences prefs = NbPreferences.forModule(DarculaLAFPanel.class); cbFontSizeOverride.setSelected(prefs.getBoolean(DarculaLAFOptionsPanelController.OVERRIDE_FONT_BOOLEAN, false)); lblFontName.setText(prefs.get(DarculaLAFOptionsPanelController.FONT_STRING, DarculaLFCustoms.DEFAULT_FONT)); cbTreeIndentOverride.setSelected(prefs.getBoolean(DarculaLAFOptionsPanelController.OVERRIDE_TREE_INDENT_BOOLEAN, false)); spTreeIndent.setValue(prefs.getInt(DarculaLAFOptionsPanelController.TREE_INDENT_INT, UIManager.getInt("Tree.leftChildIndent"))); cbInvertIcons.setSelected(prefs.getBoolean(DarculaLAFOptionsPanelController.INVERT_ICONS_BOOLEAN, false)); cbStretchedTabs.setSelected(prefs.getBoolean(DarculaLAFOptionsPanelController.STRETCHED_TABS_BOOLEAN, false)); reinitUI(); }
private void saveLuytenPreferences(Preferences prefs) throws Exception { for (Field field : LuytenPreferences.class.getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers())) continue; field.setAccessible(true); String prefId = field.getName(); Object value = field.get(luytenPreferences); if (field.getType() == String.class) { prefs.put(prefId, (String) (value == null ? "" : value)); } else if (field.getType() == Boolean.class || field.getType() == boolean.class) { prefs.putBoolean(prefId, (Boolean) (value == null ? new Boolean(false) : value)); } else if (field.getType() == Integer.class || field.getType() == int.class) { prefs.putInt(prefId, (Integer) (value == null ? new Integer(0) : value)); } } }
public void valueChanged (ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) return; prefs.put("system.font", (String)fontList.getSelectedValue()); updateFont(); } });
/** * Resolve the given path and key against the given Preferences. * @param path the preferences path (placeholder part before '/') * @param key the preferences key (placeholder part after '/') * @param preferences the Preferences to resolve against * @return the value for the placeholder, or {@code null} if none found */ @Nullable protected String resolvePlaceholder(@Nullable String path, String key, Preferences preferences) { if (path != null) { // Do not create the node if it does not exist... try { if (preferences.nodeExists(path)) { return preferences.node(path).get(key, null); } else { return null; } } catch (BackingStoreException ex) { throw new BeanDefinitionStoreException("Cannot access specified node path [" + path + "]", ex); } } else { return preferences.get(key, null); } }
void store() { Preferences prefs = NbPreferences.forModule(DarculaLAFPanel.class); prefs.putBoolean(DarculaLAFOptionsPanelController.OVERRIDE_FONT_BOOLEAN, cbFontSizeOverride.isSelected()); prefs.put(DarculaLAFOptionsPanelController.FONT_STRING, lblFontName.getText()); prefs.putBoolean(DarculaLAFOptionsPanelController.OVERRIDE_TREE_INDENT_BOOLEAN, cbTreeIndentOverride.isSelected()); prefs.putInt(DarculaLAFOptionsPanelController.TREE_INDENT_INT, (Integer) spTreeIndent.getValue()); prefs.putBoolean(DarculaLAFOptionsPanelController.INVERT_ICONS_BOOLEAN, cbInvertIcons.isSelected()); prefs.putBoolean(DarculaLAFOptionsPanelController.STRETCHED_TABS_BOOLEAN, cbStretchedTabs.isSelected()); }