Search in sources :

Example 81 with Preferences

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

the class AbstractAuthenticator method setPassword.

public static void setPassword(String password) {
    final Preferences pref = Preferences.userRoot().node(NODEHTTP);
    pref.put(HTTPPASS, password);
}
Also used : Preferences(java.util.prefs.Preferences)

Example 82 with Preferences

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

the class AbstractAuthenticator method setHost.

public static void setHost(String host) {
    final Preferences pref = Preferences.userRoot().node(NODEHTTP);
    pref.put(PROXYHOST, host);
}
Also used : Preferences(java.util.prefs.Preferences)

Example 83 with Preferences

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

the class IncomeExpensePieChartDialogController method initialize.

@FXML
public void initialize() {
    // Respect animation preference
    pieChart.animatedProperty().set(Options.animationsEnabledProperty().get());
    accountComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null && newValue.getParent().getAccountType() != AccountType.ROOT) {
            pieChart.setCursor(CustomCursor.getZoomOutCursor());
        } else {
            pieChart.setCursor(Cursor.DEFAULT);
        }
    });
    final Preferences preferences = Preferences.userNodeForPackage(IncomeExpensePieChartDialogController.class).node("IncomeExpensePieChart");
    accountComboBox.setPredicate(new ParentAccountPredicate());
    if (preferences.get(LAST_ACCOUNT, null) != null) {
        final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
        Objects.requireNonNull(engine);
        final Account account = engine.getAccountByUuid(preferences.get(LAST_ACCOUNT, null));
        if (account != null) {
            accountComboBox.setValue(account);
        }
    }
    startDatePicker.setValue(endDatePicker.getValue().minusYears(1));
    final ChangeListener<Object> listener = (observable, oldValue, newValue) -> {
        if (newValue != null) {
            updateChart();
            preferences.put(LAST_ACCOUNT, accountComboBox.getValue().getUuid());
        }
    };
    accountComboBox.valueProperty().addListener(listener);
    startDatePicker.valueProperty().addListener(listener);
    endDatePicker.valueProperty().addListener(listener);
    pieChart.setLegendSide(Side.BOTTOM);
    // zoom out
    pieChart.setOnMouseClicked(event -> {
        if (!nodeFocused && accountComboBox.getValue().getParent().getAccountType() != AccountType.ROOT) {
            accountComboBox.setValue(accountComboBox.getValue().getParent());
        }
    });
    // Push the initial load to the end of the platform thread for better startup and nicer visual effect
    Platform.runLater(this::updateChart);
}
Also used : DoughnutChart(jgnash.uifx.control.DoughnutChart) Scene(javafx.scene.Scene) Engine(jgnash.engine.Engine) EngineFactory(jgnash.engine.EngineFactory) FXCollections(javafx.collections.FXCollections) StackPane(javafx.scene.layout.StackPane) ParentAccountPredicate(jgnash.util.function.ParentAccountPredicate) Side(javafx.geometry.Side) AccountComboBox(jgnash.uifx.control.AccountComboBox) NumberFormat(java.text.NumberFormat) ResourceBundle(java.util.ResourceBundle) AccountType(jgnash.engine.AccountType) Tooltip(javafx.scene.control.Tooltip) CurrencyNode(jgnash.engine.CurrencyNode) ObjectProperty(javafx.beans.property.ObjectProperty) InjectFXML(jgnash.uifx.util.InjectFXML) Preferences(java.util.prefs.Preferences) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Cursor(javafx.scene.Cursor) PieChart(javafx.scene.chart.PieChart) CommodityFormat(jgnash.text.CommodityFormat) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LocalDate(java.time.LocalDate) CustomCursor(jgnash.resource.cursor.CustomCursor) Account(jgnash.engine.Account) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) DatePickerEx(jgnash.uifx.control.DatePickerEx) Options(jgnash.uifx.Options) Account(jgnash.engine.Account) ParentAccountPredicate(jgnash.util.function.ParentAccountPredicate) Preferences(java.util.prefs.Preferences) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 84 with Preferences

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

the class JasperViewerDialogController method handleSaveAction.

