List of usage examples for java.util.prefs Preferences userRoot
public static Preferences userRoot()
From source file:modmanager.MainWindow.java
private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened {//GEN-HEADEREND:event_formWindowOpened Preferences node = Preferences.userRoot().node("jskyrimmodmanager/window"); this.setLocation(node.getInt("x", 0), node.getInt("y", 0)); this.setSize(node.getInt("width", 800), node.getInt("height", 600)); this.setExtendedState(node.getInt("state", JFrame.MAXIMIZED_BOTH)); }
From source file:com.example.app.profile.ui.user.UserValueViewer.java
private void setupUI() { removeAllComponents();/*from w w w . j a v a 2s . c o m*/ User currentUser = _userDAO.getAssertedCurrentUser(); Profile profile = _uiPreferences.getSelectedCompany(); final ImageComponent userImage = new ImageComponent(); if (getUser().getImage() != null) { try { final Dimension size = ImageFileUtil.getDimension(getUser().getImage(), true); // We are showing a max height of 200px if (size != null && size.getHeightMetric().intValue() < MAX_HEIGHT_PROFILE_PIC_VIEW) userImage.setSize(size); else userImage.setHeight(new PixelMetric(MAX_HEIGHT_PROFILE_PIC_VIEW)); } catch (IOException e) { _logger.debug("Unable to get file dimension.", e); } userImage.setImage(new Image(getUser().getImage())); } else userImage.setImage(new Image(_appUtil.getDefaultUserImage())); userImage.addClassName("image"); final Container userImageField = of("prop picture", userImage); final TextEditor nameField = new TextEditor(LABEL_NAME(), NameCellRenderer.getFormattedString(getUser().getPrincipal().getContact().getName())); nameField.setEditable(false); setFieldVisibility(nameField); nameField.addClassName("name"); Address address = ContactUtil .getAddress(getUser().getPrincipal().getContact(), ContactDataCategory.values()) .orElse(new Address()); final Container addressContainer = Container.of("prop address", LABEL_ADDRESS(), new AddressCellRenderer(address)); final TextEditor emailField = new TextEditor(LABEL_EMAIL(), ContactUtil.getEmailAddress(getUser().getPrincipal().getContact(), ContactDataCategory.values()) .map(EmailAddress::getEmail).orElse("")); emailField.setEditable(false); setFieldVisibility(emailField); emailField.addClassName("email"); final TextEditor phoneField = new TextEditor(LABEL_PHONE(), ContactUtil.getPhoneNumber(getUser().getPrincipal().getContact(), ContactDataCategory.values()) .map(PhoneNumber::toExternalForm).orElse("")); phoneField.setEditable(false); setFieldVisibility(phoneField); phoneField.addClassName("phone"); final TextEditor smsPhoneField = new TextEditor(LABEL_SMS_PHONE(), Optional.ofNullable(getUser().getSmsPhone()).map(PhoneNumber::toExternalForm).orElse("")); smsPhoneField.setEditable(false); setFieldVisibility(smsPhoneField); smsPhoneField.addClassName("sms-phone"); final TextEditor timeZoneField = new TextEditor(LABEL_PREFERRED_TIME_ZONE(), Optional.ofNullable(getUser().getPrincipal().getContact().getPreferredTimeZone()) // .map(tz -> tz.getDisplayName(false, TimeZone.LONG, getLocaleContext().getLocale())) .map(TimeZone::getID).orElse("")); timeZoneField.setEditable(false); setFieldVisibility(timeZoneField); timeZoneField.addClassName("time-zone"); final ComboBoxValueEditor<Profile> coachingField = new ComboBoxValueEditor<>(_terms.company(), Collections.singletonList(profile), profile); coachingField.setEditable(false); coachingField.addClassName("coaching"); final CheckboxValueEditor<LocalizedObjectKey> contactPrefsField = new CheckboxValueEditor<>( LABEL_CONTACT_PREFERENCES(), Collections.singleton(LABEL_SEND_NOTIFICATION_TO_PHONESMS()), null); contactPrefsField.getLabel().withHTMLElement(HTMLElement.h3); contactPrefsField.withHTMLElement(HTMLElement.section); contactPrefsField.setEditable(false); contactPrefsField.setVisible(Objects.equals(currentUser.getId(), getUser().getId())); if (getUser().getPreferredContactMethod() == ContactMethod.PhoneSms) contactPrefsField.setValue(Collections.singleton(LABEL_SEND_NOTIFICATION_TO_PHONESMS())); List<Link> links = LoginLandingLinks.getAvailableLinks(getUser(), getLocaleContext()); links = nullFirst(links); final ComboBoxValueEditor<Link> loginLangingPage = new ComboBoxValueEditor<>(LABEL_LOGIN_LANDING_PAGE(), links, null); //This field is available when the current user is the user being viewed // AND only to the user who has a particular membership under the company. loginLangingPage.setVisible(Objects.equals(currentUser.getId(), getUser().getId()) && _profileDAO.getMembershipsForUser(getUser(), null, getSession().getTimeZone()).stream() .map(Membership::getMembershipType).filter(membershipType1 -> membershipType1 != null) .anyMatch(membershipType -> membershipType.equals(_mtp.companyAdmin()))); loginLangingPage.setCellRenderer(new CustomCellRenderer(CommonButtonText.PLEASE_SELECT, input -> { Link link = (Link) input; return TextSources.createText(link.getAdditionalAttributes().get("label")); })); 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)) { loginLangingPage.setValue(l); break; } } loginLangingPage.getLabel().withHTMLElement(HTMLElement.h3); loginLangingPage.withHTMLElement(HTMLElement.section); loginLangingPage.setEditable(false); add(userImageField); add(nameField); add(addressContainer); add(emailField); add(phoneField); if (getUser().getSmsPhone() != null) add(smsPhoneField); add(timeZoneField); if (isAdminMode()) { add(coachingField); } add(contactPrefsField); add(loginLangingPage); }
From source file:org.syncany.plugins.php.PhpTransferManager.java
@SuppressWarnings("deprecation") private CloseableHttpClient getHttpClient() { try {// w w w . j a v a2 s . c o m @SuppressWarnings("deprecation") SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { if (lastSite != null && !lastSite.equals("")) { Preferences prefs = Preferences.userRoot().node(this.getClass().getName()); int prevr = prefs.getInt(lastSite, -1); if (prevr == -1) { int r = JOptionPane.showConfirmDialog(null, lastSite + "'s SSL certificate is not trusted, do you want to accept it?", "Accept SSL Certificate?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); logger.warning(lastSite + " not trusted, user answered " + r); prevr = r; prefs.putInt(lastSite, r); } logger.warning(lastSite + " not trusted, registered user answer: " + prevr); if (prevr == 0) { return true; } else { return false; } } else { return false; } } }); @SuppressWarnings("deprecation") SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", 443, sf)); @SuppressWarnings("deprecation") ClientConnectionManager ccm = new ThreadSafeClientConnManager(registry); return new DefaultHttpClient(ccm); } catch (Exception e) { return new DefaultHttpClient(); } }
From source file:main.UIController.java
private Preferences getCurrentPreferences() { Preferences prefs = this.getPreferences(); if (prefs == null || !(prefs instanceof Preferences)) { prefs = Preferences.userRoot().node(this.getClass().getName()); this.setPreferences(prefs); }//from ww w . j ava 2 s . c o m return prefs; }
From source file:org.rhq.enterprise.server.agent.EmbeddedAgentBootstrapService.java
/** * Returns the preferences for this agent. The node returned is where all preferences are to be stored. * * @return the agent preferences/*from w ww . ja v a2 s . c o m*/ */ private Preferences getPreferencesNode() { Preferences top_node = Preferences.userRoot().node(AgentConfigurationConstants.PREFERENCE_NODE_PARENT); Preferences preferences_node = top_node.node(getPreferencesNodeName()); return preferences_node; }
From source file:com.gnadenheimer.mg.frames.admin.FrameConfigAdmin.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed try {/*from www .ja va 2s . c o m*/ // prefs.put("PrinterName", cboPrinter.getSelectedItem().toString()); Preferences.userRoot().node("MG").put("DatabaseIP", txtIP.getText()); Preferences.userRoot().node("MG").put("Datadir", txtDatadir.getText()); Preferences.userRoot().node("MG").put("isServer", String.valueOf(rbServidor.isSelected())); Preferences.userRoot().node("MG").put("modoImpresion", cboModoImpresion.getSelectedItem().toString()); Preferences.userRoot().node("MG").put("formatoFactura", cboFormatoFactura.getSelectedItem().toString()); Preferences.userRoot().node("MG").put("cobrarAC", String.valueOf(rbCobrarACPorMes.isSelected())); Preferences.userRoot().node("MG").put("anoActivo", String.valueOf(jspAnoActivo.getValue())); this.setVisible(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.mg.frames.admin.FrameConfigAdmin.java
private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameActivated txtIP.setText(Preferences.userRoot().node("MG").get("DatabaseIP", "127.0.0.1")); txtDatadir.setText(Preferences.userRoot().node("MG").get("Datadir", "C:\\javadb")); rbServidor.setSelected(Boolean.parseBoolean(Preferences.userRoot().node("MG").get("isServer", "true"))); cboModoImpresion.setSelectedItem(Preferences.userRoot().node("MG").get("modoImpresion", "Normal")); cboFormatoFactura//from ww w. j a va 2s . com .setSelectedItem(Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla")); rbCobrarACPorMes .setSelected(Boolean.parseBoolean(Preferences.userRoot().node("MG").get("cobrarAC", "true"))); jspAnoActivo.setValue(Integer.parseInt( Preferences.userRoot().node("MG").get("anoActivo", String.valueOf(LocalDate.now().getYear())))); }
From source file:org.rhq.server.control.command.AbstractInstall.java
private void clearAgentPreferences() throws Exception { log.info("Removing any existing agent preferences from default preference node"); // remove everything EXCEPT the security token Preferences agentPrefs = getAgentPreferences(); String[] prefKeys = null;/*from ww w .j av a2 s .c o m*/ try { prefKeys = agentPrefs.keys(); } catch (Exception e) { log.warn("Failed to get agent preferences - cannot clear them: " + e); } if (prefKeys != null && prefKeys.length > 0) { for (String prefKey : prefKeys) { if (!prefKey.equals(PREF_RHQ_AGENT_SECURITY_TOKEN)) { agentPrefs.remove(prefKey); } } agentPrefs.flush(); Preferences.userRoot().sync(); } }
From source file:org.rhq.server.control.command.AbstractInstall.java
private Preferences getAgentPreferences() { Preferences agentPrefs = Preferences.userRoot().node("rhq-agent/default"); return agentPrefs; }
From source file:com.marginallyclever.makelangelo.MainGUI.java
protected void AdjustGraphics() { final Preferences graphics_prefs = Preferences.userRoot().node("DrawBot").node("Graphics"); final JDialog driver = new JDialog(mainframe, translator.get("MenuGraphicsTitle"), true); driver.setLayout(new GridBagLayout()); //final JCheckBox allow_metrics = new JCheckBox(String.valueOf("I want to add the distance drawn to the // total")); //allow_metrics.setSelected(allowMetrics); final JCheckBox show_pen_up = new JCheckBox(translator.get("MenuGraphicsPenUp")); final JCheckBox antialias_on = new JCheckBox(translator.get("MenuGraphicsAntialias")); final JCheckBox speed_over_quality = new JCheckBox(translator.get("MenuGraphicsSpeedVSQuality")); final JCheckBox draw_all_while_running = new JCheckBox(translator.get("MenuGraphicsDrawWhileRunning")); show_pen_up.setSelected(graphics_prefs.getBoolean("show pen up", false)); antialias_on.setSelected(graphics_prefs.getBoolean("antialias", true)); speed_over_quality.setSelected(graphics_prefs.getBoolean("speed over quality", true)); draw_all_while_running.setSelected(graphics_prefs.getBoolean("Draw all while running", true)); final JButton cancel = new JButton(translator.get("Cancel")); final JButton save = new JButton(translator.get("Save")); GridBagConstraints c = new GridBagConstraints(); //c.gridwidth=4; c.gridx=0; c.gridy=0; driver.add(allow_metrics,c); int y = 0;/*from ww w .ja v a2s . c om*/ c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(show_pen_up, c); y++; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(draw_all_while_running, c); y++; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(antialias_on, c); y++; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(speed_over_quality, c); y++; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 2; c.gridy = y; driver.add(save, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 3; c.gridy = y; driver.add(cancel, c); ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); if (subject == save) { //allowMetrics = allow_metrics.isSelected(); graphics_prefs.putBoolean("show pen up", show_pen_up.isSelected()); graphics_prefs.putBoolean("antialias", antialias_on.isSelected()); graphics_prefs.putBoolean("speed over quality", speed_over_quality.isSelected()); graphics_prefs.putBoolean("Draw all while running", draw_all_while_running.isSelected()); previewPane.setShowPenUp(show_pen_up.isSelected()); driver.dispose(); } if (subject == cancel) { driver.dispose(); } } }; save.addActionListener(driveButtons); cancel.addActionListener(driveButtons); driver.getRootPane().setDefaultButton(save); driver.pack(); driver.setVisible(true); }