Example usage for com.jgoodies.binding.beans BeanAdapter BeanAdapter

List of usage examples for com.jgoodies.binding.beans BeanAdapter BeanAdapter

Introduction

In this page you can find the example usage for com.jgoodies.binding.beans BeanAdapter BeanAdapter.

Prototype

public BeanAdapter(ValueModel beanChannel, boolean observeChanges) 

Source Link

Document

Constructs a BeanAdapter for the given bean channel; observes changes if specified.

It is strongly recommended that the bean channel checks the identity not equity.

Usage

From source file:com.cedarsoft.configuration.xml.ConfigBindingGuiceTest.java

License:Open Source License

@Before
public void setUp() throws Exception {

    injector = Guice.createInjector(new AbstractModule() {
        @Override//ww  w.  ja v  a2 s  .  c  om
        protected void configure() {
            bind(Configuration.class).toInstance(new BaseConfiguration());

            bind(MyBean.class).toProvider(new Provider<MyBean>() {
                @Inject
                Configuration configuration;

                @Override
                @Nonnull
                public MyBean get() {
                    MyBean myBean = new MyBean();
                    BeanAdapter<MyBean> beanAdapter = new BeanAdapter<MyBean>(myBean, true);
                    ConfigurationAccess<String> configurationAccess = new ConfigurationAccess<String>(
                            configuration, String.class, MyBean.PROPERTY_VALUE, "theDefaultValue");
                    ConfigurationBinding.bind(configurationAccess,
                            beanAdapter.getValueModel(MyBean.PROPERTY_VALUE));
                    return myBean;
                }
            }).in(Scopes.SINGLETON);
        }
    });
}

From source file:com.cedarsoft.configuration.xml.ConfigurationBindingTest.java

License:Open Source License

@Test
public void testMapping() {
    MyBean bean = new MyBean();
    BeanAdapter<MyBean> beanAdapter = new BeanAdapter<MyBean>(bean, true);
    ValueModel valueModel = beanAdapter.getValueModel("value");

    ConfigurationAccess<String> configurationAccess = new ConfigurationAccess<String>(configuration,
            String.class, "valueKey", "theDefaultValue");

    //manually/*from ww w  .j av  a 2s.  c  o m*/
    ConfigurationConnector<String> connector = new ConfigurationConnector<String>(valueModel,
            configurationAccess);
    assertEquals("", bean.getValue());
    connector.readFromConfiguration();
    assertEquals("theDefaultValue", bean.getValue());
    assertEquals("theDefaultValue", configuration.getString("valueKey"));

    bean.setValue("newValue");
    assertEquals("newValue", bean.getValue());
    assertEquals("newValue", configuration.getString("valueKey"));
}

From source file:com.cedarsoft.configuration.xml.ConfigurationBindingTest.java

License:Open Source License

@Test
public void testMapping2() {
    MyBean bean = new MyBean();
    BeanAdapter<MyBean> beanAdapter = new BeanAdapter<MyBean>(bean, true);

    ConfigurationAccess<String> configurationAccess = new ConfigurationAccess<String>(configuration,
            String.class, "valueKey", "theDefaultValue");

    //manually//from w ww . j  a v a2 s  . c  om
    ConfigurationBinding.bind(configurationAccess, beanAdapter.getValueModel("value"));
    assertEquals("theDefaultValue", bean.getValue());
    assertEquals("theDefaultValue", configuration.getString("valueKey"));

    bean.setValue("newValue");
    assertEquals("newValue", bean.getValue());
    assertEquals("newValue", configuration.getString("valueKey"));
}

From source file:com.cedarsoft.configuration.xml.ConfigurationBindingTest.java

License:Open Source License

