use of javafx.scene.input.KeyEvent in project jabref by JabRef.
the class KeyBindingsDialogViewModelTest method testSaveNewKeyBindingsToPreferences.
@Test
public void testSaveNewKeyBindingsToPreferences() {
setKeyBindingViewModel(KeyBinding.ABBREVIATE);
KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "J", "J", KeyCode.J, true, true, true, false);
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent));
model.setNewBindingForCurrent(shortcutKeyEvent);
model.saveKeyBindings();
assertTrue(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent));
}
use of javafx.scene.input.KeyEvent in project jabref by JabRef.
the class KeyBindingsDialogViewModelTest method testInvalidKeyBindingIsNotSaved.
@Test
public void testInvalidKeyBindingIsNotSaved() {
setKeyBindingViewModel(KeyBinding.COPY);
KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_RELEASED, "Q", "Q", KeyCode.Q, false, false, false, false);
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent));
model.setNewBindingForCurrent(shortcutKeyEvent);
KeyCombination combination = KeyCombination.keyCombination(keyBindingRepository.get(KeyBinding.COPY).get());
assertFalse(keyBindingRepository.checkKeyCombinationEquality(combination, shortcutKeyEvent));
model.saveKeyBindings();
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent));
}
use of javafx.scene.input.KeyEvent in project jabref by JabRef.
the class KeyBindingsDialogViewModelTest method testKeyBindingCategory.
@Test
public void testKeyBindingCategory() {
KeyBindingViewModel bindViewModel = new KeyBindingViewModel(keyBindingRepository, KeyBindingCategory.FILE);
model.selectedKeyBindingProperty().set(bindViewModel);
KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "M", "M", KeyCode.M, true, true, true, false);
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent));
model.setNewBindingForCurrent(shortcutKeyEvent);
assertNull(model.selectedKeyBindingProperty().get().getKeyBinding());
}
use of javafx.scene.input.KeyEvent in project jgnash by ccavanaugh.
the class JasperViewerDialogController method initialize.
@FXML
private void initialize() {
busyPane = new BusyPane();
stackPane.getChildren().add(busyPane);
screenResolution = Screen.getPrimary().getDpi();
saveButton.disableProperty().bind(jasperPrint.isNull());
printButton.disableProperty().bind(jasperPrint.isNull());
reportFormatButton.disableProperty().bind(jasperPrint.isNull());
fontSizeSpinner.disableProperty().bind(jasperPrint.isNull());
firstButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
previousButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
nextButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
lastButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
fitPageButton.disableProperty().bind(jasperPrint.isNull());
fitHeightButton.disableProperty().bind(jasperPrint.isNull());
fitWidthButton.disableProperty().bind(jasperPrint.isNull());
zoomComboBox.disableProperty().bind(jasperPrint.isNull());
zoomInButton.disableProperty().bind(jasperPrint.isNull().or(zoomProperty.greaterThanOrEqualTo(DEFAULT_ZOOMS[DEFAULT_ZOOMS.length - 1] / 100)));
zoomOutButton.disableProperty().bind(jasperPrint.isNull().or(zoomProperty.lessThanOrEqualTo(DEFAULT_ZOOMS[0] / 100)));
fitPageButton.setSelected(true);
firstButton.prefHeightProperty().bind(saveButton.heightProperty());
previousButton.prefHeightProperty().bind(saveButton.heightProperty());
nextButton.prefHeightProperty().bind(saveButton.heightProperty());
lastButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomInButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomOutButton.prefHeightProperty().bind(saveButton.heightProperty());
fitHeightButton.prefHeightProperty().bind(saveButton.heightProperty());
fitWidthButton.prefHeightProperty().bind(saveButton.heightProperty());
fitPageButton.prefHeightProperty().bind(saveButton.heightProperty());
fontSizeSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(5, 15, 7));
report.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
jasperPrint.set(newValue.createJasperPrint(false));
fontSizeSpinner.valueFactoryProperty().get().setValue(newValue.getBaseFontSize());
newValue.refreshCallBackProperty().set(() -> createJasperPrint(newValue));
} else {
jasperPrint.set(null);
}
});
jasperPrint.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
pageCount.set(newValue.getPages().size());
} else {
pageCount.set(0);
}
Platform.runLater(this::refresh);
});
reportControllerPaneProperty.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
reportControllerPane.getChildren().addAll(newValue);
}
});
fontSizeSpinner.valueProperty().addListener((observable, oldValue, newValue) -> {
report.get().setBaseFontSize(newValue);
Platform.runLater(() -> createJasperPrint(report.get()));
});
pagePane.setSpacing(PAGE_BORDER);
pagePane.setPadding(new Insets(PAGE_BORDER));
pagePane.setAlignment(Pos.CENTER);
scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
if (fitWidthButton.isSelected()) {
handleFitPageWidthAction();
}
scrollPane.setFitToWidth(pagePane.prefWidth(-1) < newValue.getWidth());
scrollPane.setFitToHeight(pagePane.prefHeight(-1) < newValue.getHeight());
});
scrollPane.vvalueProperty().addListener((ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
final double interval = 1d / (double) pageCount.get();
double low = pageIndex.get() * interval;
double hi = low + interval;
int newPageIndex = pageIndex.get();
if (hi < newValue.doubleValue() && pageIndex.get() < pageCount.get()) {
while (hi < newValue.doubleValue()) {
newPageIndex++;
hi += interval;
}
// increase the page index to match the scroll position
setPageIndex(newPageIndex);
} else if (low > newValue.doubleValue() && pageIndex.get() > 0) {
while (low > newValue.doubleValue()) {
newPageIndex--;
low -= interval;
}
// decrease the page index to match the scroll position
setPageIndex(newPageIndex);
}
});
for (int zoom : DEFAULT_ZOOMS) {
zoomComboBox.getItems().add(zoom + "%");
}
zoomComboBox.getSelectionModel().select(DEFAULT_ZOOM_INDEX);
zoomComboBox.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
if (e.getCode() == KeyCode.ENTER) {
handleZoomChangedAction();
}
});
setZoomRatio(1);
}
use of javafx.scene.input.KeyEvent in project bisq-api by mrosseel.
the class BisqApiWithUI method start.
@SuppressWarnings("PointlessBooleanExpression")
@Override
public void start(Stage stage) throws IOException {
BisqApiWithUI.primaryStage = stage;
String logPath = Paths.get(bisqEnvironment.getProperty(AppOptionKeys.APP_DATA_DIR_KEY), "bisq").toString();
Log.setup(logPath);
log.info("Log files under: " + logPath);
Utilities.printSysInfo();
Log.setLevel(Level.toLevel(bisqEnvironment.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));
UserThread.setExecutor(Platform::runLater);
UserThread.setTimerClass(UITimer.class);
shutDownHandler = this::stop;
BisqApp.shutDownHandler = shutDownHandler;
// setup UncaughtExceptionHandler
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread
if (throwable.getCause() != null && throwable.getCause().getCause() != null && throwable.getCause().getCause() instanceof BlockStoreException) {
log.error(throwable.getMessage());
} else if (throwable instanceof ClassCastException && "sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData".equals(throwable.getMessage())) {
log.warn(throwable.getMessage());
} else {
log.error("Uncaught Exception from thread " + Thread.currentThread().getName());
log.error("throwableMessage= " + throwable.getMessage());
log.error("throwableClass= " + throwable.getClass());
log.error("Stack trace:\n" + ExceptionUtils.getStackTrace(throwable));
throwable.printStackTrace();
UserThread.execute(() -> showErrorPopup(throwable, false));
}
};
Thread.setDefaultUncaughtExceptionHandler(handler);
Thread.currentThread().setUncaughtExceptionHandler(handler);
try {
Utilities.checkCryptoPolicySetup();
} catch (NoSuchAlgorithmException | LimitedKeyStrengthException e) {
e.printStackTrace();
UserThread.execute(() -> showErrorPopup(e, true));
}
Security.addProvider(new BouncyCastleProvider());
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();
Res.setBaseCurrencyCode(currencyCode);
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
CurrencyUtil.setBaseCurrencyCode(currencyCode);
try {
// Guice
bisqAppModule = new BisqAppModule(bisqEnvironment, primaryStage);
injector = Guice.createInjector(bisqAppModule);
injector.getInstance(InjectorViewFactory.class).setInjector(injector);
injector.getInstance(BisqApiApplication.class).run("server", "bisq-api.yml");
// All classes which are persisting objects need to be added here
// Maintain order!
ArrayList<PersistedDataHost> persistedDataHosts = new ArrayList<>();
persistedDataHosts.add(injector.getInstance(Preferences.class));
persistedDataHosts.add(injector.getInstance(User.class));
persistedDataHosts.add(injector.getInstance(Navigation.class));
persistedDataHosts.add(injector.getInstance(AddressEntryList.class));
persistedDataHosts.add(injector.getInstance(TradeManager.class));
persistedDataHosts.add(injector.getInstance(OpenOfferManager.class));
persistedDataHosts.add(injector.getInstance(TradeManager.class));
persistedDataHosts.add(injector.getInstance(ClosedTradableManager.class));
persistedDataHosts.add(injector.getInstance(FailedTradesManager.class));
persistedDataHosts.add(injector.getInstance(DisputeManager.class));
persistedDataHosts.add(injector.getInstance(P2PService.class));
persistedDataHosts.add(injector.getInstance(VotingManager.class));
persistedDataHosts.add(injector.getInstance(CompensationRequestManager.class));
// we apply at startup the reading of persisted data but don't want to get it triggered in the constructor
persistedDataHosts.stream().forEach(e -> {
try {
log.debug("call readPersisted at " + e.getClass().getSimpleName());
e.readPersisted();
} catch (Throwable e1) {
log.error("readPersisted error", e1);
}
});
Version.setBaseCryptoNetworkId(BisqEnvironment.getBaseCurrencyNetwork().ordinal());
Version.printVersion();
if (Utilities.isLinux())
System.setProperty("prism.lcdtext", "false");
Storage.setDatabaseCorruptionHandler((String fileName) -> {
corruptedDatabaseFiles.add(fileName);
if (mainView != null)
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
});
// load the main view and create the main scene
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
mainView = (MainView) viewLoader.load(MainView.class);
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
/* Storage.setDatabaseCorruptionHandler((String fileName) -> {
corruptedDatabaseFiles.add(fileName);
if (mainView != null)
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
});*/
// 740
scene = new Scene(mainView.getRoot(), 1200, 710);
Font.loadFont(getClass().getResource("/fonts/Verdana.ttf").toExternalForm(), 13);
Font.loadFont(getClass().getResource("/fonts/VerdanaBold.ttf").toExternalForm(), 13);
Font.loadFont(getClass().getResource("/fonts/VerdanaItalic.ttf").toExternalForm(), 13);
Font.loadFont(getClass().getResource("/fonts/VerdanaBoldItalic.ttf").toExternalForm(), 13);
scene.getStylesheets().setAll("/io/bisq/gui/bisq.css", "/io/bisq/gui/images.css", "/io/bisq/gui/CandleStickChart.css");
// configure the system tray
SystemTray.create(primaryStage, shutDownHandler);
primaryStage.setOnCloseRequest(event -> {
event.consume();
stop();
});
scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> {
Utilities.isAltOrCtrlPressed(KeyCode.W, keyEvent);
if (Utilities.isCtrlPressed(KeyCode.W, keyEvent) || Utilities.isCtrlPressed(KeyCode.Q, keyEvent)) {
stop();
} else {
if (Utilities.isAltOrCtrlPressed(KeyCode.E, keyEvent)) {
showEmptyWalletPopup(injector.getInstance(BtcWalletService.class));
} else if (Utilities.isAltOrCtrlPressed(KeyCode.M, keyEvent)) {
showSendAlertMessagePopup();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.F, keyEvent)) {
showFilterPopup();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.J, keyEvent)) {
WalletsManager walletsManager = injector.getInstance(WalletsManager.class);
if (walletsManager.areWalletsAvailable())
new ShowWalletDataWindow(walletsManager).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.G, keyEvent)) {
if (injector.getInstance(BtcWalletService.class).isWalletReady())
injector.getInstance(ManualPayoutTxWindow.class).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else if (DevEnv.DEV_MODE) {
// dev ode only
if (Utilities.isAltOrCtrlPressed(KeyCode.B, keyEvent)) {
// BSQ empty wallet not public yet
showEmptyWalletPopup(injector.getInstance(BsqWalletService.class));
} else if (Utilities.isAltOrCtrlPressed(KeyCode.P, keyEvent)) {
showFPSWindow();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.Z, keyEvent)) {
showDebugWindow();
}
}
}
});
// configure the primary stage
primaryStage.setTitle(bisqEnvironment.getRequiredProperty(AppOptionKeys.APP_NAME_KEY));
primaryStage.setScene(scene);
primaryStage.setMinWidth(1020);
primaryStage.setMinHeight(620);
// on windows the title icon is also used as task bar icon in a larger size
// on Linux no title icon is supported but also a large task bar icon is derived from that title icon
String iconPath;
if (Utilities.isOSX())
iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png";
else if (Utilities.isWindows())
iconPath = "/images/task_bar_icon_windows.png";
else
iconPath = "/images/task_bar_icon_linux.png";
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));
// make the UI visible
primaryStage.show();
if (!Utilities.isCorrectOSArchitecture()) {
String osArchitecture = Utilities.getOSArchitecture();
// We don't force a shutdown as the osArchitecture might in strange cases return a wrong value.
// Needs at least more testing on different machines...
new Popup<>().warning(Res.get("popup.warning.wrongVersion", osArchitecture, Utilities.getJVMArchitecture(), osArchitecture)).show();
}
UserThread.runPeriodically(() -> Profiler.printSystemLoad(log), LOG_MEMORY_PERIOD_MIN, TimeUnit.MINUTES);
} catch (Throwable throwable) {
log.error("Error during app init", throwable);
showErrorPopup(throwable, false);
}
}
Aggregations