Search in sources :

Example 21 with ButtonBarBuilder

use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.

the class ContentSelectorDialog method initLayout.

private void initLayout() {
    fieldNameField.setEnabled(false);
    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(), Localization.lang("Field name")));
    wordPan.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.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(new HelpAction(HelpFile.CONTENT_SELECTOR).getHelpButton());
    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);
}
Also used : Insets(java.awt.Insets) HelpAction(org.jabref.gui.help.HelpAction) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder)

Example 22 with ButtonBarBuilder

use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.

the class DatabasePropertiesDialog method init.

private void init() {
    DirectoryDialogConfiguration directoryDialogConfiguration = new DirectoryDialogConfiguration.Builder().withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
    DialogService ds = new FXDialogService();
    JButton browseFile = new JButton(Localization.lang("Browse"));
    JButton browseFileIndv = new JButton(Localization.lang("Browse"));
    browseFile.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> ds.showDirectorySelectionDialog(directoryDialogConfiguration)).ifPresent(f -> fileDir.setText(f.toAbsolutePath().toString())));
    browseFileIndv.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> ds.showDirectorySelectionDialog(directoryDialogConfiguration)).ifPresent(f -> fileDirIndv.setText(f.toAbsolutePath().toString())));
    setupSortOrderConfiguration();
    FormLayout form = new FormLayout("left:pref, 4dlu, pref:grow, 4dlu, pref:grow, 4dlu, pref", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, fill:pref:grow, 180dlu, fill:pref:grow,");
    FormBuilder builder = FormBuilder.create().layout(form);
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    builder.add(Localization.lang("Library encoding")).xy(1, 1);
    builder.add(encoding).xy(3, 1);
    builder.addSeparator(Localization.lang("Override default file directories")).xyw(1, 3, 5);
    builder.add(Localization.lang("General file directory")).xy(1, 5);
    builder.add(fileDir).xy(3, 5);
    builder.add(browseFile).xy(5, 5);
    builder.add(Localization.lang("User-specific file directory")).xy(1, 7);
    builder.add(fileDirIndv).xy(3, 7);
    builder.add(browseFileIndv).xy(5, 7);
    builder.addSeparator(Localization.lang("Save sort order")).xyw(1, 13, 5);
    builder.add(saveInOriginalOrder).xyw(1, 15, 5);
    builder.add(saveInSpecifiedOrder).xyw(1, 17, 5);
    saveOrderPanel = new SaveOrderConfigDisplay();
    builder.add(saveOrderPanel.getPanel()).xyw(1, 21, 5);
    builder.addSeparator(Localization.lang("Library protection")).xyw(1, 23, 5);
    builder.add(protect).xyw(1, 25, 5);
    fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"), Cleanups.DEFAULT_SAVE_ACTIONS);
    builder.addSeparator(Localization.lang("Save actions")).xyw(1, 27, 5);
    builder.add(fieldFormatterCleanupsPanel).xyw(1, 29, 5);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addRelatedGap();
    bb.addButton(new HelpAction(HelpFile.DATABASE_PROPERTIES).getHelpButton());
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    pack();
    AbstractAction closeAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };
    ActionMap am = builder.getPanel().getActionMap();
    InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", closeAction);
    ok.addActionListener(e -> {
        storeSettings();
        dispose();
    });
    cancel.addActionListener(e -> dispose());
}
Also used : ActionListener(java.awt.event.ActionListener) JTextField(javax.swing.JTextField) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) DialogService(org.jabref.gui.DialogService) JabRefPreferences(org.jabref.preferences.JabRefPreferences) BasePanel(org.jabref.gui.BasePanel) Charset(java.nio.charset.Charset) Encodings(org.jabref.logic.l10n.Encodings) DirectoryDialogConfiguration(org.jabref.gui.util.DirectoryDialogConfiguration) MetaData(org.jabref.model.metadata.MetaData) Localization(org.jabref.logic.l10n.Localization) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) ActionMap(javax.swing.ActionMap) JComponent(javax.swing.JComponent) FormBuilder(com.jgoodies.forms.builder.FormBuilder) SaveOrderConfigDisplay(org.jabref.gui.SaveOrderConfigDisplay) HelpFile(org.jabref.logic.help.HelpFile) JButton(javax.swing.JButton) ButtonGroup(javax.swing.ButtonGroup) SaveOrderConfig(org.jabref.model.metadata.SaveOrderConfig) Cleanups(org.jabref.logic.cleanup.Cleanups) BorderFactory(javax.swing.BorderFactory) FXDialogService(org.jabref.gui.FXDialogService) FieldFormatterCleanupsPanel(org.jabref.gui.cleanup.FieldFormatterCleanupsPanel) ActionEvent(java.awt.event.ActionEvent) JRadioButton(javax.swing.JRadioButton) Globals(org.jabref.Globals) DefaultTaskExecutor(org.jabref.gui.util.DefaultTaskExecutor) JabRefDialog(org.jabref.gui.JabRefDialog) AbstractAction(javax.swing.AbstractAction) FormLayout(com.jgoodies.forms.layout.FormLayout) DatabaseLocation(org.jabref.model.database.DatabaseLocation) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) InputMap(javax.swing.InputMap) KeyBinding(org.jabref.gui.keyboard.KeyBinding) HelpAction(org.jabref.gui.help.HelpAction) FormLayout(com.jgoodies.forms.layout.FormLayout) FormBuilder(com.jgoodies.forms.builder.FormBuilder) DialogService(org.jabref.gui.DialogService) FXDialogService(org.jabref.gui.FXDialogService) HelpAction(org.jabref.gui.help.HelpAction) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) FormBuilder(com.jgoodies.forms.builder.FormBuilder) JButton(javax.swing.JButton) FXDialogService(org.jabref.gui.FXDialogService) SaveOrderConfigDisplay(org.jabref.gui.SaveOrderConfigDisplay) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) DirectoryDialogConfiguration(org.jabref.gui.util.DirectoryDialogConfiguration) InputMap(javax.swing.InputMap) FieldFormatterCleanupsPanel(org.jabref.gui.cleanup.FieldFormatterCleanupsPanel) AbstractAction(javax.swing.AbstractAction)

