Search in sources :

Example 6 with ColumnConstraintsWithPercentage

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

the class CompactListElementSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final GridPane container = new GridPane();
    container.getStyleClass().add("compactListElement");
    List<ColumnConstraints> constraints = new ArrayList<>();
    // add the miniature icon
    container.add(createMiniature(), 0, 0);
    constraints.add(new ColumnConstraints());
    // add the title label
    container.add(createTitle(), 1, 0);
    constraints.add(new ColumnConstraintsWithPercentage(40));
    // add the additional information
    getControl().getAdditionalInformation().forEach(information -> {
        final Label informationLabel = new Label(information.getContent());
        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 7 with ColumnConstraintsWithPercentage

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

the class ShortcutInformationPanelSkin method createPropertiesGrid.

/**
 * Creates a new {@link GridPane} containing the properties of the selected shortcut
 *
 * @return a new {@link GridPane} containing the properties of the selected shortcut
 */
private GridPane createPropertiesGrid() {
    final GridPane propertiesGrid = new GridPane();
    propertiesGrid.getStyleClass().add("grid");
    ColumnConstraints titleColumn = new ColumnConstraintsWithPercentage(30);
    ColumnConstraints valueColumn = new ColumnConstraintsWithPercentage(70);
    propertiesGrid.getColumnConstraints().addAll(titleColumn, valueColumn);
    // ensure that changes to the shortcutProperties map result in updates to the GridPane
    shortcutProperties.addListener((Observable invalidation) -> updateProperties(propertiesGrid));
    // initialize the properties grid correctly
    updateProperties(propertiesGrid);
    return propertiesGrid;
}
Also used : ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) GridPane(javafx.scene.layout.GridPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Observable(javafx.beans.Observable)

Example 8 with ColumnConstraintsWithPercentage

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

the class ShortcutCreationPanelSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final GridPane gridPane = new GridPane();
    gridPane.getStyleClass().add("shortcut-information-grid");
    ColumnConstraints labelConstraints = new ColumnConstraintsWithPercentage(30);
    ColumnConstraints valueConstraints = new ColumnConstraintsWithPercentage(70);
    gridPane.getColumnConstraints().addAll(labelConstraints, valueConstraints);
    // add name input
    final TextField name = addName(gridPane);
    final Tooltip nameErrorTooltip = new Tooltip(tr("Please specify a name!"));
    // add category input
    final TextField category = addCategory(gridPane);
    final Tooltip categoryErrorTooltip = new Tooltip(tr("Please specify a category!"));
    // add description input
    final TextArea description = addDescription(gridPane);
    // add miniature input
    final TextField miniature = addMiniature(gridPane);
    final Tooltip miniatureErrorTooltip = new Tooltip(tr("Please specify a valid miniature!"));
    // add executable input
    final TextField executable = addExecutable(gridPane);
    final Tooltip executableErrorTooltip = new Tooltip(tr("Please specify a valid executable!"));
    // add create button
    final Button createButton = new Button(tr("Create"));
    createButton.setOnMouseClicked(event -> {
        boolean error = false;
        if (StringUtils.isEmpty(name.getText())) {
            name.pseudoClassStateChanged(errorClass, true);
            name.setTooltip(nameErrorTooltip);
            error = true;
        }
        if (StringUtils.isEmpty(category.getText())) {
            category.pseudoClassStateChanged(errorClass, true);
            category.setTooltip(categoryErrorTooltip);
            error = true;
        }
        URI miniatureUri = null;
        // but if a miniature is given, it must exist
        if (StringUtils.isNotEmpty(miniature.getText())) {
            File miniatureFile = new File(miniature.getText());
            if (miniatureFile.exists()) {
                miniatureUri = miniatureFile.toURI();
            } else {
                miniature.pseudoClassStateChanged(errorClass, true);
                miniature.setTooltip(miniatureErrorTooltip);
                error = true;
            }
        }
        File executableFile = new File(executable.getText());
        if (!executableFile.exists()) {
            executable.pseudoClassStateChanged(errorClass, true);
            executable.setTooltip(executableErrorTooltip);
            error = true;
        }
        if (!error) {
            final ShortcutCreationDTO newShortcut = new ShortcutCreationDTO.Builder().withName(name.getText()).withCategory(category.getText()).withDescription(description.getText()).withMiniature(miniatureUri).withExecutable(executableFile).build();
            getControl().getOnCreateShortcut().accept(newShortcut);
        }
    });
    final VBox container = new VBox(gridPane, createButton);
    container.getStyleClass().addAll("library-details-panel-content", "create-shortcut-panel-content");
    getChildren().setAll(container);
}
Also used : ShortcutCreationDTO(org.phoenicis.library.dto.ShortcutCreationDTO) URI(java.net.URI) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) File(java.io.File)

Example 9 with ColumnConstraintsWithPercentage

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

the class ShortcutInformationPanelSkin method createPropertiesGrid.

/**
 * Creates a new {@link GridPane} containing the properties of the selected shortcut
 *
 * @return a new {@link GridPane} containing the properties of the selected shortcut
 */
private GridPane createPropertiesGrid() {
    final GridPane propertiesGrid = new GridPane();
    propertiesGrid.getStyleClass().add("grid");
    ColumnConstraints titleColumn = new ColumnConstraintsWithPercentage(30);
    ColumnConstraints valueColumn = new ColumnConstraintsWithPercentage(70);
    propertiesGrid.getColumnConstraints().addAll(titleColumn, valueColumn);
    // ensure that changes to the shortcutProperties map result in updates to the GridPane
    shortcutProperties.addListener((Observable invalidation) -> updateProperties(propertiesGrid));
    // initialize the properties grid correctly
    updateProperties(propertiesGrid);
    return propertiesGrid;
}
Also used : ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) GridPane(javafx.scene.layout.GridPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Observable(javafx.beans.Observable)

Example 10 with ColumnConstraintsWithPercentage

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

the class CompactListElementSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final GridPane container = new GridPane();
    container.getStyleClass().add("compactListElement");
    List<ColumnConstraints> constraints = new ArrayList<>();
    // add the miniature icon
    container.add(createMiniature(), 0, 0);
    constraints.add(new ColumnConstraints());
    // add the title label
    container.add(createTitle(), 1, 0);
    constraints.add(new ColumnConstraintsWithPercentage(40));
    // add the additional information
    getControl().getAdditionalInformation().forEach(information -> {
        final Label informationLabel = new Label(information.getContent());
        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)

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