@Test
public void testMappingList() {
    MyBean bean = new MyBean();
    assertEquals(0, bean.getValues().size());
    BeanAdapter<MyBean> beanAdapter = new BeanAdapter<MyBean>(bean, true);

    ConfigurationAccess<List> configurationAccess = new ConfigurationAccess<List>(configuration, List.class,
            "values", Arrays.asList("a", "b"));
    ConfigurationBinding.bind(configurationAccess, beanAdapter.getValueModel("values"));

    assertEquals(2, bean.getValues().size());
    assertEquals("a", bean.getValues().get(0));
    assertEquals("b", bean.getValues().get(1));

    assertEquals(2, configuration.getList("values").size());
    assertEquals("a", configuration.getList("values").get(0));
    assertEquals("b", configuration.getList("values").get(1));

    bean.addValue("c");

    assertEquals(3, bean.getValues().size());
    assertEquals("a", bean.getValues().get(0));
    assertEquals("b", bean.getValues().get(1));
    assertEquals("c", bean.getValues().get(2));

    assertEquals(3, configuration.getList("values").size());
    assertEquals("a", configuration.getList("values").get(0));
    assertEquals("b", configuration.getList("values").get(1));
    assertEquals("c", configuration.getList("values").get(2));

    bean.removeValue("b");

    assertEquals(2, bean.getValues().size());
    assertEquals("a", bean.getValues().get(0));
    assertEquals("c", bean.getValues().get(1));

    assertEquals(2, configuration.getList("values").size());
    assertEquals("a", configuration.getList("values").get(0));
    assertEquals("c", configuration.getList("values").get(1));
}

From source file:com.salas.bb.core.actions.ActionsTable.java

License:Open Source License

/**
 * Registers articles related actions./*from  w  ww . j a  v a  2  s  .c  o  m*/
 */
