List of usage examples for java.util.prefs Preferences userNodeForPackage
public static Preferences userNodeForPackage(Class<?> c)
From source file:ch.astina.hesperid.installer.web.services.InstallationManager.java
public void saveHomeDirectory(String homedirectory) { Preferences prefs = Preferences.userNodeForPackage(InstallationManager.class); prefs.put(HOME_DIRECTORY, homedirectory); try {/*from ww w . j a v a 2 s . co m*/ prefs.flush(); } catch (BackingStoreException ex) { logger.error("Could not store home directory", ex); } }
From source file:verdandi.ui.common.WidthStoringTable.java
/** * Stores thw width of the columns to a preference. The preference is stored * beneath the node for the Package of the implementing class. Preferences are * named {@link #PREFIX_COL_WIDTH} plus the column index. * //from ww w . j a va 2 s. c om * @see #PREFIX_COL_WIDTH */ public void storeWidths() { Preferences prefs = Preferences.userNodeForPackage(getClass()); LOG.debug("Storing widths to " + prefs.absolutePath() + "; " + getModel().getClass().getSimpleName()); for (int i = 0; i < getModel().getColumnCount(); i++) { int width = getColumnModel().getColumn(i).getWidth(); LOG.debug("Store " + widthPref + i + "=" + width); prefs.putInt(widthPref + i, width); } try { prefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } }
From source file:com.mirth.connect.client.ui.components.MirthTable.java
public MirthTable(String prefix, Set<String> defaultVisibleColumns) { super();//from w w w .ja va2 s . com this.prefix = prefix; this.defaultVisibleColumns = defaultVisibleColumns; userPreferences = Preferences.userNodeForPackage(Mirth.class); columnOrderMap = new HashMap<String, Integer>(); if (StringUtils.isNotEmpty(prefix)) { try { userPreferences = Preferences.userNodeForPackage(Mirth.class); String columns = userPreferences.get(prefix + "ColumnOrderMap", ""); if (StringUtils.isNotEmpty(columns)) { columnOrderMap = (Map<String, Integer>) ObjectXMLSerializer.getInstance().deserialize(columns, Map.class); } } catch (Exception e) { } sortKeys = new ArrayList<SortKey>(); try { String sortOrder = userPreferences.get(prefix + "SortOrder", ""); if (StringUtils.isNotEmpty(sortOrder)) { sortKeys = ObjectXMLSerializer.getInstance().deserialize(sortOrder, List.class); } } catch (Exception e) { } } setDragEnabled(true); addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { boolean isAccelerated = (((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0) || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)); if ((e.getKeyCode() == KeyEvent.VK_S) && isAccelerated) { PlatformUI.MIRTH_FRAME.doContextSensitiveSave(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); /* * Swingx 1.0 has this set to true by default, which doesn't allow dragging and dropping * into tables. Swingx 0.8 had this set to false. Tables that want it set to true can * override it. */ putClientProperty("terminateEditOnFocusLost", Boolean.FALSE); getTableHeader().addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { saveColumnOrder(); } }); final JButton columnControlButton = new JButton(new ColumnControlButton(this).getIcon()); columnControlButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPopupMenu columnMenu = getColumnMenu(); Dimension buttonSize = columnControlButton.getSize(); int xPos = columnControlButton.getComponentOrientation().isLeftToRight() ? buttonSize.width - columnMenu.getPreferredSize().width : 0; columnMenu.show(columnControlButton, xPos, columnControlButton.getHeight()); } }); setColumnControl(columnControlButton); }
From source file:codeswarm.ui.MainView.java
/** * initializes the Dialog and sets the dialog-values according to the * user's preferences (the last values entered). * @param args java arguments passed to the main method. The first parameter * will be passed to {@link code_swarm}. It specifies the config-file. *//*from ww w. j a v a2 s.c o m*/ public MainView(String[] args) { this.args = args; initComponents(); this.getRootPane().setDefaultButton(goButton); Preferences p = Preferences.userNodeForPackage(MainView.class); String username = p.get("username", ""); userName.setText(username); String url = p.get("repositoryURL", "http://"); repositoryURL.setText(url); }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
public SpinCADFile() { // create a Preferences instance (somewhere later in the code) prefs = Preferences.userNodeForPackage(this.getClass()); }
From source file:org.lantern.MacProxyManager.java
public MacProxyManager(String sessionId, int port) { this.sessionId = sessionId; this.port = port; prefs = Preferences.userNodeForPackage(MacProxyManager.class); }
From source file:org.javaswift.cloudie.login.CredentialsStore.java
/** * lists the available credentials for this user. * @return the credentials.//from ww w.j av a2 s .c o m */ public List<Credentials> getAvailableCredentials() { List<Credentials> results = new ArrayList<Credentials>(); try { Preferences prefs = Preferences.userNodeForPackage(CredentialsStore.class); for (String node : prefs.childrenNames()) { Preferences cred = prefs.node(node); try { results.add(toCredentials(cred)); } catch (IllegalArgumentException ex) { LoggerFactory.getLogger(getClass()).warn("Bad preferences node - skipping"); } } } catch (BackingStoreException ex) { throw new RuntimeException(ex); } return results; }
From source file:org.jamocha.gui.JamochaGui.java
private void loadState(final Stage primaryStage) { final Preferences userPrefs = Preferences.userNodeForPackage(getClass()); // get window location from user preferences: use x=100, y=100, width=400, height=400 as // default//from w ww.j av a 2 s.c om primaryStage.setX(userPrefs.getDouble("stage.x", 100)); primaryStage.setY(userPrefs.getDouble("stage.y", 100)); primaryStage.setWidth(userPrefs.getDouble("stage.width", 800)); primaryStage.setHeight(userPrefs.getDouble("stage.height", 600)); }
From source file:org.pentaho.di.core.util.AbstractStepMeta.java
/** * Saves properties to preferences.//from w w w . j a va2s. c o m * * @throws BackingStoreException * ... */ public void saveAsPreferences() throws BackingStoreException { final Preferences node = Preferences.userNodeForPackage(this.getClass()); this.getProperties().walk(new SaveToPreferences(node)); node.flush(); }
From source file:verdandi.ui.common.WidthStoringTable.java
/** * Initializes the column widths.// w ww .ja v a 2 s . com */ protected void initWidths() { LOG.debug("Initialising columns of table: " + getClass().getName()); Preferences prefs = Preferences.userNodeForPackage(getClass()); for (int i = 0; i < getModel().getColumnCount(); i++) { int width = prefs.getInt(widthPref + i, getColumnModel().getColumn(i).getPreferredWidth()); LOG.debug("Init width of col " + i + " to " + width); getColumnModel().getColumn(i).setPreferredWidth(width); } }