List of usage examples for java.util.prefs Preferences userRoot
public static Preferences userRoot()
From source file:org.kuali.test.ui.components.panels.FileTestPanel.java
/** * * @param e/* w ww .ja v a 2s. co m*/ */ @Override protected void handleUnprocessedActionEvent(ActionEvent e) { if (Constants.FILE_SEARCH_ACTION.equals(e.getActionCommand())) { Preferences proot = Preferences.userRoot(); Preferences node = proot.node(Constants.PREFS_FILES_NODE); String lastDir = node.get(Constants.PREFS_LAST_FILE_TEST_DIR, System.getProperty("user.home")); JFileChooser chooser = new JFileChooser(lastDir); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { return (f.isDirectory() && f.exists()); } @Override public String getDescription() { return "file inquiry directory"; } }); int returnVal = chooser.showOpenDialog(getMainframe()); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); fileDirectory.setText(f.getPath()); node.put(Constants.PREFS_LAST_FILE_TEST_DIR, f.getPath()); } } else if (Constants.FILE_EXISTS.equals(e.getActionCommand())) { getFileCheckCondition(Constants.FILE_DOES_NOT_EXIST).setSelected(false); getFileCheckCondition(Constants.FILE_SIZE_GREATER_THAN_ZERO).setEnabled(true); getFileCheckCondition(Constants.FILE_CREATED_TODAY).setEnabled(true); getFileCheckCondition(Constants.FILE_CREATED_YESTERDAY).setEnabled(true); containingText.setEnabled(true); } else if (Constants.FILE_DOES_NOT_EXIST.equals(e.getActionCommand())) { getFileCheckCondition(Constants.FILE_EXISTS).setSelected(false); getFileCheckCondition(Constants.FILE_SIZE_GREATER_THAN_ZERO).setSelected(false); getFileCheckCondition(Constants.FILE_SIZE_GREATER_THAN_ZERO).setEnabled(false); getFileCheckCondition(Constants.FILE_CREATED_TODAY).setSelected(false); getFileCheckCondition(Constants.FILE_CREATED_TODAY).setEnabled(false); getFileCheckCondition(Constants.FILE_CREATED_YESTERDAY).setSelected(false); getFileCheckCondition(Constants.FILE_CREATED_YESTERDAY).setEnabled(false); containingText.setText(""); containingText.setEnabled(false); } else if (Constants.FILE_CREATED_TODAY.equals(e.getActionCommand())) { getFileCheckCondition(Constants.FILE_CREATED_YESTERDAY).setSelected(false); } else if (Constants.FILE_CREATED_YESTERDAY.equals(e.getActionCommand())) { getFileCheckCondition(Constants.FILE_CREATED_TODAY).setSelected(false); } }
From source file:com.itemanalysis.jmetrik.gui.JmetrikPreferencesManager.java
public JmetrikPreferencesManager() { propertyChangeListeners = new ArrayList<PropertyChangeListener>(); p = Preferences.userRoot().node(JMETRIK_PREFERENCES_NODE); // removeAllPreferences();//debugging only initializePreferences();/*w ww . ja v a2 s .c o m*/ // printAllPreferences();//debugging only }
From source file:com.gnadenheimer.mg3.utils.Utils.java
public void printFactura(TblFacturas factura) { try {/* w ww .jav a 2s. c o m*/ Map parameters = new HashMap(); parameters.put("factura_id", factura.getNro()); parameters.put("fechahora", java.sql.Date.valueOf(factura.getFechahora().toLocalDate())); parameters.put("razon_social", factura.getRazonSocial()); parameters.put("ruc", factura.getRuc()); parameters.put("domicilio", factura.getDomicilio()); parameters.put("box", factura.getCasillaDeCorreo() == null ? "" : factura.getCasillaDeCorreo().toString()); parameters.put("usuario", factura.getIdUser().getNombrecompleto()); parameters.put("importe_aporte", factura.getImporteAporte()); parameters.put("importe_donacion", factura.getImporteDonacion()); parameters.put("logo", getClass().getResourceAsStream("/reports/cclogo200.png")); parameters.put("logo2", getClass().getResourceAsStream("/reports/cclogo200.png")); parameters.put("logo3", getClass().getResourceAsStream("/reports/cclogo200.png")); parameters.put(JRParameter.REPORT_LOCALE, Locale.forLanguageTag("es")); //JOptionPane.showMessageDialog(null, getClass().getResource("/reports/cclogo200.png").getPath()); String reportFactura = Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla"); if (reportFactura.equals("Preimpreso sin rejilla")) { reportFactura = "factura_con_rejilla"; } else if (reportFactura.equals("Preimpreso con rejilla")) { reportFactura = "factura"; } else if (reportFactura.equals("Preimpreso con rejilla modelo especial Bethel Theodor")) { reportFactura = "factura_bethel"; } JasperReport report = JasperCompileManager .compileReport(getClass().getResourceAsStream("/reports/" + reportFactura + ".jrxml")); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource()); jasperPrint.setLeftMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaLeftMargin", "0"))); jasperPrint.setTopMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaTopMargin", "0"))); //JasperViewer jReportsViewer = new JasperViewer(jasperPrint, false); //jReportsViewer.setVisible(true); jasperPrint.setLeftMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaLeftMargin", "0"))); jasperPrint.setTopMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaTopMargin", "0"))); JasperPrintManager.printReport(jasperPrint, false); } catch (Exception ex) { App.showException(Thread.currentThread().getStackTrace()[1].getMethodName(), ex.getMessage(), ex); LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex); } }
From source file:org.kuali.test.creator.TestCreator.java
private void loadPreferences() { try {/*from www . ja va 2 s . co m*/ Preferences proot = Preferences.userRoot(); Preferences node = proot.node(Constants.PREFS_ROOT_NODE); int left = node.getInt(Constants.PREFS_MAINFRAME_LEFT, Constants.MAINFRAME_DEFAULT_LEFT); int top = node.getInt(Constants.PREFS_MAINFRAME_TOP, Constants.MAINFRAME_DEFAULT_TOP); int width = node.getInt(Constants.PREFS_MAINFRAME_WIDTH, Constants.MAINFRAME_DEFAULT_WIDTH); int height = node.getInt(Constants.PREFS_MAINFRAME_HEIGHT, Constants.MAINFRAME_DEFAULT_HEIGHT); setState(node.getInt(Constants.PREFS_MAINFRAME_WINDOW_STATE, Frame.NORMAL)); setBounds(left, top, width, height); node.flush(); } catch (BackingStoreException ex) { LOG.error(ex.toString(), ex); } }
From source file:de.ingrid.usermanagement.jetspeed.IngridRoleManager.java
/** * @see org.apache.jetspeed.security.RoleManager#getRole(java.lang.String) *///w w w.ja v a 2s . c o m public Role getRole(String roleFullPathName) throws SecurityException { ArgUtil.notNull(new Object[] { roleFullPathName }, new String[] { "roleFullPathName" }, "getRole(java.lang.String)"); String fullPath = RolePrincipalImpl.getFullPathFromPrincipalName(roleFullPathName); Principal rolePrincipal = roleSecurityHandler.getRolePrincipal(roleFullPathName); if (null == rolePrincipal) { throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName)); } Preferences preferences = Preferences.userRoot().node(fullPath); Role role = new RoleImpl(rolePrincipal, preferences); return role; }
From source file:com.gnadenheimer.mg.utils.Utils.java
public void printFactura(TblFacturas factura) { try {//from ww w .j a v a 2s .c om Map parameters = new HashMap(); parameters.put("factura_id", factura.getNro()); parameters.put("fechahora", java.sql.Date.valueOf(factura.getFechahora().toLocalDate())); parameters.put("razon_social", factura.getRazonSocial()); parameters.put("ruc", factura.getRuc()); parameters.put("domicilio", factura.getDomicilio()); parameters.put("box", factura.getCasillaDeCorreo() == null ? "" : factura.getCasillaDeCorreo().toString()); parameters.put("usuario", factura.getIdUser().getNombrecompleto()); parameters.put("importe_aporte", factura.getImporteAporte()); parameters.put("importe_donacion", factura.getImporteDonacion()); parameters.put("logo", getClass().getResourceAsStream("/reports/cclogo200.png")); parameters.put("logo2", getClass().getResourceAsStream("/reports/cclogo200.png")); parameters.put("logo3", getClass().getResourceAsStream("/reports/cclogo200.png")); parameters.put("logo-bethel", getClass().getResourceAsStream("/images/logo-bethel.png")); parameters.put("logo-bethel2", getClass().getResourceAsStream("/images/logo-bethel.png")); parameters.put("logo-friesen", getClass().getResourceAsStream("/images/logo-friesen.png")); parameters.put(JRParameter.REPORT_LOCALE, Locale.forLanguageTag("es")); //JOptionPane.showMessageDialog(null, getClass().getResource("/reports/cclogo200.png").getPath()); String reportFactura = Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla"); if (reportFactura.equals("Preimpreso sin rejilla")) { reportFactura = "factura_con_rejilla"; } else if (reportFactura.equals("Preimpreso sin rejilla - CREDITO")) { reportFactura = "factura_con_rejilla_credito"; } else if (reportFactura.equals("Preimpreso con rejilla")) { reportFactura = "factura"; } else if (reportFactura.equals("Preimpreso con rejilla modelo especial Bethel Theodor")) { reportFactura = "factura_bethel"; } else if (reportFactura.equals("Preimpreso sin rejilla Bethel")) { reportFactura = "factura_con_rejilla_bethel_full"; } JasperReport report = JasperCompileManager .compileReport(getClass().getResourceAsStream("/reports/" + reportFactura + ".jrxml")); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource()); jasperPrint.setLeftMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaLeftMargin", "0"))); jasperPrint.setTopMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaTopMargin", "0"))); //JasperViewer jReportsViewer = new JasperViewer(jasperPrint, false); //jReportsViewer.setVisible(true); jasperPrint.setLeftMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaLeftMargin", "0"))); jasperPrint.setTopMargin( Integer.getInteger(Preferences.userRoot().node("MG").get("facturaTopMargin", "0"))); JasperPrintManager.printReport(jasperPrint, false); } catch (Exception ex) { JOptionPane.showMessageDialog(null, Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage()); LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex); } }
From source file:com.example.app.profile.ui.user.UserPropertyEditor.java
@SuppressWarnings("Duplicates") @Override//from w w w . j a v a 2s. c o m public void init() { super.init(); NavigationAction saveAction = CommonActions.SAVE.navAction(); saveAction.onCondition(input -> persist(user -> { assert user != null : "User should not be null if you are persisting!"; UserValueEditor editor = getValueEditor(); User currentUser = _userDAO.getAssertedCurrentUser(); _sessionHelper.beginTransaction(); boolean success = false; try { if (Objects.equals(currentUser.getId(), user.getId())) { user.setPreferredContactMethod(editor.commitValuePreferredContactMethod()); final Link link = editor.commitValueLoginLandingPage(); if (link != null) { Preferences userPref = Preferences.userRoot().node(User.LOGIN_PREF_NODE); userPref.put(User.LOGIN_PREF_NODE_LANDING_PAGE, link.getURIAsString()); } } user = _userDAO.mergeUser(user); try { boolean result = true; EmailAddress emailAddress = ContactUtil .getEmailAddress(user.getPrincipal().getContact(), ContactDataCategory.values()) .orElseThrow(() -> new IllegalStateException( "Email Address was null on PrincipalValueEditor. This should not happen.")); if (user.getPrincipal().getPasswordCredentials() == null) { String randomPassword = UUID.randomUUID().toString(); List<Notification> notifications = new ArrayList<>(); result = _principalDAO.setNewPassword(user.getPrincipal(), emailAddress.getEmail(), notifications, randomPassword); if (result) { user.setPrincipal(_er.reattachIfNecessary(user.getPrincipal())); user.getPrincipal().getCredentials().forEach(cred -> { if (_er.narrowProxyIfPossible(cred) instanceof PasswordCredentials) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, -10); cred.setExpireDate(cal.getTime()); } }); _principalDAO.savePrincipal(user.getPrincipal()); } else { final Notifiable notifiable = getNotifiable(); notifications.forEach(notifiable::sendNotification); } } else { PasswordCredentials creds = user.getPrincipal().getPasswordCredentials(); creds.setUsername(emailAddress.getEmail()); _principalDAO.savePrincipal(user.getPrincipal()); } if (!_principalDAO.getAllRoles(user.getPrincipal()) .contains(_appUtil.getFrontEndAccessRole())) { user.getPrincipal().getChildren().add(_appUtil.getFrontEndAccessRole()); _principalDAO.savePrincipal(user.getPrincipal()); } user = _userDAO.mergeUser(user); Company userProfile = _uiPreferences.getSelectedCompany(); if (userProfile != null && !userProfile.getUsers().contains(user) && _newUser) { _companyDAO.addUserToCompany(userProfile, user); List<MembershipType> coachingMemTypes = editor.commitValueCoachingMemType(); final User finalUser = user; coachingMemTypes.forEach(coachingMemType -> _profileDAO.saveMembership( _profileDAO.createMembership(userProfile, finalUser, coachingMemType, ZonedDateTime.now(getSession().getTimeZone().toZoneId()), true))); } if (editor.getPictureEditor().getModificationState().isModified()) { _userDAO.saveUserImage(user, editor.getPictureEditor().commitValue()); } success = result; if (success) { setSaved(user); } } catch (NonUniqueCredentialsException e) { _logger.error("Unable to persist changes to the Principal.", e); getNotifiable().sendNotification(error(ERROR_MESSAGE_USERNAME_EXISTS_FMT(USER()))); } _sessionHelper.commitTransaction(); } finally { if (!success) _sessionHelper.recoverableRollbackTransaction(); } if (success) { _uiPreferences.addMessage( new NotificationImpl(NotificationType.INFO, INFO_SHOULD_PICK_ONE_ROLE_NEW_USER())); } return success; })); saveAction.configure().toPage(ApplicationFunctions.User.VIEW).withSourceComponent(this); saveAction.setPropertyValueResolver(new CurrentURLPropertyValueResolver() { @Override public Map<String, Object> resolve(PropertyValueResolverParameter parameter) { Map<String, Object> map = super.resolve(parameter); map.put(URLProperties.USER, _saved); return map; } }); saveAction.setTarget(this, "close"); NavigationAction cancelAction = CommonActions.CANCEL.navAction(); cancelAction.configure().toReturnPath(ApplicationFunctions.User.MANAGEMENT).usingCurrentURLData() .withSourceComponent(this); cancelAction.setTarget(this, "close"); setPersistenceActions(saveAction, cancelAction); _notifications.forEach(notification -> getNotifiable().sendNotification(notification)); }
From source file:com.symbian.utils.config.ConfigUtils.java
/** * load the Configuration settings from files. * //w ww .j a va 2s . co m * @param aPrefFile * The Java Preference file to import/load. * * @throws IOException * If the load doesn't work. */ public void importConfig(final File aPrefFile) throws IOException { try { Preferences.importPreferences(new FileInputStream(aPrefFile)); iPrefrences = Preferences.userRoot().node(iNodeName); } catch (FileNotFoundException lFileNotFoundException) { throw new IOException("Cannot create new properties file: " + aPrefFile.getPath() + ": " + lFileNotFoundException.getMessage()); } catch (IOException lIOException) { throw new IOException( "Properties file I/O error: " + aPrefFile.getPath() + ", " + lIOException.getMessage()); } catch (InvalidPreferencesFormatException lIPFE) { throw new IOException( "Prefrences files are not valid: " + aPrefFile.getPath() + ", " + lIPFE.getMessage()); } }
From source file:org.kuali.test.creator.TestCreator.java
public String getLocalRunEmailAddress() { return Preferences.userRoot().node(Constants.PREFS_ROOT_NODE).get(Constants.LOCAL_RUN_EMAIL, ""); }
From source file:org.kuali.test.creator.TestCreator.java
private void savePreferences() { try {// www . j a v a2 s . c o m Preferences proot = Preferences.userRoot(); Preferences node = proot.node(Constants.PREFS_ROOT_NODE); Rectangle rect = getBounds(); node.putInt(Constants.PREFS_MAINFRAME_LEFT, rect.x); node.putInt(Constants.PREFS_MAINFRAME_TOP, rect.y); node.putInt(Constants.PREFS_MAINFRAME_WIDTH, rect.width); node.putInt(Constants.PREFS_MAINFRAME_HEIGHT, rect.height); node.putInt(Constants.PREFS_HORIZONTAL_DIVIDER_LOCATION, hsplitPane.getDividerLocation()); node.putInt(Constants.PREFS_VERTICAL_DIVIDER_LOCATION, vsplitPane.getDividerLocation()); node.putInt(Constants.PREFS_MAINFRAME_WINDOW_STATE, getState()); node.flush(); } catch (BackingStoreException ex) { LOG.error(ex.toString(), ex); } }