private static void registerArticleActions() {
    FeedRenderingSettings feedRenderingSettings = GlobalModel.SINGLETON.getGlobalRenderingSettings();

    // Factory for valueModels corresponding to bean properties of GlobalRenderingSettings
    BeanAdapter globChannelRenderingAdapter = new BeanAdapter(feedRenderingSettings, true);

    ValueModel articleFilterModelHolder = globChannelRenderingAdapter.getValueModel("articleFilter");
    ValueModel articleViewModeHolder = GlobalModel.SINGLETON.getViewModeValueModel();

    ActionManager.register(CMD_ARTICLE_WHATIS, new ShowTipAction(TipOfTheDay.TIP_WHAT_IS_ARTICLE));
    ActionManager.register(CMD_ARTICLE_BROWSE, BrowseArticleAction.getInstance());
    ActionManager.register(CMD_ARTICLE_BROWSE_TB, new ActionAlias(BrowseArticleAction.getInstance()));
    ActionManager.register(CMD_ARTICLE_COPY_TEXT, SelectedTextCopyAction.getInstance());
    ActionManager.register(CMD_ARTICLE_COPY_TEXT_STYLED, StyledTextCopyAction.getInstance());
    ActionManager.register(CMD_ARTICLE_COPY_LINK, ArticleLinkCopyAction.getInstance());
    ActionManager.register(CMD_ARTICLE_SEND_LINK, ArticleLinkSendAction.getInstance());
    ActionManager.register(CMD_ARTICLE_SAVE_IMAGE, SaveImageAction.getInstance());
    ActionManager.register(CMD_ARTICLE_GOTO_NEXT_UNREAD, GotoNextUnreadAction.getInstance());
    ActionManager.register(CMD_ARTICLE_GOTO_NEXT_UNREAD_TB,
            new ActionAlias(GotoNextUnreadAction.getInstance()));
    ActionManager.register(CMD_ARTICLE_GOTO_NEXT_UNREAD_FEED, GotoNextUnreadInNextFeedAction.getInstance());
    ActionManager.register(CMD_ARTICLE_GOTO_PREV_UNREAD, GotoPreviousUnreadAction.getInstance());
    ActionManager.register(CMD_ARTICLE_PROPERTIES, ShowArticlePropertiesAction.getInstance());
    ActionManager.register(CMD_ARTICLE_MARK_UNREAD, MarkArticleUnreadAction.getInstance());
    ActionManager.register(CMD_ARTICLE_MARK_READ, MarkArticleReadAction.getInstance());
    ActionManager.register(CMD_ARTICLE_FONT_BIGGER, new FontSizeBiasChangeAction(1));
    ActionManager.register(CMD_ARTICLE_FONT_SMALLER, new FontSizeBiasChangeAction(-1));

    ActionManager.register(CMD_ARTICLE_SHOW_ALL_TB,
            ToggleAction.createRadio(articleFilterModelHolder, new Integer(IFeedDisplayConstants.FILTER_ALL)));
    ActionManager.register(CMD_ARTICLE_SHOW_UNREAD_TB, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_UNREAD)));
    ActionManager.register(CMD_ARTICLE_SHOW_PINNED_TB, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_PINNED)));
    ActionManager.register(CMD_ARTICLE_SHOW_POSITIVE_TB, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_POSITIVE)));
    ActionManager.register(CMD_ARTICLE_SHOW_NEGATIVE_TB, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_NEGATIVE)));
    ActionManager.register(CMD_ARTICLE_SHOW_NON_NEGATIVE_TB, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_NON_NEGATIVE)));

    ActionManager.register(CMD_ARTICLE_SHOW_ALL,
            ToggleAction.createRadio(articleFilterModelHolder, new Integer(IFeedDisplayConstants.FILTER_ALL)));
    ActionManager.register(CMD_ARTICLE_SHOW_UNREAD, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_UNREAD)));
    ActionManager.register(CMD_ARTICLE_SHOW_PINNED, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_PINNED)));
    ActionManager.register(CMD_ARTICLE_SHOW_POSITIVE, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_POSITIVE)));
    ActionManager.register(CMD_ARTICLE_SHOW_NEGATIVE, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_NEGATIVE)));
    ActionManager.register(CMD_ARTICLE_SHOW_NON_NEGATIVE, ToggleAction.createRadio(articleFilterModelHolder,
            new Integer(IFeedDisplayConstants.FILTER_NON_NEGATIVE)));

    ActionManager.register(CMD_ARTICLE_VIDEMODE_MINI,
            ToggleAction.createRadio(articleViewModeHolder, FeedRenderingSettings.VIEW_MODE_MINIMAL));
    ActionManager.register(CMD_ARTICLE_VIEWMODE_BRIEF,
            ToggleAction.createRadio(articleViewModeHolder, FeedRenderingSettings.VIEW_MODE_BRIEF));
    ActionManager.register(CMD_ARTICLE_VIEWMODE_FULL,
            ToggleAction.createRadio(articleViewModeHolder, FeedRenderingSettings.VIEW_MODE_FULL));

    ActionManager.register(CMD_ARTICLE_VIEWMODE_MINI_TB,
            ToggleAction.createRadio(articleViewModeHolder, FeedRenderingSettings.VIEW_MODE_MINIMAL));
    ActionManager.register(CMD_ARTICLE_VIEWMODE_BRIEF_TB,
            ToggleAction.createRadio(articleViewModeHolder, FeedRenderingSettings.VIEW_MODE_BRIEF));
    ActionManager.register(CMD_ARTICLE_VIEWMODE_FULL_TB,
            ToggleAction.createRadio(articleViewModeHolder, FeedRenderingSettings.VIEW_MODE_FULL));

    ActionManager.register(CMD_ARTICLE_TAGS, ShowArticleTagsAction.getInstance());
    ActionManager.register(CMD_ARTICLE_PIN_UNPIN, PinUnpinArticleAction.getInstance());

    ActionManager.register(CMD_ARTICLE_HYPERLINK_OPEN, HyperLinkOpenAction.getInstance());
    ActionManager.register(CMD_ARTICLE_HYPERLINK_COPY, HyperLinkCopyAction.getInstance());
    ActionManager.register(CMD_ARTICLE_HYPERLINK_SAVE_AS, HyperLinkSaveAsAction.getInstance());
    ActionManager.register(CMD_ARTICLE_HYPERLINK_SEND, HyperLinkEmailAction.getInstance());

    ActionManager.register(CMD_ARTICLE_POST_TO_BLOG, PostToBlogAction.getInstanceForArticle());
    ActionManager.register(CMD_ARTICLE_TWEET_THIS, TweetThisAction.getInstance());

    ActionManager.register(CMD_ARTICLE_BLOCK_IMAGE, BlockImageAction.getInstance());
    ActionManager.register(CMD_ARTICLE_DISCOVER, DiscoverInArticlesAction.getInstance());
}

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

