List of usage examples for java.util.prefs Preferences userNodeForPackage
public static Preferences userNodeForPackage(Class<?> c)
From source file:com.projity.util.VersionUtils.java
public static boolean versionCheck(boolean warnIfBad) { String version = VersionUtils.getVersion(); if (version == null) // for running in debugger version = "0"; Preferences pref = Preferences.userNodeForPackage(VersionUtils.class); String localVersion = pref.get("Angel Falls Version", "unknown"); boolean updated = !localVersion.equals(version); String javaVersion = System.getProperty("java.version"); log.info("Angel Falls Version: " + version + " local version " + localVersion + " updated=" + updated + " java version=" + javaVersion); pref.put("JavaVersion", javaVersion); if (updated) { Environment.setUpdated(true); pref.put("PODVersion", version); try {/*from www . j a v a 2 s . c o m*/ pref.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } if (warnIfBad && Environment.isApplet()) { if (javaVersion.equals("1.6.0_09") || javaVersion.equals("1.6.0_08") || javaVersion.equals("1.6.0_07") || javaVersion.equals("1.6.0_06") || javaVersion.equals("1.6.0_05") || javaVersion.equals("1.6.0_04")) { Environment.setNeedToRestart(true); SwingUtilities.invokeLater(new Runnable() { public void run() { Alert.error(Messages.getString("Error.restart")); } }); } } } else { try { pref.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } } return updated; }
From source file:org.javaswift.cloudie.login.CredentialsStore.java
/** * saves the given credentials./*from ww w . j a v a2s . c o m*/ * @param cr the credentials. */ public void save(Credentials cr) { try { Preferences prefs = Preferences.userNodeForPackage(CredentialsStore.class); saveCredentials(prefs.node(cr.toString()), cr); prefs.flush(); } catch (BackingStoreException ex) { throw new RuntimeException(ex); } }
From source file:com.esri.geoevent.test.performance.ui.ProducerController.java
@Override protected void saveState() { Protocol selectedProtocol = protocol.getValue(); int portNumber = NumberUtils.toInt(port.getText(), DEFAULT_COMMAND_PORT); int serverPortNumber = NumberUtils.toInt(serverPort.getText(), DEFAULT_SERVER_PORT); Preferences preferences = Preferences.userNodeForPackage(ProducerController.class); preferences.put("protocol", selectedProtocol.toString()); preferences.put("port", String.valueOf(portNumber)); preferences.put("serverPort", String.valueOf(serverPortNumber)); }
From source file:com.mirth.connect.client.ui.SettingsPanelAdministrator.java
public void doRefresh() { if (PlatformUI.MIRTH_FRAME.alertRefresh()) { return;/* w w w. jav a 2s. c o m*/ } dashboardRefreshIntervalField.setDocument(new MirthFieldConstraints(3, false, false, true)); messageBrowserPageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true)); eventBrowserPageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true)); userPreferences = Preferences.userNodeForPackage(Mirth.class); int interval = userPreferences.getInt("intervalTime", 10); dashboardRefreshIntervalField.setText(interval + ""); int messageBrowserPageSize = userPreferences.getInt("messageBrowserPageSize", 20); messageBrowserPageSizeField.setText(messageBrowserPageSize + ""); int eventBrowserPageSize = userPreferences.getInt("eventBrowserPageSize", 100); eventBrowserPageSizeField.setText(eventBrowserPageSize + ""); if (userPreferences.getBoolean("messageBrowserFormat", true)) { formatYesRadio.setSelected(true); } else { formatNoRadio.setSelected(true); } if (userPreferences.getBoolean("textSearchWarning", true)) { textSearchWarningYesRadio.setSelected(true); } else { textSearchWarningNoRadio.setSelected(true); } String importChannelCodeTemplateLibraries = userPreferences.get("importChannelCodeTemplateLibraries", null); if (importChannelCodeTemplateLibraries == null) { importChannelLibrariesAskRadio.setSelected(true); } else if (Boolean.parseBoolean(importChannelCodeTemplateLibraries)) { importChannelLibrariesYesRadio.setSelected(true); } else { importChannelLibrariesNoRadio.setSelected(true); } String exportChannelCodeTemplateLibraries = userPreferences.get("exportChannelCodeTemplateLibraries", null); if (exportChannelCodeTemplateLibraries == null) { exportChannelLibrariesAskRadio.setSelected(true); } else if (Boolean.parseBoolean(exportChannelCodeTemplateLibraries)) { exportChannelLibrariesYesRadio.setSelected(true); } else { exportChannelLibrariesNoRadio.setSelected(true); } final String workingId = getFrame().startWorking("Loading " + getTabName() + " settings..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { private String checkForNotifications = null; public Void doInBackground() { try { checkForNotifications = getFrame().mirthClient.getUserPreference(currentUser.getId(), "checkForNotifications"); } catch (ClientException e) { getFrame().alertThrowable(getFrame(), e); } return null; } @Override public void done() { if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) { checkForNotificationsYesRadio.setSelected(true); } else { checkForNotificationsNoRadio.setSelected(true); } getFrame().stopWorking(workingId); } }; worker.execute(); RSTAPreferences rstaPreferences = MirthRSyntaxTextArea.getRSTAPreferences(); updateShortcutKeyTable(rstaPreferences); updateRestoreDefaultsButton(); AutoCompleteProperties autoCompleteProperties = rstaPreferences.getAutoCompleteProperties(); autoCompleteIncludeLettersCheckBox.setSelected(autoCompleteProperties.isActivateAfterLetters()); autoCompleteCharactersField.setText(autoCompleteProperties.getActivateAfterOthers()); autoCompleteDelayField.setText(String.valueOf(autoCompleteProperties.getActivationDelay())); }
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); }/* w ww .j ava 2 s .co m*/ return firstLaunch; }
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()); }/*from w w w.j av a2s. com*/ }
From source file:Clavis.Windows.WShedule.java
/** * Creates new form NewJPanel/*from w w w .j a va 2s.c o m*/ * * @param comp * @param cor * @param mat * @param url * @param lingua */ public WShedule(javax.swing.JDialog comp, java.awt.Color cor, Keys.Material mat, String url, Langs.Locale lingua) { componentepai = comp; painelcor = cor; this.mat = mat; this.url = url; prefs = Preferences.userNodeForPackage(this.getClass()); this.lingua = lingua; inicio = new TimeDate.Date(); fim = new TimeDate.Date(); lista = new java.util.ArrayList<>(); estado = ""; }
From source file:com.esri.geoevent.test.performance.ui.ConsumerController.java
@Override protected void saveState() { Protocol selectedProtocol = protocol.getValue(); int portNumber = NumberUtils.toInt(port.getText(), DEFAULT_COMMAND_PORT); int serverPortNumber = NumberUtils.toInt(serverPort.getText(), DEFAULT_SERVER_PORT); Preferences preferences = Preferences.userNodeForPackage(ConsumerController.class); preferences.put("protocol", selectedProtocol.toString()); preferences.put("port", String.valueOf(portNumber)); preferences.put("serverPort", String.valueOf(serverPortNumber)); }
From source file:com.basho.riak.pbc.RiakClient.java
/** * helper method to use a reasonable default client id * beware, it caches the client id. If you call it multiple times on the same client * you get the *same* id (not good for reusing a client with different ids) * //from ww w . j av a 2s . c o m * @throws IOException */ public void prepareClientID() throws IOException { Preferences prefs = Preferences.userNodeForPackage(RiakClient.class); String clid = prefs.get("client_id", null); if (clid == null) { SecureRandom sr; try { sr = SecureRandom.getInstance("SHA1PRNG"); // Not totally secure, but doesn't need to be // and 100% less prone to 30 second hangs on linux jdk5 sr.setSeed(UUID.randomUUID().getLeastSignificantBits() + new Date().getTime()); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } byte[] data = new byte[6]; sr.nextBytes(data); clid = CharsetUtils.asString(Base64.encodeBase64Chunked(data), CharsetUtils.ISO_8859_1); prefs.put("client_id", clid); try { prefs.flush(); } catch (BackingStoreException e) { throw new IOException(e.toString()); } } setClientID(clid); }
From source file:org.javaswift.cloudie.login.CredentialsStore.java
/** * deletes the credentials./*from www . j a v a 2 s . com*/ * @param cr the credentials. */ public void delete(Credentials cr) { try { Preferences prefs = Preferences.userNodeForPackage(CredentialsStore.class); prefs.node(cr.toString()).removeNode(); prefs.flush(); } catch (BackingStoreException ex) { throw new RuntimeException(ex); } }