Example 23 with ButtonBarBuilder

use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.

the class ExternalFileTypeEditor method init.

private void init() {
    ok.addActionListener(e -> {
        storeSettings();
        dispose();
    });
    Action cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };
    cancel.addActionListener(cancelAction);
    // The toDefaults resets the entire list to its default values.
    toDefaults.addActionListener(e -> {
        List<ExternalFileType> list = ExternalFileTypes.getDefaultExternalFileTypes();
        fileTypes.clear();
        fileTypes.addAll(list);
        Collections.sort(fileTypes);
        tableModel.fireTableDataChanged();
    });
    add.addActionListener(e -> {
        ExternalFileType type = new ExternalFileType("", "", "", "", "new", IconTheme.JabRefIcon.FILE.getSmallIcon());
        getEditor(type).setVisible(true);
        if (entryEditor.okPressed()) {
            fileTypes.add(type);
            tableModel.fireTableDataChanged();
        }
    });
    remove.addActionListener(e -> {
        int[] rows = table.getSelectedRows();
        if (rows.length == 0) {
            return;
        }
        for (int i = rows.length - 1; i >= 0; i--) {
            fileTypes.remove(rows[i]);
        }
        tableModel.fireTableDataChanged();
        if (!fileTypes.isEmpty()) {
            int row = Math.min(rows[0], fileTypes.size() - 1);
            table.setRowSelectionInterval(row, row);
        }
    });
    edit.addActionListener(editListener);
    fileTypes = new ArrayList<>();
    setValues();
    tableModel = new FileTypeTableModel();
    table = new JTable(tableModel);
    table.setDefaultRenderer(ImageIcon.class, new IconRenderer());
    table.addMouseListener(new TableClickListener());
    table.getColumnModel().getColumn(0).setMaxWidth(24);
    table.getColumnModel().getColumn(0).setMinWidth(24);
    table.getColumnModel().getColumn(1).setMinWidth(170);
    table.getColumnModel().getColumn(2).setMinWidth(60);
    table.getColumnModel().getColumn(3).setMinWidth(100);
    table.getColumnModel().getColumn(0).setResizable(false);
    JScrollPane sp = new JScrollPane(table);
    JPanel upper = new JPanel();
    upper.setLayout(new BorderLayout());
    upper.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    upper.add(sp, BorderLayout.CENTER);
    getContentPane().add(upper, BorderLayout.CENTER);
    ButtonStackBuilder bs = new ButtonStackBuilder();
    bs.addButton(add);
    bs.addButton(remove);
    bs.addButton(edit);
    bs.addRelatedGap();
    bs.addButton(toDefaults);
    upper.add(bs.getPanel(), BorderLayout.EAST);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    pack();
    // Key bindings:
    ActionMap am = upper.getActionMap();
    InputMap im = upper.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelAction);
    am = bb.getPanel().getActionMap();
    im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelAction);
    if (frame == null) {
        setLocationRelativeTo(dialog);
    } else {
        setLocationRelativeTo(frame);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Action(javax.swing.Action) MnemonicAwareAction(org.jabref.gui.actions.MnemonicAwareAction) AbstractAction(javax.swing.AbstractAction) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) BorderLayout(java.awt.BorderLayout) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) JTable(javax.swing.JTable) InputMap(javax.swing.InputMap) ButtonStackBuilder(com.jgoodies.forms.builder.ButtonStackBuilder) AbstractAction(javax.swing.AbstractAction)

Example 24 with ButtonBarBuilder

