Example usage for javax.swing JTextArea getText

List of usage examples for javax.swing JTextArea getText

Introduction

In this page you can find the example usage for javax.swing JTextArea getText.

Prototype

public String getText() 

Source Link

Document

Returns the text contained in this TextComponent.

Usage

From source file:cool.pandora.modeller.ui.jpanel.base.BagInfoForm.java

/**
 * getBagInfoMap.//ww  w .  j  ava 2 s  .c  om
 *
 * @return map
 */
public HashMap<String, String> getBagInfoMap() {
    final HashMap<String, String> map = new HashMap<>();
    String key = "";
    String value = "";
    final Component[] components = getFieldComponents();
    for (int i = 0; i < components.length; i++) {
        Component c;
        c = components[i];
        if (c instanceof JLabel) {
            final JLabel label = (JLabel) c;
            key = label.getText();
        }
        i++;
        // Is required component
        c = components[i];
        i++;
        c = components[i];
        if (c instanceof JTextField) {
            final JTextField tf = (JTextField) c;
            value = tf.getText();
        } else if (c instanceof JTextArea) {
            final JTextArea ta = (JTextArea) c;
            value = ta.getText();
        } else if (c instanceof JComboBox) {
            final JComboBox<?> tb = (JComboBox<?>) c;
            value = (String) tb.getSelectedItem();
        }
        map.put(key, value);
        i++;
        c = components[i];
    }
    return map;
}

From source file:CubaHSQLDBServer.java

private void addCopyPopup(final JTextArea source) {
    final JPopupMenu popup = new JPopupMenu();
    popup.add(new AbstractAction("Copy to clipboard") {
        @Override/*from  www  .j  a va 2 s .  c  o m*/
        public void actionPerformed(ActionEvent e) {
            StringSelection contents = new StringSelection(source.getText());
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, contents);
        }
    });
    source.add(popup);
    source.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show(source, e.getX(), e.getY());
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show(source, e.getX(), e.getY());
            }
        }
    });
}

From source file:com.hexidec.ekit.component.HTMLUtilities.java

public void delete() throws BadLocationException, IOException {
    JTextPane jtpMain = parent.getTextPane();
    JTextArea jtpSource = parent.getSourcePane();
    ExtendedHTMLDocument htmlDoc = parent.getExtendedHtmlDoc();
    int selStart = jtpMain.getSelectionStart();
    int selEnd = jtpMain.getSelectionEnd();
    String[] posStrings = getUniString(2);
    if (posStrings == null) {
        return;/*from   w  w  w .  j a va2s.  c om*/
    }
    htmlDoc.insertString(selStart, posStrings[0], null);
    htmlDoc.insertString(selEnd + posStrings[0].length(), posStrings[1], null);
    parent.refreshOnUpdate();
    int start = jtpSource.getText().indexOf(posStrings[0]);
    int end = jtpSource.getText().indexOf(posStrings[1]);
    if (start == -1 || end == -1) {
        return;
    }
    String htmlString = new String();
    htmlString += jtpSource.getText().substring(0, start);
    htmlString += jtpSource.getText().substring(start + posStrings[0].length(), end);
    htmlString += jtpSource.getText().substring(end + posStrings[1].length(), jtpSource.getText().length());
    String source = htmlString;
    end = end - posStrings[0].length();
    htmlString = new String();
    htmlString += source.substring(0, start);
    htmlString += getAllTableTags(source.substring(start, end));
    htmlString += source.substring(end, source.length());
    parent.getTextPane().setText(htmlString);
    parent.refreshOnUpdate();
}

From source file:hermes.renderers.DefaultMessageRenderer.java

/**
 * Show the TextMessage in a JTextArea./*from w  ww .  ja v a2s.c o m*/
 * 
 * @param textMessage
 * @return
 * @throws JMSException
 */
