use of org.jabref.gui.util.DirectoryDialogConfiguration in project jabref by JabRef.
the class FindUnlinkedFilesDialog method setupActions.
/**
* Sets up the actions for the components.
*/
private void setupActions() {
DirectoryDialogConfiguration directoryDialogConfiguration = new DirectoryDialogConfiguration.Builder().withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
DialogService ds = new FXDialogService();
/**
* Stores the selected directory.
*/
buttonBrowse.addActionListener(e -> {
Optional<Path> selectedDirectory = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showDirectorySelectionDialog(directoryDialogConfiguration));
selectedDirectory.ifPresent(d -> {
textfieldDirectoryPath.setText(d.toAbsolutePath().toString());
storeLastSelectedDirectory(d);
});
});
buttonScan.addActionListener(e -> startSearch());
/**
* Action for the button "Import...". <br>
* <br>
* Actions on this button will start the import of all file of all
* selected nodes in this dialogs tree view. <br>
*/
ActionListener actionListenerImportEntrys = e -> startImport();
buttonApply.addActionListener(actionListenerImportEntrys);
buttonClose.addActionListener(e -> dispose());
}
use of org.jabref.gui.util.DirectoryDialogConfiguration in project jabref by JabRef.
the class OpenOfficePanel method showManualConnectionDialog.
private void showManualConnectionDialog() {
dialogOkPressed = false;
final JDialog cDiag = new JDialog(frame, Localization.lang("Set connection parameters"), true);
final NativeDesktop nativeDesktop = JabRefDesktop.getNativeDesktop();
final DialogService dirDialog = new FXDialogService();
DirectoryDialogConfiguration dirDialogConfiguration = new DirectoryDialogConfiguration.Builder().withInitialDirectory(nativeDesktop.getApplicationDirectory()).build();
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().withInitialDirectory(nativeDesktop.getApplicationDirectory()).build();
DialogService fileDialog = new FXDialogService();
// Path fields
final JTextField ooPath = new JTextField(30);
JButton browseOOPath = new JButton(Localization.lang("Browse"));
ooPath.setText(preferences.getInstallationPath());
browseOOPath.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> dirDialog.showDirectorySelectionDialog(dirDialogConfiguration)).ifPresent(f -> ooPath.setText(f.toAbsolutePath().toString())));
final JTextField ooExec = new JTextField(30);
JButton browseOOExec = new JButton(Localization.lang("Browse"));
ooExec.setText(preferences.getExecutablePath());
browseOOExec.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> fileDialog.showFileOpenDialog(fileDialogConfiguration)).ifPresent(f -> ooExec.setText(f.toAbsolutePath().toString())));
final JTextField ooJars = new JTextField(30);
ooJars.setText(preferences.getJarsPath());
JButton browseOOJars = new JButton(Localization.lang("Browse"));
browseOOJars.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> dirDialog.showDirectorySelectionDialog(dirDialogConfiguration)).ifPresent(f -> ooJars.setText(f.toAbsolutePath().toString())));
FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, fill:pref", "pref"));
if (OS.WINDOWS || OS.OS_X) {
builder.add(Localization.lang("Path to OpenOffice/LibreOffice directory")).xy(1, 1);
builder.add(ooPath).xy(3, 1);
builder.add(browseOOPath).xy(5, 1);
} else {
builder.add(Localization.lang("Path to OpenOffice/LibreOffice executable")).xy(1, 1);
builder.add(ooExec).xy(3, 1);
builder.add(browseOOExec).xy(5, 1);
builder.appendRows("4dlu, pref");
builder.add(Localization.lang("Path to OpenOffice/LibreOffice library dir")).xy(1, 3);
builder.add(ooJars).xy(3, 3);
builder.add(browseOOJars).xy(5, 3);
}
builder.padding("5dlu, 5dlu, 5dlu, 5dlu");
cDiag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
// Buttons
JButton ok = new JButton(Localization.lang("OK"));
JButton cancel = new JButton(Localization.lang("Cancel"));
ok.addActionListener(e -> {
if (OS.WINDOWS || OS.OS_X) {
preferences.updateConnectionParams(ooPath.getText(), ooPath.getText(), ooPath.getText());
} else {
preferences.updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText());
}
dialogOkPressed = true;
cDiag.dispose();
});
cancel.addActionListener(e -> cDiag.dispose());
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addRelatedGap();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
bb.padding("5dlu, 5dlu, 5dlu, 5dlu");
cDiag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
// Finish and show dirDialog
cDiag.pack();
cDiag.setLocationRelativeTo(frame);
cDiag.setVisible(true);
}
use of org.jabref.gui.util.DirectoryDialogConfiguration in project jabref by JabRef.
the class DetectOpenOfficeInstallation method selectInstallationPath.
private Optional<Path> selectInstallationPath() {
final NativeDesktop nativeDesktop = JabRefDesktop.getNativeDesktop();
JOptionPane.showMessageDialog(parent, Localization.lang("Unable to autodetect OpenOffice/LibreOffice installation. Please choose the installation directory manually."), Localization.lang("Could not find OpenOffice/LibreOffice installation"), JOptionPane.INFORMATION_MESSAGE);
DialogService ds = new FXDialogService();
DirectoryDialogConfiguration dirDialogConfiguration = new DirectoryDialogConfiguration.Builder().withInitialDirectory(nativeDesktop.getApplicationDirectory()).build();
Optional<Path> path = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showDirectorySelectionDialog(dirDialogConfiguration));
if (path.isPresent()) {
return path;
}
return Optional.empty();
}
use of org.jabref.gui.util.DirectoryDialogConfiguration 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());
}
Aggregations