Example usage for java.util.prefs Preferences putInt

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

Introduction

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

Prototype

public abstract void putInt(String key, int value);

Source Link

Document

Associates a string representing the specified int value with the specified key in this preference node.

Usage

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

public ValueSetDefinitionDetails(LB_VSD_GUI lb_vsd_gui, Shell parent, ValueSetDefinition vd) {
    this.lb_vsd_gui_ = lb_vsd_gui;
    vd_ = vd;//from  www .  j  a v a  2  s. c o m
    shell_ = new Shell(parent.getDisplay());

    Device device = Display.getCurrent();
    redColor_ = new Color(device, 255, 0, 0);

    errorHandler = new DialogHandler(shell_);
    shell_.setText("Value Set Definition Details " + Constants.version);
    shell_.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            /*
             * Save the size and location of the main window.
             */
            int width = shell_.getSize().x;
            int height = shell_.getSize().y;
            int locX = shell_.getLocation().x;
            int locY = shell_.getLocation().y;

            Preferences p = Preferences.systemNodeForPackage(this.getClass());
            p.putInt("console_width", width);
            p.putInt("console_height", height);
            p.putInt("console_loc_x", locX);
            p.putInt("console_loc_y", locY);
        }
    });

    GridLayout layout = new GridLayout(1, true);
    shell_.setLayout(layout);

    shell_.setImage(new Image(shell_.getDisplay(), this.getClass().getResourceAsStream("/icons/icon.gif")));

    SashForm topBottom = new SashForm(shell_, SWT.VERTICAL);
    topBottom.SASH_WIDTH = 5;
    topBottom.setLayout(new GridLayout());
    GridData gd = new GridData(GridData.FILL_BOTH);
    topBottom.setLayoutData(gd);
    topBottom.setVisible(true);

    buildValueSetsComposite(topBottom);

    SashForm leftRightBottom = new SashForm(topBottom, SWT.HORIZONTAL);
    leftRightBottom.SASH_WIDTH = 5;
    buildDefinitionEntryConposite(leftRightBottom);

    buildMenus();

    if (vd != null) {
        disableTextFields();
        enableRefButtons();
        enablePropertyButtons();
    } else {
        resolveButton_.setEnabled(false);
        enableTextFields();
        disableRefButtons();
        disablePropertyButtons();
    }

    shell_.open();
}

From source file:org.LexGrid.LexBIG.gui.valueSetsView.PropertyView.java

public PropertyView(LB_VSD_GUI lb_vsd_gui, ValueSetDefinitionDetails vsdDetails, Shell parent,
        ValueSetDefinition vd, Property property) {
    this.lb_vsd_gui_ = lb_vsd_gui;

    property_ = property;/* w  w w  . j  ava  2  s .c  o m*/
    shell_ = new Shell(parent.getDisplay());
    vsdDetails_ = vsdDetails;
    oldProperty_ = property;

    Device device = Display.getCurrent();
    redColor_ = new Color(device, 255, 0, 0);

    errorHandler = new DialogHandler(shell_);
    shell_.setText("Property Details ");
    shell_.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            /*
             * Save the size and location of the main window.
             */
            int width = shell_.getSize().x;
            int height = shell_.getSize().y;
            int locX = shell_.getLocation().x;
            int locY = shell_.getLocation().y;

            Preferences p = Preferences.systemNodeForPackage(this.getClass());
            p.putInt("console_width", width);
            p.putInt("console_height", height);
            p.putInt("console_loc_x", locX);
            p.putInt("console_loc_y", locY);
        }
    });

    GridLayout layout = new GridLayout(1, true);
    shell_.setLayout(layout);

    shell_.setImage(new Image(shell_.getDisplay(), this.getClass().getResourceAsStream("/icons/icon.gif")));

    SashForm topBottom = new SashForm(shell_, SWT.VERTICAL);
    topBottom.SASH_WIDTH = 5;
    topBottom.setLayout(new GridLayout());
    GridData gd = new GridData(GridData.FILL_BOTH);
    topBottom.setLayoutData(gd);
    topBottom.setVisible(true);

    buildPropertyComposite(topBottom);

    SashForm leftRightBottom = new SashForm(topBottom, SWT.HORIZONTAL);
    leftRightBottom.SASH_WIDTH = 5;
    buildPropertyQualifierConposite(leftRightBottom);

    // disable all the text fields
    if (property != null) {
        disableTextFields();
        enablePropertyQualButtons();
    } else {
        enableTextFields();
        disablePropertyQualButtons();
    }

    shell_.open();
}

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

public void storeViewPreferences(Preferences prefs, RestorePreferences rp) throws PreferencesException {
    preserveCellExtent(userResourceCellExtent, resPlan.getResourceHeader());
    //      preserveCellExtent(userTimelineCellExtent, resPlan.getTimelineHeader());

    int swingConstant = resPlan.getOrientation().swingConstant();
    if (prefs != null) {
        prefs.putInt("orientation", swingConstant);
    }/*from w  w w .  j  a  va  2  s .c o m*/
    if (rp != null) {
        rp.orientation = swingConstant;
    }
    for (Orientation orientation : Orientation.values()) {
        String vh = orientation.select("H", "V");
        if (prefs != null) {
            prefs.putInt("resourceCellExtent" + vh, orientation.extentFrom(userResourceCellExtent));
            //            prefs.putInt("timelineCellExtent" + vh, orientation.extentFrom(userTimelineCellExtent));
        }
        if (rp != null) {
            rp.resourceCellExtent.put("resourceCellExtent" + vh,
                    orientation.extentFrom(userResourceCellExtent));

            //rp.timelineCellExtent.put("timelineCellExtent" + vh, orientation.extentFrom(userTimelineCellExtent));
            for (TimeGranularity tg : this.getTimeGranularities()) {
                rp.timelineCellExtent.put(tg.getType().getValue() + "_timelineCellExtent" + "H",
                        tg.getCellExtent(Orientation.HORIZONTAL));
                rp.timelineCellExtent.put(tg.getType().getValue() + "_timelineCellExtent" + "V",
                        tg.getCellExtent(Orientation.VERTICAL));
            }
        }
    }
}

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.
 *///w  w w . j  a  va 2 s  .c om
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

/**
 * 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.
 * /*  www  .j  av  a 2s.  c  o m*/
 * @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:verdandi.ui.settings.DefaultSettingsPanel.java

public void storePrefs() {
    Preferences prefs = Preferences.userNodeForPackage(DurationFormatter.class);

    if (radioFormatHHQuarters.isSelected()) {
        prefs.putInt(DurationFormatter.PREF_DISPLAY_MODE, DurationFormatter.DISPLAY_DURATION_HH_QUARTER);
    } else if (radioFormatHHMM.isSelected()) {
        prefs.putInt(DurationFormatter.PREF_DISPLAY_MODE, DurationFormatter.DISPLAY_DURATION_HHMM);
    }//from   w  ww  .jav  a 2s  . c  om

    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        LOG.error("Cannot store Prefs: ", e);
    }
    conf.setStorePasswd(storePasswordCheckBox.isSelected());
    conf.setShowTimerOnStartup(showTimerOnStartupCheckBox.isSelected());

    for (Entry<String, JTextField> pt : persistenceFields.entrySet()) {
        conf.setConfigProperty(pt.getKey(), pt.getValue().getText());
    }

    conf.setConfigProperty(AnnotatedWorkRecordView.PREF_RESTORE_ON_INIT,
            Boolean.toString(initAnnotatedWorkRecordsOnStartup.isSelected()));

    workDaySettingsPanel.commit();

}