Java Code Examples for java.util.prefs.Preferences#putLong()
The following examples show how to use
java.util.prefs.Preferences#putLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Feedback.java From Raccoon with Apache License 2.0 | 6 votes |
/** * Call this when the user performs a "use" action. * * @param center * a component to center the feedback dialog upon (or null). */ public static void used(JFrame center) { Preferences prefs = Preferences.userNodeForPackage(Feedback.class); if (prefs.getBoolean(KEY_DONE, false)) { return; } long count = prefs.getLong(KEY_COUNT, 0) + 1; prefs.putLong(KEY_COUNT, count); long first = prefs.getLong(KEY_FIRST, 0); if (first == 0) { first = System.currentTimeMillis(); prefs.putLong(KEY_FIRST, first); } try { prefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } if (count >= USES) { if (System.currentTimeMillis() >= first + (DAYS * 24 * 60 * 60 * 1000)) { showDialog(center); } } }
Example 2
Source File: TestXMLStore.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() throws IOException { storeFile = tempFolder.newFile().getAbsolutePath(); XMLStore store = XMLStore.createFromFile(storeFile, null); PreferencesExt prefs = store.getPreferences(); prefs.putDouble("testD", 3.14157); prefs.putFloat("testF", 1.23456F); prefs.putLong("testL", 12345678900L); prefs.putInt("testI", 123456789); prefs.put("testS", "youdBeDeadbyNow"); prefs.putBoolean("testB", true); byte[] barr = new byte[3]; barr[0] = 1; barr[1] = 2; barr[2] = 3; prefs.putByteArray("testBA", barr); Preferences subnode = prefs.node("SemperUbi"); subnode.putDouble("testD", 3.14158); subnode.putFloat("testF", 1.23457F); subnode.putLong("testL", 12345678901L); subnode.putInt("testI", 123456780); subnode.put("testS", "youdBeLivebyNow"); subnode.putBoolean("testB", false); byte[] barr2 = new byte[3]; barr2[0] = 2; barr2[1] = 3; barr2[2] = 4; subnode.putByteArray("testBA", barr2); store.save(); }
Example 3
Source File: FormattingCustomizerPanel.java From netbeans with Apache License 2.0 | 5 votes |
private static void deepCopy(Preferences from, Preferences to) throws BackingStoreException { for(String kid : from.childrenNames()) { Preferences fromKid = from.node(kid); Preferences toKid = to.node(kid); deepCopy(fromKid, toKid); } for(String key : from.keys()) { String value = from.get(key, null); if (value == null) continue; Class type = guessType(value); if (Integer.class == type) { to.putInt(key, from.getInt(key, -1)); } else if (Long.class == type) { to.putLong(key, from.getLong(key, -1L)); } else if (Float.class == type) { to.putFloat(key, from.getFloat(key, -1f)); } else if (Double.class == type) { to.putDouble(key, from.getDouble(key, -1D)); } else if (Boolean.class == type) { to.putBoolean(key, from.getBoolean(key, false)); } else if (String.class == type) { to.put(key, value); } else /* byte [] */ { to.putByteArray(key, from.getByteArray(key, new byte [0])); } } }
Example 4
Source File: Feedback.java From Raccoon with Apache License 2.0 | 5 votes |
private static void showDialog(JFrame center) { Preferences prefs = Preferences.userNodeForPackage(Feedback.class); Object[] options = { Messages.getString("Feedback.yes"), Messages.getString("Feedback.later"), Messages.getString("Feedback.no") }; String title = Messages.getString("Feedback.title"); String message = Messages.getString("Feedback.message"); int n = JOptionPane.showOptionDialog(center, message, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); switch (n) { case 0: { prefs.putBoolean(KEY_DONE, true); BrowseUtil.openUrl(URL); break; } case 1: { prefs.putLong(KEY_COUNT, 0); break; } case 2: { prefs.putBoolean(KEY_DONE, true); break; } } try { prefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } }
Example 5
Source File: PreferencesUsageDataStore.java From pdfsam with GNU Affero General Public License v3.0 | 4 votes |
private void incrementTotalUsage() { Preferences node = Preferences.userRoot().node(USAGE_PATH); node.putLong(TASKS_EXECUTED_KEY, node.getLong(TASKS_EXECUTED_KEY, 0) + 1); }