List of usage examples for java.util.prefs Preferences get
public abstract String get(String key, String def);
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 {//w w w . ja v a 2 s. c om 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:org.rhq.enterprise.server.agent.EmbeddedAgentBootstrapService.java
public Properties getAgentConfiguration() { try {/* w w w .ja v a2 s . c om*/ Properties properties = new Properties(); Preferences prefs = getPreferencesNode(); for (String key : prefs.keys()) { properties.setProperty(key, prefs.get(key, "?")); } return properties; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java
private void rootRightClickAction(final MouseEvent evt) { JPopupMenu menu = new JPopupMenu(); JMenuItem refreshItem = new JMenuItem("Refresh Templates"); JMenuItem resetConnectionItem = new JMenuItem("Reset Connection"); menu.add(refreshItem);/*from w w w . j a v a2 s. c o m*/ menu.add(resetConnectionItem); refreshItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // simulate close and open to refresh the tree componentClosed(); componentOpened(); } }); resetConnectionItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent evt) { ServerDetailsView serverDetails = getRefreshServerDetails(); // set previous preferences Preferences prefs = NbPreferences.forModule(ResourceExplorerTopComponent.class); serverDetails.setDetails(prefs.get("scheme", "http"), prefs.get("host", "localhost"), prefs.get("port", "8080"), prefs.get("username", StringUtils.EMPTY), prefs.get("password", StringUtils.EMPTY)); // reset connection preferences prefs.remove("scheme"); prefs.remove("host"); prefs.remove("port"); prefs.remove("username"); prefs.remove("password"); serverDetails.setVisible(true); } }); menu.show(evt.getComponent(), evt.getX(), evt.getY()); }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Gets the annoyance mode from the perferences or returns the default. * * @return the annoyance mode/* ww w .jav a 2 s .c o m*/ */ public String getAnnoyanceMode() { Preferences preferences = Preferences.userNodeForPackage(this.getClass()); return preferences.get(ANNOYANCE_MODE, ANNOYANCE_JORDAN); }
From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java
@Override public void componentOpened() { // look for connection preferences Preferences prefs = NbPreferences.forModule(ResourceExplorerTopComponent.class); if (StringUtils.isBlank(prefs.get("scheme", null)) || StringUtils.isBlank(prefs.get("host", null)) || StringUtils.isBlank(prefs.get("port", null)) || StringUtils.isBlank(prefs.get("username", null)) || StringUtils.isBlank(prefs.get("password", null))) { new ServerDetailsView(null, true).setVisible(true); }//from w w w . j a v a2 s .c om try { mailTemplateManagerService = ResourceConnector.getMailTemplateManagerService(); reportTemplateManagerService = ResourceConnector.getReportTemplateManagerService(); // init tree, because on close it is reset initTemplatesTree(); // Load templates LOG.info("Loading Apache Syncope templates..."); Runnable tsk = new Runnable() { @Override public void run() { final ProgressHandle progr = ProgressHandle.createHandle("Loading Templates", new Cancellable() { @Override public boolean cancel() { return true; } }); progr.start(); progr.progress("Loading Templates."); addMailTemplates(); addReportXslts(); progr.finish(); } }; REQUEST_PROCESSOR.post(tsk); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Generic Error", JOptionPane.ERROR_MESSAGE); ServerDetailsView serverDetails = getRefreshServerDetails(); } Runnable tsk = new Runnable() { @Override public void run() { final ProgressHandle progr = ProgressHandle.createHandle("Loading Templates", new Cancellable() { @Override public boolean cancel() { return true; } }); progr.start(); progr.progress("Loading Templates."); addMailTemplates(); addReportXslts(); progr.finish(); } }; RequestProcessor.getDefault().post(tsk); }
From source file:org.tros.torgo.ControllerBase.java
/** * Open a file./*www. j av a 2s. c o m*/ */ @Override public void openFile() { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(ControllerBase.class); chooser.setCurrentDirectory( new File(prefs.get(ControllerBase.class.getName() + "-working-directory", "."))); if (chooser.showOpenDialog(window) == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getPath(); prefs.put(ControllerBase.class.getName() + "-working-directory", chooser.getSelectedFile().getParent()); openFile(chooser.getSelectedFile()); } }
From source file:org.tros.torgo.ControllerBase.java
/** * Save the script as a new file.// ww w .j a v a2s. co m */ @Override public void saveFileAs() { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(ControllerBase.class); chooser.setCurrentDirectory( new File(prefs.get(ControllerBase.class.getName() + "-working-directory", "."))); int result = chooser.showSaveDialog(window); if (result == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getPath(); prefs.put(ControllerBase.class.getName() + "-working-directory", chooser.getSelectedFile().getParent()); saveFile(); } }
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 w ww .ja v a 2 s . com*/ * @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.apache.cayenne.modeler.dialog.codegen.GeneratorController.java
/** * Creates a class generator for provided selections. *///from w w w.j a v a 2 s. co m public Collection<ClassGenerationAction> createGenerator() { File outputDir = getOutputDir(); // no destination folder if (outputDir == null) { JOptionPane.showMessageDialog(this.getView(), "Select directory for source files."); return null; } // no such folder if (!outputDir.exists() && !outputDir.mkdirs()) { JOptionPane.showMessageDialog(this.getView(), "Can't create directory " + outputDir + ". Select a different one."); return null; } // not a directory if (!outputDir.isDirectory()) { JOptionPane.showMessageDialog(this.getView(), outputDir + " is not a valid directory."); return null; } // remove generic entities... Collection<ObjEntity> selectedEntities = new ArrayList<>(getParentController().getSelectedEntities()); Iterator<ObjEntity> it = selectedEntities.iterator(); while (it.hasNext()) { if (it.next().isGeneric()) { it.remove(); } } Collection<ClassGenerationAction> generators = new ArrayList<>(); Collection<StandardPanelComponent> dataMapLines = ((GeneratorControllerPanel) getView()).getDataMapLines(); for (DataMap map : getParentController().getDataMaps()) { try { ClassGenerationAction generator = newGenerator(); generator.setArtifactsGenerationMode(mode); generator.setDataMap(map); LinkedList<ObjEntity> objEntities = new LinkedList<>(map.getObjEntities()); objEntities.retainAll(selectedEntities); generator.addEntities(objEntities); LinkedList<Embeddable> embeddables = new LinkedList<>(map.getEmbeddables()); embeddables.retainAll(getParentController().getSelectedEmbeddables()); generator.addEmbeddables(embeddables); generator.addQueries(map.getQueryDescriptors()); Preferences preferences = application.getPreferencesNode(GeneralPreferences.class, ""); if (preferences != null) { generator.setEncoding(preferences.get(GeneralPreferences.ENCODING_PREFERENCE, null)); } generator.setDestDir(outputDir); generator.setMakePairs(true); for (StandardPanelComponent dataMapLine : dataMapLines) { if (dataMapLine.getDataMap() == map && !Util.isEmptyString(dataMapLine.getSuperclassPackage().getText())) { generator.setSuperPkg(dataMapLine.getSuperclassPackage().getText()); break; } } generators.add(generator); } catch (CayenneException exception) { JOptionPane.showMessageDialog(this.getView(), exception.getUnlabeledMessage()); return null; } } return generators; }
From source file:PreferenceExample.java
public void printInformation(Preferences p) throws BackingStoreException { System.out.println("Node's absolute path: " + p.absolutePath()); System.out.print("Node's children: "); for (String s : p.childrenNames()) { System.out.print(s + " "); }/*from w w w . ja va 2s .co m*/ System.out.println(""); System.out.print("Node's keys: "); for (String s : p.keys()) { System.out.print(s + " "); } System.out.println(""); System.out.println("Node's name: " + p.name()); System.out.println("Node's parent: " + p.parent()); System.out.println("NODE: " + p); System.out.println("userNodeForPackage: " + Preferences.userNodeForPackage(PreferenceExample.class)); System.out.println("All information in node"); for (String s : p.keys()) { System.out.println(" " + s + " = " + p.get(s, "")); } }