Example usage for com.jgoodies.forms.builder ButtonBarBuilder ButtonBarBuilder

List of usage examples for com.jgoodies.forms.builder ButtonBarBuilder ButtonBarBuilder

Introduction

In this page you can find the example usage for com.jgoodies.forms.builder ButtonBarBuilder ButtonBarBuilder.

Prototype

public ButtonBarBuilder(JPanel panel) 

Source Link

Document

Constructs an empty ButtonBarBuilder on the given panel.

Usage

From source file:com.eviware.soapui.support.components.DirectoryFormComponent.java

License:EUPL

public DirectoryFormComponent(String tooltip) {
    ButtonBarBuilder builder = new ButtonBarBuilder(this);
    textField = new JTextField(30);
    textField.setToolTipText(tooltip);/*from   w w w .j a v a 2  s  .  co  m*/
    builder.addGriddedGrowing(textField);
    builder.addRelatedGap();
    builder.addFixed(new JButton(new SelectDirectoryAction()));
}

From source file:com.eviware.soapui.support.components.FileFormComponent.java

License:EUPL

public FileFormComponent(String tooltip) {
    ButtonBarBuilder builder = new ButtonBarBuilder(this);
    textField = new JTextField(30);
    textField.setToolTipText(tooltip);//from  w  w w  .  ja v  a  2  s .com
    builder.addGriddedGrowing(textField);
    builder.addRelatedGap();
    builder.addFixed(new JButton(new SelectFileAction()));
}

From source file:com.eviware.soapui.support.components.JButtonBar.java

License:EUPL

public JButtonBar() {
    builder = new ButtonBarBuilder(this);
}

From source file:com.eviware.soapui.support.components.JEditorStatusBar.java

License:EUPL

public JEditorStatusBar(JEditorStatusBarTarget target) {
    this.target = target;

    caretLabel = new JLabel();
    caretLabel.setPreferredSize(new Dimension(60, 16));

    infoLabel = new JLabel();
    infoLabel.setVisible(false);/* w w  w  . j  av  a  2  s . c  o m*/

    caretLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, Color.LIGHT_GRAY),
                    BorderFactory.createMatteBorder(0, 1, 0, 0, Color.WHITE)));

    ButtonBarBuilder builder = new ButtonBarBuilder(this);
    builder.addGriddedGrowing(infoLabel);
    builder.addStrut(Sizes.pixel(2));

    statusPanel = new JPanel(new BorderLayout());
    statusPanel.setPreferredSize(new Dimension(60, 16));

    statusPanel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, Color.LIGHT_GRAY),
                    BorderFactory.createMatteBorder(0, 1, 0, 0, Color.WHITE)));

    builder.addFixed(statusPanel);
    builder.addFixed(caretLabel);
    builder.getPanel();
}

From source file:com.eviware.x.impl.swing.FileFormField.java

License:EUPL

public FileFormField(String tooltip, FieldType type, String name) {
    super(new JPanel());
    this.type = type;

    ButtonBarBuilder builder = new ButtonBarBuilder(getComponent());
    textField = new JUndoableTextField(30);
    textField.setName(name);/* w ww .j a  v a 2 s.c  om*/
    textField.setToolTipText(tooltip);
    builder.addGriddedGrowing(textField);
    builder.addRelatedGap();
    selectDirectoryButton = new JButton(new SelectDirectoryAction());
    builder.addFixed(selectDirectoryButton);

    textField.getDocument().addDocumentListener(new DocumentListenerAdapter() {

        @Override
        public void update(Document document) {
            String text = textField.getText();

            if (!updating) {
                fireValueChanged(text, oldValue);
            }

            oldValue = text;
        }
    });
}

From source file:net.sf.jabref.ContentSelectorDialog2.java

License:Open Source License

