Example usage for java.util.prefs Preferences getBoolean

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

Introduction

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

Prototype

public abstract boolean getBoolean(String key, boolean def);

Source Link

Document

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

Usage

From source file:com.github.alexfalappa.nbspringboot.projects.customizer.CfgPropsDialog.java

/** Creates new form CfgPropsDialog */
public CfgPropsDialog(java.awt.Dialog parent) {
    super(parent, true);
    initComponents();/*from   w w  w .  j a v a 2s  .c  o m*/
    // retrieve some flads from prefs
    final Preferences prefs = NbPreferences.forModule(PrefConstants.class);
    final boolean bDeprLast = prefs.getBoolean(PREF_DEPR_SORT_LAST, true);
    bDeprErrorShow = prefs.getBoolean(PREF_DEPR_ERROR_SHOW, false);
    // setup props sorting
    this.sortedProps = new TreeSet<>(new ConfigurationMetadataComparator(bDeprLast));
    // setup property list
    lCfgProps.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final ConfigurationMetadataProperty selectedValue = lCfgProps.getSelectedValue();
                if (selectedValue != null) {
                    tpDetails.setText(Utils.cfgPropDetailsHtml(selectedValue));
                    tpDetails.setCaretPosition(0);
                }
            }
        }
    });
    // set default button
    rootPane.setDefaultButton(bOk);
    // close dialog with ESC key
    final ActionListener escAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            CfgPropsDialog.this.setVisible(false);
        }
    };
    rootPane.registerKeyboardAction(escAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);
}

From source file:org.tros.logo.swing.LogoMenuBar.java

/**
 * Constructor./*from   w  w  w  .jav a  2 s  .c o  m*/
 *
 * @param parent
 * @param controller
 * @param canvas
 */
@SuppressWarnings("OverridableMethodCallInConstructor")
public LogoMenuBar(Component parent, Controller controller, LogoCanvas canvas) {
    super(parent, controller);
    this.canvas = canvas;

    add(setupExportMenu());
    add(setupToolsMenu());
    JMenu menu = new JMenu("Logo Options");
    menu.add(setupMenu("Examples From Tortue", "logo/examples/tortue"));
    menu.add(setupMenu("Examples From ANTLR", "logo/examples/antlr"));

    final java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(LogoMenuBar.class);
    final JCheckBoxMenuItem speedMenu = new JCheckBoxMenuItem("Wait for Repaint");
    boolean checked = prefs.getBoolean(WAIT_FOR_REPAINT, true);
    speedMenu.setSelected(checked);
    speedMenu.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            prefs.putBoolean(WAIT_FOR_REPAINT, speedMenu.isSelected());
        }
    });
    menu.add(speedMenu);
    add(menu);
}

From source file:com.moteiv.trawler.Trawler.java

private void loadPrefs() {
    // extract preference data
    Preferences prefs = Preferences.userNodeForPackage(com.moteiv.trawler.Trawler.class);
    // set the data
    vSave.setSelected(prefs.getBoolean(PREF_V_SAVE, true));
    vBlink.setSelected(prefs.getBoolean(PREF_V_BLINK, false));
    vLabels.setSelected(prefs.getBoolean(PREF_V_LABELS, true));
    eLabels.setSelected(prefs.getBoolean(PREF_E_LABELS, true));
    eFilter.setSelected(prefs.getBoolean(PREF_E_FILTER, true));
    vDispose.setValue(prefs.getInt(PREF_V_DISPOSE, NodeData.getNodeDelay() / 1000));
    eDispose.setValue(prefs.getInt(PREF_E_DISPOSE, LinkData.getEdgeDelay() / 1000));
    // update the processing engines to reflect the new data
    processEvent(vSave);/*from   ww w .  j  ava 2 s .co  m*/
    processEvent(vBlink);
    processEvent(vLabels);
    processEvent(eLabels);
    processEvent(eFilter);
    LinkData.setEdgeDelay(eDispose.getValue() * 1000);
    NodeData.setNodeDelay(vDispose.getValue() * 1000);
}

From source file:org.tros.logo.swing.LogoPanel.java