protected JComponent handleTextMessage(final TextMessage textMessage) throws JMSException {
    //
    // Show the text in a JTextArea, you can edit the message in place and
    // then drop it onto another queue/topic.

    final String text = textMessage.getText();
    final JTextArea textPane = new JTextArea();

    // final CharBuffer bytes = CharBuffer.wrap(text.subSequence(0,
    // text.length())) ;
    // final JTextArea textPane = new MyTextArea(new PlainDocument(new
    // MappedStringContent(bytes))) ;

    textPane.setEditable(false);
    textPane.setFont(Font.decode("Monospaced-PLAIN-12"));
    textPane.setLineWrap(true);
    textPane.setWrapStyleWord(true);

    textPane.append(text);

    textPane.getDocument().addDocumentListener(new DocumentListener() {
        public void doChange() {
            try {
                textMessage.setText(textPane.getText());
            } catch (JMSException e) {
                JOptionPane.showMessageDialog(textPane, "Unable to update the TextMessage: " + e.getMessage(),
                        "Error modifying message content", JOptionPane.ERROR_MESSAGE);

                try {
                    textPane.setText(textMessage.getText());
                } catch (JMSException e1) {
                    log.error(e1.getMessage(), e1);
                }

                textPane.setEditable(false);
                textPane.getDocument().removeDocumentListener(this);
            }
        }

        @Override
        public void changedUpdate(DocumentEvent arg0) {
            doChange();
        }

        @Override
        public void insertUpdate(DocumentEvent arg0) {
            doChange();
        }

        @Override
        public void removeUpdate(DocumentEvent arg0) {
            doChange();
        }
    });

    textPane.setCaretPosition(0);

    return textPane;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTextArea.java

@Override
protected JTextArea createTextComponentImpl() {
    final JTextArea impl = new TextAreaFlushableField();

    if (isTabTraversal()) {
        Set<KeyStroke> forwardFocusKey = Collections.singleton(getKeyStroke(KeyEvent.VK_TAB, 0));
        impl.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardFocusKey);

        Set<KeyStroke> backwardFocusKey = Collections
                .singleton(getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK));
        impl.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardFocusKey);

        impl.addKeyListener(new KeyAdapter() {
            @Override/* w w  w  .j av  a  2s.  com*/
            public void keyPressed(KeyEvent e) {
                if (isEnabled() && isEditable() && e.getKeyCode() == KeyEvent.VK_TAB
                        && e.getModifiers() == KeyEvent.CTRL_MASK) {

                    if (StringUtils.isEmpty(impl.getText())) {
                        impl.setText("\t");
                    } else {
                        impl.append("\t");
                    }
                }
            }
        });
    }

    impl.setLineWrap(true);
    impl.setWrapStyleWord(true);

    int height = (int) impl.getPreferredSize().getHeight();
    impl.setMinimumSize(new Dimension(0, height));

    composition = new JScrollPane(impl);
    composition.setPreferredSize(new Dimension(150, height));
    composition.setMinimumSize(new Dimension(0, height));

    doc.putProperty("filterNewlines", false);

    return impl;
}

From source file:hspc.submissionsprogram.AppDisplay.java