private void initLayout() {
    fieldNameField.setEnabled(false);/* w ww  .  j a  va2s . c o  m*/
    fieldList.setVisibleRowCount(4);
    wordList.setVisibleRowCount(10);
    final String VAL = "Uren luren himmelturen, ja Besseggen.";
    fieldList.setPrototypeCellValue(VAL);
    wordList.setPrototypeCellValue(VAL);

    fieldPan.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Field name")));
    wordPan.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Keyword")));
    fieldPan.setLayout(gbl);
    wordPan.setLayout(gbl);
    con.insets = new Insets(2, 2, 2, 2);
    con.fill = GridBagConstraints.BOTH;
    con.gridwidth = 2;
    con.weightx = 1;
    con.weighty = 1;
    con.gridx = 0;
    con.gridy = 0;
    gbl.setConstraints(fPane, con);
    fieldPan.add(fPane);
    gbl.setConstraints(wPane, con);
    wordPan.add(wPane);
    con.gridwidth = 1;
    con.gridx = 2;
    //con.weightx = 0.7;
    con.gridheight = 2;
    gbl.setConstraints(fieldNamePan, con);
    fieldPan.add(fieldNamePan);
    gbl.setConstraints(wordEditPan, con);
    wordPan.add(wordEditPan);
    con.gridx = 0;
    con.gridy = 1;
    con.weightx = 0;
    con.weighty = 0;
    con.gridwidth = 1;
    con.gridheight = 1;
    con.fill = GridBagConstraints.NONE;
    con.anchor = GridBagConstraints.WEST;
    gbl.setConstraints(newField, con);
    fieldPan.add(newField);
    gbl.setConstraints(newWord, con);
    wordPan.add(newWord);
    con.gridx = 1;
    //con.anchor = GridBagConstraints.EAST;
    gbl.setConstraints(removeField, con);
    fieldPan.add(removeField);
    gbl.setConstraints(removeWord, con);
    wordPan.add(removeWord);
    con.anchor = GridBagConstraints.WEST;
    con.gridx = 0;
    con.gridy = 0;
    gbl.setConstraints(fieldNameField, con);
    fieldNamePan.add(fieldNameField);
    gbl.setConstraints(wordEditField, con);
    wordEditPan.add(wordEditField);

    // Add buttons:
    ButtonBarBuilder bsb = new ButtonBarBuilder(buttonPan);
    bsb.addGlue();
    bsb.addButton(ok);
    bsb.addButton(apply);
    bsb.addButton(cancel);
    bsb.addRelatedGap();
    bsb.addButton(help);
    bsb.addGlue();

    // Add panels to dialog:
    con.fill = GridBagConstraints.BOTH;
    getContentPane().setLayout(gbl);
    con.weightx = 1;
    con.weighty = 0.5;
    con.gridwidth = 1;
    con.gridheight = 1;
    con.gridx = 0;
    con.gridy = 0;
    gbl.setConstraints(fieldPan, con);
    getContentPane().add(fieldPan);
    con.gridy = 1;
    gbl.setConstraints(wordPan, con);
    getContentPane().add(wordPan);
    con.weighty = 0;
    con.gridy = 2;
    con.insets = new Insets(12, 2, 2, 2);
    gbl.setConstraints(buttonPan, con);
    getContentPane().add(buttonPan);

}

From source file:net.sf.jabref.EntryTypeDialog.java

License:Open Source License

public EntryTypeDialog(JabRefFrame baseFrame_) {
    super(baseFrame_, true); // Set modal on.

    setTitle(Globals.lang("Select entry type"));

    addWindowListener(new WindowAdapter() {

        @Override/* w  w w  . j a  v  a2  s . c  o  m*/
        public void windowClosing(WindowEvent e) {
            cancelAction.actionPerformed(null);
        }
    });

    getContentPane().setLayout(new BorderLayout());
    JPanel pan = new JPanel();
    getContentPane().add(pan, BorderLayout.CENTER);
    JPanel buttons = new JPanel();
    JButton // ok = new JButton("Ok"),
    cancel = new JButton(Globals.lang("Cancel"));
    //ok.addActionListener(this);
    cancel.addActionListener(this);

    // Make ESC close dialog, equivalent to clicking Cancel.
    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(baseFrame_.prefs.getKey("Close dialog"), "close");
    cancel.getActionMap().put("close", cancelAction);

    //buttons.add(ok);
    ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
    //buttons.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
    bb.addGlue();
    bb.addButton(cancel);
    bb.addGlue();

    getContentPane().add(buttons, BorderLayout.SOUTH);
    GridBagLayout gbl = new GridBagLayout();
    pan.setLayout(gbl);
    GridBagConstraints con = new GridBagConstraints();
    con.anchor = GridBagConstraints.WEST;
    con.fill = GridBagConstraints.HORIZONTAL;
    con.insets = new Insets(4, 4, 4, 4);
    int col = 0;

    for (BibtexEntryType tp : BibtexEntryType.ALL_TYPES.values()) {
        if (tp.isVisibleAtNewEntryDialog()) {
            TypeButton b = new TypeButton(StringUtil.nCase(tp.getName()), tp);
            b.addActionListener(this);
            // Check if we should finish the row.
            col++;
            if (col == EntryTypeDialog.COLNUM) {
                col = 0;
                con.gridwidth = GridBagConstraints.REMAINDER;
            } else {
                con.gridwidth = 1;
            }
            gbl.setConstraints(b, con);
            pan.add(b);
        }
    }
    pan.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Entry types")));
    //pan.setBackground(Color.white);
    //buttons.setBackground(Color.white);
    pack();
    setResizable(false);
}

