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