Search in sources :

Example 61 with Preferences

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

the class ReportFactory method setMonoFont.

/**
     * Sets the name of the mono spaced font to use
     * 
     * @param font font name to use
     */
public static void setMonoFont(final String font) {
    Preferences p = Preferences.userNodeForPackage(ReportFactory.class);
    p.put(MONOSPACE, font);
}
Also used : Preferences(java.util.prefs.Preferences)

Example 62 with Preferences

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

the class ReportPrintFactory method getPageFormat.

static PageFormat getPageFormat(final BaseDynamicJasperReport report) {
    Preferences p = report.getPreferences();
    double height = p.getDouble(HEIGHT, 0);
    double width = p.getDouble(WIDTH, 0);
    int orientation = p.getInt(ORIENTATION, 0);
    double imageableHeight = p.getDouble(IMAGEABLE_HEIGHT, 0);
    double imageableWidth = p.getDouble(IMAGEABLE_WIDTH, 0);
    double imageableX = p.getDouble(IMAGEABLE_X, 0);
    double imageableY = p.getDouble(IMAGEABLE_Y, 0);
    if (height == 0 || width == 0 || imageableHeight == 0 || imageableWidth == 0) {
        return getDefaultPage();
    }
    PrinterJob job = PrinterJob.getPrinterJob();
    PageFormat pf = job.defaultPage();
    pf.setOrientation(orientation);
    Paper paper = pf.getPaper();
    paper.setSize(width, height);
    paper.setImageableArea(imageableX, imageableY, imageableWidth, imageableHeight);
    pf.setPaper(paper);
    return pf;
}
Also used : PageFormat(java.awt.print.PageFormat) Paper(java.awt.print.Paper) Preferences(java.util.prefs.Preferences) PrinterJob(java.awt.print.PrinterJob)

Example 63 with Preferences

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

the class ReportPrintFactory method savePageFormat.

/**
     * Save a {@code PageFormat} to preferences
     * 
     * @param report report
     * @param format {@code PageFormat} to save
     */
static void savePageFormat(final BaseDynamicJasperReport report, final PageFormat format) {
    Preferences p = report.getPreferences();
    p.putInt(ORIENTATION, format.getOrientation());
    Paper paper = format.getPaper();
    p.putDouble(HEIGHT, paper.getHeight());
    p.putDouble(WIDTH, paper.getWidth());
    p.putDouble(IMAGEABLE_HEIGHT, paper.getImageableHeight());
    p.putDouble(IMAGEABLE_WIDTH, paper.getImageableWidth());
    p.putDouble(IMAGEABLE_X, paper.getImageableX());
    p.putDouble(IMAGEABLE_Y, paper.getImageableY());
}
Also used : Paper(java.awt.print.Paper) Preferences(java.util.prefs.Preferences)

Example 64 with Preferences

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

the class Main method setupNetworking.

/**
     * Setup the networking to handle authentication requests and work http proxies correctly.
     */
private static void setupNetworking() {
    final Preferences auth = Preferences.userRoot().node(NetworkAuthenticator.NODEHTTP);
    if (auth.getBoolean(NetworkAuthenticator.USEPROXY, false)) {
        String proxyHost = auth.get(NetworkAuthenticator.PROXYHOST, "");
        String proxyPort = auth.get(NetworkAuthenticator.PROXYPORT, "");
        System.getProperties().put("http.proxyHost", proxyHost);
        System.getProperties().put("http.proxyPort", proxyPort);
        // this will deal with any authentication requests properly
        java.net.Authenticator.setDefault(new NetworkAuthenticator());
        System.out.println(ResourceUtils.getString("Message.Proxy") + proxyHost + ":" + proxyPort);
    }
}
Also used : NetworkAuthenticator(jgnash.ui.net.NetworkAuthenticator) Preferences(java.util.prefs.Preferences) PortablePreferences(jgnash.util.prefs.PortablePreferences)

Example 65 with Preferences

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

the class BudgetPanel method exportBudgetAction.

private void exportBudgetAction() {
    final Preferences pref = Preferences.userNodeForPackage(BudgetPanel.class);
    final ResourceBundle rb = ResourceUtils.getBundle();
    JFileChooser chooser = new JFileChooser(pref.get(CURRENT_DIR, null));
    chooser.setMultiSelectionEnabled(false);
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.addChoosableFileFilter(new FileNameExtensionFilter(rb.getString("Label.SpreadsheetFiles") + " (*.xls, *.xlsx)", "xls", "xlsx"));
    if (chooser.showSaveDialog(UIApplication.getFrame()) == JFileChooser.APPROVE_OPTION) {
        pref.put(CURRENT_DIR, chooser.getCurrentDirectory().getAbsolutePath());
        final File file = new File(chooser.getSelectedFile().getAbsolutePath());
        final class Export extends SwingWorker<String, Void> {

            @Override
            protected String doInBackground() throws Exception {
                UIApplication.getFrame().displayWaitMessage(rb.getString("Message.PleaseWait"));
                return BudgetResultsExport.exportBudgetResultsModel(file.toPath(), resultsModel);
            }

            @Override
            protected void done() {
                UIApplication.getFrame().stopWaitMessage();
                try {
                    String message = get();
                    // display any errors that may have occurred
                    if (message != null) {
                        StaticUIMethods.displayError(message);
                    }
                } catch (InterruptedException | ExecutionException e) {
                    logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
                }
            }
        }
        new Export().execute();
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) SwingWorker(javax.swing.SwingWorker) BudgetResultsExport(jgnash.engine.budget.BudgetResultsExport) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) ExecutionException(java.util.concurrent.ExecutionException) File(java.io.File)

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