Example usage for javax.swing JCheckBox isSelected

List of usage examples for javax.swing JCheckBox isSelected

Introduction

In this page you can find the example usage for javax.swing JCheckBox isSelected.

Prototype

public boolean isSelected() 

Source Link

Document

Returns the state of the button.

Usage

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openAnalyseDialog(final int chip) {
    JTextField optionsField = new JTextField();
    JTextField destinationField = new JTextField();

    // compute and try default names for options file.
    // In order : <firmware>.dfr.txt , <firmware>.txt , dfr.txt (or the same for dtx)
    File optionsFile = new File(imageFile[chip].getParentFile(),
            FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath())
                    + ((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt"));
    if (!optionsFile.exists()) {
        optionsFile = new File(imageFile[chip].getParentFile(),
                FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".txt");
        if (!optionsFile.exists()) {
            optionsFile = new File(imageFile[chip].getParentFile(),
                    ((chip == Constants.CHIP_FR) ? "dfr.txt" : "dtx.txt"));
            if (!optionsFile.exists()) {
                optionsFile = null;/*from   w  ww .  j a  va  2 s  .  c o  m*/
            }
        }
    }
    if (optionsFile != null) {
        optionsField.setText(optionsFile.getAbsolutePath());
    }

    // compute default name for output
    File outputFile = new File(imageFile[chip].getParentFile(),
            FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".asm");
    destinationField.setText(outputFile.getAbsolutePath());

    final JCheckBox writeOutputCheckbox = new JCheckBox("Write disassembly to file");

    final FileSelectionPanel destinationFileSelectionPanel = new FileSelectionPanel("Destination file",
            destinationField, false);
    destinationFileSelectionPanel.setFileFilter(".asm", "Assembly language file (*.asm)");
    writeOutputCheckbox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean writeToFile = writeOutputCheckbox.isSelected();
            destinationFileSelectionPanel.setEnabled(writeToFile);
            prefs.setWriteDisassemblyToFile(chip, writeToFile);
        }
    });

    writeOutputCheckbox.setSelected(prefs.isWriteDisassemblyToFile(chip));
    destinationFileSelectionPanel.setEnabled(prefs.isWriteDisassemblyToFile(chip));

    FileSelectionPanel fileSelectionPanel = new FileSelectionPanel(
            (chip == Constants.CHIP_FR) ? "Dfr options file" : "Dtx options file", optionsField, false);
    fileSelectionPanel.setFileFilter((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt",
            (chip == Constants.CHIP_FR) ? "Dfr options file (*.dfr.txt)" : "Dtx options file (*.dtx.txt)");
    final JComponent[] inputs = new JComponent[] {
            //new FileSelectionPanel("Source file", sourceFile, false, dependencies),
            fileSelectionPanel, writeOutputCheckbox, destinationFileSelectionPanel,
            makeOutputOptionCheckBox(chip, OutputOption.STRUCTURE, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.ORDINAL, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.PARAMETERS, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.INT40, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.MEMORY, prefs.getOutputOptions(chip), true),
            new JLabel("(hover over the options for help. See also 'Tools/Options/Disassembler output')",
                    SwingConstants.CENTER) };

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose analyse options",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) {
        String outputFilename = writeOutputCheckbox.isSelected() ? destinationField.getText() : null;
        boolean cancel = false;
        if (outputFilename != null) {
            if (new File(outputFilename).exists()) {
                if (JOptionPane.showConfirmDialog(this,
                        "File '" + outputFilename + "' already exists.\nDo you really want to overwrite it ?",
                        "File exists", JOptionPane.YES_NO_OPTION,
                        JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
                    cancel = true;
                }
            }
        }
        if (!cancel) {
            AnalyseProgressDialog analyseProgressDialog = new AnalyseProgressDialog(this,
                    framework.getPlatform(chip).getMemory());
            analyseProgressDialog.startBackgroundAnalysis(chip, optionsField.getText(), outputFilename);
            analyseProgressDialog.setVisible(true);
        }
    }
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private void saveSubTree(@SuppressWarnings("rawtypes") final Enumeration children,
        final List<Parameter> parameterList, final List<SubmodelParameter> submodelParameterList,
        final Set<ParameterInfo> invalids) throws IOException {

    final ObjectFactory factory = new ObjectFactory();
    while (children.hasMoreElements()) {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement();

        @SuppressWarnings("unchecked")
        final Pair<ParameterInfo, JComponent> userData = (Pair<ParameterInfo, JComponent>) node.getUserObject();
        final ParameterInfo parameterInfo = userData.getFirst();
        final JComponent valueContainer = userData.getSecond();

        Parameter parameter = null;
        SubmodelParameter submodelParameter = null;
        if (parameterInfo instanceof ISubmodelGUIInfo) {
            final ISubmodelGUIInfo sgi = (ISubmodelGUIInfo) parameterInfo;
            if (sgi.getParent() != null) {
                final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                @SuppressWarnings("unchecked")
                final Pair<ParameterInfo, JComponent> parentUserData = (Pair<ParameterInfo, JComponent>) parentNode
                        .getUserObject();
                final SubmodelInfo parentParameterInfo = (SubmodelInfo) parentUserData.getFirst();
                if (invalids.contains(parentParameterInfo)
                        || !classEquals(parentParameterInfo.getActualType(), sgi.getParentValue())) {
                    invalids.add(parameterInfo);
                    continue;
                }/*from  w  w w.  ja  va2s .  c o  m*/
            }
        }

        if (parameterInfo instanceof SubmodelInfo) {
            submodelParameter = factory.createSubmodelParameter();
            submodelParameter.setName(parameterInfo.getName());
        } else {
            parameter = factory.createParameter();
            parameter.setName(parameterInfo.getName());
        }

        if (parameterInfo.isBoolean()) {
            final JCheckBox checkBox = (JCheckBox) valueContainer;
            parameter.getContent().add(String.valueOf(checkBox.isSelected()));
        } else if (parameterInfo.isEnum()) {
            final JComboBox comboBox = (JComboBox) valueContainer;
            parameter.getContent().add(String.valueOf(comboBox.getSelectedItem()));
        } else if (parameterInfo instanceof MasonChooserParameterInfo) {
            final JComboBox comboBox = (JComboBox) valueContainer;
            parameter.getContent().add(String.valueOf(comboBox.getSelectedIndex()));
        } else if (parameterInfo instanceof SubmodelInfo) {
            final JComboBox comboBox = (JComboBox) ((JPanel) valueContainer).getComponent(0);
            final ClassElement selectedElement = (ClassElement) comboBox.getSelectedItem();

            if (selectedElement.clazz == null)
                throw new IOException("No type is selected for parameter "
                        + parameterInfo.getName().replaceAll("([A-Z])", " $1") + ".");

            submodelParameter.setType(selectedElement.clazz.getName());
            saveSubTree(node.children(), submodelParameter.getParameterList(),
                    submodelParameter.getSubmodelParameterList(), invalids);
        } else if (parameterInfo.isFile()) {
            final JTextField textField = (JTextField) valueContainer.getComponent(0);
            parameter.getContent().add(textField.getToolTipText());
        } else if (parameterInfo instanceof MasonIntervalParameterInfo) {
            final JTextField textField = (JTextField) valueContainer.getComponent(0);
            parameter.getContent().add(textField.getText().trim());
        } else {
            final JTextField textField = (JTextField) valueContainer;
            String text = String.valueOf(ParameterInfo.getValue(textField.getText(), parameterInfo.getType()));
            if ("String".equals(parameterInfo.getType()) && parameterInfo.getValue() == null)
                text = textField.getText().trim();
            parameter.getContent().add(text);
        }

        if (parameter != null)
            parameterList.add(parameter);
        else if (submodelParameter != null)
            submodelParameterList.add(submodelParameter);
    }
}

From source file:com.marginallyclever.makelangelo.MainGUI.java

protected void JogMotors() {
    JDialog driver = new JDialog(mainframe, translator.get("JogMotors"), true);
    driver.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    final JButton buttonAneg = new JButton(translator.get("JogIn"));
    final JButton buttonApos = new JButton(translator.get("JogOut"));
    final JCheckBox m1i = new JCheckBox(translator.get("Invert"), machineConfiguration.m1invert);

    final JButton buttonBneg = new JButton(translator.get("JogIn"));
    final JButton buttonBpos = new JButton(translator.get("JogOut"));
    final JCheckBox m2i = new JCheckBox(translator.get("Invert"), machineConfiguration.m2invert);

    c.gridx = 0;/*  w w w .j  a v  a2  s  .c o  m*/
    c.gridy = 0;
    driver.add(new JLabel(translator.get("Left")), c);
    c.gridx = 0;
    c.gridy = 1;
    driver.add(new JLabel(translator.get("Right")), c);

    c.gridx = 1;
    c.gridy = 0;
    driver.add(buttonAneg, c);
    c.gridx = 1;
    c.gridy = 1;
    driver.add(buttonBneg, c);

    c.gridx = 2;
    c.gridy = 0;
    driver.add(buttonApos, c);
    c.gridx = 2;
    c.gridy = 1;
    driver.add(buttonBpos, c);

    c.gridx = 3;
    c.gridy = 0;
    driver.add(m1i, c);
    c.gridx = 3;
    c.gridy = 1;
    driver.add(m2i, c);

    ActionListener driveButtons = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object subject = e.getSource();
            if (subject == buttonApos)
                sendLineToRobot("D00 L100");
            if (subject == buttonAneg)
                sendLineToRobot("D00 L-100");
            if (subject == buttonBpos)
                sendLineToRobot("D00 R100");
            if (subject == buttonBneg)
                sendLineToRobot("D00 R-100");
            sendLineToRobot("M114");
        }
    };

    ActionListener invertButtons = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            machineConfiguration.m1invert = m1i.isSelected();
            machineConfiguration.m2invert = m2i.isSelected();
            machineConfiguration.SaveConfig();
            SendConfig();
        }
    };

    buttonApos.addActionListener(driveButtons);
    buttonAneg.addActionListener(driveButtons);

    buttonBpos.addActionListener(driveButtons);
    buttonBneg.addActionListener(driveButtons);

    m1i.addActionListener(invertButtons);
    m2i.addActionListener(invertButtons);

    sendLineToRobot("M114");
    driver.pack();
    driver.setVisible(true);
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

