Search in sources :

Example 16 with TextWithStyle

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

the class EnginePanel method populateContent.

private void populateContent() {
    final GridPane informationContentPane = new GridPane();
    informationContentPane.getStyleClass().add("grid");
    informationContentPane.add(new TextWithStyle(tr("Version:"), CAPTION_TITLE_CSS_CLASS), 0, 0);
    Label name = new Label(engineDTO.getVersion());
    name.setWrapText(true);
    informationContentPane.add(name, 1, 0);
    int rowIdx = 1;
    for (Map.Entry<String, String> userData : engineDTO.getUserData().entrySet()) {
        informationContentPane.add(new TextWithStyle(userData.getKey(), CAPTION_TITLE_CSS_CLASS), 0, rowIdx);
        Label path = new Label(userData.getValue());
        path.setWrapText(true);
        informationContentPane.add(path, 1, rowIdx);
        rowIdx++;
    }
    informationContentPane.setHgap(20);
    informationContentPane.setVgap(10);
    Button installButton = new Button(tr("Install"));
    installButton.setOnMouseClicked(evt -> {
        try {
            onEngineInstall.accept(engineDTO);
        } catch (IllegalArgumentException e) {
            LOGGER.error("Failed to get engine", e);
            new ErrorMessage(tr("Error while trying to install the engine"), e).show();
        }
    });
    Button deleteButton = new Button(tr("Delete"));
    deleteButton.setOnMouseClicked(evt -> {
        try {
            onEngineDelete.accept(engineDTO);
        } catch (IllegalArgumentException e) {
            LOGGER.error("Failed to get engine", e);
            new ErrorMessage(tr("Error while trying to delete the engine"), e).show();
        }
    });
    Region spacer = new Region();
    spacer.setPrefHeight(30);
    VBox.setVgrow(spacer, Priority.NEVER);
    HBox buttonBox = new HBox();
    buttonBox.setSpacing(10);
    buttonBox.getChildren().addAll(installButton, deleteButton);
    Region progressSpacer = new Region();
    progressSpacer.setPrefHeight(30);
    VBox.setVgrow(progressSpacer, Priority.NEVER);
    this.setCenter(new VBox(informationContentPane, spacer, buttonBox, progressSpacer));
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) Label(javafx.scene.control.Label) Button(javafx.scene.control.Button) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) Map(java.util.Map)

Example 17 with TextWithStyle

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

the class UserInterfacePanel method populate.

private void populate() {
    this.title = new TextWithStyle(tr("User Interface Settings"), "title");
    this.themeGrid = new GridPane();
    this.themeGrid.getStyleClass().add("grid");
    this.themeGrid.setHgap(20);
    this.themeGrid.setVgap(10);
    // Change Theme
    this.themeTitle = new TextWithStyle(tr("Theme:"), "captionTitle");
    this.themes = new ComboBox<>();
    this.themes.getItems().setAll(Themes.all());
    this.themes.setValue(Themes.fromShortName(settingsManager.getTheme()).orElse(Themes.DEFAULT));
    this.themes.setOnAction(event -> {
        this.handleThemeChange();
        this.save();
    });
    // View Script Sources
    this.showScriptSource = new CheckBox();
    this.showScriptSource.setSelected(settingsManager.isViewScriptSource());
    this.showScriptSource.setOnAction(event -> this.save());
    this.showScriptDescription = new Label(tr("Select, if you want to view the source repository of the scripts"));
    // Scale UI
    this.scale = new Slider(8, 16, settingsManager.getScale());
    this.scaleDescription = new Label(tr("Scale the user interface."));
    this.scale.valueProperty().addListener((observableValue, oldValue, newValue) -> {
        this.pause.setOnFinished(event -> {
            getScene().getRoot().setStyle(String.format("-fx-font-size: %.2fpt;", newValue));
            this.save();
        });
        this.pause.playFromStart();
    });
    this.themeGrid.add(themeTitle, 0, 0);
    this.themeGrid.add(themes, 1, 0);
    this.themeGrid.add(showScriptSource, 0, 1);
    this.themeGrid.add(showScriptDescription, 1, 1);
    this.themeGrid.add(scale, 0, 2);
    this.themeGrid.add(scaleDescription, 1, 2);
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane) Slider(javafx.scene.control.Slider) CheckBox(javafx.scene.control.CheckBox) Label(javafx.scene.control.Label)

