List of usage examples for java.util.prefs Preferences userNodeForPackage
public static Preferences userNodeForPackage(Class<?> c)
From source file:com.greenpepper.server.license.LicenceGenerator.java
private static LicenseParam getLicenseParam() { final KeyStoreParam privateKeyStoreParam = new KeyStoreParam() { public InputStream getStream() throws IOException { final String resourceName = "privateKeys.store"; final InputStream in = getClass().getResourceAsStream(resourceName); if (in == null) throw new FileNotFoundException(resourceName); return in; }//from w w w . j ava2 s . c om public String getAlias() { return "privatekey"; } public String getStorePwd() { return "gr33np3pp3r"; } public String getKeyPwd() { return getStorePwd(); } }; final CipherParam cipherParam = new CipherParam() { public String getKeyPwd() { return "gr33np3pp3r"; } }; final LicenseParam licenseParam = new LicenseParam() { public String getSubject() { return "GreenPepper"; } public Preferences getPreferences() { return Preferences.userNodeForPackage(LicenceGenerator.class); } public KeyStoreParam getKeyStoreParam() { return privateKeyStoreParam; } public CipherParam getCipherParam() { return cipherParam; } }; return licenseParam; }
From source file:au.org.ala.delta.editor.EditorPreferences.java
public static void setImportFileFilter(String filter) { Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class); if (prefs != null) { prefs.put(IMPORT_FILE_FILTER_KEY, filter); }//from w w w. j a v a 2s . c o m }
From source file:net.sourceforge.metware.binche.execs.BiNCheExec.java
private void runDefault(String inputPath, String outputPath) { LOGGER.log(Level.INFO, "############ Start ############"); Preferences binchePrefs = Preferences.userNodeForPackage(BiNChe.class); try {/*from w w w . j a va 2 s .c o m*/ if (binchePrefs.keys().length == 0) { new OfficialChEBIOboLoader(); } } catch (BackingStoreException e) { LOGGER.error("Problems loading preferences", e); return; } catch (IOException e) { LOGGER.error("Problems loading preferences", e); return; } //String ontologyFile = getClass().getResource("/BiNGO/data/chebi_clean.obo").getFile(); String ontologyFile = binchePrefs.get(BiNChEOntologyPrefs.RoleAndStructOntology.name(), null); String elementsForEnrichFile = inputPath; LOGGER.log(Level.INFO, "Setting default parameters ..."); BingoParameters parametersSaddle = getDefaultParameters(ontologyFile); BiNChe binche = new BiNChe(); binche.setParameters(parametersSaddle); LOGGER.log(Level.INFO, "Reading input file ..."); try { binche.loadDesiredElementsForEnrichmentFromFile(elementsForEnrichFile); } catch (IOException exception) { LOGGER.log(Level.ERROR, "Error reading file: " + exception.getMessage()); System.exit(1); } binche.execute(); ChebiGraph chebiGraph = new ChebiGraph(binche.getEnrichedNodes(), binche.getOntology(), binche.getInputNodes()); //new ChebiGraph(binche.getPValueMap(), binche.getOntology(), binche.getInputNodes()); LOGGER.log(Level.INFO, "Writing out graph ..."); SvgWriter writer = new SvgWriter(); writer.writeSvg(chebiGraph.getVisualisationServer(), outputPath); LOGGER.log(Level.INFO, "############ Stop ############"); }
From source file:com.mirth.connect.client.ui.components.MirthTreeTable.java
public MirthTreeTable(String prefix, Set<String> defaultVisibleColumns) { customHiddenColumnMap = new HashMap<String, Set<String>>(); this.prefix = prefix; this.defaultVisibleColumns = defaultVisibleColumns; columnOrderMap = new HashMap<String, Integer>(); sortOrderColumn = -1;/*from ww w .java2 s . co m*/ sortOrder = null; if (StringUtils.isNotEmpty(prefix)) { try { userPreferences = Preferences.userNodeForPackage(Mirth.class); String columns = userPreferences.get(prefix + "ColumnOrderMap", ""); if (StringUtils.isNotEmpty(columns)) { columnOrderMap = (Map<String, Integer>) ObjectXMLSerializer.getInstance().deserialize(columns, Map.class); } } catch (Exception e) { } try { String order = userPreferences.get(prefix + "SortOrder", ""); if (StringUtils.isNotEmpty(order)) { sortOrder = ObjectXMLSerializer.getInstance().deserialize(order, SortOrder.class); sortOrderColumn = userPreferences.getInt(prefix + "SortOrderColumn", -1); } } catch (Exception e) { } } addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { boolean isAccelerated = (((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0) || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)); if ((e.getKeyCode() == KeyEvent.VK_S) && isAccelerated) { PlatformUI.MIRTH_FRAME.doContextSensitiveSave(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); /* * Swingx 1.0 has this set to true by default, which doesn't allow dragging and dropping * into tables. Swingx 0.8 had this set to false. Tables that want it set to true can * override it. */ putClientProperty("terminateEditOnFocusLost", Boolean.FALSE); JTableHeader header = getTableHeader(); header.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { saveColumnOrder(); } }); header.setDefaultRenderer(new SortableHeaderCellRenderer(header.getDefaultRenderer())); final JButton columnControlButton = new JButton(new ColumnControlButton(this).getIcon()); columnControlButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPopupMenu columnMenu = getColumnMenu(); Dimension buttonSize = columnControlButton.getSize(); int xPos = columnControlButton.getComponentOrientation().isLeftToRight() ? buttonSize.width - columnMenu.getPreferredSize().width : 0; columnMenu.show(columnControlButton, xPos, columnControlButton.getHeight()); } }); setColumnControl(columnControlButton); }
From source file:ome.formats.importer.ImportConfig.java
/** * Static method for creating {@link Preferences} during construction if * necessary./* www .j a v a 2s . c om*/ */ private static Preferences prefs() { Preferences prefs = Preferences.userNodeForPackage(ImportConfig.class); try { prefs.flush(); } catch (Exception e) { log.error("Error flushing preferences"); } return prefs; }
From source file:com.trifork.riak.RiakClient.java
/** * helper method to use a reasonable default client id * /*w w w .jav a2s .c om*/ * @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"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } byte[] data = new byte[6]; sr.nextBytes(data); clid = Base64Coder.encodeLines(data); prefs.put("client_id", clid); try { prefs.flush(); } catch (BackingStoreException e) { throw new IOException(e); } } setClientID(clid); }
From source file:org.openpnp.model.Configuration.java
private Configuration(File configurationDirectory) { this.configurationDirectory = configurationDirectory; this.prefs = Preferences.userNodeForPackage(Configuration.class); }
From source file:net.chaosserver.timelord.swingui.AnnoyTimeDialog.java
/** * Captures the action and processes and closes the dialog. * * @param evt the action event triggering the method *///from w w w . ja v a2 s . c o m public void actionPerformed(ActionEvent evt) { if (ACTION_OK.equals(evt.getActionCommand())) { int minuteValue = minuteSlider.getValue(); double fractionValue = minuteValue / 60d; if (log.isDebugEnabled()) { log.debug("Got back minute value [" + minuteValue + "] as fraction value [" + fractionValue + "]"); } Preferences preferences = Preferences.userNodeForPackage(Timelord.class); preferences.putDouble(Timelord.TIME_INCREMENT, fractionValue); this.setVisible(false); } else if (ACTION_CANCEL.equals(evt.getActionCommand())) { this.setVisible(false); } }
From source file:net.sf.ginp.setup.SetupManagerImpl.java
/** * @param configUrl//from ww w .j a v a2s .c o m * @param configuration * @return the saves prefs object */ private Preferences storeConfig(final URL configUrl, final String configuration) { Preferences preferences = Preferences.userNodeForPackage(SetupManagerImpl.class); preferences.put(configUrl.toExternalForm(), configuration); return preferences; }
From source file:au.org.ala.delta.editor.EditorPreferences.java
public static EditorAdvanceMode getEditorAdvanceMode() { Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class); if (prefs != null) { String mode = prefs.get(ADVANCE_MODE_KEY, DEFAULT_EDITOR_ADVANCE_MODE.toString()); return EditorAdvanceMode.valueOf(mode); }/*from w w w.j a v a 2 s . c om*/ return DEFAULT_EDITOR_ADVANCE_MODE; }