/** {@inheritDoc} 
 *///from w ww .j ava2s . c om
@Override
public boolean onButtonPress(final Button button) {
    if (Button.NEXT.equals(button)) {
        ParameterTree parameterTree = null;
        if (tabbedPane.getSelectedIndex() == SINGLE_RUN_GUI_TABINDEX) {
            currentModelHandler.setIntelliMethodPlugin(null);
            parameterTree = new ParameterTree();
            final Set<ParameterInfo> invalids = new HashSet<ParameterInfo>();

            @SuppressWarnings("rawtypes")
            final Enumeration treeValues = parameterValueComponentTree.breadthFirstEnumeration();
            treeValues.nextElement(); // root element
            while (treeValues.hasMoreElements()) {
                final DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeValues.nextElement();
                @SuppressWarnings("unchecked")
                final Pair<ParameterInfo, JComponent> userData = (Pair<ParameterInfo, JComponent>) node
                        .getUserObject();
                final ParameterInfo parameterInfo = userData.getFirst();
                final JComponent valueContainer = userData.getSecond();

                if (parameterInfo instanceof ISubmodelGUIInfo) {
                    final ISubmodelGUIInfo sgi = (ISubmodelGUIInfo) parameterInfo;
                    if (sgi.getParent() != null) {
                        final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                        @SuppressWarnings("unchecked")
                        final Pair<ParameterInfo, JComponent> parentUserData = (Pair<ParameterInfo, JComponent>) parentNode
                                .getUserObject();
                        final SubmodelInfo parentParameterInfo = (SubmodelInfo) parentUserData.getFirst();
                        if (invalids.contains(parentParameterInfo)
                                || !classEquals(parentParameterInfo.getActualType(), sgi.getParentValue())) {
                            invalids.add(parameterInfo);
                            continue;
                        }
                    }
                }

                if (parameterInfo.isBoolean()) {
                    final JCheckBox checkBox = (JCheckBox) valueContainer;
                    parameterInfo.setValue(checkBox.isSelected());
                } else if (parameterInfo.isEnum()) {
                    final JComboBox comboBox = (JComboBox) valueContainer;
                    parameterInfo.setValue(comboBox.getSelectedItem());
                } else if (parameterInfo instanceof MasonChooserParameterInfo) {
                    final JComboBox comboBox = (JComboBox) valueContainer;
                    parameterInfo.setValue(comboBox.getSelectedIndex());
                } else if (parameterInfo instanceof SubmodelInfo) {
                    // we don't need the SubmodelInfo parameters anymore (all descendant parameters are in the tree too)
                    // but we need to check that an actual type is provided
                    final SubmodelInfo smi = (SubmodelInfo) parameterInfo;
                    final JComboBox comboBox = (JComboBox) ((JPanel) valueContainer).getComponent(0);
                    final ClassElement selected = (ClassElement) comboBox.getSelectedItem();
                    smi.setActualType(selected.clazz, selected.instance);

                    if (smi.getActualType() == null) {
                        final String errorMsg = "Please select a type from the dropdown list of "
                                + smi.getName().replaceAll("([A-Z])", " $1");
                        JOptionPane.showMessageDialog(wizard, new JLabel(errorMsg), "Error",
                                JOptionPane.ERROR_MESSAGE);
                        return false;
                    }

                    //continue;
                } else if (parameterInfo.isFile()) {
                    final JTextField textField = (JTextField) valueContainer.getComponent(0);
                    if (textField.getText().trim().isEmpty())
                        log.warn("Empty string was specified as file parameter "
                                + parameterInfo.getName().replaceAll("([A-Z])", " $1"));

                    final File file = new File(textField.getToolTipText());
                    if (!file.exists()) {
                        final String errorMsg = "Please specify an existing file parameter "
                                + parameterInfo.getName().replaceAll("([A-Z])", " $1");
                        JOptionPane.showMessageDialog(wizard, new JLabel(errorMsg), "Error",
                                JOptionPane.ERROR_MESSAGE);
                        return false;
                    }

                    parameterInfo.setValue(
                            ParameterInfo.getValue(textField.getToolTipText(), parameterInfo.getType()));
                } else if (parameterInfo instanceof MasonIntervalParameterInfo) {
                    final JTextField textField = (JTextField) valueContainer.getComponent(0);
                    parameterInfo.setValue(
                            ParameterInfo.getValue(textField.getText().trim(), parameterInfo.getType()));
                } else {
                    final JTextField textField = (JTextField) valueContainer;
                    parameterInfo
                            .setValue(ParameterInfo.getValue(textField.getText(), parameterInfo.getType()));
                    if ("String".equals(parameterInfo.getType()) && parameterInfo.getValue() == null)
                        parameterInfo.setValue(textField.getText().trim());
                }

                final AbstractParameterInfo<?> batchParameterInfo = InfoConverter
                        .parameterInfo2ParameterInfo(parameterInfo);
                parameterTree.addNode(batchParameterInfo);
            }

            dashboard.setOnLineCharts(onLineChartsCheckBox.isSelected());
            dashboard.setDisplayAdvancedCharts(advancedChartsCheckBox.isSelected());
        }

        if (tabbedPane.getSelectedIndex() == PARAMSWEEP_GUI_TABINDEX) {
            currentModelHandler.setIntelliMethodPlugin(null);
            boolean success = true;
            if (editedNode != null)
                success = modify();

            if (success) {
                String invalidInfoName = checkInfos(true);
                if (invalidInfoName != null) {
                    Utilities.userAlert(sweepPanel,
                            "Please select a type from the dropdown list of " + invalidInfoName);
                    return false;
                }

                invalidInfoName = checkInfos(false);
                if (invalidInfoName != null) {
                    Utilities.userAlert(sweepPanel, "Please specify a file for parameter " + invalidInfoName);
                    return false;
                }

                if (needWarning()) {
                    final int result = Utilities.askUser(sweepPanel, false, "Warning",
                            "There are two or more combination boxes that contains non-constant parameters."
                                    + " Parameters are unsynchronized:",
                            "simulation may exit before all parameter values are assigned.", " ",
                            "To explore all possible combinations you must use only one combination box.", " ",
                            "Do you want to run simulation with these parameter settings?");
                    if (result == 0) {
                        return false;
                    }
                }

                try {
                    parameterTree = createParameterTreeFromParamSweepGUI();

                    final ParameterNode rootNode = parameterTree.getRoot();
                    dumpParameterTree(rootNode);

                    //                  dashboard.setOnLineCharts(onLineChartsCheckBoxPSW.isSelected());
                } catch (final ModelInformationException e) {
                    JOptionPane.showMessageDialog(wizard, new JLabel(e.getMessage()),
                            "Error while creating runs", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                    return false;
                }
            } else
                return false;
        }

        if (tabbedPane.getSelectedIndex() == GASEARCH_GUI_TABINDEX) {
            final IIntelliDynamicMethodPlugin gaPlugin = (IIntelliDynamicMethodPlugin) gaSearchHandler;
            currentModelHandler.setIntelliMethodPlugin(gaPlugin);
            boolean success = gaSearchPanel.closeActiveModification();

            if (success) {
                String invalidInfoName = checkInfosInGeneTree();
                if (invalidInfoName != null) {
                    Utilities.userAlert(sweepPanel,
                            "Please select a type from the dropdown list of " + invalidInfoName);
                    return false;
                }

                final String[] errors = gaSearchHandler.checkGAModel();
                if (errors != null) {
                    Utilities.userAlert(sweepPanel, (Object[]) errors);
                    return false;
                }

                final DefaultMutableTreeNode parameterTreeRootNode = new DefaultMutableTreeNode();
                final IIntelliContext ctx = new DashboardIntelliContext(parameterTreeRootNode,
                        gaSearchHandler.getChromosomeTree());
                gaPlugin.alterParameterTree(ctx);
                parameterTree = InfoConverter.node2ParameterTree(parameterTreeRootNode);
                dashboard.setOptimizationDirection(gaSearchHandler.getFitnessFunctionDirection());

            } else
                return false;
        }

        currentModelHandler.setParameters(parameterTree);
    }

    return true;
}

From source file:com.nikonhacker.gui.EmulatorUI.java

@SuppressWarnings("MagicConstant")
protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenuItem tmpMenuItem;/*from   w  ww.  j  a  v  a 2s  .co  m*/

    //Set up the file menu.
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    //load image
    for (int chip = 0; chip < 2; chip++) {
        loadMenuItem[chip] = new JMenuItem("Load " + Constants.CHIP_LABEL[chip] + " firmware image");
        if (chip == Constants.CHIP_FR)
            loadMenuItem[chip].setMnemonic(KEY_EVENT_LOAD);
        loadMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_LOAD, KEY_CHIP_MODIFIER[chip]));
        loadMenuItem[chip].setActionCommand(COMMAND_IMAGE_LOAD[chip]);
        loadMenuItem[chip].addActionListener(this);
        fileMenu.add(loadMenuItem[chip]);
    }

    fileMenu.add(new JSeparator());

    //decoder
    tmpMenuItem = new JMenuItem("Decode firmware");
    tmpMenuItem.setMnemonic(KeyEvent.VK_D);
    tmpMenuItem.setActionCommand(COMMAND_DECODE);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    //encoder
    tmpMenuItem = new JMenuItem("Encode firmware (alpha)");
    tmpMenuItem.setMnemonic(KeyEvent.VK_E);
    tmpMenuItem.setActionCommand(COMMAND_ENCODE);
    tmpMenuItem.addActionListener(this);
    //        fileMenu.add(tmpMenuItem);

    fileMenu.add(new JSeparator());

    //decoder
    tmpMenuItem = new JMenuItem("Decode lens correction data");
    //tmpMenuItem.setMnemonic(KeyEvent.VK_D);
    tmpMenuItem.setActionCommand(COMMAND_DECODE_NKLD);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    fileMenu.add(new JSeparator());

    //Save state
    tmpMenuItem = new JMenuItem("Save state");
    tmpMenuItem.setActionCommand(COMMAND_SAVE_STATE);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    //Load state
    tmpMenuItem = new JMenuItem("Load state");
    tmpMenuItem.setActionCommand(COMMAND_LOAD_STATE);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    fileMenu.add(new JSeparator());

    //quit
    tmpMenuItem = new JMenuItem("Quit");
    tmpMenuItem.setMnemonic(KEY_EVENT_QUIT);
    tmpMenuItem.setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_QUIT, ActionEvent.ALT_MASK));
    tmpMenuItem.setActionCommand(COMMAND_QUIT);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    //Set up the run menu.
    JMenu runMenu = new JMenu("Run");
    runMenu.setMnemonic(KeyEvent.VK_R);
    menuBar.add(runMenu);

    for (int chip = 0; chip < 2; chip++) {
        //emulator play
        playMenuItem[chip] = new JMenuItem("Start (or resume) " + Constants.CHIP_LABEL[chip] + " emulator");
        playMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_RUN[chip], ActionEvent.ALT_MASK));
        playMenuItem[chip].setActionCommand(COMMAND_EMULATOR_PLAY[chip]);
        playMenuItem[chip].addActionListener(this);
        runMenu.add(playMenuItem[chip]);

        //emulator debug
        debugMenuItem[chip] = new JMenuItem("Debug " + Constants.CHIP_LABEL[chip] + " emulator");
        debugMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_DEBUG[chip], ActionEvent.ALT_MASK));
        debugMenuItem[chip].setActionCommand(COMMAND_EMULATOR_DEBUG[chip]);
        debugMenuItem[chip].addActionListener(this);
        runMenu.add(debugMenuItem[chip]);

        //emulator pause
        pauseMenuItem[chip] = new JMenuItem("Pause " + Constants.CHIP_LABEL[chip] + " emulator");
        pauseMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_PAUSE[chip], ActionEvent.ALT_MASK));
        pauseMenuItem[chip].setActionCommand(COMMAND_EMULATOR_PAUSE[chip]);
        pauseMenuItem[chip].addActionListener(this);
        runMenu.add(pauseMenuItem[chip]);

        //emulator step
        stepMenuItem[chip] = new JMenuItem("Step " + Constants.CHIP_LABEL[chip] + " emulator");
        stepMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_STEP[chip], ActionEvent.ALT_MASK));
        stepMenuItem[chip].setActionCommand(COMMAND_EMULATOR_STEP[chip]);
        stepMenuItem[chip].addActionListener(this);
        runMenu.add(stepMenuItem[chip]);

        //emulator stop
        stopMenuItem[chip] = new JMenuItem("Stop and reset " + Constants.CHIP_LABEL[chip] + " emulator");
        stopMenuItem[chip].setActionCommand(COMMAND_EMULATOR_STOP[chip]);
        stopMenuItem[chip].addActionListener(this);
        runMenu.add(stopMenuItem[chip]);

        runMenu.add(new JSeparator());

        //setup breakpoints
        breakpointMenuItem[chip] = new JMenuItem("Setup " + Constants.CHIP_LABEL[chip] + " breakpoints");
        breakpointMenuItem[chip].setActionCommand(COMMAND_SETUP_BREAKPOINTS[chip]);
        breakpointMenuItem[chip].addActionListener(this);
        runMenu.add(breakpointMenuItem[chip]);

        if (chip == Constants.CHIP_FR) {
            runMenu.add(new JSeparator());
        }
    }

    //Set up the components menu.
    JMenu componentsMenu = new JMenu("Components");
    componentsMenu.setMnemonic(KeyEvent.VK_O);
    menuBar.add(componentsMenu);

    for (int chip = 0; chip < 2; chip++) {
        //CPU state
        cpuStateMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " CPU State window");
        if (chip == Constants.CHIP_FR)
            cpuStateMenuItem[chip].setMnemonic(KEY_EVENT_CPUSTATE);
        cpuStateMenuItem[chip]
                .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_CPUSTATE, KEY_CHIP_MODIFIER[chip]));
        cpuStateMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CPUSTATE_WINDOW[chip]);
        cpuStateMenuItem[chip].addActionListener(this);
        componentsMenu.add(cpuStateMenuItem[chip]);

        //memory hex editor
        memoryHexEditorMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " Memory hex editor");
        if (chip == Constants.CHIP_FR)
            memoryHexEditorMenuItem[chip].setMnemonic(KEY_EVENT_MEMORY);
        memoryHexEditorMenuItem[chip]
                .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_MEMORY, KEY_CHIP_MODIFIER[chip]));
        memoryHexEditorMenuItem[chip].setActionCommand(COMMAND_TOGGLE_MEMORY_HEX_EDITOR[chip]);
        memoryHexEditorMenuItem[chip].addActionListener(this);
        componentsMenu.add(memoryHexEditorMenuItem[chip]);

        //Interrupt controller
        interruptControllerMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " interrupt controller");
        interruptControllerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_INTERRUPT_CONTROLLER_WINDOW[chip]);
        interruptControllerMenuItem[chip].addActionListener(this);
        componentsMenu.add(interruptControllerMenuItem[chip]);

        //Programmble timers
        programmableTimersMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " programmable timers");
        programmableTimersMenuItem[chip].setActionCommand(COMMAND_TOGGLE_PROGRAMMABLE_TIMERS_WINDOW[chip]);
        programmableTimersMenuItem[chip].addActionListener(this);
        componentsMenu.add(programmableTimersMenuItem[chip]);

        //Serial interface
        serialInterfacesMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " serial interfaces");
        serialInterfacesMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SERIAL_INTERFACES[chip]);
        serialInterfacesMenuItem[chip].addActionListener(this);
        componentsMenu.add(serialInterfacesMenuItem[chip]);

        // I/O
        ioPortsMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " I/O ports");
        ioPortsMenuItem[chip].setActionCommand(COMMAND_TOGGLE_IO_PORTS_WINDOW[chip]);
        ioPortsMenuItem[chip].addActionListener(this);
        componentsMenu.add(ioPortsMenuItem[chip]);

        //Serial devices
        serialDevicesMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " serial devices");
        serialDevicesMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SERIAL_DEVICES[chip]);
        serialDevicesMenuItem[chip].addActionListener(this);
        componentsMenu.add(serialDevicesMenuItem[chip]);

        componentsMenu.add(new JSeparator());
    }

    //screen emulator: FR80 only
    screenEmulatorMenuItem = new JCheckBoxMenuItem("Screen emulator (FR only)");
    screenEmulatorMenuItem.setMnemonic(KEY_EVENT_SCREEN);
    screenEmulatorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_SCREEN, ActionEvent.ALT_MASK));
    screenEmulatorMenuItem.setActionCommand(COMMAND_TOGGLE_SCREEN_EMULATOR);
    screenEmulatorMenuItem.addActionListener(this);
    componentsMenu.add(screenEmulatorMenuItem);

    //Component 4006: FR80 only
    component4006MenuItem = new JCheckBoxMenuItem("Component 4006 window (FR only)");
    component4006MenuItem.setMnemonic(KeyEvent.VK_4);
    component4006MenuItem.setActionCommand(COMMAND_TOGGLE_COMPONENT_4006_WINDOW);
    component4006MenuItem.addActionListener(this);
    componentsMenu.add(component4006MenuItem);

    componentsMenu.add(new JSeparator());

    //A/D converter: TX19 only for now
    adConverterMenuItem[Constants.CHIP_TX] = new JCheckBoxMenuItem(
            Constants.CHIP_LABEL[Constants.CHIP_TX] + " A/D converter (TX only)");
    adConverterMenuItem[Constants.CHIP_TX].setActionCommand(COMMAND_TOGGLE_AD_CONVERTER[Constants.CHIP_TX]);
    adConverterMenuItem[Constants.CHIP_TX].addActionListener(this);
    componentsMenu.add(adConverterMenuItem[Constants.CHIP_TX]);

    //Front panel: TX19 only
    frontPanelMenuItem = new JCheckBoxMenuItem("Front panel (TX only)");
    frontPanelMenuItem.setActionCommand(COMMAND_TOGGLE_FRONT_PANEL);
    frontPanelMenuItem.addActionListener(this);
    componentsMenu.add(frontPanelMenuItem);

    //Set up the trace menu.
    JMenu traceMenu = new JMenu("Trace");
    traceMenu.setMnemonic(KeyEvent.VK_C);
    menuBar.add(traceMenu);

    for (int chip = 0; chip < 2; chip++) {
        //memory activity viewer
        memoryActivityViewerMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " Memory activity viewer");
        memoryActivityViewerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_MEMORY_ACTIVITY_VIEWER[chip]);
        memoryActivityViewerMenuItem[chip].addActionListener(this);
        traceMenu.add(memoryActivityViewerMenuItem[chip]);

        //disassembly
        disassemblyMenuItem[chip] = new JCheckBoxMenuItem(
                "Real-time " + Constants.CHIP_LABEL[chip] + " disassembly log");
        if (chip == Constants.CHIP_FR)
            disassemblyMenuItem[chip].setMnemonic(KEY_EVENT_REALTIME_DISASSEMBLY);
        disassemblyMenuItem[chip].setAccelerator(
                KeyStroke.getKeyStroke(KEY_EVENT_REALTIME_DISASSEMBLY, KEY_CHIP_MODIFIER[chip]));
        disassemblyMenuItem[chip].setActionCommand(COMMAND_TOGGLE_DISASSEMBLY_WINDOW[chip]);
        disassemblyMenuItem[chip].addActionListener(this);
        traceMenu.add(disassemblyMenuItem[chip]);

        //Custom logger
        customMemoryRangeLoggerMenuItem[chip] = new JCheckBoxMenuItem(
                "Custom " + Constants.CHIP_LABEL[chip] + " logger window");
        customMemoryRangeLoggerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CUSTOM_LOGGER_WINDOW[chip]);
        customMemoryRangeLoggerMenuItem[chip].addActionListener(this);
        traceMenu.add(customMemoryRangeLoggerMenuItem[chip]);

        //Call Stack logger
        callStackMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " Call stack logger");
        callStackMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CALL_STACK_WINDOW[chip]);
        callStackMenuItem[chip].addActionListener(this);
        traceMenu.add(callStackMenuItem[chip]);

        //ITRON Object
        iTronObjectMenuItem[chip] = new JCheckBoxMenuItem("ITRON " + Constants.CHIP_LABEL[chip] + " Objects");
        iTronObjectMenuItem[chip].setActionCommand(COMMAND_TOGGLE_ITRON_OBJECT_WINDOW[chip]);
        iTronObjectMenuItem[chip].addActionListener(this);
        traceMenu.add(iTronObjectMenuItem[chip]);

        //ITRON Return Stack
        iTronReturnStackMenuItem[chip] = new JCheckBoxMenuItem(
                "ITRON " + Constants.CHIP_LABEL[chip] + " Return stack");
        iTronReturnStackMenuItem[chip].setActionCommand(COMMAND_TOGGLE_ITRON_RETURN_STACK_WINDOW[chip]);
        iTronReturnStackMenuItem[chip].addActionListener(this);
        traceMenu.add(iTronReturnStackMenuItem[chip]);

        traceMenu.add(new JSeparator());
    }

    //Set up the source menu.
    JMenu sourceMenu = new JMenu("Source");
    sourceMenu.setMnemonic(KEY_EVENT_SCREEN);
    menuBar.add(sourceMenu);

    // FR syscall symbols
    generateSysSymbolsMenuItem = new JMenuItem(
            "Generate " + Constants.CHIP_LABEL[Constants.CHIP_FR] + " system call symbols");
    generateSysSymbolsMenuItem.setActionCommand(COMMAND_GENERATE_SYS_SYMBOLS);
    generateSysSymbolsMenuItem.addActionListener(this);
    sourceMenu.add(generateSysSymbolsMenuItem);

    for (int chip = 0; chip < 2; chip++) {

        sourceMenu.add(new JSeparator());

        //analyse / disassemble
        analyseMenuItem[chip] = new JMenuItem("Analyse / Disassemble " + Constants.CHIP_LABEL[chip] + " code");
        analyseMenuItem[chip].setActionCommand(COMMAND_ANALYSE_DISASSEMBLE[chip]);
        analyseMenuItem[chip].addActionListener(this);
        sourceMenu.add(analyseMenuItem[chip]);

        sourceMenu.add(new JSeparator());

        //code structure
        codeStructureMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " code structure");
        codeStructureMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CODE_STRUCTURE_WINDOW[chip]);
        codeStructureMenuItem[chip].addActionListener(this);
        sourceMenu.add(codeStructureMenuItem[chip]);

        //source code
        sourceCodeMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " source code");
        if (chip == Constants.CHIP_FR)
            sourceCodeMenuItem[chip].setMnemonic(KEY_EVENT_SOURCE);
        sourceCodeMenuItem[chip]
                .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_SOURCE, KEY_CHIP_MODIFIER[chip]));
        sourceCodeMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SOURCE_CODE_WINDOW[chip]);
        sourceCodeMenuItem[chip].addActionListener(this);
        sourceMenu.add(sourceCodeMenuItem[chip]);

        if (chip == Constants.CHIP_FR) {
            sourceMenu.add(new JSeparator());
        }
    }

    //Set up the tools menu.
    JMenu toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    menuBar.add(toolsMenu);

    for (int chip = 0; chip < 2; chip++) {
        // save/load memory area
        saveLoadMemoryMenuItem[chip] = new JMenuItem(
                "Save/Load " + Constants.CHIP_LABEL[chip] + " memory area");
        saveLoadMemoryMenuItem[chip].setActionCommand(COMMAND_SAVE_LOAD_MEMORY[chip]);
        saveLoadMemoryMenuItem[chip].addActionListener(this);
        toolsMenu.add(saveLoadMemoryMenuItem[chip]);

        //chip options
        chipOptionsMenuItem[chip] = new JMenuItem(Constants.CHIP_LABEL[chip] + " options");
        chipOptionsMenuItem[chip].setActionCommand(COMMAND_CHIP_OPTIONS[chip]);
        chipOptionsMenuItem[chip].addActionListener(this);
        toolsMenu.add(chipOptionsMenuItem[chip]);

        toolsMenu.add(new JSeparator());

    }

    //disassembly options
    uiOptionsMenuItem = new JMenuItem("Preferences");
    uiOptionsMenuItem.setActionCommand(COMMAND_UI_OPTIONS);
    uiOptionsMenuItem.addActionListener(this);
    toolsMenu.add(uiOptionsMenuItem);

    //Set up the help menu.
    JMenu helpMenu = new JMenu("?");
    menuBar.add(helpMenu);

    //about
    JMenuItem aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.setActionCommand(COMMAND_ABOUT);
    aboutMenuItem.addActionListener(this);
    helpMenu.add(aboutMenuItem);

    //        JMenuItem testMenuItem = new JMenuItem("Test");
    //        testMenuItem.setActionCommand(COMMAND_TEST);
    //        testMenuItem.addActionListener(this);
    //        helpMenu.add(testMenuItem);

    // Global "Keep in sync" setting
    menuBar.add(Box.createHorizontalGlue());
    final JCheckBox syncEmulators = new JCheckBox("Keep emulators in sync");
    syncEmulators.setSelected(prefs.isSyncPlay());
    framework.getMasterClock().setSyncPlay(prefs.isSyncPlay());
    syncEmulators.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            prefs.setSyncPlay(syncEmulators.isSelected());
            framework.getMasterClock().setSyncPlay(syncEmulators.isSelected());
        }
    });
    menuBar.add(syncEmulators);
    return menuBar;
}

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * MS?//from   w ww.  j a va  2  s  .co m
 * ?MS??????
 * ????[Cookie][]?????
 * ??1???????????????
 */
