Example usage for javax.swing JCheckBox getName

List of usage examples for javax.swing JCheckBox getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Gets the name of the component.

Usage

From source file:configuration.Util.java

private static void uspBoxComboboxVal(workflow_properties properties, HashMap<JCheckBox, JComboBox> BoxCombo) {
    for (JCheckBox cb : BoxCombo.keySet()) {
        boolean b = false;
        String k_s = cb.getName();
        if (properties.isSet(k_s)) {
            b = true;/*w w w.j a va 2 s.co  m*/
        }
        if (BoxCombo.get(cb) != null) {
            String v_s = BoxCombo.get(cb).getName();
            if (properties.isSet(v_s)) {
                String s_bk = properties.get(v_s);
                BoxCombo.get(cb).setSelectedItem(s_bk);
                BoxCombo.get(cb).setEnabled(false);
                if (b) {
                    properties.put(cb.getName(), s_bk);
                }
            }
        }
    }
}

From source file:configuration.Util.java

private static void uspBoxSpinVal(workflow_properties properties, HashMap<JCheckBox, JSpinner> BoxSpin) {
    for (JCheckBox cb : BoxSpin.keySet()) {
        boolean b = false;
        String k_s = cb.getName();
        if (properties.isSet(k_s)) {
            b = true;/*from   w  ww.  ja  v a 2s.  co m*/
        }
        if (BoxSpin.get(cb) != null) {
            String v_s = BoxSpin.get(cb).getName();
            if (properties.isSet(v_s)) {
                String s_bk = properties.get(v_s);
                if (valIsInt(v_s)) {
                    BoxSpin.get(cb).setValue(Integer.parseInt(s_bk));
                } else if (valIsDouble(v_s)) {
                    BoxSpin.get(cb).setValue(Double.parseDouble(s_bk));
                } else if (valIsFloat(v_s)) {
                    BoxSpin.get(cb).setValue(Float.parseFloat(s_bk));
                } else if (valIsByte(v_s)) {
                    BoxSpin.get(cb).setValue(Byte.parseByte(s_bk));
                } else if (valIsShort(v_s)) {
                    BoxSpin.get(cb).setValue(Short.parseShort(s_bk));
                } else if (valIsLong(v_s)) {
                    BoxSpin.get(cb).setValue(Long.parseLong(s_bk));
                }
                BoxSpin.get(cb).setEnabled(false);
                if (b) {
                    properties.put(cb.getName(), s_bk);
                }
            }
        }
    }
}

From source file:configuration.Util.java

private static void eao_BoxSpin(workflow_properties properties, boolean e,
        HashMap<JCheckBox, JSpinner> BoxSpin) {
    for (JCheckBox cb : BoxSpin.keySet()) {
        cb.setEnabled(e);// ww w  .  j ava2 s  .  c o  m
        if (BoxSpin.get(cb) != null) {
            String s = cb.getName();
            if (properties.isSet(s) && e == true) {
                BoxSpin.get(cb).setEnabled(true);
            } else {
                BoxSpin.get(cb).setEnabled(false);
            }
        }
    }
}

From source file:configuration.Util.java

private static void eao_BoxText(workflow_properties properties, boolean e,
        HashMap<JCheckBox, JTextField> BoxText) {
    for (JCheckBox cb : BoxText.keySet()) {
        cb.setEnabled(e);/*  ww w  .  j  av  a2  s  .  c o  m*/
        if (BoxText.get(cb) != null) {
            String s = cb.getName();
            if (properties.isSet(s) && e == true) {
                BoxText.get(cb).setEnabled(true);
            } else {
                BoxText.get(cb).setEnabled(false);
            }
        }
    }
}

From source file:configuration.Util.java

private static void eao_BoxCombo(workflow_properties properties, boolean e,
        HashMap<JCheckBox, JComboBox> BoxCombo) {
    for (JCheckBox cb : BoxCombo.keySet()) {
        cb.setEnabled(e);/*  w ww .j  a  v  a 2s  . c o m*/
        if (BoxCombo.get(cb) != null) {
            String s = cb.getName();
            if (properties.isSet(s) && e == true) {
                BoxCombo.get(cb).setEnabled(true);
            } else {
                BoxCombo.get(cb).setEnabled(false);
            }
        }
    }
}

From source file:com.xtructure.xevolution.gui.components.CollectArgsDialog.java

/**
 * Creates a new {@link CollectArgsDialog}
 * //from  w w  w.  j a va  2 s  .com
 * @param frame
 *            the parent JFrame for the new {@link CollectArgsDialog}
 * @param statusBar
 *            the {@link StatusBar} to update (can be null)
 * @param title
 *            the title of the new {@link CollectArgsDialog}
 * @param xOptions
 *            the {@link Collection} of {@link XOption}s for which to
 *            collect user input
 */
