public static String getFont() { return prefs.get(PREF_FONT, DEFAULT_FONT); } public static void setFont(String font) { prefs.put(PREF_FONT, font); }
public static String getEncoding() { return prefs.get(PREF_ENCODING, DEFAULT_ENCODING); } public static void setEncoding(String encoding) { prefs.put(PREF_ENCODING, encoding); }
/** * 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); } }
public static TreeReaderFactory getTreeReaderFactory() { return lookupTreeReaderFactory(prefs.get(PREF_TREE_READER_FACTORY, DEFAULT_TREE_READER_FACTORY)); }
public static HeadFinder getHeadFinder() { return lookupHeadFinder(prefs.get(PREF_HEAD_FINDER, DEFAULT_HEAD_FINDER)); }
// 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"
Ini ini = new Ini(new File(filename)); java.util.prefs.Preferences prefs = new IniPreferences(ini); System.out.println("grumpy/homePage: " + prefs.node("grumpy").get("homePage", null));
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 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 JadxSettings load() { try { String jsonSettings = PREFS.get(JADX_GUI_KEY, ""); JadxSettings settings = fromString(jsonSettings); if (settings == null) { LOG.debug("Created new settings."); settings = JadxSettings.makeDefault(); } else { settings.fixOnLoad(); } if (LOG.isDebugEnabled()) { LOG.debug("Loaded settings: {}", makeString(settings)); } return settings; } catch (Exception e) { LOG.error("Error load settings", e); return new JadxSettings(); } }
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Choose TrueType font file", FileDialog.LOAD); dialog.setLocationRelativeTo(null); dialog.setFile("*.ttf"); dialog.setDirectory(prefs.get("dir.font", "")); dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.font", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; fontFileText.setText(new File(dialog.getDirectory(), fileName).getAbsolutePath()); } });
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Choose TrueType font file", FileDialog.LOAD); dialog.setLocationRelativeTo(null); dialog.setFile("*.ttf"); dialog.setDirectory(prefs.get("dir.font", "")); dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.font", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; fontFileText.setText(new File(dialog.getDirectory(), fileName).getAbsolutePath()); } });
/** * {@inheritDoc} * * @see at.aschauer.commons.pentaho.plugin.PluginProperty#readFromPreferences(java.util.prefs.Preferences) */ public void readFromPreferences( final Preferences node ) { this.setValue( node.get( this.getKey(), this.getValue() ) ); }
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Save Hiero settings file", FileDialog.SAVE); dialog.setLocationRelativeTo(null); dialog.setFile("*.hiero"); dialog.setDirectory(prefs.get("dir.save", "")); if (lastSaveFilename.length() > 0) { dialog.setFile(lastSaveFilename); } else if (lastOpenFilename.length() > 0) { dialog.setFile(lastOpenFilename); } dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.save", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; if (!fileName.endsWith(".hiero")) fileName += ".hiero"; lastSaveFilename = fileName; File file = new File(dialog.getDirectory(), fileName); try { save(file); } catch (IOException ex) { throw new RuntimeException("Error saving Hiero settings file: " + file.getAbsolutePath(), ex); } } });
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Save Hiero settings file", FileDialog.SAVE); dialog.setLocationRelativeTo(null); dialog.setFile("*.hiero"); dialog.setDirectory(prefs.get("dir.save", "")); if (lastSaveFilename.length() > 0) { dialog.setFile(lastSaveFilename); } else if (lastOpenFilename.length() > 0) { dialog.setFile(lastOpenFilename); } dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.save", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; if (!fileName.endsWith(".hiero")) fileName += ".hiero"; lastSaveFilename = fileName; File file = new File(dialog.getDirectory(), fileName); try { save(file); } catch (IOException ex) { throw new RuntimeException("Error saving Hiero settings file: " + file.getAbsolutePath(), ex); } } });
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Save BMFont files", FileDialog.SAVE); dialog.setLocationRelativeTo(null); dialog.setFile("*.fnt"); dialog.setDirectory(prefs.get("dir.savebm", "")); if (lastSaveBMFilename.length() > 0) { dialog.setFile(lastSaveBMFilename); } else if (lastOpenFilename.length() > 0) { dialog.setFile(lastOpenFilename.replace(".hiero", ".fnt")); } dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.savebm", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; lastSaveBMFilename = fileName; saveBm(new File(dialog.getDirectory(), fileName)); } });
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Save BMFont files", FileDialog.SAVE); dialog.setLocationRelativeTo(null); dialog.setFile("*.fnt"); dialog.setDirectory(prefs.get("dir.savebm", "")); if (lastSaveBMFilename.length() > 0) { dialog.setFile(lastSaveBMFilename); } else if (lastOpenFilename.length() > 0) { dialog.setFile(lastOpenFilename.replace(".hiero", ".fnt")); } dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.savebm", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; lastSaveBMFilename = fileName; saveBm(new File(dialog.getDirectory(), fileName)); } });
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Open Hiero settings file", FileDialog.LOAD); dialog.setLocationRelativeTo(null); dialog.setFile("*.hiero"); dialog.setDirectory(prefs.get("dir.open", "")); dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.open", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; lastOpenFilename = fileName; open(new File(dialog.getDirectory(), fileName)); } });
public void actionPerformed (ActionEvent evt) { FileDialog dialog = new FileDialog(Hiero.this, "Open Hiero settings file", FileDialog.LOAD); dialog.setLocationRelativeTo(null); dialog.setFile("*.hiero"); dialog.setDirectory(prefs.get("dir.open", "")); dialog.setVisible(true); if (dialog.getDirectory() != null) { prefs.put("dir.open", dialog.getDirectory()); } String fileName = dialog.getFile(); if (fileName == null) return; lastOpenFilename = fileName; open(new File(dialog.getDirectory(), fileName)); } });
/** * {@inheritDoc} * * @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 ) ); }