private void initMsInfo() {
    msCheck = new LinkedHashMap<String, JCheckBox>();
    isMsCheck = new HashMap<String, Boolean>();

    // Cookie?Cookie?MS???
    List<String> valueGetList = Arrays.asList(SystemProperties.getInstance().getDefaultMsList());
    //        ArrayList<String> valueGetList = cm.getCookie(COOKIE_MS);
    List<String> valueSetList = new ArrayList<String>();

    boolean checked = false;

    List<String> list = Arrays.asList(instInfo.getMsAll());

    //      LOGGER.info("instInfo.getMsAll().length -> " + list.size());
    for (String val : list) {
        //      for ( int j=0; j<list.size(); j++ ) {
        //         String val = list.get(j);

        JCheckBox chkBox;

        // Cookie???
        if (valueGetList.size() != 0) {
            if (valueGetList.contains(val)) {
                chkBox = new JCheckBox(val, true);
                checked = true;
            } else {
                chkBox = new JCheckBox(val, false);
            }
        } else {
            chkBox = new JCheckBox(val, true);
            checked = true;
            valueSetList.add(val);
        }

        msCheck.put(val, chkBox);
        isMsCheck.put(val, chkBox.isSelected());
    }

    // MS????????
    if (msCheck.size() == 0 && isMsCheck.size() == 0) {
        JOptionPane.showMessageDialog(null, "MS Type is not registered in the database.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    // ???????MS?1?????????????
    if (!checked) {
        for (Iterator i = msCheck.keySet().iterator(); i.hasNext();) {
            String key = (String) i.next();
            ((JCheckBox) msCheck.get(key)).setSelected(true);
            isMsCheck.put(key, true);
            valueSetList.add(key);
        }
    }

    // ????Cookie??????Cookie?
    if (valueGetList.size() == 0) {
        SystemProperties.setDefaultMsList(valueSetList);
        //         cm.setCookie(COOKIE_MS, valueSetList);
    }
}

From source file:com.declarativa.interprolog.gui.Ini.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    try {//from  ww w. j a  v a 2 s. c  o m
        Forest<String, Integer> forest = new DelegateForest<>();
        ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest));

        Layout layout = new BalloonLayout(forest);
        //Layout layout = new TreeLayout(forest, 70, 70);
        final BaseJungScene scene = new SceneImpl(g, layout);

        jLayeredPane1.setLayout(new BorderLayout());
        jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER);

        final JCheckBox checkbox = new JCheckBox("Animate iterative layouts");

        scene.setLayoutAnimationFramesPerSecond(48);

        //**********************
        DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>();
        shapes.addElement(new EdgeShape.QuadCurve<String, Number>());
        shapes.addElement(new EdgeShape.BentLine<String, Number>());
        shapes.addElement(new EdgeShape.CubicCurve<String, Number>());
        shapes.addElement(new EdgeShape.Line<String, Number>());
        shapes.addElement(new EdgeShape.Box<String, Number>());
        shapes.addElement(new EdgeShape.Orthogonal<String, Number>());
        shapes.addElement(new EdgeShape.Wedge<String, Number>(10));

        /*
        final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>(shapes);
        shapesBox.addActionListener(new ActionListener() {
                
        @Override
        public void actionPerformed(ActionEvent ae) {
        Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox.getSelectedItem();
        scene.setConnectionEdgeShape(xform);
        }
        });
                
                
                
        shapesBox.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) {
        o = o.getClass().getSimpleName();
        return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
        });
        shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>());
                
        */
        final JLabel selectionLabel = new JLabel("<html>&nbsp;</html>");
        System.out.println("LOOKUP IS " + scene.getLookup());
        Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class);
        LookupListener listener = new LookupListener() {
            @Override
            public void resultChanged(LookupEvent le) {
                System.out.println("RES CHANGED");
                Lookup.Result<String> res = (Lookup.Result<String>) le.getSource();
                StringBuilder sb = new StringBuilder("<html>");
                List<String> l = new ArrayList<>(res.allInstances());
                Collections.sort(l);
                for (String s : l) {
                    if (sb.length() != 0) {
                        sb.append(", ");
                    }
                    sb.append(s);
                }
                sb.append("</html>");
                selectionLabel.setText(sb.toString());
                System.out.println("LOOKUP EVENT " + sb);
            }
        };
        selectedNodes.addLookupListener(listener);
        selectedNodes.allInstances();

        checkbox.setSelected(true);
        checkbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                scene.setAnimateIterativeLayouts(checkbox.isSelected());
            }
        });

        jLayeredPane1.setSize(456, 458);
        ////        jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowOpened(WindowEvent we) {
                scene.relayout(true);
                scene.validate();
            }
        });

        /*
                
        int returnVal = fileChooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fileChooser.getSelectedFile();
                
        fileChooser.addChoosableFileFilter(new FileFilter() {
                
        public String getDescription() {
        return "Prolog native program (*.P)";
        }
                
        public boolean accept(File f) {
        if (f.isDirectory()) {
        return true;
        } else {
        return f.getName().toLowerCase().endsWith(".P");
        }
        }
        });
                
        try {
        // What to do with the file, e.g. display it in a TextArea
        prologOutput.read(new FileReader(file.getAbsolutePath()), null);
        } catch (IOException ex) {
        System.out.println("problem accessing file" + file.getAbsolutePath());
        }
        } else {
        System.out.println("File access cancelled by user.");
        }
                
        */

        //One file chooser for each buton click
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
        System.out.println("AUCH");
    }
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Constructs the MessageFilter (this.filter) based on the current form selections
 *///  ww  w . ja  v a  2 s .co  m
