Example usage for java.util.prefs Preferences getInt

List of usage examples for java.util.prefs Preferences getInt

Introduction

In this page you can find the example usage for java.util.prefs Preferences getInt.

Prototype

public abstract int getInt(String key, int def);

Source Link

Document

Returns the int value represented by the string associated with the specified key in this preference node.

Usage

From source file:org.esa.snap.smart.configurator.PerformanceParameters.java

/**
 *
 * Reads the parameters files and system settings to retrieve the actual performance parameters.
 * It updates the "actualParameters" according to the configuration loaded.
 *
 * @return the actual performance parameters, loaded by this method
 *///from w  w w .j  a  v a 2s.c o  m
synchronized static PerformanceParameters loadConfiguration() {

    Config configuration = Config.instance().load();
    Preferences preferences = configuration.preferences();

    PerformanceParameters actualParameters = new PerformanceParameters();

    VMParameters netBeansVmParameters = VMParameters.load();
    actualParameters.setVMParameters(netBeansVmParameters.toString());
    actualParameters.setCachePath(SystemUtils.getCacheDir().toPath());

    final int defaultNbThreads = JavaSystemInfos.getInstance().getNbCPUs();
    actualParameters
            .setNbThreads(preferences.getInt(SystemUtils.SNAP_PARALLELISM_PROPERTY_NAME, defaultNbThreads));
    //actualParameters.setDefaultTileSize(preferences.getInt(PROPERTY_DEFAULT_TILE_SIZE, 0));
    actualParameters.setTileWidth(preferences.get(SYSPROP_READER_TILE_WIDTH, null));
    actualParameters.setTileHeight(preferences.get(SYSPROP_READER_TILE_HEIGHT, null));
    actualParameters.setCacheSize(preferences.getInt(PROPERTY_JAI_CACHE_SIZE, 1024));

    return actualParameters;
}

From source file:org.kuali.test.creator.TestCreator.java

