Search in sources :

Example 16 with ColumnConstraintsWithPercentage

use of org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage in project POL-POM-5 by PlayOnLinux.

the class ShortcutInformationPanelSkin method createControlButtons.

/**
 * Creates a new {@link GridPane} containing the control buttons for the selected shortcut.
 * These control buttons consist of:
 * <ul>
 * <li>The run button</li>
 * <li>The stop button</li>
 * <li>The uninstall button</li>
 * </ul>
 *
 * @return A new {@link GridPane} containing the control buttons for the selected shortcut
 */
private GridPane createControlButtons() {
    final GridPane controlButtons = new GridPane();
    controlButtons.getStyleClass().add("shortcut-control-button-group");
    final Button runButton = new Button(tr("Run"));
    runButton.getStyleClass().addAll("shortcutButton", "runButton");
    runButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutRun()).ifPresent(onShortcutRun -> onShortcutRun.accept(getControl().getShortcut())));
    GridPane.setHalignment(runButton, HPos.CENTER);
    final Button stopButton = new Button(tr("Close"));
    stopButton.getStyleClass().addAll("shortcutButton", "stopButton");
    stopButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutStop()).ifPresent(onShortcutStop -> onShortcutStop.accept(getControl().getShortcut())));
    GridPane.setHalignment(stopButton, HPos.CENTER);
    final Button uninstallButton = new Button(tr("Uninstall"));
    uninstallButton.getStyleClass().addAll("shortcutButton", "uninstallButton");
    uninstallButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutUninstall()).ifPresent(onShortcutUninstall -> onShortcutUninstall.accept(getControl().getShortcut())));
    GridPane.setHalignment(uninstallButton, HPos.CENTER);
    if (getControl().getJavaFxSettingsManager().isAdvancedMode()) {
        final Button editButton = new Button(tr("Edit"));
        editButton.getStyleClass().addAll("shortcutButton", "editButton");
        editButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutEdit()).ifPresent(onShortcutEdit -> onShortcutEdit.accept(getControl().getShortcut())));
        GridPane.setHalignment(editButton, HPos.CENTER);
        ColumnConstraints runColumn = new ColumnConstraintsWithPercentage(100 / 4);
        ColumnConstraints stopColumn = new ColumnConstraintsWithPercentage(100 / 4);
        ColumnConstraints uninstallColumn = new ColumnConstraintsWithPercentage(100 / 4);
        ColumnConstraints editColumn = new ColumnConstraintsWithPercentage(100 / 4);
        controlButtons.getColumnConstraints().addAll(runColumn, stopColumn, uninstallColumn, editColumn);
        controlButtons.addRow(0, runButton, stopButton, uninstallButton, editButton);
    } else {
        ColumnConstraints runColumn = new ColumnConstraintsWithPercentage(100 / 3);
        ColumnConstraints stopColumn = new ColumnConstraintsWithPercentage(100 / 3);
        ColumnConstraints uninstallColumn = new ColumnConstraintsWithPercentage(100 / 3);
        controlButtons.getColumnConstraints().addAll(runColumn, stopColumn, uninstallColumn);
        controlButtons.addRow(0, runButton, stopButton, uninstallButton);
    }
    return controlButtons;
}
Also used : Button(javafx.scene.control.Button) StringBinding(javafx.beans.binding.StringBinding) HPos(javafx.geometry.HPos) StringUtils(org.apache.commons.lang.StringUtils) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) ColumnConstraints(javafx.scene.layout.ColumnConstraints) StringBindings(org.phoenicis.javafx.utils.StringBindings) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) VBox(javafx.scene.layout.VBox) VPos(javafx.geometry.VPos) ShortcutInformationPanel(org.phoenicis.javafx.components.library.control.ShortcutInformationPanel) Map(java.util.Map) KeyAttributeList(org.phoenicis.javafx.components.common.control.KeyAttributeList) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) TypeReference(com.fasterxml.jackson.core.type.TypeReference) GridPane(javafx.scene.layout.GridPane) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) IOException(java.io.IOException) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) ObservableMap(javafx.collections.ObservableMap) Observable(javafx.beans.Observable) Region(javafx.scene.layout.Region) Optional(java.util.Optional) CollectionBindings(org.phoenicis.javafx.utils.CollectionBindings) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) GridPane(javafx.scene.layout.GridPane) Button(javafx.scene.control.Button) ColumnConstraints(javafx.scene.layout.ColumnConstraints)

Example 17 with ColumnConstraintsWithPercentage

use of org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage in project POL-POM-5 by PhoenicisOrg.

the class DetailsListElementSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final GridPane container = new GridPane();
    container.getStyleClass().add("detailsListElement");
    final List<ColumnConstraints> constraints = new ArrayList<>();
    // add the title label
    container.add(createTitle(), 0, 0);
    constraints.add(new ColumnConstraintsWithPercentage(30));
    // TODO: the skin should react to changes done to the additional information list
    // TODO: the skin should react to changes done to the detailed information list
    Stream.concat(getControl().getAdditionalInformation().stream(), getControl().getDetailedInformation().stream()).forEach(information -> {
        final Label informationLabel = new Label(information.getContent());
        informationLabel.setWrapText(true);
        informationLabel.getStyleClass().add("information");
        container.add(informationLabel, constraints.size(), 0);
        constraints.add(new ColumnConstraintsWithPercentage(information.getWidth()));
    });
    // set the last constraint to fill the remaining space
    constraints.set(constraints.size() - 1, new ColumnConstraints());
    container.getColumnConstraints().setAll(constraints);
    getChildren().addAll(container);
}
Also used : ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) GridPane(javafx.scene.layout.GridPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) ArrayList(java.util.ArrayList) Label(javafx.scene.control.Label)

