use of org.jabref.JabRefException in project jabref by JabRef.
the class ConnectToSharedDatabaseDialog method setupActions.
/**
* Defines and sets the different actions up.
*/
private void setupActions() {
Action openAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
try {
checkFields();
connectionProperties = new DBMSConnectionProperties();
connectionProperties.setType((DBMSType) dbmsTypeDropDown.getSelectedItem());
connectionProperties.setHost(hostField.getText());
connectionProperties.setPort(Integer.parseInt(portField.getText()));
connectionProperties.setDatabase(databaseField.getText());
connectionProperties.setUser(userField.getText());
//JPasswordField.getPassword() does not return a String, but a char array.
connectionProperties.setPassword(new String(passwordField.getPassword()));
openSharedDatabase();
} catch (JabRefException exception) {
JOptionPane.showMessageDialog(ConnectToSharedDatabaseDialog.this, exception.getMessage(), Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE);
}
}
};
connectButton.addActionListener(openAction);
cancelButton.addActionListener(e -> dispose());
/**
* Set up a listener which updates the default port number once the selection in dbmsTypeDropDown has changed.
*/
Action dbmsTypeDropDownAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
portField.setText(Integer.toString(((DBMSType) dbmsTypeDropDown.getSelectedItem()).getDefaultPort()));
}
};
dbmsTypeDropDown.addActionListener(dbmsTypeDropDownAction);
// Add enter button action listener
connectButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter_pressed");
connectButton.getActionMap().put("Enter_pressed", openAction);
browseButton.addActionListener(e -> showFileChooser());
autosaveFile.addActionListener(e -> updateEnableState());
}
use of org.jabref.JabRefException in project jabref by JabRef.
the class ArgumentProcessor method importPreferences.
private void importPreferences() {
try {
Globals.prefs.importPreferences(cli.getPreferencesImport());
EntryTypes.loadCustomEntryTypes(Globals.prefs.loadCustomEntryTypes(BibDatabaseMode.BIBTEX), Globals.prefs.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Map<String, ExportFormat> customFormats = Globals.prefs.customExports.getCustomExportFormats(Globals.prefs, Globals.journalAbbreviationLoader);
LayoutFormatterPreferences layoutPreferences = Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs);
ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences);
} catch (JabRefException ex) {
LOGGER.error("Cannot import preferences", ex);
}
}
Aggregations