@Override
public void repaint() {
    if (SwingUtilities.isEventDispatchThread()) {
        LogoPanel.super.repaint();
    } else {//from w w  w.j  a  v a 2  s  .  c  o  m
        java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(LogoMenuBar.class);
        if (prefs.getBoolean(LogoMenuBar.WAIT_FOR_REPAINT, true)) {
            try {
                SwingUtilities.invokeAndWait(new Runnable() {

                    @Override
                    public void run() {
                        LogoPanel.super.repaint();
                    }
                });
            } catch (InterruptedException | InvocationTargetException ex) {
                org.tros.utils.logging.Logging.getLogFactory().getLogger(LogoPanel.class).fatal(null, ex);
            }
        } else {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    LogoPanel.super.repaint();
                }
            });
        }
    }
}

From source file:ffx.ui.ModelingPanel.java

private void initialize() {
    // Command Description
    descriptTextArea = new JTextArea();
    descriptTextArea.setEditable(false);
    descriptTextArea.setLineWrap(true);/*from   w w  w  . j a v a  2s .  c om*/
    descriptTextArea.setWrapStyleWord(true);
    descriptTextArea.setDoubleBuffered(true);
    Insets insets = descriptTextArea.getInsets();
    insets.set(5, 5, 5, 5);
    descriptTextArea.setMargin(insets);
    descriptScrollPane = new JScrollPane(descriptTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    descriptScrollPane.setBorder(etchedBorder);
    // Command Input
    commandTextArea = new JTextArea();
    commandTextArea.setEditable(false);
    commandTextArea.setLineWrap(true);
    commandTextArea.setWrapStyleWord(true);
    commandTextArea.setDoubleBuffered(true);
    commandTextArea.setMargin(insets);
    // Command Options
    optionsTabbedPane = new JTabbedPane();
    statusLabel = new JLabel();
    statusLabel.setBorder(etchedBorder);
    statusLabel.setToolTipText("  Modeling command that will be executed");
    commandPanel = new JPanel(flowLayout);
    commandPanel.add(optionsTabbedPane);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, commandPanel, descriptScrollPane);
    splitPane.setContinuousLayout(true);
    splitPane.setResizeWeight(1.0d);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    add(statusLabel, BorderLayout.SOUTH);
    // Initialize the Amino/Nucleic Acid ComboBox.
    acidComboBox.setEditable(false);
    acidComboBox.setMaximumSize(sizer.getPreferredSize());
    acidComboBox.setPreferredSize(sizer.getPreferredSize());
    acidComboBox.setMinimumSize(sizer.getPreferredSize());
    acidComboBox.setFont(Font.decode("Monospaced"));
    acidTextField.setMaximumSize(sizer.getPreferredSize());
    acidTextField.setMinimumSize(sizer.getPreferredSize());
    acidTextField.setPreferredSize(sizer.getPreferredSize());
    acidTextArea.setEditable(false);
    acidTextArea.setWrapStyleWord(true);
    acidTextArea.setLineWrap(true);
    acidTextArea.setFont(Font.decode("Monospaced"));
    acidScrollPane = new JScrollPane(acidTextArea);
    Dimension d = new Dimension(300, 400);
    acidScrollPane.setPreferredSize(d);
    acidScrollPane.setMaximumSize(d);
    acidScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    // Load the FFX commands.xml file that defines FFX commands.
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setEntityResolver(new DTDResolver());
        URL comURL = getClass().getClassLoader().getResource("ffx/ui/commands/commands.xml");
        Document doc = db.parse(comURL.openStream());
        NodeList nodelist = doc.getChildNodes();
        Node commandroot = null;
        for (int i = 0; i < nodelist.getLength(); i++) {
            commandroot = nodelist.item(i);
            if (commandroot.getNodeName().equals("FFXCommands") && commandroot instanceof Element) {
                break;
            }
        }
        if (commandroot == null || !(commandroot instanceof Element)) {
            commandList = null;
        }
        commandList = ((Element) commandroot).getElementsByTagName("Command");
    } catch (ParserConfigurationException | SAXException | IOException e) {
        System.err.println(e);
    } finally {
        if (commandList == null) {
            System.out.println("Force Field X commands.xml could not be parsed.");
            logger.severe("Force Field X will exit.");
            System.exit(-1);
        }
    }
    // Create a ComboBox with commands specific to each type of coordinate
    // file.
    xyzCommands = new JComboBox<>();
    intCommands = new JComboBox<>();
    arcCommands = new JComboBox<>();
    pdbCommands = new JComboBox<>();
    anyCommands = new JComboBox<>();
    Element command;
    String name;
    int numcommands = commandList.getLength();
    for (int i = 0; i < numcommands; i++) {
        command = (Element) commandList.item(i);
        name = command.getAttribute("name");
        String temp = command.getAttribute("fileType");
        if (temp.contains("ANY")) {
            temp = "XYZ INT ARC PDB";
            anyCommands.addItem(name);
        }
        String[] types = temp.split(" +");
        for (String type : types) {
            if (type.contains("XYZ")) {
                xyzCommands.addItem(name);
            }
            if (type.contains("INT")) {
                intCommands.addItem(name);
            }
            if (type.contains("ARC")) {
                arcCommands.addItem(name);
            }
            if (type.contains("PDB")) {
                pdbCommands.addItem(name);
            }
        }
    }
    initCommandComboBox(xyzCommands);
    initCommandComboBox(intCommands);
    initCommandComboBox(arcCommands);
    initCommandComboBox(pdbCommands);
    initCommandComboBox(anyCommands);
    currentCommandBox = anyCommands;
    activeCommand = (String) anyCommands.getSelectedItem();
    // Load the default Command.
    loadCommand();
    // Load the default Log File Settings.
    logSettings.setActionCommand("LogSettings");
    loadLogSettings();

    // Create the Toolbar.
    toolBar = new JToolBar("Modeling Commands", JToolBar.HORIZONTAL);
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
    jbLaunch = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/cog_go.png")));
    jbLaunch.setActionCommand("Launch");
    jbLaunch.setToolTipText("Launch the Force Field X Command");
    jbLaunch.addActionListener(this);
    insets.set(2, 2, 2, 2);
    jbLaunch.setMargin(insets);
    toolBar.add(jbLaunch);
    jbStop = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/stop.png")));
    jbStop.setActionCommand("End");
    jbStop.setToolTipText("Terminate the Current Force Field X Command");
    jbStop.addActionListener(this);
    jbStop.setMargin(insets);
    jbStop.setEnabled(false);
    toolBar.add(jbStop);
    toolBar.addSeparator();
    toolBar.add(anyCommands);
    currentCommandBox = anyCommands;
    toolBar.addSeparator();
    /*
     toolBar.add(logSettings);
     JButton jbdelete = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/page_delete.png")));
     jbdelete.setActionCommand("Delete");
     jbdelete.setToolTipText("Delete Log Files");
     jbdelete.addActionListener(this);
     jbdelete.setMargin(insets);
     toolBar.add(jbdelete);
     toolBar.addSeparator();
     */
    ImageIcon icinfo = new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/information.png"));
    descriptCheckBox = new JCheckBoxMenuItem(icinfo);
    descriptCheckBox.addActionListener(this);
    descriptCheckBox.setActionCommand("Description");
    descriptCheckBox.setToolTipText("Show/Hide Modeling Command Descriptions");
    descriptCheckBox.setMargin(insets);
    toolBar.add(descriptCheckBox);
    toolBar.add(new JLabel(""));
    toolBar.setBorderPainted(false);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    add(toolBar, BorderLayout.NORTH);
    // Load ModelingPanel preferences.
    Preferences prefs = Preferences.userNodeForPackage(ffx.ui.ModelingPanel.class);
    descriptCheckBox.setSelected(!prefs.getBoolean("JobPanel_description", true));
    descriptCheckBox.doClick();
}

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;/*  w  ww. ja  v a  2  s.c o m*/

    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);
}