License:Open Source License

/**
 * Create the panel./*from  w  w w. ja  v  a 2s.co m*/
 */
public ActionPanel(final IActionDevice device, final T action) {

    setDevice(device);
    setAction(action);

    setLayout(new GridBagLayout());
    setBackground(DropletColors.getBackgroundColor(getDevice()));

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

    BeanAdapter<IAction> adapter = new BeanAdapter<IAction>(action, true);

    // enabled checkbox
    cbEnable = BasicComponentFactory.createCheckBox(adapter.getValueModel(IAction.PROPERTY_ENABLED),
            StringUtils.EMPTY);
    cbEnable.setToolTipText(Messages.getString("ActionPanel.enableAction.tooltip")); //$NON-NLS-1$
    cbEnable.setFocusable(false);
    UiUtils.editGridBagConstraints(gbc, 0, 0, 0, 0);
    add(cbEnable, gbc);

    // offset spinner
    spOffset = new MouseWheelSpinner(true);
    spOffset.setToolTipText(Messages.getString("ActionPanel.Offset.Tooltip")); //$NON-NLS-1$
    spOffset.setModel(SpinnerAdapterFactory.createNumberAdapter(adapter.getValueModel(IAction.PROPERTY_OFFSET),
            0, 0, ActionPanel.MAX_TIME_INPUT, 1));
    ((JSpinner.DefaultEditor) spOffset.getEditor()).getTextField().setColumns(4);
    UiUtils.editGridBagConstraints(gbc, 1, 0, 0, 0);
    add(spOffset, gbc);

    // duration spinner
    spDuration = new MouseWheelSpinner(true);
    spDuration.setToolTipText(Messages.getString("ActionPanel.Duration.Tooltip")); //$NON-NLS-1$
    if (action instanceof IDurationAction) {
        spDuration.setModel(SpinnerAdapterFactory.createNumberAdapter(
                adapter.getValueModel(IDurationAction.PROPERTY_DURATION), 0, 0, ActionPanel.MAX_TIME_INPUT, 1));
        ((JSpinner.DefaultEditor) spDuration.getEditor()).getTextField().setColumns(4);
        UiUtils.editGridBagConstraints(gbc, 2, 0, 0, 0);
        add(spDuration, gbc);
    }

    // remove button
    btnRemove = new JButton(Messages.getString("ActionPanel.removeAction")); //$NON-NLS-1$
    btnRemove.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            remove();
        }
    });
    btnRemove.setToolTipText(Messages.getString("ActionPanel.removeAction.tooltip")); //$NON-NLS-1$
    btnRemove.setFocusable(false);
    UiUtils.editGridBagConstraints(gbc, 3, 0, 0, 0);
    add(btnRemove, gbc);

}

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

License:Open Source License

/**
 * Create the panel.// w  w w  .ja v  a2s  .  c  o m
 */
public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) {

    this.parent = parent;

    setDevice(device);

    setLayout(new BorderLayout(0, 5));
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    setBackground(DropletColors.getBackgroundColor(device));

    BeanAdapter<T> adapter = new BeanAdapter<T>(device, true);

    // device name textfield
    txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME));
    txtName.setHorizontalAlignment(SwingConstants.CENTER);
    txtName.setColumns(1);
    txtName.setToolTipText(device.getName());
    adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            txtName.setToolTipText(device.getName());
        }
    });
    add(txtName, BorderLayout.NORTH);

    // actions panel with scroll pane
    actionsPanel = new JPanel();
    actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS));
    actionsPanel.setBackground(getBackground());

    JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // resize vertical scrollbar
    scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    SwingUtilities.updateComponentTreeUI(scrollPane);
    // we need no border
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    add(scrollPane, BorderLayout.CENTER);

    {
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1));

        createAddButton(panel);

        // remove button
        JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$
        btnRemove.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent action) {
                int retVal = JOptionPane.showConfirmDialog(DevicePanel.this,
                        Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (retVal == JOptionPane.YES_OPTION) {
                    droplet.removeDevice(device);
                }
            }
        });
        btnRemove.setFocusable(false);
        panel.add(btnRemove);

        add(panel, BorderLayout.SOUTH);
    }

}

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