AppDisplay() {
    this.setTitle("Dominion High School Programming Contest");
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.setResizable(false);

    WindowListener exitListener = new WindowAdapter() {
        @Override/*from   www.  j a v  a  2s .c  o m*/
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    this.addWindowListener(exitListener);

    JTabbedPane pane = new JTabbedPane();
    this.add(pane);

    JPanel submitPanel = new JPanel(null);
    submitPanel.setPreferredSize(new Dimension(500, 500));

    UIManager.put("FileChooser.readOnly", true);
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setBounds(0, 0, 500, 350);
    fileChooser.setVisible(true);
    FileNameExtensionFilter javaFilter = new FileNameExtensionFilter("Java files (*.java)", "java");
    fileChooser.setFileFilter(javaFilter);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setControlButtonsAreShown(false);
    submitPanel.add(fileChooser);

    JSeparator separator1 = new JSeparator();
    separator1.setBounds(12, 350, 476, 2);
    separator1.setForeground(new Color(122, 138, 152));
    submitPanel.add(separator1);

    JLabel problemChooserLabel = new JLabel("Problem:");
    problemChooserLabel.setBounds(12, 360, 74, 25);
    submitPanel.add(problemChooserLabel);

    String[] listOfProblems = Main.Configuration.get("problem_names")
            .split(Main.Configuration.get("name_delimiter"));
    JComboBox problems = new JComboBox<>(listOfProblems);
    problems.setBounds(96, 360, 393, 25);
    submitPanel.add(problems);

    JButton submit = new JButton("Submit");
    submit.setBounds(170, 458, 160, 30);
    submit.addActionListener(e -> {
        try {
            File file = fileChooser.getSelectedFile();
            try {
                CloseableHttpClient httpClient = HttpClients.createDefault();
                HttpPost uploadFile = new HttpPost(Main.Configuration.get("submit_url"));

                MultipartEntityBuilder builder = MultipartEntityBuilder.create();
                builder.addTextBody("accountID", Main.accountID, ContentType.TEXT_PLAIN);
                builder.addTextBody("problem", String.valueOf(problems.getSelectedItem()),
                        ContentType.TEXT_PLAIN);
                builder.addBinaryBody("submission", file, ContentType.APPLICATION_OCTET_STREAM, file.getName());
                HttpEntity multipart = builder.build();

                uploadFile.setEntity(multipart);

                CloseableHttpResponse response = httpClient.execute(uploadFile);
                HttpEntity responseEntity = response.getEntity();
                String inputLine;
                BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
                try {
                    if ((inputLine = br.readLine()) != null) {
                        int rowIndex = Integer.parseInt(inputLine);
                        new ResultWatcher(rowIndex);
                    }
                    br.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } catch (NullPointerException ex) {
            JOptionPane.showMessageDialog(this, "No file selected.\nPlease select a java file.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
    });
    submitPanel.add(submit);

    JPanel clarificationsPanel = new JPanel(null);
    clarificationsPanel.setPreferredSize(new Dimension(500, 500));

    cList = new JList<>();
    cList.setBounds(12, 12, 476, 200);
    cList.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    cList.setBackground(new Color(254, 254, 255));
    clarificationsPanel.add(cList);

    JButton viewC = new JButton("View");
    viewC.setBounds(12, 224, 232, 25);
    viewC.addActionListener(e -> {
        if (cList.getSelectedIndex() != -1) {
            int id = Integer.parseInt(cList.getSelectedValue().split("\\.")[0]);
            clarificationDatas.stream().filter(data -> data.getId() == id).forEach(
                    data -> new ClarificationDisplay(data.getProblem(), data.getText(), data.getResponse()));
        }
    });
    clarificationsPanel.add(viewC);

    JButton refreshC = new JButton("Refresh");
    refreshC.setBounds(256, 224, 232, 25);
    refreshC.addActionListener(e -> updateCList(true));
    clarificationsPanel.add(refreshC);

    JSeparator separator2 = new JSeparator();
    separator2.setBounds(12, 261, 476, 2);
    separator2.setForeground(new Color(122, 138, 152));
    clarificationsPanel.add(separator2);

    JLabel problemChooserLabelC = new JLabel("Problem:");
    problemChooserLabelC.setBounds(12, 273, 74, 25);
    clarificationsPanel.add(problemChooserLabelC);

    JComboBox problemsC = new JComboBox<>(listOfProblems);
    problemsC.setBounds(96, 273, 393, 25);
    clarificationsPanel.add(problemsC);

    JTextArea textAreaC = new JTextArea();
    textAreaC.setLineWrap(true);
    textAreaC.setWrapStyleWord(true);
    textAreaC.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    textAreaC.setBackground(new Color(254, 254, 255));

    JScrollPane areaScrollPane = new JScrollPane(textAreaC);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setBounds(12, 312, 477, 134);
    clarificationsPanel.add(areaScrollPane);

    JButton submitC = new JButton("Submit Clarification");
    submitC.setBounds(170, 458, 160, 30);
    submitC.addActionListener(e -> {
        if (textAreaC.getText().length() > 2048) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too long.\nMaximum of 2048 characters allowed.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        } else if (textAreaC.getText().length() < 20) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too short.\nClarifications must be at least 20 characters, but no more than 2048.",
                    "Error", JOptionPane.WARNING_MESSAGE);
        } else {
            Connection conn = null;
            PreparedStatement stmt = null;
            try {
                Class.forName(JDBC_DRIVER);

                conn = DriverManager.getConnection(Main.Configuration.get("jdbc_mysql_address"),
                        Main.Configuration.get("mysql_user"), Main.Configuration.get("mysql_pass"));

                String sql = "INSERT INTO clarifications (team, problem, text) VALUES (?, ?, ?)";
                stmt = conn.prepareStatement(sql);

                stmt.setInt(1, Integer.parseInt(String.valueOf(Main.accountID)));
                stmt.setString(2, String.valueOf(problemsC.getSelectedItem()));
                stmt.setString(3, String.valueOf(textAreaC.getText()));

                textAreaC.setText("");

                stmt.executeUpdate();

                stmt.close();
                conn.close();

                updateCList(false);
            } catch (Exception ex) {
                ex.printStackTrace();
            } finally {
                try {
                    if (stmt != null) {
                        stmt.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
                try {
                    if (conn != null) {
                        conn.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
            }
        }
    });
    clarificationsPanel.add(submitC);

    pane.addTab("Submit", submitPanel);
    pane.addTab("Clarifications", clarificationsPanel);

    Timer timer = new Timer();
    TimerTask updateTask = new TimerTask() {
        @Override
        public void run() {
            updateCList(false);
        }
    };
    timer.schedule(updateTask, 10000, 10000);

    updateCList(false);

    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
}

From source file:edu.smc.mediacommons.panels.SecurityPanel.java

public SecurityPanel() {
    setLayout(null);/*from  www  .  jav  a  2s .  c o m*/

    FILE_CHOOSER = new JFileChooser();

    JButton openFile = Utils.createButton("Open File", 10, 20, 100, 30, null);
    add(openFile);

    JButton saveFile = Utils.createButton("Save File", 110, 20, 100, 30, null);
    add(saveFile);

    JButton decrypt = Utils.createButton("Decrypt", 210, 20, 100, 30, null);
    add(decrypt);

    JButton encrypt = Utils.createButton("Encrypt", 310, 20, 100, 30, null);
    add(encrypt);

    JTextField path = Utils.createTextField(10, 30, 300, 20);
    path.setText("No file selected");

    final JTextArea viewer = new JTextArea();
    JScrollPane pastePane = new JScrollPane(viewer);
    pastePane.setBounds(15, 60, 400, 200);
    add(pastePane);

    openFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (FILE_CHOOSER.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) {
                File toRead = FILE_CHOOSER.getSelectedFile();

                if (toRead == null) {
                    JOptionPane.showMessageDialog(getParent(), "The input file does not exist!",
                            "Opening Failed...", JOptionPane.WARNING_MESSAGE);
                } else {
                    try {
                        List<String> lines = IOUtils.readLines(new FileInputStream(toRead), "UTF-8");

                        viewer.setText("");

                        for (String line : lines) {
                            viewer.append(line);
                        }
                    } catch (IOException ex) {

                    }
                }
            }
        }
    });

    saveFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (FILE_CHOOSER.showSaveDialog(getParent()) == JFileChooser.APPROVE_OPTION) {
                File toWrite = FILE_CHOOSER.getSelectedFile();

                Utils.writeToFile(viewer.getText(), toWrite);
                JOptionPane.showMessageDialog(getParent(),
                        "The file has now been saved to\n" + toWrite.getPath());
            }
        }
    });

    encrypt.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String password = Utils.getPasswordInput(getParent());

            if (password != null) {
                try {
                    BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor();
                    basicTextEncryptor.setPassword(password);

                    String text = basicTextEncryptor.encrypt(viewer.getText());
                    viewer.setText(text);
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(getParent(),
                            "Could not encrypt the text, an unexpected error occurred.", "Encryption Failed...",
                            JOptionPane.WARNING_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(getParent(),
                        "Could not encrypt the text, as no\npassword has been specified.",
                        "Encryption Failed...", JOptionPane.WARNING_MESSAGE);
            }
        }
    });

    decrypt.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String password = Utils.getPasswordInput(getParent());

            if (password != null) {
                try {
                    BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor();
                    basicTextEncryptor.setPassword(password);

                    String text = basicTextEncryptor.decrypt(viewer.getText());
                    viewer.setText(text);
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(getParent(),
                            "Could not decrypt the text, an unexpected error occurred.", "Decryption Failed...",
                            JOptionPane.WARNING_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(getParent(),
                        "Could not decrypt the text, as no\npassword has been specified.",
                        "Decryption Failed...", JOptionPane.WARNING_MESSAGE);
            }
        }
    });
}