private boolean generateMessageFilter() {
    messageFilter = new MessageFilter();

    // set start/end date
    try {
        messageFilter.setStartDate(getCalendar(mirthDatePicker1, mirthTimePicker1));
        Calendar endCalendar = getCalendar(mirthDatePicker2, mirthTimePicker2);

        if (endCalendar != null && !mirthTimePicker2.isEnabled()) {
            // If the end time picker is disabled, it will be set to 00:00:00 of the day provided.
            // Since our query is using <= instead of <, we add one day and then subtract a millisecond 
            // in order to set the time to the last millisecond of the day we want to search on
            endCalendar.add(Calendar.DATE, 1);
            endCalendar.add(Calendar.MILLISECOND, -1);
        }
        messageFilter.setEndDate(endCalendar);
    } catch (ParseException e) {
        parent.alertError(parent, "Invalid date.");
        return false;
    }

    Calendar startDate = messageFilter.getStartDate();
    Calendar endDate = messageFilter.getEndDate();

    if (startDate != null && endDate != null && startDate.getTimeInMillis() > endDate.getTimeInMillis()) {
        parent.alertError(parent, "Start date cannot be after the end date.");
        return false;
    }

    // Set text search
    String textSearch = StringUtils.trim(textSearchField.getText());

    if (textSearch.length() > 0) {
        messageFilter.setTextSearch(textSearch);
        List<String> textSearchMetaDataColumns = new ArrayList<String>();

        for (MetaDataColumn metaDataColumn : getMetaDataColumns()) {
            if (metaDataColumn.getType() == MetaDataColumnType.STRING) {
                textSearchMetaDataColumns.add(metaDataColumn.getName());
            }
        }

        messageFilter.setTextSearchMetaDataColumns(textSearchMetaDataColumns);
    }

    if (regexTextSearchCheckBox.isSelected()) {
        messageFilter.setTextSearchRegex(true);
    }

    // set status
    Set<Status> statuses = new HashSet<Status>();

    if (statusBoxReceived.isSelected()) {
        statuses.add(Status.RECEIVED);
    }

    if (statusBoxTransformed.isSelected()) {
        statuses.add(Status.TRANSFORMED);
    }

    if (statusBoxFiltered.isSelected()) {
        statuses.add(Status.FILTERED);
    }

    if (statusBoxSent.isSelected()) {
        statuses.add(Status.SENT);
    }

    if (statusBoxError.isSelected()) {
        statuses.add(Status.ERROR);
    }

    if (statusBoxQueued.isSelected()) {
        statuses.add(Status.QUEUED);
    }

    if (!statuses.isEmpty()) {
        messageFilter.setStatuses(statuses);
    }

    if (StringUtils.isNotEmpty(textSearch)
            && Preferences.userNodeForPackage(Mirth.class).getBoolean("textSearchWarning", true)) {
        JCheckBox dontShowTextSearchWarningCheckBox = new JCheckBox(
                "Don't show this message again in the future");

        String textSearchWarning = "<html>Text searching may take a long time, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>";
        String textRegexSearchWarning = "<html>Regular expression pattern matching may take a long time and be a costly operation, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>";
        String searchWarning = (regexTextSearchCheckBox.isSelected()) ? textRegexSearchWarning
                : textSearchWarning;
        Object[] params = new Object[] { searchWarning, dontShowTextSearchWarningCheckBox };
        int result = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        Preferences.userNodeForPackage(Mirth.class).putBoolean("textSearchWarning",
                !dontShowTextSearchWarningCheckBox.isSelected());

        if (result != JOptionPane.YES_OPTION) {
            return false;
        }
    }

    advancedSearchPopup.applySelectionsToFilter(messageFilter);
    selectedMetaDataIds = messageFilter.getIncludedMetaDataIds();

    if (messageFilter.getMaxMessageId() == null) {
        try {
            Long maxMessageId = parent.mirthClient.getMaxMessageId(channelId);
            messageFilter.setMaxMessageId(maxMessageId);
        } catch (ClientException e) {
            parent.alertThrowable(parent, e);
            return false;
        }
    }

    return true;
}

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  w  w  .  j  a va 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:com.nikonhacker.gui.EmulatorUI.java

