List of usage examples for java.util.prefs Preferences userNodeForPackage
public static Preferences userNodeForPackage(Class<?> c)
From source file:smarthome.FXMLDocumentController.java
public void setPreference(String arg1, String arg2, String arg3) { Preferences prefs = Preferences.userNodeForPackage(SmartHome.class); prefs.put("ipaddress", arg1); prefs.put("videolink", arg2); prefs.put("voiceflag", arg3); }
From source file:com.diversityarrays.dal.db.TestDalDatabase.java
@SuppressWarnings({ "rawtypes", "unchecked" }) static private DalDatabase createKddartDalDatabase() throws DalDbException { Preferences preferences = Preferences.userNodeForPackage(DalServer.class); DalDbProviderService service = new KddartDalDbProviderService(); Map<Parameter<?>, ParameterValue<?>> parameterValues = new HashMap<Parameter<?>, ParameterValue<?>>(); Preferences serviceNode = preferences.node("service/" + service.getClass().getName()); for (Parameter<?> param : service.getParametersRequired()) { String s = serviceNode.get(param.name, null); try {/*from w w w . j ava 2 s . co m*/ Object value = param.stringToValue(s); parameterValues.put(param, new ParameterValue(param, value)); if (KddartDalDatabase.PARAM_USERNAME.equals(param.name)) { USERNAME = s; } else if (KddartDalDatabase.PARAM_PASSWORD.equals(param.name)) { PASSWORD = s; } } catch (ParameterException e) { Throwable t = e.getCause(); if (t == null) { t = e; } if (t instanceof RuntimeException) { throw ((RuntimeException) t); } throw new RuntimeException(t); } } KddartDalDatabase result = (KddartDalDatabase) service.createDatabase(parameterValues.values(), ClosureUtils.nopClosure(), false); System.out.println(TestDalDatabase.class.getName() + " for KDDart: " + result.getDatabaseName()); result.setAutoSwitchGroupOnLogin(true); return result; }
From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java
/** * Loads up a clean event browser as if a new one was constructed. *//*from w w w. j a v a 2 s .co m*/ public void loadNew(String eventNameFilter) { // Set the default page size pageSizeField.setText( String.valueOf(Preferences.userNodeForPackage(Mirth.class).getInt("eventBrowserPageSize", 100))); if (eventNameFilter != null) { nameField.setText(eventNameFilter); } else { nameField.setText(""); } updateCachedUserMap(); advancedSearchPopup.reset(); runSearch(); }
From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java
private void initComponents() { regularExpressionPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, fill, insets 0")); regularExpressionPanel.setBackground(UIConstants.BACKGROUND_COLOR); regularExpressionPanel.setBorder(BorderFactory.createTitledBorder("Regular Expressions")); regexExampleTextField = new JTextField(); regexExampleTextField.setText("(?:OBX\\|(?:[^|]*\\|){4}(?:[^|^]*\\^){4})([^|^\\r\\n]*)(?:[|^\\r\\n]|$)"); regexExampleTextField.setEditable(false); regexExampleTextField.setBorder(null); regexExampleTextField.setOpaque(false); regexTable = new MirthTable(); regexTable.setModel(new RefreshTableModel(new Object[] { "Regular Expression", "MIME Type" }, 0)); regexTable.setDragEnabled(false);/*from www . j a va2 s.c om*/ regexTable.setRowSelectionAllowed(true); regexTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); regexTable.setRowHeight(UIConstants.ROW_HEIGHT); regexTable.setFocusable(true); regexTable.setOpaque(true); regexTable.getTableHeader().setReorderingAllowed(false); regexTable.setEditable(true); regexTable.setSortable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { regexTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } regexTable.getColumnExt(0).setMinWidth(105); regexTable.getColumnExt(0).setPreferredWidth(350); regexTable.getColumnExt(0).setToolTipText( "<html>The regular expression that will be used to match and extract attachments.<br>If capturing groups are used, only the last group will be extracted.</html>"); regexTable.getColumnExt(1).setMinWidth(63); regexTable.getColumnExt(1).setToolTipText( "The MIME type of the extracted attachment data. Source map variables may be used here."); regexTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { regexDeleteButton.setEnabled(regexTable.getSelectedRow() >= 0); } }); regexTableScrollPane = new JScrollPane(regexTable); regexNewButton = new JButton("New"); regexNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { regexNewButtonActionPerformed(); } }); regexDeleteButton = new JButton("Delete"); regexDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { regexDeleteButtonActionPerformed(); } }); regexDeleteButton.setEnabled(false); stringReplacementPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0")); stringReplacementPanel.setBackground(UIConstants.BACKGROUND_COLOR); stringReplacementPanel.setBorder(BorderFactory.createTitledBorder("String Replacement")); stringReplacementLabel = new JLabel(); stringReplacementLabel.setText( "<html>Replace strings on the matched data before storing. Do not use regular expressions in these fields or surround with quotes.<br>\nExample: Use <b>\\\\X0D0A\\\\</b> and <b>\\r\\n</b> to replace \\X0D0A\\ with actual CRLF characters. </html>"); inboundReplacementTable = new MirthTable(); inboundScrollPane = new JScrollPane(); inboundScrollPane.setViewportView(inboundReplacementTable); outboundReplacementTable = new MirthTable(); outboundScrollPane = new JScrollPane(); outboundScrollPane.setViewportView(outboundReplacementTable); inboundButtonPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0", "", "")); inboundButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR); inboundNewButton = new JButton("New"); inboundNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { inboundNewButtonActionPerformed(evt); } }); inboundDeleteButton = new JButton("Delete"); inboundDeleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { inboundDeleteButtonActionPerformed(evt); } }); outboundButtonPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0", "", "")); outboundButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR); outboundNewButton = new JButton("New"); outboundNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { outboundNewButtonActionPerformed(evt); } }); outboundDeleteButton = new JButton("Delete"); outboundDeleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { outboundDeleteButtonActionPerformed(evt); } }); separator = new JSeparator(); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeButtonActionPerformed(evt); } }); }
From source file:com.mirth.connect.client.ui.SettingsPanelDatabaseTasks.java
private void initComponents() { JPanel containerPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill")); containerPanel.setBackground(getBackground()); containerPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Database Tasks", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); containerPanel.add(new JLabel( "Cleanup or optimization tasks for the internal database. If no tasks are present, no action is necessary."), "top, wrap"); taskTable = new MirthTable(); taskTable/* w w w . ja v a 2 s . c om*/ .setModel(new RefreshTableModel(new Object[] { "Status", "Name", "Description", "Start Time" }, 0)); taskTable.setDragEnabled(false); taskTable.setRowSelectionAllowed(true); taskTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); taskTable.setRowHeight(UIConstants.ROW_HEIGHT); taskTable.setFocusable(false); taskTable.setOpaque(true); taskTable.getTableHeader().setReorderingAllowed(false); taskTable.setEditable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { taskTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } taskTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (taskTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { taskTable.clearSelection(); setVisibleTasks(2, 3, false); } } }); taskTable.getColumnModel().getColumn(0).setMinWidth(75); taskTable.getColumnModel().getColumn(0).setMaxWidth(75); taskTable.getColumnModel().getColumn(0).setCellRenderer(new ImageCellRenderer()); taskTable.getColumnModel().getColumn(1).setMinWidth(45); taskTable.getColumnModel().getColumn(1).setPreferredWidth(250); taskTable.getColumnModel().getColumn(2).setMinWidth(75); taskTable.getColumnModel().getColumn(2).setPreferredWidth(475); taskTable.getColumnModel().getColumn(3).setMinWidth(95); taskTable.getColumnModel().getColumn(3).setMaxWidth(95); taskTable.getColumnModel().getColumn(3).setCellRenderer(new DateCellRenderer()); taskTable.getSelectionModel().addListSelectionListener(this); JScrollPane taskTableScrollPane = new JScrollPane(taskTable); containerPanel.add(taskTableScrollPane, "grow, push"); add(containerPanel, "grow, h 60%"); JPanel channelsPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill")); channelsPanel.setBackground(getBackground()); channelsPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Affected Channels", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); channelsTable = new MirthTable(); channelsTable.setModel(new RefreshTableModel(new Object[] { "Name", "Id" }, 0)); channelsTable.setDragEnabled(false); channelsTable.setRowSelectionAllowed(false); channelsTable.setRowHeight(UIConstants.ROW_HEIGHT); channelsTable.setFocusable(false); channelsTable.setOpaque(true); channelsTable.getTableHeader().setReorderingAllowed(false); channelsTable.setEditable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { channelsTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } channelsPanel.add(new JScrollPane(channelsTable), "grow"); add(channelsPanel, "newline, grow, h 40%"); }
From source file:org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.java
private List<FSFontInfo> loadCache(List<File> files) { // Get the preferences database for this package. Preferences prefs = Preferences.userNodeForPackage(FileSystemFontProvider.class); List<FSFontInfo> results = new ArrayList<FSFontInfo>(); for (File file : files) { // The second argument is the default if the key isn't found. byte[] stored = prefs.getByteArray(file.getAbsolutePath(), null); if (stored != null) { try { ByteArrayInputStream byteIn = new ByteArrayInputStream(stored); ObjectInputStream objectIn = new ObjectInputStream(byteIn); Object object = objectIn.readObject(); if (object instanceof FSFontInfo) { FSFontInfo info = (FSFontInfo) object; info.parent = this; results.add(info);/*from w w w . j a v a 2s. c o m*/ } } catch (ClassNotFoundException e) { LOG.error("Error loading font cache, will be re-built", e); return null; } catch (IOException e) { LOG.error("Error loading font cache, will be re-built", e); return null; } } else { // re-build the entire cache if we encounter un-cached fonts (could be optimised) LOG.warn("New fonts found, font cache will be re-built"); return null; } } return results; }
From source file:org.cryptomator.ui.util.SingleInstanceManager.java
static Optional<Integer> getSavedPort(String applicationKey) { int port = Preferences.userNodeForPackage(Main.class).getInt(applicationKey, -1); if (port == -1) { LOG.info("no running instance found"); return Optional.empty(); }//from ww w . j a va2s . c om return Optional.of(port); }
From source file:de.tbuchloh.kiskis.KisKis.java
private static void resetPreferences() { try {/* ww w . j a v a 2 s . c o m*/ final Preferences p = Preferences.userNodeForPackage(KisKis.class); p.removeNode(); p.flush(); if (PREF_FILE.exists()) { PREF_FILE.delete(); } System.out.println("All preferences for package '" + KisKis.class.getPackage().getName() + "' were removed!\nYou can restart the application now!"); } catch (final BackingStoreException e) { throw new Error(e); } }
From source file:de.ailis.oneinstance.OneInstance.java
/** * Unregisters this instance of the application. If this is the first * instance then the server is closed and the port is removed from * the preferences. If this is not the first instance then this method * does nothing./* w ww. j a v a2s . c om*/ * * This method should be called when the application exits. But it is * not a requirement. When you don't do this then the port number will * stay in the preferences so on next start of the application this port * number must be validated. So by calling this method on application exit * you just save the time for this port validation. * * @param mainClass * The main class of the application. Must not be null. * This is used as the user node key for the preferences. */ public void unregister(Class<?> mainClass) { if (mainClass == null) throw new IllegalArgumentException("mainClass must be set"); // Nothing to do when no server socket is present if (this.server == null) return; // Close the server socket this.server.stop(); this.server = null; // Remove the port from the preferences Preferences prefs = Preferences.userNodeForPackage(mainClass); prefs.remove(PORT_KEY); try { prefs.flush(); } catch (BackingStoreException e) { LOG.error(e.toString(), e); } }
From source file:net.sqs2.omr.app.MarkReaderControllerImpl.java
public Preferences getPreferences() { if (this.prefs == null) { this.prefs = Preferences.userNodeForPackage(this.getClass()); }// ww w . j a v a 2s .c o m return this.prefs; }