Search in sources :

Example 1 with JabRefException

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());
}
Also used : SaveDatabaseAction(org.jabref.gui.exporter.SaveDatabaseAction) AbstractAction(javax.swing.AbstractAction) HelpAction(org.jabref.gui.help.HelpAction) Action(javax.swing.Action) JabRefException(org.jabref.JabRefException) ActionEvent(java.awt.event.ActionEvent) DBMSType(org.jabref.shared.DBMSType) AbstractAction(javax.swing.AbstractAction) DBMSConnectionProperties(org.jabref.shared.DBMSConnectionProperties)

Example 2 with JabRefException

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);
    }
}
Also used : LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) JabRefException(org.jabref.JabRefException) SavePreferences(org.jabref.logic.exporter.SavePreferences) IExportFormat(org.jabref.logic.exporter.IExportFormat) ExportFormat(org.jabref.logic.exporter.ExportFormat)

Aggregations

JabRefException (org.jabref.JabRefException)2 ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 Action (javax.swing.Action)1 SaveDatabaseAction (org.jabref.gui.exporter.SaveDatabaseAction)1 HelpAction (org.jabref.gui.help.HelpAction)1 ExportFormat (org.jabref.logic.exporter.ExportFormat)1 IExportFormat (org.jabref.logic.exporter.IExportFormat)1 SavePreferences (org.jabref.logic.exporter.SavePreferences)1 LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)1 DBMSConnectionProperties (org.jabref.shared.DBMSConnectionProperties)1 DBMSType (org.jabref.shared.DBMSType)1