public CollectArgsDialog(JFrame frame, final StatusBar statusBar, String title,
        final Collection<XOption<?>> xOptions) {
    super(frame, title, true);

    argComponents = new ArrayList<JComponent>();

    final CollectArgsDialog dialog = this;
    JPanel panel = new JPanel(new GridBagLayout());
    getContentPane().add(panel);
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(3, 3, 3, 3);
    c.fill = GridBagConstraints.BOTH;

    int row = 0;
    for (XOption<?> xOption : xOptions) {
        if (xOption.getName() == null) {
            continue;
        }
        if (xOption.hasArg()) {
            JLabel label = new JLabel(xOption.getName());
            JTextField textField = new JTextField();
            textField.setName(xOption.getOpt());
            textField.setToolTipText(xOption.getDescription());
            argComponents.add(textField);
            c.gridx = 0;
            c.gridy = row;
            panel.add(label, c);
            c.gridx = 1;
            c.gridy = row;
            panel.add(textField, c);
        } else {
            JCheckBox checkBox = new JCheckBox(xOption.getName());
            checkBox.setName(xOption.getOpt());
            checkBox.setToolTipText(xOption.getDescription());
            argComponents.add(checkBox);
            c.gridx = 0;
            c.gridy = row;
            panel.add(checkBox, c);
        }
        row++;
    }

    JPanel buttonPanel = new JPanel();
    c.gridx = 1;
    c.gridy = row;
    panel.add(buttonPanel, c);

    JButton okButton = new JButton(new AbstractAction("OK") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            if (statusBar != null) {
                statusBar.setMessage("building args...");
            }
            ArrayList<String> args = new ArrayList<String>();
            for (JComponent component : argComponents) {
                if (component instanceof JCheckBox) {
                    JCheckBox checkbox = (JCheckBox) component;
                    String opt = checkbox.getName();
                    if (checkbox.isSelected()) {
                        args.add("-" + opt);
                    }
                }
                if (component instanceof JTextField) {
                    JTextField textField = (JTextField) component;
                    String opt = textField.getName();
                    String text = textField.getText().trim();
                    if (!text.isEmpty()) {
                        args.add("-" + opt);
                        args.add("\"" + text + "\"");
                    }
                }
            }
            if (statusBar != null) {
                statusBar.setMessage("parsing args...");
            }
            try {
                Options options = new Options();
                for (XOption<?> xOpt : xOptions) {
                    options.addOption(xOpt);
                }
                XOption.parseArgs(options, args.toArray(new String[0]));
                dialog.success = true;
            } catch (ParseException e1) {
                e1.printStackTrace();
                dialog.success = false;
            }
            if (statusBar != null) {
                statusBar.clearMessage();
            }
        }
    });
    buttonPanel.add(okButton);
    getRootPane().setDefaultButton(okButton);

    buttonPanel.add(new JButton(new AbstractAction("Cancel") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            if (statusBar != null) {
                statusBar.clearMessage();
            }
        }
    }));
    pack();
    setLocationRelativeTo(frame);
    setVisible(true);
}

From source file:configuration.Util.java

public static void boxEventSpinner(workflow_properties properties, javax.swing.JCheckBox b,
        javax.swing.JSpinner s) {
    if (b == null) {
        properties.put(s.getName(), s.getValue());
    } else {// w  w  w.j  a v a2s  . c om
        if (b.isSelected() == true) {
            if (s == null) {
                properties.put(b.getName(), b.isSelected());
            } else {
                s.setEnabled(true);
                properties.put(s.getName(), s.getValue());
                properties.put(b.getName(), s.getValue());
            }
        } else {
            properties.remove(b.getName());
            if (s != null) {
                s.setEnabled(false);
            }
        }
    }
}

From source file:configuration.Util.java

public static void boxEventText(workflow_properties properties, javax.swing.JCheckBox b,
        javax.swing.JTextField t) {
    if (b == null) {
        properties.put(t.getName(), t.getText());
    } else {//from   w  w w  .  j a  v  a 2s  .  c  o  m
        if (b.isSelected() == true) {
            if (t == null) {
                properties.put(b.getName(), b.isSelected());
            } else {
                t.setEnabled(true);
                properties.put(t.getName(), t.getText());
                properties.put(b.getName(), t.getText());
            }
        } else {
            properties.remove(b.getName());
            if (t != null) {
                t.setEnabled(false);
            }
        }
    }
}

From source file:configuration.Util.java

public static void boxEventComboBox(workflow_properties properties, javax.swing.JCheckBox b,
        javax.swing.JComboBox s) {
    if (b == null) {
        properties.put(s.getName(), s);/*from   w ww.  ja  v a2 s.c o  m*/
    } else {
        if (b.isSelected() == true) {
            String i = (String) s.getSelectedItem();
            if (s == null) {
                properties.put(b.getName(), b.isSelected());
            } else {
                s.setEnabled(true);
                properties.put(s.getName(), i);
                properties.put(b.getName(), i);
            }
        } else {
            properties.remove(b.getName());
            if (s != null) {
                s.setEnabled(false);
            }
        }
    }
}

From source file:ffx.ui.ModelingPanel.java

/**
 * Create a string representing the modeling command to execute.
 *
 * @return the modeling command string.// www  .ja  va2  s  .  com
 */