use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.

the class StyleSelectDialog method init.

private void init() {
    setupPopupMenu();
    addButton.addActionListener(actionEvent -> {
        AddFileDialog addDialog = new AddFileDialog();
        addDialog.setDirectoryPath(preferences.getCurrentStyle());
        addDialog.setVisible(true);
        addDialog.getFileName().ifPresent(fileName -> {
            if (loader.addStyleIfValid(fileName)) {
                preferences.setCurrentStyle(fileName);
            }
        });
        updateStyles();
    });
    addButton.setToolTipText(Localization.lang("Add style file"));
    removeButton.addActionListener(removeAction);
    removeButton.setToolTipText(Localization.lang("Remove style"));
    // Create a preview panel for previewing styles
    // Must be done before creating the table to avoid NPEs
    preview = new PreviewPanel(null, null);
    // Use the test entry from the Preview settings tab in Preferences:
    preview.setEntry(prevEntry);
    setupTable();
    updateStyles();
    // Build dialog
    diag = new JDialog(frame, Localization.lang("Select style"), true);
    FormBuilder builder = FormBuilder.create();
    builder.layout(new FormLayout("fill:pref:grow, 4dlu, left:pref, 4dlu, left:pref", "pref, 4dlu, 100dlu:grow, 4dlu, pref, 4dlu, fill:100dlu"));
    builder.add(Localization.lang("Select one of the available styles or add a style file from disk.")).xyw(1, 1, 5);
    builder.add(new JScrollPane(table)).xyw(1, 3, 5);
    builder.add(addButton).xy(3, 5);
    builder.add(removeButton).xy(5, 5);
    builder.add(preview).xyw(1, 7, 5);
    builder.padding("5dlu, 5dlu, 5dlu, 5dlu");
    diag.add(builder.getPanel(), BorderLayout.CENTER);
    AbstractAction okListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) {
                JOptionPane.showMessageDialog(diag, Localization.lang("You must select a valid style file."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            okPressed = true;
            storeSettings();
            diag.dispose();
        }
    };
    ok.addActionListener(okListener);
    Action cancelListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            diag.dispose();
        }
    };
    cancel.addActionListener(cancelListener);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.add(bb.getPanel(), BorderLayout.SOUTH);
    ActionMap am = bb.getPanel().getActionMap();
    InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelListener);
    im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk");
    am.put("enterOk", okListener);
    diag.pack();
    WindowLocation pw = new WindowLocation(diag, JabRefPreferences.STYLES_POS_X, JabRefPreferences.STYLES_POS_Y, JabRefPreferences.STYLES_SIZE_X, JabRefPreferences.STYLES_SIZE_Y);
    pw.displayWindowAtStoredLocation();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JScrollPane(javax.swing.JScrollPane) FormBuilder(com.jgoodies.forms.builder.FormBuilder) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) PreviewPanel(org.jabref.gui.PreviewPanel) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) InputMap(javax.swing.InputMap) WindowLocation(org.jabref.gui.util.WindowLocation) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog)

Example 25 with ButtonBarBuilder

use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.

the class StyleSelectDialog method displayStyle.

private void displayStyle(OOBibStyle style) {
    // Make a dialog box to display the contents:
    final JDialog dd = new JDialog(diag, style.getName(), true);
    JTextArea ta = new JTextArea(style.getLocalCopy());
    ta.setEditable(false);
    JScrollPane sp = new JScrollPane(ta);
    sp.setPreferredSize(new Dimension(700, 500));
    dd.getContentPane().add(sp, BorderLayout.CENTER);
    JButton okButton = new JButton(Localization.lang("OK"));
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(okButton);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    dd.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    okButton.addActionListener(actionEvent -> dd.dispose());
    dd.pack();
    dd.setLocationRelativeTo(diag);
    dd.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) JDialog(javax.swing.JDialog)

Aggregations

ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)34 FormLayout (com.jgoodies.forms.layout.FormLayout)17 JButton (javax.swing.JButton)17 ActionEvent (java.awt.event.ActionEvent)14 AbstractAction (javax.swing.AbstractAction)14 JScrollPane (javax.swing.JScrollPane)13 ActionMap (javax.swing.ActionMap)11 InputMap (javax.swing.InputMap)11 JDialog (javax.swing.JDialog)11 JPanel (javax.swing.JPanel)9 FormBuilder (com.jgoodies.forms.builder.FormBuilder)8 BorderLayout (java.awt.BorderLayout)8 Action (javax.swing.Action)8 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)6 Dimension (java.awt.Dimension)6 ButtonGroup (javax.swing.ButtonGroup)5 JTextField (javax.swing.JTextField)4 NamedCompound (org.jabref.gui.undo.NamedCompound)4 WindowLocation (org.jabref.gui.util.WindowLocation)4 Insets (java.awt.Insets)3