use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.
the class EntryTypeDialog method createCancelButtonBarPanel.
private JPanel createCancelButtonBarPanel() {
JButton cancel = new JButton(Localization.lang("Cancel"));
cancel.addActionListener(this);
// Make ESC close dialog, equivalent to clicking Cancel.
cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
cancel.getActionMap().put("close", cancelAction);
JPanel buttons = new JPanel();
ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
bb.addGlue();
bb.addButton(cancel);
bb.addGlue();
return buttons;
}
use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.
the class GenFieldsCustomizer method jbInit.
private void jbInit() {
ok.setText(Localization.lang("OK"));
ok.addActionListener(e -> okActionPerformed());
cancel.setText(Localization.lang("Cancel"));
cancel.addActionListener(e -> dispose());
jLabel1.setText(Localization.lang("Delimit fields with semicolon, ex.") + ": url;pdf;note");
jPanel3.setLayout(gridBagLayout2);
jPanel4.setBorder(BorderFactory.createEtchedBorder());
jPanel4.setLayout(gridBagLayout1);
jLabel2.setText(Localization.lang("General fields"));
setFieldsText();
revert.setText(Localization.lang("Default"));
revert.addActionListener(e -> revertActionPerformed());
this.getContentPane().add(buttons, BorderLayout.SOUTH);
ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
bb.addGlue();
bb.addButton(ok);
bb.addButton(revert);
bb.addButton(cancel);
bb.addStrut(Sizes.DLUX5);
bb.addButton(helpBut);
bb.addGlue();
this.getContentPane().add(jPanel3, BorderLayout.CENTER);
jPanel3.add(jLabel1, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
jPanel3.add(jPanel4, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 318, 193));
jPanel4.add(jScrollPane1, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
jScrollPane1.getViewport().add(fieldsArea, null);
jPanel4.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
// Key bindings:
ActionMap am = buttons.getActionMap();
InputMap im = buttons.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
}
use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.
the class MassSetFieldAction method createDialog.
private void createDialog() {
diag = new JDialog(frame, Localization.lang("Set/clear/rename fields"), true);
field = new JComboBox<>();
field.setEditable(true);
text = new JTextField();
text.setEnabled(false);
renameTo = new JTextField();
renameTo.setEnabled(false);
JButton ok = new JButton(Localization.lang("OK"));
JButton cancel = new JButton(Localization.lang("Cancel"));
all = new JRadioButton(Localization.lang("All entries"));
selected = new JRadioButton(Localization.lang("Selected entries"));
clear = new JRadioButton(Localization.lang("Clear fields"));
set = new JRadioButton(Localization.lang("Set fields"));
rename = new JRadioButton(Localization.lang("Rename field to") + ":");
rename.setToolTipText(Localization.lang("Move contents of a field into a field with a different name"));
Set<String> allFields = frame.getCurrentBasePanel().getDatabase().getAllVisibleFields();
for (String f : allFields) {
field.addItem(f);
}
set.addChangeListener(e -> text.setEnabled(set.isSelected()));
clear.addChangeListener(e -> overwrite.setEnabled(!clear.isSelected()));
rename.addChangeListener(e -> renameTo.setEnabled(rename.isSelected()));
overwrite = new JCheckBox(Localization.lang("Overwrite existing field values"), true);
ButtonGroup bg = new ButtonGroup();
bg.add(all);
bg.add(selected);
bg = new ButtonGroup();
bg.add(clear);
bg.add(set);
bg.add(rename);
FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 4dlu, fill:100dlu:grow", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref"));
builder.addSeparator(Localization.lang("Field name")).xyw(1, 1, 3);
builder.add(Localization.lang("Field name")).xy(1, 3);
builder.add(field).xy(3, 3);
builder.addSeparator(Localization.lang("Include entries")).xyw(1, 5, 3);
builder.add(all).xyw(1, 7, 3);
builder.add(selected).xyw(1, 9, 3);
builder.addSeparator(Localization.lang("New field value")).xyw(1, 11, 3);
builder.add(set).xy(1, 13);
builder.add(text).xy(3, 13);
builder.add(clear).xyw(1, 15, 3);
builder.add(rename).xy(1, 17);
builder.add(renameTo).xy(3, 17);
builder.add(overwrite).xyw(1, 19, 3);
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
diag.pack();
ok.addActionListener(e -> {
String fieldText = (String) field.getSelectedItem();
if ((fieldText == null) || fieldText.trim().isEmpty()) {
JOptionPane.showMessageDialog(diag, Localization.lang("You must enter at least one field name"), "", JOptionPane.ERROR_MESSAGE);
return;
}
if (rename.isSelected()) {
String[] fields = getFieldNames(fieldText);
if (fields.length > 1) {
JOptionPane.showMessageDialog(diag, Localization.lang("You can only rename one field at a time"), "", JOptionPane.ERROR_MESSAGE);
return;
}
}
canceled = false;
diag.dispose();
});
Action cancelAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
canceled = true;
diag.dispose();
}
};
cancel.addActionListener(cancelAction);
// Key bindings:
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", cancelAction);
}
use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.
the class FromAuxDialog method jbInit.
private void jbInit() {
JPanel panel1 = new JPanel();
panel1.setLayout(new BorderLayout());
generateButton.setText(Localization.lang("Generate"));
generateButton.setEnabled(false);
generateButton.addActionListener(e -> {
generatePressed = true;
dispose();
});
cancelButton.setText(Localization.lang("Cancel"));
cancelButton.addActionListener(e -> dispose());
parseButton.setText(Localization.lang("Parse"));
parseButton.addActionListener(e -> parseActionPerformed());
initPanels();
// insert the buttons
ButtonBarBuilder bb = new ButtonBarBuilder();
JPanel buttonPanel = bb.getPanel();
buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bb.addGlue();
bb.addButton(parseButton);
bb.addRelatedGap();
bb.addButton(generateButton);
bb.addButton(cancelButton);
bb.addGlue();
this.setModal(true);
this.setResizable(true);
this.setTitle(Localization.lang("AUX file import"));
JLabel desc = new JLabel("<html><h3>" + Localization.lang("AUX file import") + "</h3><p>" + Localization.lang("This feature generates a new library based on which entries " + "are needed in an existing LaTeX document.") + "</p>" + "<p>" + Localization.lang("You need to select one of your open libraries from which to choose " + "entries, as well as the AUX file produced by LaTeX when compiling your document.") + "</p></html>");
desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
panel1.add(desc, BorderLayout.NORTH);
JPanel centerPane = new JPanel(new BorderLayout());
centerPane.add(buttons, BorderLayout.NORTH);
centerPane.add(statusPanel, BorderLayout.CENTER);
getContentPane().add(panel1, BorderLayout.NORTH);
getContentPane().add(centerPane, BorderLayout.CENTER);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
// Key bindings:
ActionMap am = statusPanel.getActionMap();
InputMap im = statusPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
}
use of com.jgoodies.forms.builder.ButtonBarBuilder in project jabref by JabRef.
the class EntryCustomizationDialog method initGui.
private void initGui() {
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
if (frame.getCurrentBasePanel() == null) {
bibDatabaseMode = Globals.prefs.getDefaultBibDatabaseMode();
} else {
bibDatabaseMode = frame.getCurrentBasePanel().getBibDatabaseContext().getMode();
}
biblatexMode = BibDatabaseMode.BIBLATEX.equals(bibDatabaseMode);
JPanel main = new JPanel();
JPanel buttons = new JPanel();
JPanel right = new JPanel();
main.setLayout(new BorderLayout());
right.setLayout(new GridLayout(biblatexMode ? 2 : 1, 2));
List<String> entryTypes = new ArrayList<>();
for (String s : EntryTypes.getAllTypes(bibDatabaseMode)) {
entryTypes.add(s);
}
typeComp = new EntryTypeList(entryTypes, bibDatabaseMode);
typeComp.addListSelectionListener(this);
typeComp.addAdditionActionListener(e -> typeComp.selectField(e.getActionCommand()));
typeComp.addDefaultActionListener(new DefaultListener());
typeComp.setListSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//typeComp.setEnabled(false);
reqComp = new FieldSetComponent(Localization.lang("Required fields"), new ArrayList<>(), preset, true, true);
reqComp.setEnabled(false);
reqComp.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
ListDataListener dataListener = new DataListener();
reqComp.addListDataListener(dataListener);
optComp = new FieldSetComponent(Localization.lang("Optional fields"), new ArrayList<>(), preset, true, true);
optComp.setEnabled(false);
optComp.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
optComp.addListDataListener(dataListener);
right.add(reqComp);
right.add(optComp);
if (biblatexMode) {
optComp2 = new FieldSetComponent(Localization.lang("Optional fields") + " 2", new ArrayList<>(), preset, true, true);
optComp2.setEnabled(false);
optComp2.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
optComp2.addListDataListener(dataListener);
right.add(new JPanel());
right.add(optComp2);
}
//right.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Fields")));
right.setBorder(BorderFactory.createEtchedBorder());
ok = new JButton(Localization.lang("OK"));
cancel = new JButton(Localization.lang("Cancel"));
apply = new JButton(Localization.lang("Apply"));
ok.addActionListener(e -> {
applyChanges();
dispose();
});
apply.addActionListener(e -> applyChanges());
cancel.addActionListener(e -> dispose());
ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
bb.addGlue();
bb.addButton(ok);
bb.addButton(apply);
bb.addButton(cancel);
bb.addGlue();
AbstractAction closeAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
};
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", closeAction);
//con.fill = GridBagConstraints.BOTH;
//con.weightx = 0.3;
//con.weighty = 1;
//gbl.setConstraints(typeComp, con);
main.add(typeComp, BorderLayout.WEST);
main.add(right, BorderLayout.CENTER);
main.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
pane.add(main, BorderLayout.CENTER);
pane.add(buttons, BorderLayout.SOUTH);
pack();
}
Aggregations