List of usage examples for java.util.prefs Preferences userRoot
public static Preferences userRoot()
From source file:org.pdfsam.ui.StatefullPreferencesStageServiceTest.java
@Test public void newsStageDisplayed() { assertEquals(0, Preferences.userRoot().node(StatefullPreferencesStageService.STAGE_PATH) .getLong(StatefullPreferencesStageService.NEWS_STAGE_DISPLAY_TIME_KEY, 0)); victim.newsStageDisplayed();/*from w ww.j a va 2s .co m*/ assertNotEquals(0, Preferences.userRoot().node(StatefullPreferencesStageService.STAGE_PATH) .getLong(StatefullPreferencesStageService.NEWS_STAGE_DISPLAY_TIME_KEY, 0)); }
From source file:nl.toolforge.karma.core.manifest.ManifestCollector.java
/** * Retrieves the last used manifest or <code>null</code> when none was found. * * @return The last used manifest./* www. ja v a2s . co m*/ * @throws ManifestException When the manifest referred to by {@link Manifest.HISTORY_KEY} could not be loaded. */ public Manifest loadManifestFromHistory() throws LocationException, ManifestException { String contextManifest = workingContext.getContextManifestPreference(); String manifestId = Preferences.userRoot().get(contextManifest, null); if (manifestId != null) { ManifestFactory manifestFactory = new ManifestFactory(); ManifestLoader loader = new ManifestLoader(workingContext); Manifest manifest = manifestFactory.create(workingContext, loader.load(manifestId)); return manifest; } return null; }
From source file:org.pdfsam.module.PreferencesUsageDataStore.java
public List<ModuleUsage> getUsages() { Preferences prefs = Preferences.userRoot().node(USAGE_PATH); List<ModuleUsage> retList = new ArrayList<>(); try {/*from ww w. ja va 2 s . co m*/ List<String> jsons = Arrays.stream(prefs.childrenNames()).parallel().map(name -> prefs.node(name)) .map(node -> node.get(MODULE_USAGE_KEY, "")).filter(json -> isNotBlank(json)).collect(toList()); for (String json : jsons) { retList.add(JSON.std.beanFrom(ModuleUsage.class, json)); } } catch (BackingStoreException | IOException e) { LOG.error("Unable to get modules usage statistics", e); } return retList; }
From source file:nl.toolforge.karma.core.cmd.impl.SelectManifest.java
/** * Activates a manifest./*from w ww. j ava2 s. c o m*/ * */ public void execute() throws CommandException { // Select a manifest and store it in the command context // try { getContext().changeCurrentManifest(getCommandLine().getOptionValue("m")); selectedManifest = getContext().getCurrentManifest(); } catch (ManifestException me) { throw new CommandException(me.getErrorCode(), me.getMessageArguments()); } catch (LocationException e) { throw new CommandException(e.getErrorCode(), e.getMessageArguments()); } // Store this manifest as the last used manifest. // String contextManifest = getWorkingContext().getContextManifestPreference(); Preferences.userRoot().put(contextManifest, getContext().getCurrentManifest().getName()); try { Preferences.userRoot().flush(); } catch (BackingStoreException e) { logger.warn("Could not write user preferences due to java.template.prefs.BackingStoreException."); } }
From source file:org.pdfsam.ui.StatefullPreferencesStageService.java
void clearStageStatus() { Preferences prefs = Preferences.userRoot().node(STAGE_PATH); try {/*from w w w . j av a2s .co m*/ prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear stage status", e); } }
From source file:org.pdfsam.module.PreferencesUsageDataStoreTest.java
@Test public void testClear() { victim.incrementUsageFor("moduleId"); victim.clear();/*from w ww . j av a 2 s . c o m*/ assertTrue(isBlank(Preferences.userRoot().node(PreferencesUsageDataStore.USAGE_PATH).node("moduleId") .get(PreferencesUsageDataStore.MODULE_USAGE_KEY, ""))); }
From source file:com.gnadenheimer.mg3.controller.admin.AdminConfigController.java
/** * Initializes the controller class./*from w w w . ja v a 2 s . co m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { try { cboTransferencias.getItems().addAll("Normal", "Triplicado"); cboFacturasFormato.getItems().addAll("Preimpreso con rejilla", "Preimpreso sin rejilla", "Preimpreso con rejilla modelo especial Bethel Theodor"); cboPeriodoFiscal.getItems().addAll(2016, 2017); txtIP.setText(Preferences.userRoot().node("MG").get("DatabaseIP", "127.000.000.001")); txtDataDir.setText(Preferences.userRoot().node("MG").get("Datadir", System.getProperty("user.dir") + File.separator + "javadb")); rbServidor.setSelected(Boolean.parseBoolean(Preferences.userRoot().node("MG").get("isServer", "true"))); rbCliente.setSelected( !Boolean.parseBoolean(Preferences.userRoot().node("MG").get("isServer", "truemaster 1"))); cboTransferencias.getSelectionModel() .select(Preferences.userRoot().node("MG").get("modoImpresion", "Normal")); cboFacturasFormato.getSelectionModel() .select(Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla")); rbAyCPorMes .setSelected(Boolean.parseBoolean(Preferences.userRoot().node("MG").get("cobrarAC", "true"))); cboPeriodoFiscal.getSelectionModel().select(Integer .valueOf(Preferences.userRoot().node("MG").getInt("PeriodoFiscal", LocalDate.now().getYear()))); txtDataDir.visibleProperty().bind(rbServidor.selectedProperty()); } catch (Exception ex) { App.showException(this.getClass().getName(), ex.getMessage(), ex); } }
From source file:org.pentaho.reporting.designer.core.settings.ProxySettings.java
public ProxySettings() { preferences = Preferences.userRoot().node("org/pentaho/reporting/designer/core/settings/proxy-settings"); //NON-NLS }
From source file:org.pdfsam.ui.StatefullPreferencesStageService.java
public void newsStageDisplayed() { Preferences.userRoot().node(STAGE_PATH).putLong(NEWS_STAGE_DISPLAY_TIME_KEY, Instant.now().toEpochMilli()); LOG.trace("Latest news stage display time stored"); }
From source file:com.maxl.java.amikodesk.Emailer.java
public Emailer(ResourceBundle rb) { m_el = "amiko@ywesee.com"; m_map_of_attachments = new TreeMap<String, String>(); m_prefs = Preferences.userRoot().node(SettingsPage.class.getName()); m_rb = rb;/*w ww. java2 s . c o m*/ loadMap(); }