use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.
the class ExternalFileTypeEntryEditor method init.
private void init(ExternalFileType inEntry) {
entry = inEntry;
icon.setText(null);
ButtonGroup bg = new ButtonGroup();
bg.add(useDefault);
bg.add(other);
FormBuilder builder = FormBuilder.create();
builder.layout(new FormLayout("left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p"));
builder.add(Localization.lang("Icon")).xy(1, 1);
builder.add(icon).xy(3, 1);
builder.add(Localization.lang("Name")).xy(1, 3);
builder.add(name).xy(3, 3);
builder.add(Localization.lang("Extension")).xy(1, 5);
builder.add(extension).xy(3, 5);
builder.add(Localization.lang("MIME type")).xy(1, 7);
builder.add(mimeType).xy(3, 7);
builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
builder.add(Localization.lang("Application")).xy(1, 9);
JButton browseBut = new JButton(Localization.lang("Browse"));
if (OS.WINDOWS) {
builder.add(useDefault).xy(3, 9);
builder.appendRows("2dlu, p");
JPanel p1 = new JPanel();
builder.add(p1).xy(1, 11);
JPanel p2 = new JPanel();
application.setPreferredSize(new Dimension(300, application.getPreferredSize().height));
BorderLayout bl = new BorderLayout();
bl.setHgap(4);
p2.setLayout(bl);
p2.add(other, BorderLayout.WEST);
p2.add(application, BorderLayout.CENTER);
builder.add(p2).xy(3, 11);
builder.add(browseBut).xy(5, 11);
} else {
builder.add(application).xy(3, 9);
builder.add(browseBut).xy(5, 9);
}
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
ok.addActionListener(e -> {
okPressed = true;
storeSettings(ExternalFileTypeEntryEditor.this.entry);
diag.dispose();
});
cancel.addActionListener(e -> diag.dispose());
if (OS.WINDOWS) {
application.getDocument().addDocumentListener(new DocumentListener() {
private void handle() {
if (application.getText().isEmpty()) {
useDefault.setSelected(true);
} else {
other.setSelected(true);
}
}
@Override
public void insertUpdate(DocumentEvent documentEvent) {
handle();
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
handle();
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
handle();
}
});
}
String title = editFileTitle;
if (entry.getName().isEmpty()) {
title = newFileTitle;
}
if (dParent == null) {
diag = new JDialog(fParent, title, true);
} else {
diag = new JDialog(dParent, title, true);
}
diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
diag.pack();
browseBut.addActionListener(browsePressed);
if (dParent == null) {
diag.setLocationRelativeTo(fParent);
} else {
diag.setLocationRelativeTo(dParent);
}
setValues(entry);
}
use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.
the class MergeEntries method initialize.
/**
* Main function for building the merge entry JPanel
*/
private void initialize() {
doneBuilding = false;
setupFields();
fillDiffModes();
// Create main layout
String colSpecMain = "left:pref, 5px, center:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, center:3cm:grow";
String colSpecMerge = "left:pref, 5px, fill:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, fill:3cm:grow";
String rowSpec = "pref, pref, 10px, fill:5cm:grow, 10px, pref, 10px, fill:3cm:grow";
StringBuilder rowBuilder = new StringBuilder("");
for (int i = 0; i < allFields.size(); i++) {
rowBuilder.append("pref, 2dlu, ");
}
rowBuilder.append("pref");
JPanel mergePanel = new JPanel();
FormLayout mainLayout = new FormLayout(colSpecMain, rowSpec);
FormLayout mergeLayout = new FormLayout(colSpecMerge, rowBuilder.toString());
mainPanel.setLayout(mainLayout);
mergePanel.setLayout(mergeLayout);
setupHeadingRows();
mainPanel.add(new JSeparator(), CELL_CONSTRAINTS.xyw(1, 3, 11));
setupEntryTypeRow(mergePanel);
int maxLabelWidth = setupFieldRows(mergePanel);
// Create and add scrollpane
scrollPane = new JScrollPane(mergePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
updateTextPanes(allFields);
mainPanel.add(scrollPane, CELL_CONSTRAINTS.xyw(1, 4, 11));
mainPanel.add(new JSeparator(), CELL_CONSTRAINTS.xyw(1, 5, 11));
synchronizeColumnWidths(mainLayout, mergeLayout, maxLabelWidth);
// Setup a PreviewPanel and a Bibtex source box for the merged entry
mainPanel.add(boldFontLabel(Localization.lang("Merged entry")), CELL_CONSTRAINTS.xyw(1, 6, 6));
entryPreview = new PreviewPanel(null, mergedEntry, null);
mainPanel.add(entryPreview, CELL_CONSTRAINTS.xyw(1, 8, 6));
mainPanel.add(boldFontLabel(Localization.lang("Merged BibTeX source code")), CELL_CONSTRAINTS.xyw(8, 6, 4));
sourceView = new JTextArea();
sourceView.setLineWrap(true);
sourceView.setFont(new Font("Monospaced", Font.PLAIN, Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)));
mainPanel.add(new JScrollPane(sourceView), CELL_CONSTRAINTS.xyw(8, 8, 4));
sourceView.setEditable(false);
// Add some margin around the layout
mainLayout.appendRow(RowSpec.decode(MARGIN));
mainLayout.appendColumn(ColumnSpec.decode(MARGIN));
mainLayout.insertRow(1, RowSpec.decode(MARGIN));
mainLayout.insertColumn(1, ColumnSpec.decode(MARGIN));
// Everything done, allow any action to actually update the merged entry
doneBuilding = true;
updateAll();
// Show what we've got
mainPanel.setVisible(true);
SwingUtilities.invokeLater(() -> scrollPane.getVerticalScrollBar().setValue(0));
}
use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.
the class MergeEntriesDialog method init.
/**
* Sets up the dialog
*
* @param selected Selected BibtexEntries
*/
private void init(List<BibEntry> selected) {
// Check if there are two entries selected
if (selected.size() != 2) {
// None selected. Inform the user to select entries first.
JOptionPane.showMessageDialog(panel.frame(), Localization.lang("You have to choose exactly two entries to merge."), MERGE_ENTRIES, JOptionPane.INFORMATION_MESSAGE);
this.dispose();
return;
}
// Store the two entries
BibEntry one = selected.get(0);
BibEntry two = selected.get(1);
MergeEntries mergeEntries = new MergeEntries(one, two, panel.getBibDatabaseContext().getMode());
// Create undo-compound
NamedCompound ce = new NamedCompound(MERGE_ENTRIES);
FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
this.setLayout(layout);
this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
this.add(new JSeparator(), cc.xy(1, 3));
// Create buttons
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
JButton cancel = new JButton(Localization.lang("Cancel"));
cancel.setActionCommand("cancel");
cancel.addActionListener(e -> {
panel.output(Localization.lang("Canceled merging entries"));
dispose();
});
JButton replaceentries = new JButton(MERGE_ENTRIES);
replaceentries.setActionCommand("replace");
replaceentries.addActionListener(e -> {
BibEntry mergedEntry = mergeEntries.getMergeEntry();
panel.insertEntry(mergedEntry);
ce.addEdit(new UndoableInsertEntry(panel.getDatabase(), mergedEntry, panel));
ce.addEdit(new UndoableRemoveEntry(panel.getDatabase(), one, panel));
panel.getDatabase().removeEntry(one);
ce.addEdit(new UndoableRemoveEntry(panel.getDatabase(), two, panel));
panel.getDatabase().removeEntry(two);
ce.end();
panel.getUndoManager().addEdit(ce);
panel.output(Localization.lang("Merged entries"));
dispose();
});
bb.addButton(new JButton[] { replaceentries, cancel });
this.add(bb.getPanel(), cc.xy(1, 5));
// Add some margin around the layout
layout.appendRow(RowSpec.decode(MARGIN));
layout.appendColumn(ColumnSpec.decode(MARGIN));
layout.insertRow(1, RowSpec.decode(MARGIN));
layout.insertColumn(1, ColumnSpec.decode(MARGIN));
WindowLocation pw = new WindowLocation(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y, JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
pw.displayWindowAtStoredLocation();
// Show what we've got
setVisible(true);
}
use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.
the class MergeFetchedEntryDialog method init.
/**
* Sets up the dialog
*/
private void init() {
mergeEntries = new MergeEntries(this.originalEntry, this.fetchedEntry, Localization.lang("Original entry"), Localization.lang("Entry from %0", type), panel.getBibDatabaseContext().getMode());
// Create undo-compound
ce = new NamedCompound(Localization.lang("Merge entry with %0 information", type));
FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
this.setLayout(layout);
this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
this.add(new JSeparator(), cc.xy(1, 3));
// Create buttons
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
JButton cancel = new JButton(new CancelAction());
JButton replaceEntry = new JButton(new ReplaceAction());
bb.addButton(replaceEntry, cancel);
this.add(bb.getPanel(), cc.xy(1, 5));
// Add some margin around the layout
layout.appendRow(RowSpec.decode(MARGIN));
layout.appendColumn(ColumnSpec.decode(MARGIN));
layout.insertRow(1, RowSpec.decode(MARGIN));
layout.insertColumn(1, ColumnSpec.decode(MARGIN));
WindowLocation pw = new WindowLocation(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y, JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
pw.displayWindowAtStoredLocation();
}
use of com.jgoodies.forms.layout.FormLayout in project jabref by JabRef.
the class DetectOpenOfficeInstallation method chooseAmongInstallations.
private Optional<Path> chooseAmongInstallations(List<Path> installDirs) {
if (installDirs.isEmpty()) {
return Optional.empty();
}
if (installDirs.size() == 1) {
return Optional.of(installDirs.get(0).toAbsolutePath());
}
// Otherwise more than one installation was found, select among them
DefaultListModel<File> mod = new DefaultListModel<>();
for (Path tmpfile : installDirs) {
mod.addElement(tmpfile.toFile());
}
JList<File> fileList = new JList<>(mod);
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fileList.setSelectedIndex(0);
FormBuilder builder = FormBuilder.create().layout(new FormLayout("pref:grow", "pref, 2dlu, pref, 4dlu, pref"));
builder.add(Localization.lang("Found more than one OpenOffice/LibreOffice executable.")).xy(1, 1);
builder.add(Localization.lang("Please choose which one to connect to:")).xy(1, 3);
builder.add(fileList).xy(1, 5);
int answer = JOptionPane.showConfirmDialog(null, builder.getPanel(), Localization.lang("Choose OpenOffice/LibreOffice executable"), JOptionPane.OK_CANCEL_OPTION);
if (answer == JOptionPane.CANCEL_OPTION) {
return Optional.empty();
} else {
return Optional.of(fileList.getSelectedValue().toPath());
}
}
Aggregations