Search in sources :

Example 16 with Observable

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;
}
Also used : Theme(org.phoenicis.javafx.themes.Theme) Observable(javafx.beans.Observable)

Example 17 with Observable

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);
}
Also used : AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) InvoiceAddressLabelWithNullableShippingAddressLabel(eu.ggnet.dwoss.customer.ui.neo.PreferedAddressLabelsController.InvoiceAddressLabelWithNullableShippingAddressLabel) InvalidationListener(javafx.beans.InvalidationListener) Observable(javafx.beans.Observable)

Example 18 with Observable

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;
}
Also used : Scene(javafx.scene.Scene) Repository(org.phoenicis.repository.types.Repository) javafx.scene.control(javafx.scene.control) SnapshotParameters(javafx.scene.SnapshotParameters) VBox(javafx.scene.layout.VBox) Bindings(javafx.beans.binding.Bindings) Function(java.util.function.Function) TransferMode(javafx.scene.input.TransferMode) RepositoriesPanel(org.phoenicis.javafx.components.setting.control.RepositoriesPanel) ArrayList(java.util.ArrayList) Dragboard(javafx.scene.input.Dragboard) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) Group(javafx.scene.Group) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) Priority(javafx.scene.layout.Priority) ActionEvent(javafx.event.ActionEvent) AddRepositoryDialog(org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog) List(java.util.List) DataFormat(javafx.scene.input.DataFormat) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog) Optional(java.util.Optional) ClipboardContent(javafx.scene.input.ClipboardContent) Image(javafx.scene.image.Image) ClipboardContent(javafx.scene.input.ClipboardContent) ArrayList(java.util.ArrayList) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) Observable(javafx.beans.Observable) Repository(org.phoenicis.repository.types.Repository) Dragboard(javafx.scene.input.Dragboard)

Example 19 with Observable

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);
}
Also used : GridPane(javafx.scene.layout.GridPane) ScrollPane(javafx.scene.control.ScrollPane) Text(javafx.scene.text.Text) VBox(javafx.scene.layout.VBox) Observable(javafx.beans.Observable)

Example 20 with Observable

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);
}
Also used : TabPane(javafx.scene.control.TabPane) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) Observable(javafx.beans.Observable)

Aggregations

Observable (javafx.beans.Observable)23 InvalidationListener (javafx.beans.InvalidationListener)7 VBox (javafx.scene.layout.VBox)7 Image (javafx.scene.image.Image)4 HBox (javafx.scene.layout.HBox)4 Text (javafx.scene.text.Text)4 Bindings (javafx.beans.binding.Bindings)3 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)3 ObservableList (javafx.collections.ObservableList)3 ActionEvent (javafx.event.ActionEvent)3 Button (javafx.scene.control.Button)3 Label (javafx.scene.control.Label)3 ImageView (javafx.scene.image.ImageView)3 GridPane (javafx.scene.layout.GridPane)3 MediaFile (com.negativevr.media_library.files.MediaFile)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 KeyFrame (javafx.animation.KeyFrame)2 KeyValue (javafx.animation.KeyValue)2