From source file:net.sf.jabref.export.CustomExportDialog.java

License:Open Source License

public CustomExportDialog(JabRefFrame parent_) {
    super(parent_, Globals.lang("Edit custom export"), true);
    parent = parent_;/* ww w.ja  v  a2  s  .  com*/
    ActionListener okListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            // Check that there are no empty strings.
            if ((layoutFile.getText().isEmpty()) || (name.getText().isEmpty())
                    || (extension.getText().isEmpty()) || (!layoutFile.getText().endsWith(".layout"))) {
                //JOptionPane.showMessageDialog
                //    (parent, Globals.lang("You must provide a name, a search "
                //           +"string and a field name for this group."),
                //           Globals.lang("Create group"),
                //     JOptionPane.ERROR_MESSAGE);
                return;
            }

            // Handling of : and ; must also be done.

            ok_pressed = true;
            dispose();
        }
    };
    JButton ok = new JButton(Globals.lang("Ok"));
    ok.addActionListener(okListener);
    name.addActionListener(okListener);
    layoutFile.addActionListener(okListener);
    extension.addActionListener(okListener);

    AbstractAction cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };

    JButton cancel = new JButton(Globals.lang("Cancel"));
    cancel.addActionListener(cancelAction);

    JButton browse = new JButton(Globals.lang("Browse"));
    browse.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            File directory = new File(Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY));
            String chosenStr = FileDialogs.getNewFile(parent, directory, ".layout", JFileChooser.OPEN_DIALOG,
                    false);
            if (chosenStr == null) {
                return;
            }
            File chosen = new File(chosenStr);

            // Update working directory for layout files.
            Globals.prefs.put(JabRefPreferences.EXPORT_WORKING_DIRECTORY, chosen.getParent());

            layoutFile.setText(chosen.getPath());
        }
    });

    // Key bindings:
    JPanel main = new JPanel();
    ActionMap am = main.getActionMap();
    InputMap im = main.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(parent.prefs().getKey("Close dialog"), "close");
    am.put("close", cancelAction);

    // Layout starts here.
    GridBagLayout gbl = new GridBagLayout();
    main.setLayout(gbl);
    main.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            Globals.lang("Export properties")));

    // Main panel:
    GridBagConstraints con = new GridBagConstraints();
    con.weightx = 0;
    con.gridwidth = 1;
    con.insets = new Insets(3, 5, 3, 5);
    con.anchor = GridBagConstraints.EAST;
    con.fill = GridBagConstraints.NONE;
    con.gridx = 0;
    con.gridy = 0;
    JLabel nl = new JLabel(Globals.lang("Export name") + ':');
    gbl.setConstraints(nl, con);
    main.add(nl);
    con.gridy = 1;
    JLabel nr = new JLabel(Globals.lang("Main layout file") + ':');
    gbl.setConstraints(nr, con);
    main.add(nr);
    con.gridy = 2;
    JLabel nf = new JLabel(Globals.lang("File extension") + ':');
    gbl.setConstraints(nf, con);
    main.add(nf);

    con.gridwidth = 2;
    con.weightx = 1;
    con.anchor = GridBagConstraints.WEST;
    con.fill = GridBagConstraints.HORIZONTAL;
    con.gridy = 0;
    con.gridx = 1;
    gbl.setConstraints(name, con);
    main.add(name);
    con.gridy = 1;
    con.gridwidth = 1;
    gbl.setConstraints(layoutFile, con);
    main.add(layoutFile);
    con.gridx = 2;
    con.weightx = 0;
    gbl.setConstraints(browse, con);
    main.add(browse);
    con.weightx = 1;
    con.gridwidth = 2;
    con.gridx = 1;
    con.gridy = 2;
    gbl.setConstraints(extension, con);
    main.add(extension);

    JPanel buttons = new JPanel();
    ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
    buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();

    getContentPane().add(main, BorderLayout.CENTER);
    getContentPane().add(buttons, BorderLayout.SOUTH);

    //pack();
    setSize(600, 170);

    Util.placeDialog(this, parent);
}

