Search in sources :

Example 21 with GridPane

use of javafx.scene.layout.GridPane in project POL-POM-5 by PlayOnLinux.

the class LibraryPanel method setShortcutDTO.

public void setShortcutDTO(ShortcutDTO shortcutDTO) {
    this.setTitle(shortcutDTO.getName());
    this.getChildren().clear();
    final VBox vBox = new VBox();
    Label description = new Label(shortcutDTO.getDescription());
    description.setWrapText(true);
    final GridPane gridPane = new GridPane();
    gridPane.getStyleClass().add("grid");
    try {
        LOGGER.info("Reading shortcut: {}", shortcutDTO.getScript());
        final Map<String, Object> shortcutProperties = objectMapper.readValue(shortcutDTO.getScript(), new TypeReference<Map<String, Object>>() {
        });
        int i = 0;
        for (String shortcutKey : shortcutProperties.keySet()) {
            final Label keyLabel = new Label(tr(unCamelize(shortcutKey)) + ":");
            keyLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
            GridPane.setValignment(keyLabel, VPos.TOP);
            gridPane.add(keyLabel, 0, i);
            final Label valueLabel = new Label(shortcutProperties.get(shortcutKey).toString());
            valueLabel.setWrapText(true);
            gridPane.add(valueLabel, 1, i);
            i++;
        }
    } catch (IOException e) {
        LOGGER.warn("Could not parse shortcut script JSON", e);
    }
    gridPane.getColumnConstraints().addAll(new ColumnConstraintsWithPercentage(30), new ColumnConstraintsWithPercentage(70));
    Region spacer = new Region();
    spacer.setPrefHeight(40);
    HBox buttons = new HBox();
    buttons.setAlignment(Pos.CENTER);
    Button runButton = new Button(tr("Run"));
    runButton.getStyleClass().addAll("shortcutButton", "runButton");
    runButton.setOnMouseClicked(event -> onShortcutRun.accept(shortcutDTO));
    Button stopButton = new Button(tr("Close"));
    stopButton.getStyleClass().addAll("shortcutButton", "stopButton");
    stopButton.setOnMouseClicked(event -> onShortcutStop.accept(shortcutDTO));
    Button uninstallButton = new Button(tr("Uninstall"));
    uninstallButton.getStyleClass().addAll("shortcutButton", "uninstallButton");
    uninstallButton.setOnMouseClicked(event -> onShortcutUninstall.accept(shortcutDTO));
    buttons.getChildren().addAll(runButton, stopButton, uninstallButton);
    vBox.getChildren().addAll(description, gridPane, spacer, buttons);
    this.setCenter(vBox);
}
Also used : HBox(javafx.scene.layout.HBox) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) IOException(java.io.IOException) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) Button(javafx.scene.control.Button) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox) Map(java.util.Map)

Example 22 with GridPane

use of javafx.scene.layout.GridPane in project aic-praise by aic-sri-international.

the class FXUtil method exception.

public static void exception(Throwable th) {
    Dialog<ButtonType> dialog = new Dialog<ButtonType>();
    dialog.setTitle("Program exception");
    final DialogPane dialogPane = dialog.getDialogPane();
    dialogPane.setContentText("Details of the problem:");
    dialogPane.getButtonTypes().addAll(ButtonType.OK);
    dialogPane.setContentText(th.getMessage());
    dialog.initModality(Modality.APPLICATION_MODAL);
    Label label = new Label("Exception stacktrace:");
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    th.printStackTrace(pw);
    pw.close();
    TextArea textArea = new TextArea(sw.toString());
    textArea.setEditable(false);
    textArea.setWrapText(true);
    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);
    GridPane root = new GridPane();
    root.setVisible(false);
    root.setMaxWidth(Double.MAX_VALUE);
    root.add(label, 0, 0);
    root.add(textArea, 0, 1);
    dialogPane.setExpandableContent(root);
    dialog.showAndWait();
}
Also used : DialogPane(javafx.scene.control.DialogPane) GridPane(javafx.scene.layout.GridPane) StringWriter(java.io.StringWriter) TextArea(javafx.scene.control.TextArea) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) PrintWriter(java.io.PrintWriter)

Example 23 with GridPane

use of javafx.scene.layout.GridPane in project jabref by JabRef.

the class EntryEditorTab method setupPanel.