From source file:edu.ku.brc.specify.config.FeedBackDlg.java

@Override
protected FeedBackSenderItem getFeedBackSenderItem(final Class<?> cls, final Exception exception) {
    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,f:p:g", "p,4px,p,4px,p,4px,p,4px,f:p:g"));

    Vector<String> taskItems = new Vector<String>();
    for (Taskable task : TaskMgr.getInstance().getAllTasks()) {
        taskItems.add(task.getTitle());//w ww .jav  a 2 s.  c  o m
    }

    String[] OTHERS = { "WEBSITE", "CSTSUP", "INSTL", "DOC", "WHTPR", "HLP" };
    for (String key : OTHERS) {
        taskItems.add(UIRegistry.getResourceString("FeedBackDlg." + key));
    }
    Collections.sort(taskItems);

    final JComboBox taskCBX = createComboBox(taskItems);
    final JTextField subjectTF = createTextField();
    final JTextField issueTF = createTextField();
    final JTextArea commentsTA = createTextArea(15, 60);

    int y = 1;
    pb.add(createI18NLabel("FeedBackDlg.INFO"), cc.xyw(1, y, 4));
    y += 2;

    pb.add(createI18NFormLabel("FeedBackDlg.SUB"), cc.xy(1, y));
    pb.add(subjectTF, cc.xyw(3, y, 2));
    y += 2;

    pb.add(createI18NFormLabel("FeedBackDlg.COMP"), cc.xy(1, y));
    pb.add(taskCBX, cc.xy(3, y));
    y += 2;

    //pb.add(createFormLabel("Question/Issue"), cc.xy(1, y));
    //pb.add(issueTF,                           cc.xyw(3, y, 2)); y += 2;

    pb.add(createI18NFormLabel("FeedBackDlg.COMM"), cc.xy(1, y));
    y += 2;
    pb.add(createScrollPane(commentsTA, true), cc.xyw(1, y, 4));
    y += 2;

    Taskable currTask = SubPaneMgr.getInstance().getCurrentSubPane().getTask();
    taskCBX.setSelectedItem(currTask != null ? currTask : TaskMgr.getDefaultTaskable());

    pb.setDefaultDialogBorder();
    CustomDialog dlg = new CustomDialog((Frame) null, UIRegistry.getResourceString("FeedBackDlg.TITLE"), true,
            pb.getPanel());

    centerAndShow(dlg);

    if (!dlg.isCancelled()) {
        String taskTitle = (String) taskCBX.getSelectedItem();
        if (taskTitle != null) {
            for (Taskable task : TaskMgr.getInstance().getAllTasks()) {
                if (task.getTitle().equals(taskTitle)) {
                    taskTitle = task.getName();
                }
            }
        } else {
            taskTitle = "No Task Name";
        }
        FeedBackSenderItem item = new FeedBackSenderItem(taskTitle, subjectTF.getText(), issueTF.getText(),
                commentsTA.getText(), "", cls != null ? cls.getName() : "");
        return item;
    }
    return null;
}

