Example usage for javax.swing JTextField getName

List of usage examples for javax.swing JTextField getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Gets the name of the component.

Usage

From source file:it.txt.access.capability.revocation.wizard.panel.PanelRevocationData.java

private boolean isMissingTextField(JTextField textBox, StringBuilder missingFieldMessage) {
    if (textBox.getText().equals("")) {
        if (missingFieldMessage.length() > 0)
            missingFieldMessage.append(", " + textBox.getName());
        else/*from  w  ww. j  av  a  2 s. co  m*/
            missingFieldMessage.append(textBox.getName());
        return true;
    }
    return false;
}

From source file:configuration.Util.java

public static void buttonEventText(workflow_properties properties, javax.swing.JRadioButton b,
        javax.swing.JTextField t) {
    if (b == null) {
        properties.put(t.getName(), t.getText());
    } else {/*from w  w w .  j a va  2 s .c  om*/
        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());
            }
        }
    }
}

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 {/*w  ww .  j  a va2 s . c om*/
        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:ffx.ui.ModelingPanel.java

/**
 * Create a string representing the modeling command to execute.
 *
 * @return the modeling command string./* w w w .  j  av a  2s . c o  m*/
 */
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();
}

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

/**
 * Creates a new {@link CollectArgsDialog}
 * // w w w .  j  a va 2s  . co  m
 * @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:nz.govt.natlib.ndha.manualdeposit.StructMapFileDescMgmtPresenter.java

StructMapFileDescMgmtPresenter(final JList lstDescription, final JTextField textfldDescription,
        final JTextField textfldFilePrefix, final JCheckBox checkAllowMultiples, final JCheckBox checkMandatory,
        final JComboBox cmbPosition, final JTextField textfldDescriptionMain, final JCheckBox checkExtraLayers,
        final JTextField textfldDescriptionL2, final JTextField textfldFilePrefixL2,
        final JCheckBox checkAllowMultiplesL2, final JTextField textfldDescriptionL3,
        final JTextField textfldFilePrefixL3, final JCheckBox checkAllowMultiplesL3,
        final JTextField textfldDescriptionL4, final JTextField textfldFilePrefixL4,
        final JCheckBox checkAllowMultiplesL4, final JButton btnAddNew, final JButton btnDelete,
        final JButton btnSave, final JButton btnCancel, final JButton btnClose, final JButton btnMoveUp,
        final JButton btnMoveDown, final JButton btnGenMainDesc, final String xmlFileName,
        final IStructMapFileDescManagement theForm) {
    jlstDescription = lstDescription;/*from   ww w.  ja  v a  2  s  .  c  o  m*/
    this.textfldDescription = textfldDescription;
    this.textfldFilePrefix = textfldFilePrefix;
    this.checkAllowMultiples = checkAllowMultiples;
    this.checkMandatory = checkMandatory;
    cmboPosition = cmbPosition;
    this.checkExtraLayers = checkExtraLayers;
    this.textfldDescriptionMain = textfldDescriptionMain;

    // Extra Layers
    extraLayers = new HashMap<String, JComponent>();
    extraLayers.put(textfldDescriptionL2.getName(), textfldDescriptionL2);
    extraLayers.put(textfldFilePrefixL2.getName(), textfldFilePrefixL2);
    extraLayers.put(checkAllowMultiplesL2.getName(), checkAllowMultiplesL2);
    extraLayers.put(textfldDescriptionL3.getName(), textfldDescriptionL3);
    extraLayers.put(textfldFilePrefixL3.getName(), textfldFilePrefixL3);
    extraLayers.put(checkAllowMultiplesL3.getName(), checkAllowMultiplesL3);
    extraLayers.put(textfldDescriptionL4.getName(), textfldDescriptionL4);
    extraLayers.put(textfldFilePrefixL4.getName(), textfldFilePrefixL4);
    extraLayers.put(checkAllowMultiplesL4.getName(), checkAllowMultiplesL4);

    bttnAddNew = btnAddNew;
    bttnDelete = btnDelete;
    bttnSave = btnSave;
    bttnCancel = btnCancel;
    bttnClose = btnClose;
    bttnMoveUp = btnMoveUp;
    bttnMoveDown = btnMoveDown;
    bttnGenMainDesc = btnGenMainDesc;
    theXmlFileName = xmlFileName;
    theStructForm = theForm;
    loadData();

    // Restrict the values of this combo box to that of possible "Position"
    // enums
    cmboPosition.setModel(new DefaultComboBoxModel(FileType.Position.values()));
    // Restrict the contents of the description and file prefix to not allow
    // special characters
    textfldDescription.setDocument(new SpecialCharFilterDocument());
    textfldFilePrefix.setDocument(new SpecialCharFilterDocument());

    loadListData();
    addEventHandlers();
    checkButtons();
}

From source file:org.codinjutsu.tools.jenkins.view.validator.NotNullValidator.java

public void validate(JTextField component) throws ConfigurationException {
    if (component.isEnabled()) { //TODO a revoir
        String value = component.getText();
        if (StringUtils.isEmpty(value)) {
            throw new ConfigurationException(String.format("'%s' must be set", component.getName()));
        }/*from  ww  w . j a  v a 2s.  c  o m*/
    }
}