Search in sources :

Example 1 with Priority

use of javafx.scene.layout.Priority in project dolphin-platform by canoo.

the class ViewFactory method updateContentByMetadata.

private void updateContentByMetadata(WithLayoutMetadata bean, Node content) {
    Priority priority = MetadataUtilities.getMetadata(ViewMetadata.JAVAFX_LAYOUT_CONTENT_GROW, bean).map(m -> Priority.valueOf(Optional.ofNullable(m.getValue()).orElse("").toString())).orElse(Priority.SOMETIMES);
    HBox.setHgrow(content, priority);
    VBox.setVgrow(content, priority);
    double margin = MetadataUtilities.getMetadata(ViewMetadata.JAVAFX_LAYOUT_MARGIN, bean).map(m -> Double.parseDouble(Optional.ofNullable(m.getValue()).orElse("0.0").toString())).orElse(0.0);
    HBox.setMargin(content, new Insets(margin));
    VBox.setMargin(content, new Insets(margin));
}
Also used : HBox(javafx.scene.layout.HBox) ControllerProxy(com.canoo.platform.remoting.client.ControllerProxy) Node(javafx.scene.Node) MetadataUtilities(com.canoo.dp.impl.platform.projector.metadata.MetadataUtilities) StackPane(javafx.scene.layout.StackPane) View(com.canoo.dp.impl.platform.projector.view.View) ViewMetadata(com.canoo.dp.impl.platform.projector.view.ViewMetadata) ClientContext(com.canoo.platform.remoting.client.ClientContext) VBox(javafx.scene.layout.VBox) ArrayList(java.util.ArrayList) Parent(javafx.scene.Parent) Priority(javafx.scene.layout.Priority) List(java.util.List) Insets(javafx.geometry.Insets) Optional(java.util.Optional) WithLayoutMetadata(com.canoo.dp.impl.platform.projector.base.WithLayoutMetadata) Pane(javafx.scene.layout.Pane) Insets(javafx.geometry.Insets) Priority(javafx.scene.layout.Priority)

Example 2 with Priority

use of javafx.scene.layout.Priority 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)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 HBox (javafx.scene.layout.HBox)2 Priority (javafx.scene.layout.Priority)2 VBox (javafx.scene.layout.VBox)2 WithLayoutMetadata (com.canoo.dp.impl.platform.projector.base.WithLayoutMetadata)1 MetadataUtilities (com.canoo.dp.impl.platform.projector.metadata.MetadataUtilities)1 View (com.canoo.dp.impl.platform.projector.view.View)1 ViewMetadata (com.canoo.dp.impl.platform.projector.view.ViewMetadata)1 ClientContext (com.canoo.platform.remoting.client.ClientContext)1 ControllerProxy (com.canoo.platform.remoting.client.ControllerProxy)1 Function (java.util.function.Function)1 Platform (javafx.application.Platform)1 Observable (javafx.beans.Observable)1 Bindings (javafx.beans.binding.Bindings)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ActionEvent (javafx.event.ActionEvent)1 Insets (javafx.geometry.Insets)1 Group (javafx.scene.Group)1