use of java.util.prefs.Preferences in project jgnash by ccavanaugh.
the class SaveFileAsAction method saveFileAs.
/**
* Opens a Save as Dialog. If the extension of the destination file is different than the file currently open, then
* an attempt is made to identify the new file format and save accordingly. Otherwise, a copy of the file is made.
*/
private static void saveFileAs() {
final ResourceBundle rb = ResourceUtils.getBundle();
final Preferences pref = Preferences.userNodeForPackage(SaveFileAsAction.class);
JFileChooser chooser = new JFileChooser(pref.get(CURRENT_DIR, null));
chooser.setMultiSelectionEnabled(false);
chooser.setDialogTitle(rb.getString("Title.SaveAs"));
final DataStoreType[] types = DataStoreType.values();
final String[] ext = new String[types.length];
for (int i = 0; i < types.length; i++) {
ext[i] = types[i].getDataStore().getFileExt();
}
StringBuilder description = new StringBuilder(rb.getString("Label.jGnashFiles") + " (");
for (int i = 0; i < types.length; i++) {
description.append("*");
description.append(types[i].getDataStore().getFileExt());
if (i < types.length - 1) {
description.append(", ");
}
}
description.append(')');
chooser.addChoosableFileFilter(new DataStoreFilter(description.toString(), ext));
if (chooser.showSaveDialog(UIApplication.getFrame()) == JFileChooser.APPROVE_OPTION) {
pref.put(CURRENT_DIR, chooser.getCurrentDirectory().getAbsolutePath());
final class SaveAs extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
UIApplication.getFrame().displayWaitMessage(rb.getString("Message.PleaseWait"));
EngineFactory.saveAs(chooser.getSelectedFile().getAbsolutePath());
return null;
}
@Override
protected void done() {
UIApplication.getFrame().stopWaitMessage();
}
}
new SaveAs().execute();
}
}
use of java.util.prefs.Preferences in project jgnash by ccavanaugh.
the class ImportOfxAction method importOfx.
private static void importOfx() {
final ResourceBundle rb = ResourceUtils.getBundle();
final Preferences pref = Preferences.userNodeForPackage(ImportOfxAction.class);
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
if (engine == null || engine.getRootAccount().getChildCount() == 0) {
StaticUIMethods.displayError(rb.getString("Message.Error.CreateBasicAccounts"));
return;
}
final JFileChooser chooser = new JFileChooser(pref.get(OFX_DIR, null));
chooser.setMultiSelectionEnabled(false);
chooser.addChoosableFileFilter(new FileNameExtensionFilter("Ofx Files (*.ofx,*.qfx)", "ofx", "qfx"));
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
pref.put(OFX_DIR, chooser.getCurrentDirectory().getAbsolutePath());
File file = chooser.getSelectedFile();
if (file.exists()) {
new Import(file).execute();
}
}
}
use of java.util.prefs.Preferences in project jgnash by ccavanaugh.
the class RegisterPanel method saveLastTabUsed.
private void saveLastTabUsed(final int index) {
Preferences tabPreferences = Preferences.userRoot().node(NODE_REG_TAB);
String id = getAccount().getUuid();
tabPreferences.putInt(id, index);
}
use of java.util.prefs.Preferences in project jgnash by ccavanaugh.
the class AbstractTransactionPanel method setRememberLastDate.
public static void setRememberLastDate(final boolean reset) {
rememberDate = reset;
Preferences p = Preferences.userNodeForPackage(AbstractTransactionPanel.class);
p.putBoolean(REMEMBER_DATE, rememberDate);
}
use of java.util.prefs.Preferences in project jgnash by ccavanaugh.
the class AccountBalanceDisplayManager method setDisplayMode.
public static void setDisplayMode(final AccountBalanceDisplayMode newMode) {
accountBalanceDisplayingMode = newMode;
Preferences p = Preferences.userNodeForPackage(AccountBalanceDisplayManager.class);
p.putInt(ACCOUNT_BALANCE_DISPLAY_MODE, accountBalanceDisplayingMode.getValue());
accountBalanceDisplayModeChanged();
}
Aggregations