private Region setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField, boolean compressed, String title) {
    setupKeyBindings(panel.getInputMap(JComponent.WHEN_FOCUSED), panel.getActionMap());
    panel.setName(title);
    editors.clear();
    List<Label> labels = new ArrayList<>();
    for (String fieldName : fields) {
        // TODO: Reenable/migrate this
        // Store the editor for later reference:
        /*
            FieldEditor fieldEditor;
            int defaultHeight;
            int wHeight = (int) (50.0 * InternalBibtexFields.getFieldWeight(field));
            if (InternalBibtexFields.getFieldProperties(field).contains(FieldProperty.SINGLE_ENTRY_LINK)) {
                fieldEditor = new EntryLinkListEditor(frame, bPanel.getBibDatabaseContext(), field, null, parent,
                        true);
                defaultHeight = 0;
            } else if (InternalBibtexFields.getFieldProperties(field).contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
                fieldEditor = new EntryLinkListEditor(frame, bPanel.getBibDatabaseContext(), field, null, parent,
                        false);
                defaultHeight = 0;
            } else {
                fieldEditor = new TextArea(field, null, getPrompt(field));
                //parent.addSearchListener((TextArea) fieldEditor);
                defaultHeight = fieldEditor.getPane().getPreferredSize().height;
            }
            
            Optional<JComponent> extra = parent.getExtra(fieldEditor);
            
            // Add autocompleter listener, if required for this field:
            /*
            AutoCompleter<String> autoCompleter = bPanel.getAutoCompleters().get(field);
            AutoCompleteListener autoCompleteListener = null;
            if (autoCompleter != null) {
                autoCompleteListener = new AutoCompleteListener(autoCompleter);
            }
            setupJTextComponent(fieldEditor.getTextComponent(), autoCompleteListener);
            fieldEditor.setAutoCompleteListener(autoCompleteListener);
            */
        FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.taskExecutor, new FXDialogService(), Globals.journalAbbreviationLoader, Globals.prefs.getJournalAbbreviationPreferences(), Globals.prefs, bPanel.getBibDatabaseContext(), entry.getType());
        fieldEditor.bindToEntry(entry);
        editors.put(fieldName, fieldEditor);
        /*
            // TODO: Reenable this
            if (i == 0) {
                activeField = fieldEditor;
            }
            */
        /*
            // TODO: Reenable this
            if (!compressed) {
                fieldEditor.getPane().setPreferredSize(new Dimension(100, Math.max(defaultHeight, wHeight)));
            }
            */
        /*
            // TODO: Reenable content selector
            if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(editor.getFieldName()).isEmpty()) {
                FieldContentSelector ws = new FieldContentSelector(frame, panel, frame, editor, storeFieldAction, false,
                        ", ");
                contentSelectors.add(ws);
                controls.add(ws, BorderLayout.NORTH);
            }
            //} else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) {
            //return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction);
             */
        labels.add(new FieldNameLabel(fieldName));
    }
    GridPane gridPane = new GridPane();
    gridPane.setPrefSize(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
    gridPane.setMaxSize(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
    gridPane.getStyleClass().add("editorPane");
    ColumnConstraints columnExpand = new ColumnConstraints();
    columnExpand.setHgrow(Priority.ALWAYS);
    ColumnConstraints columnDoNotContract = new ColumnConstraints();
    columnDoNotContract.setMinWidth(Region.USE_PREF_SIZE);
    int rows;
    if (compressed) {
        rows = (int) Math.ceil((double) fields.size() / 2);
        addColumn(gridPane, 0, labels.subList(0, rows));
        addColumn(gridPane, 3, labels.subList(rows, labels.size()));
        addColumn(gridPane, 1, editors.values().stream().map(FieldEditorFX::getNode).limit(rows));
        addColumn(gridPane, 4, editors.values().stream().map(FieldEditorFX::getNode).skip(rows));
        gridPane.getColumnConstraints().addAll(columnDoNotContract, columnExpand, new ColumnConstraints(10), columnDoNotContract, columnExpand);
    } else {
        rows = fields.size();
        addColumn(gridPane, 0, labels);
        addColumn(gridPane, 1, editors.values().stream().map(FieldEditorFX::getNode));
        gridPane.getColumnConstraints().addAll(columnDoNotContract, columnExpand);
    }
    RowConstraints rowExpand = new RowConstraints();
    rowExpand.setVgrow(Priority.ALWAYS);
    if (rows == 0) {
        rowExpand.setPercentHeight(100);
    } else {
        rowExpand.setPercentHeight(100 / rows);
    }
    for (int i = 0; i < rows; i++) {
        gridPane.getRowConstraints().add(rowExpand);
    }
    return gridPane;
}
Also used : FXDialogService(org.jabref.gui.FXDialogService) FieldNameLabel(org.jabref.gui.fieldeditors.FieldNameLabel) GridPane(javafx.scene.layout.GridPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) ArrayList(java.util.ArrayList) FieldNameLabel(org.jabref.gui.fieldeditors.FieldNameLabel) Label(javafx.scene.control.Label) FieldEditorFX(org.jabref.gui.fieldeditors.FieldEditorFX) RowConstraints(javafx.scene.layout.RowConstraints)

Example 24 with GridPane

use of javafx.scene.layout.GridPane in project Media-Library by The-Rain-Goddess.

the class ApplicationWindow method getAddWindowLayout.

private GridPane getAddWindowLayout() {
    GridPane componentLayout = new GridPane();
    componentLayout.setPadding(new Insets(10, 10, 10, 10));
    componentLayout.setVgap(5);
    componentLayout.setHgap(5);
    return componentLayout;
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets)

Example 25 with GridPane

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

Aggregations

GridPane (javafx.scene.layout.GridPane)34 Label (javafx.scene.control.Label)22 Insets (javafx.geometry.Insets)13 Button (javafx.scene.control.Button)9 TextField (javafx.scene.control.TextField)9 Scene (javafx.scene.Scene)7 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)7 Dialog (javafx.scene.control.Dialog)6 VBox (javafx.scene.layout.VBox)6 Text (javafx.scene.text.Text)5 Stage (javafx.stage.Stage)5 Pair (javafx.util.Pair)5 ButtonType (javafx.scene.control.ButtonType)4 Region (javafx.scene.layout.Region)4 JFXButton (com.jfoenix.controls.JFXButton)3 MaterialDesignIconView (de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Node (javafx.scene.Node)3 ScrollPane (javafx.scene.control.ScrollPane)3