@FXML
private void handleSaveAction() {
    Preferences preferences = Preferences.userNodeForPackage(JasperViewerDialogController.class);
    final String lastDir = preferences.get(LAST_DIR, null);
    final FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(ResourceUtils.getString("Title.SaveFile"));
    if (lastDir != null) {
        fileChooser.setInitialDirectory(new File(lastDir));
    }
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("PDF Document", "*.pdf", "*.PDF"));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("ODT Document", "*.odt", "*.ODT"));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("DOCX Document", "*.docx", "*.DOCX"));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("XLSX Document", "*.xlsx", "*.XLSX"));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("CSV Document", "*.csv", "*.CSV"));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("RTF Document", "*.rtf", "*.RTF"));
    final File file = fileChooser.showSaveDialog(MainView.getPrimaryStage());
    if (file != null) {
        preferences.put(LAST_DIR, file.getParent());
        switch(FileUtils.getFileExtension(file.getAbsolutePath()).toLowerCase(Locale.ROOT)) {
            case "pdf":
                try {
                    JasperExportManager.exportReportToPdfFile(jasperPrint.get(), file.getAbsolutePath());
                } catch (final JRException e) {
                    StaticUIMethods.displayException(e);
                }
                break;
            case "odt":
                try {
                    final JROdtExporter exporter = new JROdtExporter();
                    exporter.setExporterInput(new SimpleExporterInput(jasperPrint.get()));
                    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
                    exporter.exportReport();
                } catch (final JRException e) {
                    StaticUIMethods.displayException(e);
                }
                break;
            case "docx":
                try {
                    final JRDocxExporter exporter = new JRDocxExporter();
                    exporter.setExporterInput(new SimpleExporterInput(jasperPrint.get()));
                    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
                    exporter.exportReport();
                } catch (final JRException e) {
                    StaticUIMethods.displayException(e);
                }
                break;
            case "xlsx":
                try {
                    final JRXlsExporter exporter = new JRXlsExporter();
                    exporter.setExporterInput(new SimpleExporterInput(jasperPrint.get()));
                    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
                    final SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
                    configuration.setOnePagePerSheet(false);
                    exporter.setConfiguration(configuration);
                    exporter.exportReport();
                } catch (final JRException e) {
                    StaticUIMethods.displayException(e);
                }
                break;
            case "csv":
                try {
                    final JRCsvExporter exporter = new JRCsvExporter();
                    exporter.setExporterInput(new SimpleExporterInput(jasperPrint.get()));
                    exporter.setExporterOutput(new SimpleWriterExporterOutput(file));
                    exporter.exportReport();
                } catch (final JRException e) {
                    StaticUIMethods.displayException(e);
                }
                break;
            case "rtf":
                try {
                    final JRRtfExporter exporter = new JRRtfExporter();
                    exporter.setExporterInput(new SimpleExporterInput(jasperPrint.get()));
                    exporter.setExporterOutput(new SimpleWriterExporterOutput(file));
                    exporter.exportReport();
                } catch (final JRException e) {
                    StaticUIMethods.displayException(e);
                }
                break;
            default:
        }
    }
}
Also used : SimpleXlsReportConfiguration(net.sf.jasperreports.export.SimpleXlsReportConfiguration) JROdtExporter(net.sf.jasperreports.engine.export.oasis.JROdtExporter) JRException(net.sf.jasperreports.engine.JRException) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) JRCsvExporter(net.sf.jasperreports.engine.export.JRCsvExporter) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput) JRXlsExporter(net.sf.jasperreports.engine.export.JRXlsExporter) SimpleWriterExporterOutput(net.sf.jasperreports.export.SimpleWriterExporterOutput) FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) JRDocxExporter(net.sf.jasperreports.engine.export.ooxml.JRDocxExporter) File(java.io.File) JRRtfExporter(net.sf.jasperreports.engine.export.JRRtfExporter) FXML(javafx.fxml.FXML) InjectFXML(jgnash.uifx.util.InjectFXML)

Example 85 with Preferences

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

the class PortfolioReportController method initialize.

@FXML
private void initialize() {
    // Only show visible investment accounts
    accountComboBox.setPredicate(account -> account.instanceOf(AccountType.INVEST) && account.isVisible());
    final Preferences preferences = getPreferences();
    subAccountCheckBox.setSelected(preferences.getBoolean(RECURSIVE, true));
    longNameCheckBox.setSelected(preferences.getBoolean(VERBOSE, false));
}
Also used : Preferences(java.util.prefs.Preferences) FXML(javafx.fxml.FXML)

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