use of com.jgoodies.forms.builder.FormBuilder 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());
}
use of com.jgoodies.forms.builder.FormBuilder in project jabref by JabRef.
the class OpenOfficePanel method initPanel.
private void initPanel() {
connect.addActionListener(e -> connect(true));
manualConnect.addActionListener(e -> connect(false));
selectDocument.setToolTipText(Localization.lang("Select which open Writer document to work on"));
selectDocument.addActionListener(e -> {
try {
ooBase.selectDocument();
frame.output(Localization.lang("Connected to document") + ": " + ooBase.getCurrentDocumentTitle().orElse(""));
} catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException | NoSuchElementException | NoDocumentException ex) {
JOptionPane.showMessageDialog(frame, ex.getMessage(), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
LOGGER.warn("Problem connecting", ex);
}
});
setStyleFile.addActionListener(event -> {
if (styleDialog == null) {
styleDialog = new StyleSelectDialog(frame, preferences, loader);
}
styleDialog.setVisible(true);
styleDialog.getStyle().ifPresent(selectedStyle -> {
style = selectedStyle;
try {
style.ensureUpToDate();
} catch (IOException e) {
LOGGER.warn("Unable to reload style file '" + style.getPath() + "'", e);
}
frame.setStatus(Localization.lang("Current style is '%0'", style.getName()));
});
});
pushEntries.setToolTipText(Localization.lang("Cite selected entries between parenthesis"));
pushEntries.addActionListener(e -> pushEntries(true, true, false));
pushEntriesInt.setToolTipText(Localization.lang("Cite selected entries with in-text citation"));
pushEntriesInt.addActionListener(e -> pushEntries(false, true, false));
pushEntriesEmpty.setToolTipText(Localization.lang("Insert a citation without text (the entry will appear in the reference list)"));
pushEntriesEmpty.addActionListener(e -> pushEntries(false, false, false));
pushEntriesAdvanced.setToolTipText(Localization.lang("Cite selected entries with extra information"));
pushEntriesAdvanced.addActionListener(e -> pushEntries(false, true, true));
update.setToolTipText(Localization.lang("Ensure that the bibliography is up-to-date"));
Action updateAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
try {
if (style == null) {
style = loader.getUsedStyle();
} else {
style.ensureUpToDate();
}
ooBase.updateSortedReferenceMarks();
List<BibDatabase> databases = getBaseList();
List<String> unresolvedKeys = ooBase.refreshCiteMarkers(databases, style);
ooBase.rebuildBibTextSection(databases, style);
if (!unresolvedKeys.isEmpty()) {
JOptionPane.showMessageDialog(frame, Localization.lang("Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current library.", unresolvedKeys.get(0)), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE);
}
} catch (UndefinedCharacterFormatException ex) {
reportUndefinedCharacterFormat(ex);
} catch (UndefinedParagraphFormatException ex) {
reportUndefinedParagraphFormat(ex);
} catch (ConnectionLostException ex) {
showConnectionLostErrorMessage();
} catch (IOException ex) {
JOptionPane.showMessageDialog(frame, Localization.lang("You must select either a valid style file, or use one of the default styles."), Localization.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE);
LOGGER.warn("Problem with style file", ex);
} catch (BibEntryNotFoundException ex) {
JOptionPane.showMessageDialog(frame, Localization.lang("Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current library.", ex.getBibtexKey()), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE);
LOGGER.debug("BibEntry not found", ex);
} catch (com.sun.star.lang.IllegalArgumentException | PropertyVetoException | UnknownPropertyException | WrappedTargetException | NoSuchElementException | CreationException ex) {
LOGGER.warn("Could not update bibliography", ex);
}
}
};
update.addActionListener(updateAction);
merge.setToolTipText(Localization.lang("Combine pairs of citations that are separated by spaces only"));
merge.addActionListener(e -> {
try {
ooBase.combineCiteMarkers(getBaseList(), style);
} catch (UndefinedCharacterFormatException ex) {
reportUndefinedCharacterFormat(ex);
} catch (com.sun.star.lang.IllegalArgumentException | UnknownPropertyException | PropertyVetoException | CreationException | NoSuchElementException | WrappedTargetException | IOException | BibEntryNotFoundException ex) {
LOGGER.warn("Problem combining cite markers", ex);
}
});
settingsB.addActionListener(e -> showSettingsPopup());
manageCitations.addActionListener(e -> {
try {
CitationManager cm = new CitationManager(frame, ooBase);
cm.showDialog();
} catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) {
LOGGER.warn("Problem showing citation manager", ex);
}
});
exportCitations.addActionListener(event -> exportEntries());
selectDocument.setEnabled(false);
pushEntries.setEnabled(false);
pushEntriesInt.setEnabled(false);
pushEntriesEmpty.setEnabled(false);
pushEntriesAdvanced.setEnabled(false);
update.setEnabled(false);
merge.setEnabled(false);
manageCitations.setEnabled(false);
exportCitations.setEnabled(false);
diag = new JDialog((JFrame) null, "OpenOffice/LibreOffice panel", false);
FormBuilder mainBuilder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p,p,p,p,p,p,p,p,p,p,p"));
FormBuilder topRowBuilder = FormBuilder.create().layout(new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref", "pref"));
topRowBuilder.add(connect).xy(1, 1);
topRowBuilder.add(manualConnect).xy(3, 1);
topRowBuilder.add(selectDocument).xy(5, 1);
topRowBuilder.add(update).xy(7, 1);
topRowBuilder.add(help).xy(9, 1);
mainBuilder.add(topRowBuilder.getPanel()).xy(1, 1);
mainBuilder.add(setStyleFile).xy(1, 2);
mainBuilder.add(pushEntries).xy(1, 3);
mainBuilder.add(pushEntriesInt).xy(1, 4);
mainBuilder.add(pushEntriesAdvanced).xy(1, 5);
mainBuilder.add(pushEntriesEmpty).xy(1, 6);
mainBuilder.add(merge).xy(1, 7);
mainBuilder.add(manageCitations).xy(1, 8);
mainBuilder.add(exportCitations).xy(1, 9);
mainBuilder.add(settingsB).xy(1, 10);
JPanel content = new JPanel();
sidePane.setContentContainer(content);
content.setLayout(new BorderLayout());
content.add(mainBuilder.getPanel(), BorderLayout.CENTER);
frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(Globals.getKeyPrefs().getKey(KeyBinding.REFRESH_OO), "Refresh OO");
frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction);
}
use of com.jgoodies.forms.builder.FormBuilder 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();
}
use of com.jgoodies.forms.builder.FormBuilder in project jabref by JabRef.
the class ProtectedTermsDialog method init.
private void init() {
setupPopupMenu();
loadButton.addActionListener(actionEvent -> {
AddFileDialog addDialog = new AddFileDialog();
addDialog.setVisible(true);
addDialog.getFileName().ifPresent(fileName -> loader.addProtectedTermsListFromFile(fileName, true));
tableModel.fireTableDataChanged();
});
loadButton.setToolTipText(Localization.lang("Add protected terms file"));
removeButton.addActionListener(removeAction);
removeButton.setToolTipText(Localization.lang("Remove protected terms file"));
newButton.addActionListener(actionEvent -> {
NewProtectedTermsFileDialog newDialog = new NewProtectedTermsFileDialog(diag, loader);
newDialog.setVisible(true);
tableModel.fireTableDataChanged();
});
newButton.setToolTipText(Localization.lang("New protected terms file"));
setupTable();
// Build dialog
diag = new JDialog(frame, Localization.lang("Manage protected terms files"), true);
FormBuilder builder = FormBuilder.create();
builder.layout(new FormLayout("fill:pref:grow, 4dlu, left:pref, 4dlu, left:pref, 4dlu, left:pref", "100dlu:grow, 4dlu, pref"));
builder.add(new JScrollPane(table)).xyw(1, 1, 7);
builder.add(newButton).xy(3, 3);
builder.add(loadButton).xy(5, 3);
builder.add(removeButton).xy(7, 3);
builder.padding("5dlu, 5dlu, 5dlu, 5dlu");
diag.add(builder.getPanel(), BorderLayout.CENTER);
AbstractAction okListener = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
// Write changes to preferences
storePreferences();
diag.dispose();
}
};
ok.addActionListener(okListener);
Action cancelListener = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
// Restore from preferences
loader.update(Globals.prefs.getProtectedTermsPreferences());
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.TERMS_POS_X, JabRefPreferences.TERMS_POS_Y, JabRefPreferences.TERMS_SIZE_X, JabRefPreferences.TERMS_SIZE_Y);
pw.displayWindowAtStoredLocation();
}
Aggregations