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");
});
}
}
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);
}
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();
}
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);
}
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()));
}
Aggregations