From source file:net.sf.jabref.export.ExportCustomizationDialog.java

License:Open Source License

public ExportCustomizationDialog(JabRefFrame frame_) throws HeadlessException {

    super(frame_, Globals.lang("Manage custom exports"), false);
    frame = frame_;//  w w  w  . j  a v a  2  s.c o m
    JButton addExport = new JButton(Globals.lang("Add new"));
    addExport.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            CustomExportDialog ecd = new CustomExportDialog(frame);
            ecd.setVisible(true); // ecd.show(); -> deprecated since 1.5
            if (ecd.okPressed()) {
                String[] newFormat = new String[] { ecd.name(), ecd.layoutFile(), ecd.extension() };
                Globals.prefs.customExports.addFormat(newFormat);
                Globals.prefs.customExports.store();
            }
        }
    });

    JButton modify = new JButton(Globals.lang("Modify"));
    modify.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int row = table.getSelectedRow();
            if (row == -1) {
                return;
            }
            String[] old = Globals.prefs.customExports.getSortedList().get(row);
            CustomExportDialog ecd = new CustomExportDialog(frame, old[0], old[1], old[2]);
            ecd.setVisible(true); // ecd.show(); -> deprecated since 1.5
            if (ecd.okPressed()) {
                old[0] = ecd.name();
                old[1] = ecd.layoutFile();
                old[2] = ecd.extension();
                table.revalidate();
                table.repaint();
                Globals.prefs.customExports.store();
            }
        }
    });

    JButton remove = new JButton(Globals.lang("Remove"));
    remove.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int[] rows = table.getSelectedRows();
            if (rows.length == 0) {
                return;
            }
            String[][] entries = new String[rows.length][];
            for (int i = 0; i < rows.length; i++) {
                entries[i] = Globals.prefs.customExports.getSortedList().get(rows[i]);
            }
            for (int i = 0; i < rows.length; i++) {
                Globals.prefs.customExports.remove(entries[i]);
            }
            Globals.prefs.customExports.store();
        }
    });

    AbstractAction closeAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };

    JButton close = new JButton(Globals.lang("Close"));
    close.addActionListener(closeAction);

    JButton help = new JButton(Globals.lang("Help"));
    help.addActionListener(new HelpAction(frame.helpDiag, GUIGlobals.exportCustomizationHelp, "Help"));

    EventTableModel<String[]> tableModel = new EventTableModel<String[]>(
            Globals.prefs.customExports.getSortedList(), new ExportTableFormat());
    table = new JTable(tableModel);
    TableColumnModel cm = table.getColumnModel();
    cm.getColumn(0).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_0_WIDTH);
    cm.getColumn(1).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_1_WIDTH);
    cm.getColumn(2).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_2_WIDTH);
    JScrollPane sp = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setPreferredScrollableViewportSize(new Dimension(500, 150));
    if (table.getRowCount() > 0) {
        table.setRowSelectionInterval(0, 0);
    }

    // Key bindings:
    JPanel main = new JPanel();
    ActionMap am = main.getActionMap();
    InputMap im = main.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(frame.prefs().getKey("Close dialog"), "close");
    am.put("close", closeAction);
    //am = table.getActionMap();
    //im = table.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    //im.put(frame.prefs().getKey("Close dialog"), "close");
    //am.put("close", closeAction);
    main.setLayout(new BorderLayout());
    main.add(sp, BorderLayout.CENTER);
    JPanel buttons = new JPanel();
    ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
    buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    bb.addGlue();
    bb.addButton(addExport);
    bb.addButton(modify);
    bb.addButton(remove);
    bb.addButton(close);
    bb.addUnrelatedGap();
    bb.addButton(help);
    bb.addGlue();

    getContentPane().add(main, BorderLayout.CENTER);
    getContentPane().add(buttons, BorderLayout.SOUTH);
    pack();
    Util.placeDialog(this, frame);
    new FocusRequester(table);
}