Example 18 with TextWithStyle

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

the class RepositoriesPanel method populateRepositoryGrid.

private void populateRepositoryGrid() {
    this.title = new TextWithStyle(tr("Repositories Settings"), "title");
    this.repositoryGrid = new GridPane();
    this.repositoryGrid.getStyleClass().add("grid");
    this.repositoryText = new TextWithStyle(tr("Repository:"), "captionTitle");
    this.repositoryLayout = new VBox();
    this.repositoryLayout.setSpacing(5);
    this.repositoryListView = new ListView<>(repositories);
    this.repositoryListView.setPrefHeight(0);
    this.repositoryListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    this.repositoryListView.setEditable(true);
    this.repositoryListView.setCellFactory(param -> new DragableRepositoryListCell((repositoryUrl, toIndex) -> {
        this.repositoryManager.moveRepository(repositoryUrl, toIndex.intValue());
        this.save();
    }));
    this.repositoryButtonLayout = new HBox();
    this.repositoryButtonLayout.setSpacing(5);
    this.addButton = new Button();
    this.addButton.setText(tr("Add"));
    this.addButton.setOnAction((ActionEvent event) -> {
        AddRepositoryDialog dialog = new AddRepositoryDialog();
        dialog.initOwner(this.getParent().getScene().getWindow());
        Optional<RepositoryLocation<? extends Repository>> successResult = dialog.showAndWait();
        successResult.ifPresent(repositoryLocation -> {
            repositories.add(repositoryLocation);
            this.save();
            repositoryManager.addRepositories(0, repositoryLocation);
        });
    });
    this.removeButton = new Button();
    this.removeButton.setText(tr("Remove"));
    this.removeButton.setOnAction((ActionEvent event) -> {
        RepositoryLocation<? extends Repository>[] toRemove = repositoryListView.getSelectionModel().getSelectedItems().toArray(new RepositoryLocation[0]);
        repositories.removeAll(toRemove);
        this.save();
        repositoryManager.removeRepositories(toRemove);
    });
    this.repositoryButtonLayout.getChildren().addAll(addButton, removeButton);
    this.repositoryLayout.getChildren().addAll(repositoryListView, repositoryButtonLayout);
    VBox.setVgrow(repositoryListView, Priority.ALWAYS);
    this.repositoryGrid.add(repositoryText, 0, 0);
    this.repositoryGrid.add(repositoryLayout, 1, 0);
    GridPane.setHgrow(repositoryLayout, Priority.ALWAYS);
    GridPane.setVgrow(repositoryLayout, Priority.ALWAYS);
    GridPane.setValignment(repositoryText, VPos.TOP);
}
Also used : Pos(javafx.geometry.Pos) javafx.scene.layout(javafx.scene.layout) Repository(org.phoenicis.repository.types.Repository) javafx.scene.control(javafx.scene.control) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) RepositoryManager(org.phoenicis.repository.RepositoryManager) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) ActionEvent(javafx.event.ActionEvent) AddRepositoryDialog(org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog) Insets(javafx.geometry.Insets) SettingsManager(org.phoenicis.settings.SettingsManager) VPos(javafx.geometry.VPos) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) ActionEvent(javafx.event.ActionEvent) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) Repository(org.phoenicis.repository.types.Repository) AddRepositoryDialog(org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog)

Example 19 with TextWithStyle

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

the class UserInterfacePanel method populate.

