Example usage for com.jgoodies.binding.adapter BasicComponentFactory createTextArea

List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createTextArea

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter BasicComponentFactory createTextArea.

Prototype

public static JTextArea createTextArea(ValueModel valueModel, boolean commitOnFocusLost) 

Source Link

Document

Creates and returns a text area with the content bound to the given ValueModel.

Usage

From source file:com.stefanbrenner.droplet.ui.ProcessingPanel.java

License:Open Source License

/**
 * Create the panel./*w w  w. java  2s . c o  m*/
 * 
 * @param dropletContext
 *            the droplet context to be set
 */
public ProcessingPanel(final IDropletContext dropletContext) {

    this.metadata = dropletContext.getMetadata();
    this.metadataService = new XMPMetadataService(metadata, dropletContext);

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createTitledBorder(Messages.getString("ProcessingPanel.title"))); //$NON-NLS-1$
    setMinimumSize(new Dimension(400, 200));

    BeanAdapter<IMetadata> adapter = new BeanAdapter<IMetadata>(metadata, true);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.fill = GridBagConstraints.BOTH;

    cbEnable = new JCheckBox(Messages.getString("ProcessingPanel.writeMetadata")); //$NON-NLS-1$
    cbEnable.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent action) {
            updateState();
        }
    });
    UiUtils.editGridBagConstraints(gbc, 0, 0, 0, 0, GridBagConstraints.WEST);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(cbEnable, gbc);

    // reset gridwidth
    gbc.gridwidth = 1;

    // watch folder label
    UiUtils.editGridBagConstraints(gbc, 0, 1, 0, 0, GridBagConstraints.WEST);
    add(new JLabel(Messages.getString("ProcessingPanel.watchFolder")), gbc); //$NON-NLS-1$

    {
        JPanel watchFolderPanel = new JPanel();
        watchFolderPanel.setLayout(new BorderLayout());
        UiUtils.editGridBagConstraints(gbc, 1, 1, 1, 0);
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        add(watchFolderPanel, gbc);

        // reset gridwidth
        gbc.gridwidth = 1;

        txtWatchFolder = new JTextField();
        txtWatchFolder.setEditable(false);
        watchFolderPanel.add(txtWatchFolder, BorderLayout.CENTER);

        // file chooser for watch folder
        fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

        // watch folder button
        JButton btnWatchFolder = new JButton("..."); //$NON-NLS-1$
        btnWatchFolder.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent evt) {
                int returnVal = fileChooser.showOpenDialog(ProcessingPanel.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File directory = fileChooser.getSelectedFile();
                    txtWatchFolder.setText(directory.getAbsolutePath());
                    metadataService.setWatchFolder(directory.toURI());
                    Configuration.setWathFolder(directory.toURI());
                }
            }
        });
        watchFolderPanel.add(btnWatchFolder, BorderLayout.EAST);
    }

    // comments label
    UiUtils.editGridBagConstraints(gbc, 0, 2, 0, 1, GridBagConstraints.NORTHEAST);
    add(new JLabel(Messages.getString("ProcessingPanel.comments")), gbc); //$NON-NLS-1$

    txtComments = BasicComponentFactory.createTextArea(adapter.getValueModel(IMetadata.PROPERTY_DESCRIPTION),
            false);
    txtComments.setRows(4);
    txtComments.setColumns(20);
    txtComments.setFont(DropletFonts.FONT_STANDARD_SMALL);
    txtComments.setLineWrap(true);
    UiUtils.disableTab(txtComments);
    JScrollPane commentsScrollPane = new JScrollPane(txtComments);
    UiUtils.editGridBagConstraints(gbc, 1, 2, 1, 1);
    commentsScrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    add(commentsScrollPane, gbc);

    // tag label
    UiUtils.editGridBagConstraints(gbc, 2, 2, 0, 1, GridBagConstraints.NORTHEAST);
    add(new JLabel(Messages.getString("ProcessingPanel.tags")), gbc); //$NON-NLS-1$

    txtTags = BasicComponentFactory.createTextArea(adapter.getValueModel(IMetadata.PROPERTY_TAGS), false);
    txtTags.setRows(4);
    txtTags.setColumns(20);
    txtTags.setFont(DropletFonts.FONT_STANDARD_SMALL);
    txtTags.setLineWrap(true);
    UiUtils.disableTab(txtTags);
    JScrollPane tagScrollPane = new JScrollPane(txtTags);
    UiUtils.editGridBagConstraints(gbc, 3, 2, 1, 1, GridBagConstraints.EAST);
    tagScrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    add(tagScrollPane, gbc);

    initValuesFromConfiguration();
    updateState();
}

From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java

License:Open Source License

public static JTextArea createTextArea(ValueModel valueModel, boolean commitOnFocusLost) {
    JTextArea textArea = BasicComponentFactory.createTextArea(valueModel, commitOnFocusLost);
    textArea.addFocusListener(new ATTextFocusListener(textArea));
    return fixTabBehavior(textArea);
}

From source file:salomon.engine.util.validation.ComponentFactory.java

License:Open Source License

/**
 * @see salomon.util.gui.validation.IComponentFactory#createTextArea(java.lang.String, boolean)
 *///  ww w  .  j a va 2  s  . com
public JTextArea createTextArea(String propertyName, boolean commitOnFocusLost) {
    return BasicComponentFactory.createTextArea(_validationModel.getModel(propertyName), commitOnFocusLost);
}