From source file:it.imtech.metadata.MetaUtility.java

private String check_and_save_metadata_recursive(Map<Object, Metadata> submetadatas, boolean checkMandatory) {
    ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader);
    String error = "";

    for (Map.Entry<Object, Metadata> field : submetadatas.entrySet()) {
        if (!field.getValue().datatype.equals("Node") && field.getValue().editable.equals("Y")) {
            Component element = null;
            String midp = Integer.toString(field.getValue().MID_parent);

            if (midp.equals("11") || midp.equals("13"))
                element = BookImporter.getInstance().getComponentByName(
                        "MID_" + Integer.toString(field.getValue().MID) + "---" + field.getValue().sequence);
            else {
                element = BookImporter.getInstance()
                        .getComponentByName("MID_" + Integer.toString(field.getValue().MID));
            }//from   w w  w  . j  av  a  2 s .  c  om

            if (element != null) {
                if (field.getValue().datatype.equals("CharacterString")
                        || field.getValue().datatype.equals("LangString")
                        || field.getValue().datatype.equals("GPS")) {
                    JTextArea textTemp = (JTextArea) element;
                    field.getValue().value = textTemp.getText();

                    if (checkMandatory && field.getValue().value.length() < 1
                            && (field.getValue().mandatory.equals("Y") || field.getValue().MID == 14
                                    || field.getValue().MID == 15)) {
                        error += Utility.getBundleString("error10", bundle) + " "
                                + field.getValue().description.toString() + " "
                                + Utility.getBundleString("error11", bundle) + "!\n";
                    }
                }
                if (field.getValue().datatype.equals("LangString")) {
                    Component combobox = BookImporter.getInstance()
                            .getComponentByName("MID_" + Integer.toString(field.getValue().MID) + "_lang");
                    JComboBox tmp = (JComboBox) combobox;

                    Map.Entry tmp2 = (Map.Entry) tmp.getSelectedItem();
                    field.getValue().language = tmp2.getKey().toString();
                } else if (field.getValue().datatype.equals("DateTime")) {
                    Component combobox = BookImporter.getInstance()
                            .getComponentByName("MID_" + Integer.toString(field.getValue().MID) + "_check");
                    JCheckBox beforechrist = (JCheckBox) combobox;

                    JDateChooser datePicker = (JDateChooser) element;
                    Date data = datePicker.getDate();

                    field.getValue().value = "";

                    if (data != null) {
                        Format formatter = new SimpleDateFormat("yyyy-MM-dd");
                        String stDate = formatter.format(data);

                        if (!stDate.equals("")) {
                            if (beforechrist.isSelected()) {
                                stDate = "-" + stDate;
                            }

                            field.getValue().value = stDate;
                        }
                    }
                } else if (field.getValue().datatype.equals("Language")
                        || field.getValue().datatype.equals("Boolean")
                        || field.getValue().datatype.equals("License")
                        || field.getValue().datatype.equals("Vocabulary")) {
                    Component combobox = null;

                    if (midp.equals("11") || midp.equals("13"))
                        combobox = BookImporter.getInstance().getComponentByName("MID_"
                                + Integer.toString(field.getValue().MID) + "---" + field.getValue().sequence);
                    else
                        combobox = BookImporter.getInstance()
                                .getComponentByName("MID_" + Integer.toString(field.getValue().MID));

                    JComboBox tmp = (JComboBox) combobox;

                    Map.Entry tmp2 = (Map.Entry) tmp.getSelectedItem();

                    if (field.getValue().datatype.equals("License")
                            || field.getValue().datatype.equals("Vocabulary")) {
                        ResourceBundle tmpBundle = ResourceBundle.getBundle(Globals.RESOURCES,
                                Globals.CURRENT_LOCALE, Globals.loader);

                        if (checkMandatory
                                && tmp2.getValue().toString()
                                        .equals(Utility.getBundleString("comboselect", tmpBundle))
                                && field.getValue().mandatory.equals("Y"))
                            error += Utility.getBundleString("error10", bundle) + " "
                                    + field.getValue().description.toString() + " "
                                    + Utility.getBundleString("error11", bundle) + "!\n";
                        else if (tmp2.getValue().toString()
                                .equals(Utility.getBundleString("comboselect", tmpBundle)))
                            field.getValue().value = "";
                        else
                            field.getValue().value = tmp2.getValue().toString();
                    } else
                        field.getValue().value = tmp2.getKey().toString();
                }
            } else {
                if (midp.equals("11") || midp.equals("13")) {
                    field.getValue().value = "";
                }
            }
        }

        error += check_and_save_metadata_recursive(field.getValue().submetadatas, checkMandatory);
    }

    return error;
}