Example 18 with ColumnConstraintsWithPercentage

use of org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage in project POL-POM-5 by PhoenicisOrg.

the class ShortcutInformationPanelSkin method createControlButtons.

/**
 * Creates a new {@link GridPane} containing the control buttons for the selected shortcut.
 * These control buttons consist of:
 * <ul>
 * <li>The run button</li>
 * <li>The stop button</li>
 * <li>The uninstall button</li>
 * </ul>
 *
 * @return A new {@link GridPane} containing the control buttons for the selected shortcut
 */
private GridPane createControlButtons() {
    final GridPane controlButtons = new GridPane();
    controlButtons.getStyleClass().add("shortcut-control-button-group");
    final Button runButton = new Button(tr("Run"));
    runButton.getStyleClass().addAll("shortcutButton", "runButton");
    runButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutRun()).ifPresent(onShortcutRun -> onShortcutRun.accept(getControl().getShortcut())));
    GridPane.setHalignment(runButton, HPos.CENTER);
    final Button stopButton = new Button(tr("Close"));
    stopButton.getStyleClass().addAll("shortcutButton", "stopButton");
    stopButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutStop()).ifPresent(onShortcutStop -> onShortcutStop.accept(getControl().getShortcut())));
    GridPane.setHalignment(stopButton, HPos.CENTER);
    final Button uninstallButton = new Button(tr("Uninstall"));
    uninstallButton.getStyleClass().addAll("shortcutButton", "uninstallButton");
    uninstallButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutUninstall()).ifPresent(onShortcutUninstall -> onShortcutUninstall.accept(getControl().getShortcut())));
    GridPane.setHalignment(uninstallButton, HPos.CENTER);
    if (getControl().getJavaFxSettingsManager().isAdvancedMode()) {
        final Button editButton = new Button(tr("Edit"));
        editButton.getStyleClass().addAll("shortcutButton", "editButton");
        editButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutEdit()).ifPresent(onShortcutEdit -> onShortcutEdit.accept(getControl().getShortcut())));
        GridPane.setHalignment(editButton, HPos.CENTER);
        ColumnConstraints runColumn = new ColumnConstraintsWithPercentage(100 / 4);
        ColumnConstraints stopColumn = new ColumnConstraintsWithPercentage(100 / 4);
        ColumnConstraints uninstallColumn = new ColumnConstraintsWithPercentage(100 / 4);
        ColumnConstraints editColumn = new ColumnConstraintsWithPercentage(100 / 4);
        controlButtons.getColumnConstraints().addAll(runColumn, stopColumn, uninstallColumn, editColumn);
        controlButtons.addRow(0, runButton, stopButton, uninstallButton, editButton);
    } else {
        ColumnConstraints runColumn = new ColumnConstraintsWithPercentage(100 / 3);
        ColumnConstraints stopColumn = new ColumnConstraintsWithPercentage(100 / 3);
        ColumnConstraints uninstallColumn = new ColumnConstraintsWithPercentage(100 / 3);
        controlButtons.getColumnConstraints().addAll(runColumn, stopColumn, uninstallColumn);
        controlButtons.addRow(0, runButton, stopButton, uninstallButton);
    }
    return controlButtons;
}
Also used : Button(javafx.scene.control.Button) StringBinding(javafx.beans.binding.StringBinding) HPos(javafx.geometry.HPos) StringUtils(org.apache.commons.lang.StringUtils) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) ColumnConstraints(javafx.scene.layout.ColumnConstraints) StringBindings(org.phoenicis.javafx.utils.StringBindings) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) VBox(javafx.scene.layout.VBox) VPos(javafx.geometry.VPos) ShortcutInformationPanel(org.phoenicis.javafx.components.library.control.ShortcutInformationPanel) Map(java.util.Map) KeyAttributeList(org.phoenicis.javafx.components.common.control.KeyAttributeList) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) TypeReference(com.fasterxml.jackson.core.type.TypeReference) GridPane(javafx.scene.layout.GridPane) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) IOException(java.io.IOException) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) ObservableMap(javafx.collections.ObservableMap) Observable(javafx.beans.Observable) Region(javafx.scene.layout.Region) Optional(java.util.Optional) CollectionBindings(org.phoenicis.javafx.utils.CollectionBindings) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) GridPane(javafx.scene.layout.GridPane) Button(javafx.scene.control.Button) ColumnConstraints(javafx.scene.layout.ColumnConstraints)

Aggregations

ColumnConstraintsWithPercentage (org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage)18 GridPane (javafx.scene.layout.GridPane)14 ColumnConstraints (javafx.scene.layout.ColumnConstraints)8 VBox (javafx.scene.layout.VBox)8 Label (javafx.scene.control.Label)7 File (java.io.File)5 Button (javafx.scene.control.Button)5 Text (javafx.scene.text.Text)5 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)5 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 Observable (javafx.beans.Observable)4 ShortcutCreationDTO (org.phoenicis.library.dto.ShortcutCreationDTO)4 IOException (java.io.IOException)3 Map (java.util.Map)3 ComboBox (javafx.scene.control.ComboBox)3 Region (javafx.scene.layout.Region)3 FileChooser (javafx.stage.FileChooser)3 MouseWarpOverride (org.phoenicis.containers.wine.parameters.MouseWarpOverride)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2