From source file:net.sf.jabref.exporter.CustomExportDialog.java

License:Open Source License

public CustomExportDialog(final JabRefFrame parent) {
    super(parent, Localization.lang("Edit custom export"), true);
    ActionListener okListener = e -> {

        // Check that there are no empty strings.
        if (layoutFile.getText().isEmpty() || name.getText().isEmpty() || extension.getText().isEmpty()
                || !layoutFile.getText().endsWith(".layout")) {
            //JOptionPane.showMessageDialog
            //    (parent, Globals.lang("You must provide a name, a search "
            //           +"string and a field name for this group."),
            //           Globals.lang("Create group"),
            //     JOptionPane.ERROR_MESSAGE);
            return;
        }//w w  w. ja v  a2 s  .c  o  m

        // Handling of : and ; must also be done.

        okPressed = true;
        dispose();
    };
    JButton ok = new JButton(Localization.lang("OK"));
    ok.addActionListener(okListener);
    name.addActionListener(okListener);
    layoutFile.addActionListener(okListener);
    extension.addActionListener(okListener);

    AbstractAction cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };

    JButton cancel = new JButton(Localization.lang("Cancel"));
    cancel.addActionListener(cancelAction);

    JButton browse = new JButton(Localization.lang("Browse"));
    browse.addActionListener(e -> {
        File directory = new File(Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY));
        String chosenStr = FileDialogs.getNewFile(parent, directory, ".layout", JFileChooser.OPEN_DIALOG,
                false);
        if (chosenStr == null) {
            return;
        }
        File chosen = new File(chosenStr);

        // Update working directory for layout files.
        Globals.prefs.put(JabRefPreferences.EXPORT_WORKING_DIRECTORY, chosen.getParent());

        layoutFile.setText(chosen.getPath());
    });

    // Key bindings:
    JPanel main = new JPanel();
    ActionMap am = main.getActionMap();
    InputMap im = main.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelAction);

    // Layout starts here.
    GridBagLayout gbl = new GridBagLayout();
    main.setLayout(gbl);
    main.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            Localization.lang("Export properties")));

    // Main panel:
    GridBagConstraints con = new GridBagConstraints();
    con.weightx = 0;
    con.gridwidth = 1;
    con.insets = new Insets(3, 5, 3, 5);
    con.anchor = GridBagConstraints.EAST;
    con.fill = GridBagConstraints.NONE;
    con.gridx = 0;
    con.gridy = 0;
    JLabel nl = new JLabel(Localization.lang("Export name") + ':');
    gbl.setConstraints(nl, con);
    main.add(nl);
    con.gridy = 1;
    JLabel nr = new JLabel(Localization.lang("Main layout file") + ':');
    gbl.setConstraints(nr, con);
    main.add(nr);
    con.gridy = 2;
    JLabel nf = new JLabel(Localization.lang("File extension") + ':');
    gbl.setConstraints(nf, con);
    main.add(nf);

    con.gridwidth = 2;
    con.weightx = 1;
    con.anchor = GridBagConstraints.WEST;
    con.fill = GridBagConstraints.HORIZONTAL;
    con.gridy = 0;
    con.gridx = 1;
    gbl.setConstraints(name, con);
    main.add(name);
    con.gridy = 1;
    con.gridwidth = 1;
    gbl.setConstraints(layoutFile, con);
    main.add(layoutFile);
    con.gridx = 2;
    con.weightx = 0;
    gbl.setConstraints(browse, con);
    main.add(browse);
    con.weightx = 1;
    con.gridwidth = 2;
    con.gridx = 1;
    con.gridy = 2;
    gbl.setConstraints(extension, con);
    main.add(extension);

    JPanel buttons = new JPanel();
    ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
    buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();

    getContentPane().add(main, BorderLayout.CENTER);
    getContentPane().add(buttons, BorderLayout.SOUTH);

    setSize(700, 200);

    PositionWindow.placeDialog(this, parent);
}