Search in sources :

Example 91 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class RecurringPanel method startTimer.

private void startTimer() {
    if (timer == null) {
        Preferences p = Preferences.userNodeForPackage(getClass());
        int snooze = p.getInt(SNOOZE, DEFAULT_SNOOZE);
        timer = new Timer(snooze, this);
        timer.setInitialDelay(START_UP_DELAY);
        // Don't start until the UI has caught up
        EventQueue.invokeLater(() -> {
            timer.start();
            Logger.getLogger(RecurringPanel.class.getName()).info("Recurring timer started");
        });
    }
}
Also used : Timer(javax.swing.Timer) Preferences(java.util.prefs.Preferences)

Example 92 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class RecurringPanel method setConfirmReminderDeleteEnabled.

/**
     * Sets if confirm on transaction delete is enabled
     * 
     * @param enabled enabled state
     */
public static void setConfirmReminderDeleteEnabled(final boolean enabled) {
    confirmReminderDelete = enabled;
    Preferences p = Preferences.userNodeForPackage(RecurringPanel.class);
    p.putBoolean(CONFIRM_DELETE, confirmReminderDelete);
}
Also used : Preferences(java.util.prefs.Preferences)

Example 93 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class RecurringPanel method showRecurringDialog.

private synchronized void showRecurringDialog() {
    // exit if engine is not running or a dialog is already visible
    if (showingDialog || EngineFactory.getEngine(EngineFactory.DEFAULT) == null) {
        return;
    }
    SwingWorker<List<PendingReminder>, Void> worker = new SwingWorker<List<PendingReminder>, Void>() {

        @Override
        protected List<PendingReminder> doInBackground() throws Exception {
            final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
            Objects.requireNonNull(engine);
            return engine.getPendingReminders();
        }

        @Override
        protected void done() {
            try {
                List<PendingReminder> reminders = get();
                // Event occurs on the EDT, so no need to invoke later
                if (!reminders.isEmpty()) {
                    showingDialog = true;
                    Preferences p = Preferences.userNodeForPackage(getClass());
                    int snooze = p.getInt(SNOOZE, DEFAULT_SNOOZE);
                    // display the notification dialog
                    snooze = NotificationDialog.showDialog(reminders, snooze);
                    p.putInt(SNOOZE, snooze);
                    if (timer != null) {
                        if (snooze != 0) {
                            timer.setDelay(snooze);
                            timer.setInitialDelay(snooze);
                            timer.restart();
                        } else {
                            timer.stop();
                        }
                    } else {
                        throw new RuntimeException("Lost the timer!");
                    }
                    showingDialog = false;
                }
            } catch (final InterruptedException | ExecutionException | RuntimeException e) {
                logSevere(RecurringPanel.class, e);
            }
        }
    };
    worker.execute();
}
Also used : PendingReminder(jgnash.engine.recurring.PendingReminder) SwingWorker(javax.swing.SwingWorker) List(java.util.List) Preferences(java.util.prefs.Preferences) ExecutionException(java.util.concurrent.ExecutionException) Engine(jgnash.engine.Engine)

Example 94 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class NetworkAuthenticator method getPasswordAuthentication.

@Override
protected PasswordAuthentication getPasswordAuthentication() {
    Preferences auth = Preferences.userRoot().node(NODEHTTP);
    char[] pass = null;
    String user;
    // get the password
    String _pass = auth.get(HTTPPASS, null);
    if (_pass != null) {
        if (!_pass.isEmpty()) {
            pass = _pass.toCharArray();
        }
    }
    // get the user
    user = auth.get(HTTPUSER, null);
    if (user != null) {
        if (user.length() <= 0) {
            user = null;
        }
    }
    // if either returns null, pop a dialog
    if (user == null || pass == null) {
        JTextField username = new JTextField();
        JPasswordField password = new JPasswordField();
        JPanel panel = new JPanel(new GridLayout(2, 2));
        panel.add(new JLabel(ResourceUtils.getString("Label.UserName")));
        panel.add(username);
        panel.add(new JLabel(ResourceUtils.getString("Label.Password")));
        panel.add(password);
        int option = JOptionPane.showConfirmDialog(null, new Object[] { "Site: " + getRequestingHost(), "Realm: " + getRequestingPrompt(), panel }, "Enter Network Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
        if (option == JOptionPane.OK_OPTION) {
            user = username.getText();
            pass = password.getPassword();
        } else {
            return null;
        }
    }
    return new PasswordAuthentication(user, pass);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) Preferences(java.util.prefs.Preferences) JTextField(javax.swing.JTextField) PasswordAuthentication(java.net.PasswordAuthentication)

Example 95 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class AbstractRegisterPanel method saveColumnLayout.

void saveColumnLayout() {
    Preferences pwidth = Preferences.userRoot().node(NODE_REG_WIDTH);
    Preferences ppos = Preferences.userRoot().node(NODE_REG_POS);
    Preferences pvis = Preferences.userRoot().node(NODE_REG_VIS);
    String id = getAccount().getUuid();
    ppos.put(id, getColumnPositions());
    pwidth.put(id, getColumnWidths());
    pvis.put(id, EncodeDecode.encodeBooleanArray(getTableModel().getColumnVisibility()));
}
Also used : Preferences(java.util.prefs.Preferences)

Aggregations

Preferences (java.util.prefs.Preferences)291 BackingStoreException (java.util.prefs.BackingStoreException)49 File (java.io.File)45 ResourceBundle (java.util.ResourceBundle)24 FileChooser (javafx.stage.FileChooser)21 ArrayList (java.util.ArrayList)17 FXML (javafx.fxml.FXML)16 IOException (java.io.IOException)14 JFileChooser (javax.swing.JFileChooser)12 List (java.util.List)8 SwingWorker (javax.swing.SwingWorker)8 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)7 Engine (jgnash.engine.Engine)7 AutoCompletePreferences (org.jabref.logic.autocompleter.AutoCompletePreferences)6 FieldContentParserPreferences (org.jabref.logic.bibtex.FieldContentParserPreferences)6 LatexFieldFormatterPreferences (org.jabref.logic.bibtex.LatexFieldFormatterPreferences)6 BibtexKeyPatternPreferences (org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences)6 CleanupPreferences (org.jabref.logic.cleanup.CleanupPreferences)6 ImportFormatPreferences (org.jabref.logic.importer.ImportFormatPreferences)6 JournalAbbreviationPreferences (org.jabref.logic.journals.JournalAbbreviationPreferences)6