From source file:org.domainmath.gui.MainFrame.java

public void exitApp() {
    int j = fileTab.getTabCount() - 1;
    while (j != -1) {

        askSave(j);/*from  w  w  w  .j av  a 2s .c  om*/
        j--;
    }
    ShutDown shutDown = new ShutDown(this, "DomainMath IDE", "Really do you want to exit?");
    JButton yes = new JButton("Yes");
    JButton no = new JButton("No");
    JCheckBox confirmation = shutDown.getCheckBox();
    Preferences pr2 = Preferences.userNodeForPackage(this.getClass());
    boolean skipConfirmation = pr2.getBoolean("skip_confirmation", false);

    confirmation.addItemListener((ItemEvent e) -> {
        if (ItemEvent.DESELECTED == e.getStateChange()) {
            pr2.putBoolean("skip_confirmation", false);
        } else {
            pr2.putBoolean("skip_confirmation", true);
        }
    });

    yes.addActionListener((ActionEvent e) -> {
        exitFinal(shutDown);
    });
    no.addActionListener((ActionEvent e) -> {
        shutDown.dispose();
    });

    if (false == skipConfirmation) {
        shutDown.addButton(yes);
        shutDown.addButton(no);
        shutDown.setVisible(true);
    } else {
        exitFinal(shutDown);
    }
}