private void populate() {
    this.title = new TextWithStyle(tr("User Interface Settings"), "title");
    this.themeGrid = new GridPane();
    this.themeGrid.getStyleClass().add("grid");
    this.themeGrid.setHgap(20);
    this.themeGrid.setVgap(10);
    // Change Theme
    this.themeTitle = new TextWithStyle(tr("Theme:"), "captionTitle");
    this.themes = new ComboBox<>();
    this.themes.getItems().setAll(Themes.all());
    this.themes.setValue(Themes.fromShortName(javaFxSettingsManager.getTheme()).orElse(Themes.DEFAULT));
    this.themes.setOnAction(event -> {
        this.handleThemeChange();
        this.save();
    });
    // View Script Sources
    this.showScriptSource = new CheckBox();
    this.showScriptSource.setSelected(javaFxSettingsManager.isViewScriptSource());
    this.showScriptSource.setOnAction(event -> this.save());
    this.showScriptDescription = new Label(tr("Select, if you want to view the source repository of the scripts"));
    // Scale UI
    this.scale = new Slider(8, 16, javaFxSettingsManager.getScale());
    this.scaleDescription = new Label(tr("Scale the user interface."));
    this.scale.valueProperty().addListener((observableValue, oldValue, newValue) -> {
        this.pause.setOnFinished(event -> {
            getScene().getRoot().setStyle(String.format("-fx-font-size: %.2fpt;", newValue));
            this.save();
        });
        this.pause.playFromStart();
    });
    // restore default
    ToggleButton restoreDefault = new ToggleButton(tr("Restore defaults (requires restart)"));
    restoreDefault.setOnAction(event -> {
        this.javaFxSettingsManager.restoreDefault();
    });
    this.themeGrid.add(themeTitle, 0, 0);
    this.themeGrid.add(themes, 1, 0);
    this.themeGrid.add(showScriptSource, 0, 1);
    this.themeGrid.add(showScriptDescription, 1, 1);
    this.themeGrid.add(scale, 0, 2);
    this.themeGrid.add(scaleDescription, 1, 2);
    this.themeGrid.add(restoreDefault, 0, 3);
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane)

Example 20 with TextWithStyle

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

the class AboutPanel method populate.

private void populate() {
    this.title = new TextWithStyle(tr("About"), "title");
    this.aboutGrid = new GridPane();
    this.aboutGrid.getStyleClass().add("grid");
    this.aboutGrid.setHgap(20);
    this.aboutGrid.setVgap(10);
    this.nameDescription = new TextWithStyle(tr("Name:"), "captionTitle");
    this.nameLabel = new Label(buildInformation.getApplicationName());
    this.versionDescription = new TextWithStyle(tr("Version:"), "captionTitle");
    this.versionLabel = new Label(buildInformation.getApplicationVersion());
    this.gitRevisionDescription = new TextWithStyle(tr("Git Revision:"), "captionTitle");
    this.gitRevisionHyperlink = new Hyperlink(buildInformation.getApplicationGitRevision());
    this.gitRevisionHyperlink.setOnAction(event -> {
        try {
            URI uri = new URI("https://github.com/PhoenicisOrg/POL-POM-5/commit/" + buildInformation.getApplicationGitRevision());
            opener.open(uri);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    });
    this.buildTimestampDescription = new TextWithStyle(tr("Build Timestamp:"), "captionTitle");
    this.buildTimestampLabel = new Label(buildInformation.getApplicationBuildTimestamp());
    this.aboutGrid.add(nameDescription, 0, 0);
    this.aboutGrid.add(nameLabel, 1, 0);
    this.aboutGrid.add(versionDescription, 0, 1);
    this.aboutGrid.add(versionLabel, 1, 1);
    this.aboutGrid.add(gitRevisionDescription, 0, 2);
    this.aboutGrid.add(gitRevisionHyperlink, 1, 2);
    this.aboutGrid.add(buildTimestampDescription, 0, 3);
    this.aboutGrid.add(buildTimestampLabel, 1, 3);
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Hyperlink(javafx.scene.control.Hyperlink)

Aggregations

TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)29 Text (javafx.scene.text.Text)20 GridPane (javafx.scene.layout.GridPane)17 VBox (javafx.scene.layout.VBox)15 Button (javafx.scene.control.Button)12 Label (javafx.scene.control.Label)10 ErrorMessage (org.phoenicis.javafx.views.common.ErrorMessage)9 ComboBox (javafx.scene.control.ComboBox)7 Region (javafx.scene.layout.Region)6 ColumnConstraintsWithPercentage (org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage)5 FXCollections (javafx.collections.FXCollections)4 TilePane (javafx.scene.layout.TilePane)4 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)4 File (java.io.File)3 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 Map (java.util.Map)3 Optional (java.util.Optional)3 Platform (javafx.application.Platform)3 ObservableList (javafx.collections.ObservableList)3