Search in sources :

Example 66 with Preferences

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();
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) SwingWorker(javax.swing.SwingWorker) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) DataStoreType(jgnash.engine.DataStoreType)

Example 67 with Preferences

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();
        }
    }
}
Also used : OfxImport(jgnash.convert.imports.ofx.OfxImport) JFileChooser(javax.swing.JFileChooser) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File) Engine(jgnash.engine.Engine)

Example 68 with Preferences

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);
}
Also used : Preferences(java.util.prefs.Preferences)

Example 69 with Preferences

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);
}
Also used : Preferences(java.util.prefs.Preferences)

Example 70 with Preferences

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