private void loadPreferences() {
    try {//from   w w  w.  j  a  va2  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:org.kuali.test.creator.TestCreator.java

private void loadSplitPanes() {
    if (hsplitPane != null) {
        desktopPane.remove(hsplitPane);//from w w  w.j a va 2s.c o 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:org.kuali.test.ui.base.BaseTable.java

private int getColumnWidth(int col) {
    int retval = getConfig().getColumnWidths()[col];
    Preferences proot = Preferences.userRoot();
    Preferences node = proot.node(Constants.PREFS_TABLE_NODE);

    String key = getColumnPreferenceKey(col, "width");

    if (StringUtils.isNotBlank(key)) {
        retval = node.getInt(key, retval);
    }// ww w  .j a v a 2 s  .co m

    return retval;
}

From source file:org.LexGrid.LexBIG.gui.LB_GUI.java

License:asdf

private void setSizeFromPreviousRun() {
    Preferences p = Preferences.systemNodeForPackage(this.getClass());
    int height = p.getInt("console_height", -1);
    int width = p.getInt("console_width", -1);
    if (height < 100 || width < 100) {
        shell_.setMaximized(true);//from www .j a va  2 s .c o m
        return;
    }

    shell_.setSize(width, height);

    int locX = p.getInt("console_loc_x", 0);
    int locY = p.getInt("console_loc_y", 0);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    if (locX < 0 || locX > d.width - 200) {
        locX = 0;
    }
    if (locY < 0 || locY > d.height - 150) {
        locY = 0;
    }
    shell_.setLocation(locX, locY);
}

From source file:org.nuclos.client.common.NuclosCollectController.java

/**
 * restores the state of this <code>CollectController</code> from the preferences.
 * @param prefs/*w  ww.  j a  v a 2s  . c o  m*/
 * @return the stored collect state.
 * @throws NuclosBusinessException
 */
@Deprecated
protected int restoreStateFromPreferences(Preferences prefs) throws CommonBusinessException {
    if (this.isSearchPanelAvailable()) {
        assert this.getCollectStateModel().getOuterState() == CollectState.OUTERSTATE_UNDEFINED;
        final CollectableSearchCondition cond = SearchConditionUtils.getSearchCondition(
                prefs.node(PREFS_NODE_SEARCHCONDITION), this.getCollectableEntity().getName());
        // Always set Search mode initially, to restore the search criteria.
        // Later, the previous state is restored.
        if (cond != null) {
            this.setCollectState(CollectState.OUTERSTATE_SEARCH, CollectState.SEARCHMODE_UNSYNCHED);
            this.restoreSearchCriteriaFromPreferences(prefs);
        }
    }
    // restore collect state:
    return prefs.getInt(PREFS_KEY_OUTERSTATE, CollectState.OUTERSTATE_UNDEFINED);
}

From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java

public void restoreViewPreferences(Preferences prefs, RestorePreferences rp) throws PreferencesException {
    if (prefs != null) {
        int orientation = prefs.getInt("orientation", -1);
        userResourceCellExtent = new Dimension(prefs.getInt("resourceCellExtentH", -1),
                prefs.getInt("resourceCellExtentV", -1));
        //         userTimelineCellExtent = new Dimension(prefs.getInt("timelineCellExtentH", -1), prefs.getInt("timelineCellExtentV", -1));
        if (orientation != -1)
            resPlan.setOrientation(Orientation.fromSwingConstant(orientation));
        setCellExtent(resPlan.getResourceHeader(), userResourceCellExtent);
        //         setCellExtent(resPlan.getTimelineHeader(), userTimelineCellExtent);
    }/*w w w  . j a  v a 2  s.  com*/

    if (rp != null) {
        userResourceCellExtent = new Dimension(
                LangUtils.defaultIfNull(rp.resourceCellExtent.get("resourceCellExtentH"), -1),
                LangUtils.defaultIfNull(rp.resourceCellExtent.get("resourceCellExtentV"), -1));
        //         userTimelineCellExtent = new Dimension(LangUtils.defaultIfNull(rp.timelineCellExtent.get("timelineCellExtentH"), -1),
        //            LangUtils.defaultIfNull(rp.timelineCellExtent.get("timelineCellExtentV"), -1));
        if (rp.orientation != -1)
            resPlan.setOrientation(Orientation.fromSwingConstant(rp.orientation));
        setCellExtent(resPlan.getResourceHeader(), userResourceCellExtent);

        //setCellExtent(resPlan.getTimelineHeader(), userTimelineCellExtent);
        for (TimeGranularity tg : this.getTimeGranularities()) {
            tg.setCellExtent(Orientation.HORIZONTAL,
                    rp.timelineCellExtent.get(tg.getType().getValue() + "_timelineCellExtent" + "H"));
            tg.setCellExtent(Orientation.VERTICAL,
                    rp.timelineCellExtent.get(tg.getType().getValue() + "_timelineCellExtent" + "V"));
            if (getTimeGranularity() == tg.getType()) {
                setCellExtent(resPlan.getTimelineHeader(), tg.getCellExtent(resPlan.getOrientation()));
            }
        }
    }
}

From source file:org.tros.torgo.ControllerBase.java

/**
 * Initialize the window. This is called here from run() and not the
 * constructor so that the Service Provider doesn't load up all of the
 * necessary resources when the application loads.
 *///from   ww w.  j a  v a  2 s.c  o  m
private void initSwing() {
    this.torgoPanel = createConsole((Controller) this);
    this.torgoCanvas = createCanvas(torgoPanel);

    //init the GUI w/ the components...
    Container contentPane = window.getContentPane();
    JToolBar tb = createToolBar();
    if (tb != null) {
        contentPane.add(tb, BorderLayout.NORTH);
    }

    final java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(NamedWindow.class);
    if (torgoCanvas != null) {
        final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, torgoCanvas.getComponent(),
                torgoPanel.getComponent());
        int dividerLocation = prefs.getInt(this.getClass().getName() + "divider-location",
                window.getWidth() - 300);
        splitPane.setDividerLocation(dividerLocation);
        splitPane.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent pce) {
                prefs.putInt(this.getClass().getName() + "divider-location", splitPane.getDividerLocation());
            }
        });

        contentPane.add(splitPane);
    } else {
        contentPane.add(torgoPanel.getComponent());
    }

    JMenuBar mb = createMenuBar();
    if (mb == null) {
        mb = new TorgoMenuBar(window, this);
    }
    window.setJMenuBar(mb);
    JMenu helpMenu = new JMenu("Help");
    JMenuItem aboutMenu = new JMenuItem("About Torgo");
    try {
        java.util.Enumeration<URL> resources = ClassLoader.getSystemClassLoader()
                .getResources(ABOUT_MENU_TORGO_ICON);
        ImageIcon ico = new ImageIcon(resources.nextElement());
        aboutMenu.setIcon(ico);
    } catch (IOException ex) {
        Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex);
    }

    aboutMenu.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            AboutWindow aw = new AboutWindow();
            aw.setVisible(true);
        }
    });
    helpMenu.add(aboutMenu);

    JMenu vizMenu = new JMenu("Visualization");
    for (String name : TorgoToolkit.getVisualizers()) {
        JCheckBoxMenuItem item = new JCheckBoxMenuItem(name);
        viz.add(item);
        vizMenu.add(item);
    }
    if (vizMenu.getItemCount() > 0) {
        mb.add(vizMenu);
    }

    mb.add(helpMenu);
    window.setJMenuBar(mb);

    window.addWindowListener(new WindowListener() {

        @Override
        public void windowOpened(WindowEvent e) {
        }

        /**
         * We only care if the window is closing so we can kill the
         * interpreter thread.
         *
         * @param e
         */
        @Override
        public void windowClosing(WindowEvent e) {
            stopInterpreter();
        }

        @Override
        public void windowClosed(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
}

From source file:verdandi.ui.common.WidthStoringTable.java

/**
 * Initializes the column widths./*  w  w w  . ja  v a2 s.  c o m*/
 */
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);
    }
}

From source file:verdandi.ui.settings.DefaultSettingsPanel.java

@Override
public void reset() {
    Preferences prefs = Preferences.userNodeForPackage(DurationFormatter.class);
    int displayMode = prefs.getInt(DurationFormatter.PREF_DISPLAY_MODE,
            DurationFormatter.DISPLAY_DURATION_HHMM);
    if (displayMode == DurationFormatter.DISPLAY_DURATION_HHMM) {
        radioFormatHHMM.setSelected(true);
    } else {/*from  ww  w  .j a  va  2 s  .  c  o m*/
        radioFormatHHQuarters.setSelected(true);
    }
    storePasswordCheckBox.setSelected(conf.isStorePasswd());
    showTimerOnStartupCheckBox.setSelected(conf.isShowTimerOnStartup());
    for (Entry<String, JTextField> pt : persistenceFields.entrySet()) {
        pt.getValue().setText(conf.getConfigProperty(pt.getKey()));
    }
    workDaySettingsPanel.reset();
}