private void openUIOptionsDialog() {
    JPanel options = new JPanel(new GridLayout(0, 1));
    options.setName("User Interface");
    // Button size
    ActionListener buttonSizeRadioListener = new ActionListener() {
        @Override//from  w  ww .  j  ava 2s  .  co  m
        public void actionPerformed(ActionEvent e) {
            prefs.setButtonSize(e.getActionCommand());
        }
    };
    JRadioButton small = new JRadioButton("Small");
    small.setActionCommand(BUTTON_SIZE_SMALL);
    small.addActionListener(buttonSizeRadioListener);
    if (BUTTON_SIZE_SMALL.equals(prefs.getButtonSize()))
        small.setSelected(true);
    JRadioButton medium = new JRadioButton("Medium");
    medium.setActionCommand(BUTTON_SIZE_MEDIUM);
    medium.addActionListener(buttonSizeRadioListener);
    if (BUTTON_SIZE_MEDIUM.equals(prefs.getButtonSize()))
        medium.setSelected(true);
    JRadioButton large = new JRadioButton("Large");
    large.setActionCommand(BUTTON_SIZE_LARGE);
    large.addActionListener(buttonSizeRadioListener);
    if (BUTTON_SIZE_LARGE.equals(prefs.getButtonSize()))
        large.setSelected(true);

    ButtonGroup group = new ButtonGroup();
    group.add(small);
    group.add(medium);
    group.add(large);

    // Close windows on stop
    final JCheckBox closeAllWindowsOnStopCheckBox = new JCheckBox("Close all windows on Stop");
    closeAllWindowsOnStopCheckBox.setSelected(prefs.isCloseAllWindowsOnStop());

    // Refresh interval
    JPanel refreshIntervalPanel = new JPanel();
    final JTextField refreshIntervalField = new JTextField(5);
    refreshIntervalPanel.add(new JLabel("Refresh interval for cpu, screen, etc. (ms):"));

    refreshIntervalField.setText("" + prefs.getRefreshIntervalMs());
    refreshIntervalPanel.add(refreshIntervalField);

    // Setup panel
    options.add(new JLabel("Button size :"));
    options.add(small);
    options.add(medium);
    options.add(large);
    options.add(closeAllWindowsOnStopCheckBox);
    options.add(refreshIntervalPanel);
    options.add(new JLabel("Larger value greatly increases emulation speed"));

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, options, "Preferences",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) {
        // save
        prefs.setButtonSize(group.getSelection().getActionCommand());
        prefs.setCloseAllWindowsOnStop(closeAllWindowsOnStopCheckBox.isSelected());
        int refreshIntervalMs = 0;
        try {
            refreshIntervalMs = Integer.parseInt(refreshIntervalField.getText());
        } catch (NumberFormatException e) {
            // noop
        }
        refreshIntervalMs = Math.max(Math.min(refreshIntervalMs, 10000), 10);
        prefs.setRefreshIntervalMs(refreshIntervalMs);
        applyPrefsToUI();
    }
}