use of javafx.application.Platform in project jgnash by ccavanaugh.
the class IncomeExpensePayeePieChartDialogController method initialize.
@FXML
public void initialize() {
// Respect animation preference
debitPieChart.animatedProperty().set(Options.animationsEnabledProperty().get());
creditPieChart.animatedProperty().set(Options.animationsEnabledProperty().get());
creditPieChart.getStylesheets().addAll(CHART_CSS);
debitPieChart.getStylesheets().addAll(CHART_CSS);
creditPieChart.centerTitleProperty().set(resources.getString("Column.Credit"));
debitPieChart.centerTitleProperty().set(resources.getString("Column.Debit"));
accountComboBox.setPredicate(AccountComboBox.getShowAllPredicate());
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) {
updateCharts();
preferences.put(LAST_ACCOUNT, accountComboBox.getValue().getUuid());
}
};
accountComboBox.valueProperty().addListener(listener);
startDatePicker.valueProperty().addListener(listener);
endDatePicker.valueProperty().addListener(listener);
creditPieChart.setLegendSide(Side.BOTTOM);
debitPieChart.setLegendSide(Side.BOTTOM);
// Load in the first aux payee text field
insertAuxPayeeTextField();
restoreFilters();
// Expand the titled pane if filters are being used
Platform.runLater(() -> {
if (getPayeeTextFields().size() > 1) {
titledPane.setExpanded(true);
}
});
// Push the initial load to the end of the platform thread for better startup and nicer visual effect
Platform.runLater(this::updateCharts);
}
use of javafx.application.Platform 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);
}
use of javafx.application.Platform in project PayFile by mikehearn.
the class ConnectServerController method connect.
public void connect(ActionEvent event) {
final String serverName = server.getText().trim();
HostAndPort hostPort = verifyServerName(serverName);
if (hostPort == null)
return;
connectBtn.setDisable(true);
maybeSettleLastServer(hostPort).thenRun(() -> {
titleLabel.setText(String.format("Connecting to %s...", serverName));
Main.connect(hostPort).handle((client, ex) -> {
if (ex != null) {
Platform.runLater(() -> handleConnectError(Throwables.getRootCause(ex), serverName));
return null;
}
Main.client = client;
return client.queryFiles().whenCompleteAsync((files, ex2) -> {
if (ex2 != null) {
handleQueryFilesError(ex2);
} else {
Settings.setLastServer(hostPort);
showUIWithFiles(files);
}
}, Platform::runLater);
});
});
}
use of javafx.application.Platform in project PayFile by mikehearn.
the class Main method init.
private void init(Stage mainWindow) throws IOException {
this.mainWindow = mainWindow;
// commented out for now as Modena looks better, but might want to bring this back.
/* if (System.getProperty("os.name").toLowerCase().contains("mac")) {
AquaFx.style();
} */
// Load the GUI. The Controller class will be automagically created and wired up.
URL location = getClass().getResource("main.fxml");
FXMLLoader loader = new FXMLLoader(location);
mainUI = loader.load();
controller = loader.getController();
// Configure the window with a StackPane so we can overlay things on top of the main UI.
uiStack = new StackPane(mainUI);
mainWindow.setTitle(APP_NAME);
final Scene scene = new Scene(uiStack);
// Add CSS that we need.
TextFieldValidator.configureScene(scene);
mainWindow.setScene(scene);
// Make log output concise.
BriefLogFormatter.init();
// Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
// we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
// we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
// a future version. Also note that this doesn't affect the default executor for ListenableFutures.
// That must be specified each time.
Threading.USER_THREAD = Platform::runLater;
// Create the app kit. It won't do any heavyweight initialization until after we start it.
bitcoin = new WalletAppKit(params, new File("."), filePrefix + APP_NAME) {
@Override
protected void addWalletExtensions() throws Exception {
super.addWalletExtensions();
wallet().addExtension(new StoredPaymentChannelClientStates(wallet(), peerGroup()));
}
};
if (params == RegTestParams.get()) {
// You should run a regtest mode bitcoind locally.
bitcoin.connectToLocalHost();
} else if (params == MainNetParams.get()) {
// Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
// in the checkpoints file and then download the rest from the network. It makes things much faster.
// Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
// last months worth or more (takes a few seconds).
bitcoin.setCheckpoints(getClass().getResourceAsStream("checkpoints"));
}
// Now configure and start the appkit. It won't block for very long.
bitcoin.setDownloadListener(controller.progressBarUpdater()).setBlockingStartup(false).setUserAgent("PayFile Client", "1.0").startAndWait();
// Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
bitcoin.wallet().allowSpendingUnconfirmedTransactions();
System.out.println(bitcoin.wallet());
controller.onBitcoinSetup();
overlayUI("connect_server.fxml");
mainUI.setVisible(false);
mainWindow.show();
}
use of javafx.application.Platform in project jgnash by ccavanaugh.
the class TestFxPlugin method start.
@Override
public void start(final PluginPlatform pluginPlatform) {
System.out.println("Starting test plugin");
if (pluginPlatform != PluginPlatform.Fx) {
throw new RuntimeException("Invalid platform");
}
Platform.runLater(() -> {
//for API test. Lookup allows plugins to find nodes within the application scene
final Node node = MainView.getInstance().lookup("#fileMenu");
if (node != null) {
System.out.println("found the file menu");
// Not really a node, but the skin for the node,
System.out.println(node.getClass().toString());
}
assert MainView.getInstance().lookup("#importMenu") != null;
// Install a menu item
final MenuBar menuBar = MainView.getInstance().getMenuBar();
menuBar.getMenus().stream().filter(menu -> menu.getId().equals("fileMenu")).forEach(menu -> {
System.out.println("found the file menu");
menu.getItems().add(new MenuItem("Plugin Menu"));
});
});
}
Aggregations