private String createCommandInput() {
    StringBuilder commandLineParams = new StringBuilder(activeCommand + " ");
    // Now append command line input to a TextArea, one option per line.
    // This TextArea gets dumped to an input file.
    commandTextArea.setText("");
    int numparams = optionsTabbedPane.getTabCount();
    for (int i = 0; i < numparams; i++) {
        // A few cases require that a newLine not be generated between
        // options.
        boolean newLine = true;
        // The optionString will collect the parameters for this Option,
        // then append them to the CommandTextArea.
        StringBuilder optionString = new StringBuilder();
        JPanel optionPanel = (JPanel) optionsTabbedPane.getComponentAt(i);
        int numOptions = optionPanel.getComponentCount();
        String title = optionsTabbedPane.getTitleAt(i);
        if (title.equalsIgnoreCase("Sequence")) {
            for (int k = 0; k < acidComboBox.getItemCount(); k++) {
                if (k != 0) {
                    optionString.append("\n");
                }
                String s = (String) acidComboBox.getItemAt(k);
                s = s.substring(s.indexOf(" "), s.length()).trim();
                optionString.append(s);
            }
            // Need an extra newline for Nucleic
            if (activeCommand.equalsIgnoreCase("NUCLEIC")) {
                optionString.append("\n");
            }
        } else {
            JPanel valuePanel = (JPanel) optionPanel.getComponent(numOptions - 1);
            int numValues = valuePanel.getComponentCount();
            for (int j = 0; j < numValues; j++) {
                Component value = valuePanel.getComponent(j);
                if (value instanceof JCheckBox) {
                    JCheckBox jcbox = (JCheckBox) value;
                    if (jcbox.isSelected()) {
                        optionString.append("-");
                        optionString.append(jcbox.getName());
                        optionString.append(" ");
                        optionString.append(jcbox.getText());
                    }
                } else if (value instanceof JTextField) {
                    JTextField jtfield = (JTextField) value;
                    optionString.append("-");
                    optionString.append(jtfield.getName());
                    optionString.append(" ");
                    optionString.append(jtfield.getText());
                } else if (value instanceof JComboBox) {
                    JComboBox jcb = (JComboBox) value;
                    Object object = jcb.getSelectedItem();
                    if (object instanceof FFXSystem) {
                        FFXSystem system = (FFXSystem) object;
                        File file = system.getFile();
                        if (file != null) {
                            String absolutePath = file.getAbsolutePath();
                            if (absolutePath.endsWith("xyz")) {
                                absolutePath = absolutePath + "_1";
                            }
                            optionString.append(absolutePath);
                        }
                    }
                } else if (value instanceof JRadioButton) {
                    JRadioButton jrbutton = (JRadioButton) value;
                    if (jrbutton.isSelected()) {
                        if (!jrbutton.getText().equalsIgnoreCase("NONE")) {
                            optionString.append("-");
                            optionString.append(jrbutton.getName());
                            optionString.append(" ");
                            optionString.append(jrbutton.getText());
                        }
                        if (title.equalsIgnoreCase("C-CAP")) {
                            optionString.append("\n");
                        }
                    }
                }
            }
            // Handle Conditional Options
            if (optionPanel.getComponentCount() == 3) {
                valuePanel = (JPanel) optionPanel.getComponent(1);
                // JLabel conditionalLabel = (JLabel)
                // valuePanel.getComponent(0);
                JTextField jtf = (JTextField) valuePanel.getComponent(1);
                if (jtf.isEnabled()) {
                    String conditionalInput = jtf.getText();
                    // Post-Process the Input into Atom Pairs
                    String postProcess = jtf.getName();
                    if (postProcess != null && postProcess.equalsIgnoreCase("ATOMPAIRS")) {
                        String tokens[] = conditionalInput.split(" +");
                        StringBuilder atomPairs = new StringBuilder();
                        int atomNumber = 0;
                        for (String token : tokens) {
                            atomPairs.append(token);
                            if (atomNumber++ % 2 == 0) {
                                atomPairs.append(" ");
                            } else {
                                atomPairs.append("\n");
                            }
                        }
                        conditionalInput = atomPairs.toString();
                    }
                    // Append a newline to "enter" the option string.
                    // Append "conditional" input.
                    optionString.append("\n").append(conditionalInput);
                }
            }
        }
        if (optionString.length() > 0) {
            commandTextArea.append(optionString.toString());
            if (newLine) {
                commandTextArea.append("\n");
            }
        }
    }
    String commandInput = commandTextArea.getText();
    if (commandInput != null && !commandInput.trim().equalsIgnoreCase("")) {
        commandLineParams.append(commandInput);
    }

    // The final token on the command line is the structure file name, except
    // for protein and nucleic.
    if (!activeCommand.equalsIgnoreCase("Protein") && !activeCommand.equalsIgnoreCase("Nucleic")) {
        File file = activeSystem.getFile();
        if (file != null) {
            String name = file.getName();
            commandLineParams.append(name);
            commandLineParams.append(" ");
        } else {
            return null;
        }
    }

    return commandLineParams.toString();
}