From source file:search2go.UIFrame.java

private void map(JFormattedTextField bitScore, JFormattedTextField eValue, JComboBox originDB, JTextArea output,
        boolean fullProcess) {
    currentProj.setSelectedDBIndex(originDB.getSelectedIndex());
    currentProj.setBitScoreThreshold(Integer.parseInt(bitScore.getText()));
    currentProj.setEthreshold(Integer.parseInt(txtMapE.getText()));
    mapSequence = new ProcessSequence(currentProj, new ProcessSequenceEnd() {
        @Override/*from w  w w.j  a  va  2s .  c o m*/
        public void run() {
            if (!output.getText().contains(
                    "No valid hits found. Please retry with lower bit score or higher e-value thresholds.")) {
                if (currentProj.willDoCC())
                    currentProj.setStage(0, 2);
                if (currentProj.willDoBP())
                    currentProj.setStage(1, 2);
                if (currentProj.willDoBP())
                    currentProj.setStage(2, 2);
                output.append("Mapping done! Please proceed to Identification.\n");
                if (fullProcess) {
                    output.append("Identifying...\n");
                    identify(true);
                }
            }
            currentProj.setAvailable(true);
            prgMapping.setIndeterminate(false);
            mapButton.restore();
        }
    });

    Process mapProcess = new Process(output);

    Path mapScriptPath = new Path("Processes");
    mapScriptPath.append("MapFromBlast.py");
    mapProcess.setScriptCommand(mapScriptPath.toEscString());

    mapSequence.addProcess(mapProcess);
    mapProcess.addParameter("dir", currentProj.getPath().toEscString());
    if (!bitScore.getText().equals(""))
        mapProcess.addParameter("bs", bitScore.getText());
    if (!eValue.getText().equals(""))
        mapProcess.addParameter("e", eValue.getText());
    mapProcess.addParameter("id", originDB.getSelectedItem().toString().replaceAll(" ", ""));
    Path blastLoc = new Path(currentProj.getPath());
    blastLoc.append("BLAST_Results.xml");
    mapProcess.addParameter("o", blastLoc.toString());
    mapProcess.addParameter("gdb", currentProj.getTargetDBString());

    try {
        mapSequence.start();
        mapButton.setStopTargets(mapSequence);
        if (!fullProcess)
            mapButton.activate();
        if (currentProj.willDoCC())
            currentProj.setStage(0, 1);
        if (currentProj.willDoBP())
            currentProj.setStage(1, 1);
        if (currentProj.willDoBP())
            currentProj.setStage(2, 1);
        System.out.println(currentProj.getStage());
        output.setText("Mapping...\n");
        prgMapping.setIndeterminate(true);
    } catch (IOException ex) {
        javax.swing.JOptionPane.showMessageDialog(this, "Error running mapping program.");
    }
}