Search in sources :

Example 1 with KeyAttributeList

use of org.phoenicis.javafx.components.common.control.KeyAttributeList in project POL-POM-5 by PlayOnLinux.

the class ShortcutInformationPanelSkin method createKeyAttributeList.

private KeyAttributeList createKeyAttributeList() {
    final KeyAttributeList keyAttributeList = new KeyAttributeList();
    this.environmentAttributes.addListener((Observable invalidated) -> keyAttributeList.setAttributeMap(this.environmentAttributes));
    keyAttributeList.setAttributeMap(this.environmentAttributes);
    return keyAttributeList;
}
Also used : KeyAttributeList(org.phoenicis.javafx.components.common.control.KeyAttributeList) Observable(javafx.beans.Observable)

Example 2 with KeyAttributeList

use of org.phoenicis.javafx.components.common.control.KeyAttributeList in project POL-POM-5 by PlayOnLinux.

the class ShortcutEditingPanelSkin method createKeyAttributeList.

private KeyAttributeList createKeyAttributeList() {
    final KeyAttributeList keyAttributeList = new KeyAttributeList();
    keyAttributeList.setEditable(true);
    keyAttributeList.setOnChange(environment -> {
        // update shortcut if a part of the environment list has changed
        shortcutProperties.replace("environment", environment);
        try {
            final ShortcutDTO shortcut = getControl().getShortcut();
            final String json = new ObjectMapper().writeValueAsString(shortcutProperties);
            getControl().setShortcut(new ShortcutDTO.Builder(shortcut).withScript(json).build());
        } catch (JsonProcessingException e) {
            LOGGER.error("Creating new shortcut String failed.", e);
        }
    });
    this.environmentAttributes.addListener((Observable invalidated) -> keyAttributeList.setAttributeMap(this.environmentAttributes));
    keyAttributeList.setAttributeMap(this.environmentAttributes);
    return keyAttributeList;
}
Also used : KeyAttributeList(org.phoenicis.javafx.components.common.control.KeyAttributeList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Observable(javafx.beans.Observable)

Example 3 with KeyAttributeList

use of org.phoenicis.javafx.components.common.control.KeyAttributeList in project POL-POM-5 by PlayOnLinux.

the class ShortcutEditingPanelSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final Label descriptionLabel = new Label();
    descriptionLabel.textProperty().bind(description);
    descriptionLabel.setWrapText(true);
    final GridPane propertiesGrid = createPropertiesGrid();
    final Label environmentLabel = new Label(tr("Environment"));
    environmentLabel.getStyleClass().add("sectionTitle");
    environmentLabel.setWrapText(true);
    final KeyAttributeList environmentAttributeList = createKeyAttributeList();
    final Region spacer = new Region();
    spacer.getStyleClass().add("detailsButtonSpacer");
    final Button saveButton = new Button(tr("Save"));
    saveButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutChanged()).ifPresent(onShortcutChanged -> onShortcutChanged.accept(getControl().getShortcut())));
    final VBox container = new VBox(descriptionLabel, propertiesGrid, environmentLabel, environmentAttributeList, spacer, saveButton);
    getChildren().setAll(container);
}
Also used : Button(javafx.scene.control.Button) StringBinding(javafx.beans.binding.StringBinding) StringUtils(org.apache.commons.lang.StringUtils) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) TextArea(javafx.scene.control.TextArea) javafx.scene.layout(javafx.scene.layout) StringBindings(org.phoenicis.javafx.utils.StringBindings) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) VPos(javafx.geometry.VPos) Map(java.util.Map) KeyAttributeList(org.phoenicis.javafx.components.common.control.KeyAttributeList) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) URI(java.net.URI) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ShortcutEditingPanel(org.phoenicis.javafx.components.library.control.ShortcutEditingPanel) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) ObservableMap(javafx.collections.ObservableMap) Observable(javafx.beans.Observable) File(java.io.File) FileChooser(javafx.stage.FileChooser) Optional(java.util.Optional) CollectionBindings(org.phoenicis.javafx.utils.CollectionBindings) Button(javafx.scene.control.Button) KeyAttributeList(org.phoenicis.javafx.components.common.control.KeyAttributeList) Label(javafx.scene.control.Label)

Example 4 with KeyAttributeList

use of org.phoenicis.javafx.components.common.control.KeyAttributeList in project POL-POM-5 by PlayOnLinux.

the class ShortcutInformationPanelSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final GridPane controlButtons = createControlButtons();
    if (getControl().getJavaFxSettingsManager().isAdvancedMode()) {
        final Label descriptionLabel = new Label();
        descriptionLabel.textProperty().bind(description);
        descriptionLabel.setWrapText(true);
        final GridPane propertiesGrid = createPropertiesGrid();
        final Label environmentLabel = new Label(tr("Environment"));
        environmentLabel.getStyleClass().add("sectionTitle");
        environmentLabel.setWrapText(true);
        final KeyAttributeList environmentAttributeList = createKeyAttributeList();
        final Region spacer = new Region();
        spacer.getStyleClass().add("detailsButtonSpacer");
        final VBox container = new VBox(descriptionLabel, propertiesGrid, environmentLabel, environmentAttributeList, spacer, controlButtons);
        getChildren().setAll(container);
    } else {
        final VBox container = new VBox(controlButtons);
        getChildren().setAll(container);
    }
}
Also used : GridPane(javafx.scene.layout.GridPane) KeyAttributeList(org.phoenicis.javafx.components.common.control.KeyAttributeList) Label(javafx.scene.control.Label) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox)

Aggregations

KeyAttributeList (org.phoenicis.javafx.components.common.control.KeyAttributeList)4 Observable (javafx.beans.Observable)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Label (javafx.scene.control.Label)2 ShortcutDTO (org.phoenicis.library.dto.ShortcutDTO)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1 Map (java.util.Map)1 Optional (java.util.Optional)1 StringBinding (javafx.beans.binding.StringBinding)1 FXCollections (javafx.collections.FXCollections)1 ObservableMap (javafx.collections.ObservableMap)1 VPos (javafx.geometry.VPos)1 Button (javafx.scene.control.Button)1 TextArea (javafx.scene.control.TextArea)1 TextField (javafx.scene.control.TextField)1 javafx.scene.layout (javafx.scene.layout)1