List of usage examples for java.util.prefs Preferences userRoot
public static Preferences userRoot()
From source file:de.ingrid.usermanagement.jetspeed.IngridRoleManager.java
/** * @see org.apache.jetspeed.security.RoleManager#getRolesForUser(java.lang.String) *///from w w w .j a v a2s .c o m public Collection getRolesForUser(String username) throws SecurityException { ArgUtil.notNull(new Object[] { username }, new String[] { "username" }, "getRolesForUser(java.lang.String)"); Collection roles = new ArrayList(); Set rolePrincipals = securityMappingHandler.getRolePrincipals(username); Iterator rolePrincipalsIter = rolePrincipals.iterator(); while (rolePrincipalsIter.hasNext()) { Principal rolePrincipal = (Principal) rolePrincipalsIter.next(); Preferences preferences = Preferences.userRoot() .node(RolePrincipalImpl.getFullPathFromPrincipalName(rolePrincipal.getName())); roles.add(new RoleImpl(rolePrincipal, preferences)); } return roles; }
From source file:de.ingrid.usermanagement.jetspeed.IngridRoleManager.java
/** * @see org.apache.jetspeed.security.RoleManager#getRolesInGroup(java.lang.String) *//* www .j a v a 2 s . c o m*/ public Collection getRolesInGroup(String groupFullPathName) throws SecurityException { ArgUtil.notNull(new Object[] { groupFullPathName }, new String[] { "groupFullPathName" }, "getRolesInGroup(java.lang.String)"); Collection roles = new ArrayList(); Set rolePrincipals = securityMappingHandler.getRolePrincipalsInGroup(groupFullPathName); Iterator rolePrincipalsIter = rolePrincipals.iterator(); while (rolePrincipalsIter.hasNext()) { Principal rolePrincipal = (Principal) rolePrincipalsIter.next(); Preferences preferences = Preferences.userRoot() .node(RolePrincipalImpl.getFullPathFromPrincipalName(rolePrincipal.getName())); roles.add(new RoleImpl(rolePrincipal, preferences)); } return roles; }
From source file:com.gnadenheimer.mg3.utils.Utils.java
public void printAutofactura(TblAutofacturas factura) { try {/*from w w w . ja va2s . c o m*/ Map parameters = new HashMap(); parameters.put("factura_nro", factura.getNro()); parameters.put("fechahora", java.sql.Date.valueOf(factura.getFechahora().toLocalDate())); parameters.put("nombre", factura.getNombre()); parameters.put("ci", factura.getCi()); parameters.put("domicilio", factura.getDomicilio()); parameters.put("direccionDeTransaccion", factura.getDireccionDeTransaccion()); parameters.put("cantidad", factura.getCantidad()); parameters.put("concepto", factura.getConcepto()); parameters.put("precioUnitario", factura.getPrecioUnitario()); parameters.put("monto", factura.getMonto()); parameters.put("usuario", factura.getIdUser().getNombrecompleto()); String reportFactura = Preferences.userRoot().node("MG").get("formateFactura", "Preimpreso sin rejilla") .equals("Preimpreso sin rejilla") ? "autofactura_con_rejilla" : "autofactura"; 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:com.maxl.java.amikodesk.AMiKoDesk.java
public static void main(String[] args) { // Initialize globales m_application_data_folder = Utilities.appDataFolder(); favorite_meds_set = new HashSet<String>(); favorite_data = new DataStore(m_application_data_folder); favorite_meds_set = favorite_data.load(); // HashSet containing registration numbers // Register toolkit Toolkit tk = Toolkit.getDefaultToolkit(); tk.addAWTEventListener(WindowSaver.getInstance(m_application_data_folder), AWTEvent.WINDOW_EVENT_MASK); // Specify command line options Options options = new Options(); addOption(options, "help", "print this message", false, false); addOption(options, "version", "print the version information and exit", false, false); addOption(options, "port", "starts AmiKo-server at given port", true, false); addOption(options, "width", "sets window width", true, false); addOption(options, "height", "sets window height", true, false); addOption(options, "lang", "use given language", true, false); addOption(options, "type", "start light or full app", true, false); addOption(options, "title", "display medical info related to given title", true, false); addOption(options, "eancode", "display medical info related to given 13-digit ean-code", true, false); addOption(options, "regnr", "display medical info related to given 5-digit registration number", true, false);//w ww . java 2 s . c o m // Activate command line parser commandLineParse(options, args); // Initialize language files if (Utilities.appLanguage().equals("de")) m_rb = ResourceBundle.getBundle("amiko_de_CH", new Locale("de", "CH")); else if (Utilities.appLanguage().equals("fr")) m_rb = ResourceBundle.getBundle("amiko_fr_CH", new Locale("fr", "CH")); if (Utilities.appCustomization().equals("desitin")) { new SplashWindow(Constants.APP_NAME, 5000); } else if (Utilities.appCustomization().equals("meddrugs")) { new SplashWindow(Constants.APP_NAME, 5000); } else if (Utilities.appCustomization().equals("zurrose")) { new SplashWindow(Constants.APP_NAME, 3000); } // Load javascript String jscript_str = FileOps.readFromFile(Constants.JS_FOLDER + "main_callbacks.js"); m_jscript_str = "<script language=\"javascript\">" + jscript_str + "</script>"; // Load css style sheet m_css_str = "<style>" + FileOps.readFromFile(Constants.CSS_SHEET) + "</style>"; // Load main database m_sqldb = new MainSqlDb(); // Attempt to load alternative database. if db does not exist, load // default database // These databases are NEVER zipped! if (m_sqldb.loadDBFromPath(m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_DB_BASE + Utilities.appLanguage() + ".db") == 0) { System.out.println("Loading default amiko database"); if (Utilities.appLanguage().equals("de")) m_sqldb.loadDB("de"); else if (Utilities.appLanguage().equals("fr")) m_sqldb.loadDB("fr"); } // Load rose database if (Utilities.appCustomization().equals("zurrose")) { m_rosedb = new RoseSqlDb(); if (m_rosedb.loadDBFromPath(m_application_data_folder + "\\" + Constants.DEFAULT_ROSE_DB) == 0) { System.out.println("Loading default rose db"); m_rosedb.loadDB(); } } // Initialize update class m_maindb_update = new UpdateDb(m_sqldb); // Create shop folder in application data folder File wdir = new File(m_application_data_folder + "\\shop"); if (!wdir.exists()) wdir.mkdirs(); // Load interaction cart m_interactions_cart = new InteractionsCart(); // Create shopping cart and load related files m_shopping_cart = new ShoppingCart(); loadAuthors(); m_emailer = new Emailer(m_rb); // Create comparison cart and load related files m_comparison_cart = new ComparisonCart(); // Preferences m_prefs = Preferences.userRoot().node(SettingsPage.class.getName()); // UIUtils.setPreferredLookAn dFeel(); NativeInterface.open(); NativeSwing.initialize(); // Setup font size based on screen size UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("Dialog", Font.PLAIN, 14)); UIManager.put("Label.font", new Font("Dialog", Font.PLAIN, 12)); UIManager.put("CheckBox.font", new Font("Dialog", Font.PLAIN, 12)); UIManager.put("Button.font", new Font("Dialog", Font.BOLD, 14)); UIManager.put("ToggleButton.font", new Font("Dialog", Font.BOLD, 14)); UIManager.put("ToggleButton.select", m_selected_but_color); UIManager.put("Menu.font", new Font("Dialog", Font.PLAIN, 12)); UIManager.put("MenuBar.font", new Font("Dialog", Font.PLAIN, 12)); UIManager.put("MenuItem.font", new Font("Dialog", Font.PLAIN, 12)); UIManager.put("ToolBar.font", new Font("Dialog", Font.PLAIN, 12)); // Schedule a job for the event-dispatching thread: // creating and showing this application's GUI javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (!commandLineOptionsProvided()) { System.out.println("No relevant command line options provided... creating full GUI"); createAndShowFullGUI(); } else if (CML_OPT_TYPE.equals("full")) { System.out.println("Creating full GUI"); createAndShowFullGUI(); } else if (CML_OPT_TYPE.equals("light")) { System.out.println("Creating light GUI"); createAndShowLightGUI(); } } }); NativeInterface.runEventPump(); }
From source file:com.gnadenheimer.mg.utils.Utils.java
public void printAutofactura(TblAutofacturas factura) { try {// ww w . ja va 2 s . co m Map parameters = new HashMap(); parameters.put("factura_nro", factura.getNro()); parameters.put("fechahora", java.sql.Date.valueOf(factura.getFechahora().toLocalDate())); parameters.put("nombre", factura.getNombre()); parameters.put("ci", factura.getCi()); parameters.put("domicilio", factura.getDomicilio()); parameters.put("direccionDeTransaccion", factura.getDireccionDeTransaccion()); parameters.put("cantidad", factura.getCantidad()); parameters.put("concepto", factura.getConcepto()); parameters.put("precioUnitario", factura.getPrecioUnitario()); parameters.put("monto", factura.getMonto()); parameters.put("usuario", factura.getIdUser().getNombrecompleto()); String reportFactura = Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla"); switch (reportFactura) { case "Preimpreso sin rejilla": reportFactura = "autofactura_con_rejilla"; break; case "Preimpreso con rejilla": reportFactura = "autofactura"; break; case "Preimpreso sin rejilla Bethel": reportFactura = "autofactura_con_rejilla_bethel"; break; default: break; } 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.gnadenheimer.mg3.utils.Utils.java
public void printNotaDeCredito(TblNotasDeCredito notaDeCredito) { try {/*from ww w . j ava 2s . c o m*/ Map parameters = new HashMap(); parameters.put("nota_de_credito_nro", notaDeCredito.getNro()); parameters.put("factura_nro", notaDeCredito.getNroFactura().getNro()); parameters.put("fechahora", java.sql.Date.valueOf(notaDeCredito.getFechahora().toLocalDate())); parameters.put("razon_social", notaDeCredito.getNroFactura().getRazonSocial()); parameters.put("ruc", notaDeCredito.getNroFactura().getRuc()); parameters.put("domicilio", notaDeCredito.getNroFactura().getDomicilio()); parameters.put("box", notaDeCredito.getNroFactura().getCasillaDeCorreo() == null ? "" : notaDeCredito.getNroFactura().getCasillaDeCorreo().toString()); parameters.put("importe_aporte", notaDeCredito.getNroFactura().getImporteAporte()); parameters.put("importe_donacion", notaDeCredito.getNroFactura().getImporteDonacion()); parameters.put("usuario", notaDeCredito.getIdUser().getNombrecompleto()); /*String reportFactura = Preferences.userRoot().node("MG").get("formateFactura", "Preimpreso sin rejilla").equals("Preimpreso sin rejilla") ? "nota_de_credito_con_rejilla" : "nota_de_credito";*/ JasperReport report = JasperCompileManager .compileReport(getClass().getResourceAsStream("/reports/nota_de_credito_con_rejilla.jrxml")); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource()); //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:com.gnadenheimer.mg.utils.Utils.java
public void printNotaDeCredito(TblNotasDeCredito notaDeCredito) { try {/* w w w.j a va 2 s . c o m*/ Map parameters = new HashMap(); parameters.put("nota_de_credito_nro", notaDeCredito.getNro()); parameters.put("factura_nro", notaDeCredito.getNroFactura().getNro()); parameters.put("fechahora", java.sql.Date.valueOf(notaDeCredito.getFechahora().toLocalDate())); parameters.put("razon_social", notaDeCredito.getNroFactura().getRazonSocial()); parameters.put("ruc", notaDeCredito.getNroFactura().getRuc()); parameters.put("domicilio", notaDeCredito.getNroFactura().getDomicilio()); parameters.put("box", notaDeCredito.getNroFactura().getCasillaDeCorreo() == null ? "" : notaDeCredito.getNroFactura().getCasillaDeCorreo().toString()); parameters.put("importe_aporte", notaDeCredito.getNroFactura().getImporteAporte()); parameters.put("importe_donacion", notaDeCredito.getNroFactura().getImporteDonacion()); parameters.put("usuario", notaDeCredito.getIdUser().getNombrecompleto()); String reportNC = Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla"); switch (reportNC) { case "Preimpreso sin rejilla": reportNC = "nota_de_credito_con_rejilla"; break; case "Preimpreso con rejilla": reportNC = "nota_de_credito"; break; case "Preimpreso sin rejilla Bethel": reportNC = "nota_de_credito_con_rejilla_bethel"; break; default: break; } JasperReport report = JasperCompileManager .compileReport(getClass().getResourceAsStream("/reports/" + reportNC + ".jrxml")); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource()); //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.UserValueEditor.java
@Override public void setValue(@Nullable User value) { super.setValue(value); if (isInited()) { User currentUser = _userDAO.getAssertedCurrentUser(); _userPictureEditor.setValue(// w w w . ja v a 2s.c om Optional.ofNullable(value).map(User::getImage).map(FileEntityFileItem::new).orElse(null)); if (value != null && value.getPreferredContactMethod() == ContactMethod.PhoneSms) _contactMethodSelector.setValue(Collections.singleton(LABEL_SEND_NOTIFICATION_TO_PHONESMS())); final Preferences userPref = Preferences.userRoot().node(User.LOGIN_PREF_NODE); final String uri = userPref != null ? userPref.get(User.LOGIN_PREF_NODE_LANDING_PAGE, null) : null; for (Link l : _links) { if (l != null && l.getURIAsString().equals(uri)) { _loginLandingPage.setValue(l); break; } } _contactMethodSelector.setVisible(Objects.equals(currentUser.getId(), Optional.ofNullable(getValue()).map(User::getId).orElse(0))); //This field is available when the current user is the user being edited // AND only to the user who has a particular membership under the Profile. _loginLandingPage.setVisible( Objects.equals(currentUser.getId(), Optional.ofNullable(getValue()).map(User::getId).orElse(0)) && _profileDAO.getMembershipsForUser(getValue(), null, getSession().getTimeZone()) .stream().map(Membership::getMembershipType) .anyMatch(membershipType -> membershipType.equals(_mtp.companyAdmin()))); } }
From source file:org.kuali.test.creator.TestCreator.java
private void loadSplitPanes() { if (hsplitPane != null) { desktopPane.remove(hsplitPane);//from www . j ava 2 s .co m } hsplitPane = new JSplitPane(); vsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); JPanel p = new JPanel(new BorderLayout()); p.add(new JScrollPane(testRepositoryTree = new RepositoryTree(this)), BorderLayout.CENTER); hsplitPane.setDividerLocation(150); hsplitPane.setOneTouchExpandable(true); vsplitPane.setDividerLocation(250); vsplitPane.setTopComponent(p); vsplitPane.setBottomComponent(platformTestsPanel = new PlatformTestsPanel(this)); testRepositoryTree.addTreeSelectionListener(platformTestsPanel); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(Constants.REPOSITORY, vsplitPane); tabbedPane.addTab(Constants.DATABASES, new JScrollPane(databaseTree = new DatabaseTree(this, getConfiguration()))); tabbedPane.addTab(Constants.WEBSERVICES, new JScrollPane(webServiceTree = new WebServiceTree(this, getConfiguration()))); tabbedPane.addTab(Constants.JMX, new JScrollPane(jmxTree = new JmxTree(this, getConfiguration()))); hsplitPane.setLeftComponent(tabbedPane); hsplitPane.setRightComponent(createTestPanel = new CreateTestPanel(this)); Preferences proot = Preferences.userRoot(); Preferences node = proot.node(Constants.PREFS_ROOT_NODE); hsplitPane.setDividerLocation(node.getInt(Constants.PREFS_HORIZONTAL_DIVIDER_LOCATION, Constants.DEFAULT_HORIZONTAL_DIVIDER_LOCATION)); vsplitPane.setDividerLocation(node.getInt(Constants.PREFS_VERTICAL_DIVIDER_LOCATION, Constants.DEFAULT_VERTICAL_DIVIDER_LOCATION)); desktopPane.add(hsplitPane, BorderLayout.CENTER); }
From source file:modmanager.MainWindow.java
private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing {//GEN-HEADEREND:event_formWindowClosing Preferences node = Preferences.userRoot().node("jskyrimmodmanager/window"); node.putInt("x", this.getX()); node.putInt("y", this.getY()); node.putInt("width", this.getWidth()); node.putInt("height", this.getHeight()); node.putInt("state", this.getExtendedState()); }