List of usage examples for java.util.prefs Preferences put
public abstract void put(String key, String value);
From source file:de.maklerpoint.office.Tags.Tags.java
/** * Entfernt den Tag und ldt die Liste neu * @param tagName // w ww. j av a 2s . co m */ public static void removeTag(String tagName) { Preferences prefs = Preferences.userRoot().node(Tags.class.getName()); String taglist = prefs.get("tagListe", "Standard,ffentlich,Wichtig,Dienstlich,Persnlich"); String[] result = taglist.split(","); if (result == null) { return; } String[] clean = (String[]) ArrayUtils.removeElement(result, tagName); prefs.put("tagListe", ArrayStringTools.arrayToString(clean, ",")); InitializeTags.loadTags(); }
From source file:de.tbuchloh.kiskis.util.Settings.java
public static Preferences initPreferences() { final Preferences n = Preferences.userNodeForPackage(Settings.class); final String newVersion = BuildProperties.getVersion(); final String previousVersion = n.get(K_PROGRAM_VERSION, newVersion); if (LOG.isDebugEnabled()) { LOG.debug(String.format("oldVersion=%1$s, newVersion=%2$s", previousVersion, newVersion)); }/*from w w w . ja va2 s .com*/ if (!VersionTools.isCompatible(previousVersion, newVersion)) { LOG.debug("Versions not compatible! Recreating preference node for version=" + newVersion); try { n.removeNode(); } catch (final BackingStoreException e) { LOG.error("Could not remove preference node", e); } final Preferences newN = Preferences.userNodeForPackage(Settings.class); newN.put(K_PROGRAM_VERSION, newVersion); return newN; } LOG.debug("Preferences seem to be compatible"); return n; }
From source file:de.maklerpoint.office.Tags.Tags.java
/** * /*from w ww .jav a 2s . c o m*/ * @param tag * @param oldname */ public static void updateTag(TagObj tag, String oldname) { Preferences prefs = Preferences.userRoot().node(Tags.class.getName()); String taglist = prefs.get("tagListe", "Standard,ffentlich,Wichtig,Dienstlich,Persnlich"); String[] result = taglist.split(","); if (result == null) { return; } boolean contains = ArrayUtils.contains(result, tag.getName()); if (contains) { prefs.put("tag" + tag.getName(), tag.getTagColor() + "," + tag.getFontColor()); InitializeTags.loadTags(); } else { Tags.removeTag(oldname); addTag(tag); } }
From source file:org.broad.igv.DirectoryManager.java
/** * Move the "igv" directory to a new location, copying all contents. Returns True if the directory * is successfully moved, irrespective of any errors that might occur later (e.g. when attempting to * remove the old directory)./* www .j a va 2s. com*/ * * @param newIGVDirectory * @return True if the directory is successfully moved, false otherwise */ public static Boolean moveIGVDirectory(final File newIGVDirectory) { if (newIGVDirectory.equals(IGV_DIRECTORY)) { return false; // Nothing to do } if (IGV_DIRECTORY != null && IGV_DIRECTORY.exists()) { File oldDirectory = IGV_DIRECTORY; try { log.info("Moving igv directory from " + oldDirectory.getParent() + " to " + newIGVDirectory.getAbsolutePath()); FileUtils.copyDirectory(IGV_DIRECTORY, newIGVDirectory); IGV_DIRECTORY = newIGVDirectory; // Store location of new directory in Java preferences node (not pref.properties) Preferences prefs = Preferences.userNodeForPackage(Globals.class); prefs.put(IGV_DIR_USERPREF, newIGVDirectory.getAbsolutePath()); // Update preference manager with new file location PreferenceManager.getInstance().setPrefsFile(getPreferencesFile().getAbsolutePath()); } catch (IOException e) { log.error("Error copying IGV directory", e); MessageUtils.showMessage("<html>Error moving IGV directory:<br/> nbsp;" + e.getMessage()); return false; } // Restart the log LogManager.shutdown(); initializeLog(); // Try to delete the old directory try { deleteDirectory(oldDirectory); } catch (IOException e) { log.error("An error was encountered deleting the previous IGV directory", e); MessageUtils.showMessage("<html>An error was encountered deleting the previous IGV directory (" + e.getMessage() + "):<br> nbsp;nbsp;" + oldDirectory.getAbsolutePath() + "<br>Remaining files should be manually deleted."); } } GENOME_CACHE_DIRECTORY = null; GENE_LIST_DIRECTORY = null; BAM_CACHE_DIRECTORY = null; return true; }
From source file:com.mirth.connect.client.ui.components.rsta.MirthRSyntaxTextArea.java
public static void updateFindReplacePreferences(Preferences userPreferences) { userPreferences.put(PREFERENCES_FIND_REPLACE, rstaPreferences.getFindReplaceJSON()); }
From source file:com.mirth.connect.client.ui.components.rsta.MirthRSyntaxTextArea.java
public static void updateToggleOptionPreferences(Preferences userPreferences) { userPreferences.put(PREFERENCES_TOGGLE_OPTIONS, rstaPreferences.getToggleOptionsJSON()); }
From source file:com.mirth.connect.client.ui.components.rsta.MirthRSyntaxTextArea.java
public static void updateAutoCompletePreferences(Preferences userPreferences) { userPreferences.put(PREFERENCES_AUTO_COMPLETE, rstaPreferences.getAutoCompleteJSON()); }
From source file:org.broad.igv.DirectoryManager.java
public static File getIgvDirectory() { if (IGV_DIRECTORY == null) { // Hack for known Java / Windows bug. Attempt to remvoe (possible) read-only bit from user directory if (System.getProperty("os.name").startsWith("Windows")) { try { Runtime.getRuntime().exec("attrib -r \"" + getUserDirectory().getAbsolutePath() + "\""); } catch (Exception e) { // We tried }/*from w w w. j av a2 s .c o m*/ } IGV_DIRECTORY = getIgvDirectoryOverride(); // If still null, try the default place if (IGV_DIRECTORY == null) { File rootDir = getUserHome(); IGV_DIRECTORY = new File(rootDir, "igv"); if (!IGV_DIRECTORY.exists()) { // See if a pre-2.1 release directory exists, if so copy it File legacyDirectory = null; try { legacyDirectory = getLegacyIGVDirectory(); if (legacyDirectory.exists()) { log.info("Copying " + legacyDirectory + " => " + IGV_DIRECTORY); FileUtils.copyDirectory(legacyDirectory, IGV_DIRECTORY); } } catch (IOException e) { log.error("Error copying igv directory " + legacyDirectory + " => " + IGV_DIRECTORY, e); } } if (!IGV_DIRECTORY.exists()) { try { boolean wasSuccessful = IGV_DIRECTORY.mkdir(); if (!wasSuccessful) { System.err.println("Failed to create user directory!"); IGV_DIRECTORY = null; } } catch (Exception e) { log.error("Error creating igv directory", e); } } } // The IGV directory either doesn't exist or isn't writeable. This situation can arise with Windows Vista // and Windows 7 due to a Java bug (http://bugs.sun.com/view_bug.do?bug_id=4787931) if (IGV_DIRECTORY == null || !IGV_DIRECTORY.exists() || !canWrite(IGV_DIRECTORY)) { if (Globals.isHeadless() || Globals.isSuppressMessages()) { System.err.println("Cannot write to igv directory: " + IGV_DIRECTORY.getAbsolutePath()); IGV_DIRECTORY = (new File(".")).getParentFile(); } else { int option = JOptionPane.showConfirmDialog(null, "<html>The default IGV directory (" + IGV_DIRECTORY + ") " + "cannot be accessed. Click Yes to choose a new folder or No to exit.<br>" + "This folder will be used to create the 'igv' directory", "IGV Directory Error", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { File parentDirectory = FileDialogUtils .chooseDirectory("Select a location for the igv directory", null); if (parentDirectory != null) { IGV_DIRECTORY = new File(parentDirectory, "igv"); IGV_DIRECTORY.mkdir(); Preferences prefs = Preferences.userNodeForPackage(Globals.class); prefs.put(IGV_DIR_USERPREF, IGV_DIRECTORY.getAbsolutePath()); } } } } if (IGV_DIRECTORY == null || !IGV_DIRECTORY.canRead()) { throw new DataLoadException("Cannot read from user directory", IGV_DIRECTORY.getAbsolutePath()); } else if (!canWrite(IGV_DIRECTORY)) { throw new DataLoadException("Cannot write to user directory", IGV_DIRECTORY.getAbsolutePath()); } log.info("IGV Directory: " + IGV_DIRECTORY.getAbsolutePath()); } return IGV_DIRECTORY; }
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 {// w ww. j a va 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:au.org.ala.delta.intkey.ui.UIUtils.java
/** * Save the mode in which the application was last used before shutdown - * advanced or basic - to the preferences * //from w w w .j a v a 2 s . c om * @param advancedMode * true if application was last used in advanced mode */ public static void savePreviousApplicationMode(boolean advancedMode) { Preferences prefs = Preferences.userNodeForPackage(Intkey.class); prefs.put(MODE_PREF_KEY, advancedMode ? ADVANCED_MODE_PREF_VALUE : BASIC_MODE_PREF_VALUE); try { prefs.sync(); } catch (BackingStoreException e) { throw new RuntimeException(e); } }