use of javafx.beans.Observable in project POL-POM-5 by PlayOnLinux.
the class SettingsView method createUserInterfacePanel.
private UserInterfacePanel createUserInterfacePanel() {
final UserInterfacePanel userInterfacePanel = new UserInterfacePanel(FXCollections.observableArrayList(Themes.all()));
// set the initial values
userInterfacePanel.setScaling(javaFxSettingsManager.getScale());
userInterfacePanel.setSelectedTheme(Themes.fromShortName(javaFxSettingsManager.getTheme()).orElse(Themes.STANDARD));
userInterfacePanel.setAdvancedMode(javaFxSettingsManager.isAdvancedMode());
userInterfacePanel.setShowScriptSource(javaFxSettingsManager.isViewScriptSource());
userInterfacePanel.setOnRestoreSettings(javaFxSettingsManager::restoreDefault);
// react on changes
userInterfacePanel.scalingProperty().addListener((Observable invalidation) -> {
final double scaling = userInterfacePanel.getScaling();
this.pause.setOnFinished(event -> {
getTabPane().getScene().getRoot().setStyle(String.format("-fx-font-size: %.2fpt;", scaling));
javaFxSettingsManager.setScale(userInterfacePanel.getScaling());
javaFxSettingsManager.save();
});
this.pause.playFromStart();
});
userInterfacePanel.selectedThemeProperty().addListener((Observable invalidation) -> {
final Theme selectedTheme = userInterfacePanel.getSelectedTheme();
themeManager.setCurrentTheme(selectedTheme);
javaFxSettingsManager.setTheme(selectedTheme.getShortName());
javaFxSettingsManager.save();
});
userInterfacePanel.advancedModeProperty().addListener((Observable invalidation) -> {
final boolean advancedMode = userInterfacePanel.isAdvancedMode();
javaFxSettingsManager.setAdvancedMode(advancedMode);
javaFxSettingsManager.save();
});
userInterfacePanel.showScriptSourceProperty().addListener((Observable invalidation) -> {
final boolean showScriptSource = userInterfacePanel.isShowScriptSource();
javaFxSettingsManager.setViewScriptSource(showScriptSource);
javaFxSettingsManager.save();
});
return userInterfacePanel;
}
use of javafx.beans.Observable in project dwoss by gg-net.
the class PreferedAddressLabelsController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
saveButton.setDisable(true);
invoiceAddressCompanyListView.setCellFactory(cb -> new CompanyListCell());
invoiceAddressContactListView.setCellFactory(cb -> new ContactListCell());
invoiceAddressAddressListView.setCellFactory(cb -> new AddressListCell());
shippingAddressCompanyListView.setCellFactory(cb -> new CompanyListCell());
shippingAddressContactListView.setCellFactory(cb -> new ContactListCell());
shippingAddressAddressListView.setCellFactory(cb -> new AddressListCell());
InvalidationListener invoiceWebViewListener = (Observable observable) -> {
if (!invoiceAddressAddressListView.getSelectionModel().isEmpty()) {
AddressLabel addressLabel = new AddressLabel(invoiceAddressCompanyListView.getSelectionModel().getSelectedItem(), invoiceAddressContactListView.getSelectionModel().getSelectedItem(), invoiceAddressAddressListView.getSelectionModel().getSelectedItem(), AddressType.INVOICE);
invoiceAddressWebView.getEngine().loadContent(addressLabel.toHtml());
} else
invoiceAddressWebView.getEngine().loadContent("");
};
this.invoiceAddressAddressListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
this.invoiceAddressCompanyListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
this.invoiceAddressContactListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
InvalidationListener shippingWebViewListener = (Observable observable) -> {
if (!shippingAddressAddressListView.getSelectionModel().isEmpty()) {
AddressLabel addressLabel = new AddressLabel(shippingAddressCompanyListView.getSelectionModel().getSelectedItem(), shippingAddressContactListView.getSelectionModel().getSelectedItem(), shippingAddressAddressListView.getSelectionModel().getSelectedItem(), AddressType.SHIPPING);
shippingAddressWebView.getEngine().loadContent(addressLabel.toHtml());
} else
shippingAddressWebView.getEngine().loadContent("");
};
this.shippingAddressAddressListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
this.shippingAddressCompanyListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
this.shippingAddressContactListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
InvalidationListener saveButtonDisablingListener = (Observable observable) -> {
boolean isInvoiceAddressValid = (!invoiceAddressAddressListView.getSelectionModel().isEmpty()) && ((!invoiceAddressCompanyListView.getSelectionModel().isEmpty()) || (!invoiceAddressContactListView.getSelectionModel().isEmpty()));
boolean isShippingAddressValid = (shippingAddressAddressListView.getSelectionModel().isEmpty() && shippingAddressCompanyListView.getSelectionModel().isEmpty() && shippingAddressContactListView.getSelectionModel().isEmpty()) || ((!shippingAddressAddressListView.getSelectionModel().isEmpty()) && (!shippingAddressCompanyListView.getSelectionModel().isEmpty() || !shippingAddressContactListView.getSelectionModel().isEmpty()));
if (isInvoiceAddressValid && isShippingAddressValid)
saveButton.setDisable(false);
else
saveButton.setDisable(true);
};
invoiceAddressCompanyListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
invoiceAddressContactListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
invoiceAddressAddressListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
shippingAddressCompanyListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
shippingAddressContactListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
shippingAddressAddressListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
}
use of javafx.beans.Observable in project POL-POM-5 by PlayOnLinux.
the class RepositoriesPanelSkin method createRepositoryLocationTable.
/**
* Creates a {@link TableView} containing the {@link RepositoryLocation} objects
*
* @return A {@link TableView} containing the {@link RepositoryLocation} objects
*/
private TableView<RepositoryLocation<? extends Repository>> createRepositoryLocationTable() {
final TableView<RepositoryLocation<? extends Repository>> repositoryLocationTable = new TableView<>();
repositoryLocationTable.getStyleClass().add("repositories-table");
// add the priority column
repositoryLocationTable.getColumns().add(createColumn(tr("Priority"), repositoryLocation -> getControl().getRepositoryLocations().indexOf(repositoryLocation) + 1));
// add the repository name column
repositoryLocationTable.getColumns().add(createColumn(tr("Repository name"), RepositoryLocation::toDisplayString));
repositoryLocationTable.setRowFactory(tv -> {
final TableRow<RepositoryLocation<? extends Repository>> row = new TableRow<>();
row.getStyleClass().add("repository-row");
final Tooltip repositoryLocationTooltip = new Tooltip(tr("Move the repository up or down to change its priority"));
// ensure that the tooltip is only shown for non empty rows
row.emptyProperty().addListener((Observable invalidation) -> {
if (row.isEmpty()) {
Tooltip.uninstall(row, repositoryLocationTooltip);
} else {
Tooltip.install(row, repositoryLocationTooltip);
}
});
row.setOnDragDetected(event -> {
if (!row.isEmpty()) {
final int index = row.getIndex();
final Dragboard dragboard = row.startDragAndDrop(TransferMode.MOVE);
// create a preview image
final RepositoryLocation<? extends Repository> repositoryLocation = getControl().getRepositoryLocations().get(index);
dragboard.setDragView(createPreviewImage(repositoryLocation));
// save the dragged repository index
final ClipboardContent content = new ClipboardContent();
content.put(repositoryLocationFormat, index);
dragboard.setContent(content);
event.consume();
}
});
row.setOnDragOver(event -> {
final Dragboard dragboard = event.getDragboard();
if (dragboard.hasContent(repositoryLocationFormat) && row.getIndex() != (Integer) dragboard.getContent(repositoryLocationFormat)) {
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
event.consume();
}
});
row.setOnDragDropped(event -> {
final Dragboard dragboard = event.getDragboard();
if (dragboard.hasContent(repositoryLocationFormat)) {
final int draggedIndex = (Integer) dragboard.getContent(repositoryLocationFormat);
final List<RepositoryLocation<? extends Repository>> workingCopy = new ArrayList<>(getControl().getRepositoryLocations());
final RepositoryLocation<? extends Repository> draggedRepositoryLocation = workingCopy.remove(draggedIndex);
final int dropIndex = row.isEmpty() ? workingCopy.size() : row.getIndex();
workingCopy.add(dropIndex, draggedRepositoryLocation);
getControl().getRepositoryLocations().setAll(workingCopy);
event.setDropCompleted(true);
event.consume();
}
});
return row;
});
Bindings.bindContent(repositoryLocationTable.getItems(), getControl().getRepositoryLocations());
return repositoryLocationTable;
}
use of javafx.beans.Observable in project POL-POM-5 by PlayOnLinux.
the class ContainerEngineSettingsPanelSkin method initialise.
/**
* {@inheritDoc}
*/
@Override
public void initialise() {
final Text title = new Text(tr("Engine Settings"));
title.getStyleClass().add("title");
final GridPane engineSettingsGrid = new GridPane();
engineSettingsGrid.getStyleClass().add("engine-settings-grid");
// ensure that the shown engine settings are always up to date
getControl().containerProperty().addListener((Observable invalidation) -> updateEngineSettingsGrid(engineSettingsGrid));
getControl().getEngineSettings().addListener((Observable invalidation) -> updateEngineSettingsGrid(engineSettingsGrid));
// ensure that the shown engine settings are correctly initialized
updateEngineSettingsGrid(engineSettingsGrid);
final ScrollPane engineSettingsScrollPane = new ScrollPane(engineSettingsGrid);
engineSettingsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
engineSettingsScrollPane.setFitToWidth(true);
VBox.setVgrow(engineSettingsScrollPane, Priority.ALWAYS);
final VBox container = new VBox(title, engineSettingsScrollPane);
container.getStyleClass().addAll("container-details-panel", "container-engine-settings-panel");
getChildren().setAll(container);
}
use of javafx.beans.Observable in project POL-POM-5 by PlayOnLinux.
the class LibraryFeaturePanelSkin method createContent.
/**
* {@inheritDoc}
*/
@Override
public ObjectExpression<Node> createContent() {
final CombinedListWidget<ShortcutDTO> combinedListWidget = createCombinedListWidget();
final Tab installedApplicationsTab = new Tab(tr("My applications"), combinedListWidget);
installedApplicationsTab.setClosable(false);
final TabPane container = new TabPane();
container.getStyleClass().add("rightPane");
getControl().selectedTabProperty().addListener((Observable invalidation) -> {
final Tab selectedTab = getControl().getSelectedTab();
if (selectedTab != null) {
container.getSelectionModel().select(selectedTab);
} else {
container.getSelectionModel().selectFirst();
}
});
container.getSelectionModel().selectedItemProperty().addListener((Observable invalidation) -> getControl().setSelectedTab(container.getSelectionModel().getSelectedItem()));
Bindings.bindContentBidirectional(container.getTabs(), getControl().getTabs());
container.getTabs().add(installedApplicationsTab);
return new SimpleObjectProperty<>(container);
}
Aggregations