License:Open Source License

/**
 * Create the panel./*from w  ww.  j ava  2s.c  om*/
 */
public DropletToolbar(final JFrame frame, final IDropletContext dropletContext) {

    this.dropletContext = dropletContext;

    setLayout(new FlowLayout(FlowLayout.RIGHT));

    // show button
    JButton btnDirect = new JButton(new ControlDevcieAction(frame, dropletContext));
    add(btnDirect);

    // show button
    JButton btnShow = new JButton(new ShowAction(frame, dropletContext));
    add(btnShow);

    // send button
    JButton btnSend = new JButton(new SendAction(frame, dropletContext));
    add(btnSend);

    BeanAdapter<IDropletContext> adapter = new BeanAdapter<IDropletContext>(dropletContext, true);

    // rounds spinner
    add(new JLabel(Messages.getString("DropletToolbar.rounds"))); //$NON-NLS-1$
    spRounds = new MouseWheelSpinner(true);
    spRounds.setModel(SpinnerAdapterFactory
            .createNumberAdapter(adapter.getValueModel(IDropletContext.PROPERTY_ROUNDS), 1, 1, 9999, 1));
    ((JSpinner.DefaultEditor) spRounds.getEditor()).getTextField().setColumns(4);
    add(spRounds);

    // round delay spinner
    add(new JLabel(Messages.getString("DropletToolbar.delay"))); //$NON-NLS-1$
    spRoundDelay = new MouseWheelSpinner(true);
    spRoundDelay.setModel(SpinnerAdapterFactory.createNumberAdapter(
            adapter.getValueModel(IDropletContext.PROPERTY_ROUND_DELAY), 1000, 0, 99999999, 1));
    ((JSpinner.DefaultEditor) spRoundDelay.getEditor()).getTextField().setColumns(8);
    updateTooltip();
    adapter.addBeanPropertyChangeListener(IDropletContext.PROPERTY_ROUND_DELAY, new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            updateTooltip();
        }
    });
    add(spRoundDelay);

    // start button
    JButton btnStart = new JButton(new StartAction(frame, dropletContext));
    add(btnStart);

    // cancel button
    JButton btnCancel = new JButton(new CancelAction(frame, dropletContext));
    add(btnCancel);

}

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

License:Open Source License

/**
 * Create the panel./*from   w  w w.  j av a  2s .c  o m*/
 */
public LoggingPanel(final IDropletContext context) {

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

    BeanAdapter<IDropletContext> adapter = new BeanAdapter<IDropletContext>(context, true);

    txtMessages = BasicComponentFactory.createTextArea(adapter.getValueModel(IDropletContext.PROPERTY_LOGGING));
    txtMessages.setFocusable(true);
    txtMessages.setFocusTraversalKeysEnabled(true);
    txtMessages.setMargin(new Insets(0, 10, 0, 10));
    txtMessages.setFont(DropletFonts.FONT_LOGGING_SMALL);
    txtMessages.setEditable(false);
    JScrollPane loggingScrollPane = new JScrollPane(txtMessages);
    loggingScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        @Override
        public void adjustmentValueChanged(final AdjustmentEvent event) {
            // event.getAdjustable().setValue(event.getAdjustable().getMaximum());
            if (txtMessages.getText().length() > 1) {
                txtMessages.setCaretPosition(txtMessages.getText().length() - 1);
            }
        }
    });
    add(loggingScrollPane, BorderLayout.CENTER);

    txtMessages.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent event) {
            if ((event.getKeyCode() == KeyEvent.VK_DELETE) || (event.getKeyCode() == KeyEvent.VK_BACK_SPACE)) {
                context.clearLoggingMessages();
            }
            super.keyPressed(event);
        }
    });

}

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

License:Open Source License

/**
 * Create the panel./*from   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();
}