Search in sources :

Example 76 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 77 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)

Example 78 with GridPane

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

the class DragableRepositoryListCell method updateItem.

@Override
protected void updateItem(String item, boolean empty) {
    super.updateItem(item, empty);
    ObservableList<String> repositories = getListView().getItems();
    GridPane itemPane = new GridPane();
    Label indexLabel = new Label(String.valueOf(repositories.size() - repositories.indexOf(item)));
    indexLabel.setPrefWidth(50);
    Label repositoryLocationLabel = new Label(item);
    itemPane.add(indexLabel, 0, 0);
    itemPane.add(repositoryLocationLabel, 1, 0);
    if (!empty) {
        setGraphic(itemPane);
    } else {
        setGraphic(null);
    }
}
Also used : GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label)

Example 79 with GridPane

use of javafx.scene.layout.GridPane in project Gargoyle by callakrsos.

the class FilterTableExample method start.

@Override
public void start(Stage primaryStage) throws Exception {
    TableView<DataItem> tableView = new TableView<>();
    FxUtil.installClipboardKeyEvent(tableView);
    tableView.setItems(FXCollections.observableArrayList());
    IntStream.range(0, 20000).mapToObj(i -> new DataItem()).forEach(d -> tableView.getItems().add(d));
    TableColumn<DataItem, Integer> smallInt = new TableColumn<>("Small Int");
    smallInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getSmallIntValue()));
    TableColumn<DataItem, Integer> largeInt = new TableColumn<>("Large Int");
    largeInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getLargeIntValue()));
    TableColumn<DataItem, String> randomLetter = new TableColumn<>("Letter");
    randomLetter.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomLetter()));
    TableColumn<DataItem, String> randomString1 = new TableColumn<>("AlphaNum 1");
    randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr1()));
    TableColumn<DataItem, String> randomString2 = new TableColumn<>("AlphaNum 2");
    randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr2()));
    tableView.getColumns().addAll(smallInt, largeInt, randomLetter, randomString1, randomString2);
    Platform.runLater(() -> new TableFilter<>(tableView));
    GridPane grp = new GridPane();
    GridPane.setFillHeight(tableView, true);
    GridPane.setFillWidth(tableView, true);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    grp.getChildren().add(tableView);
    Scene scene = new Scene(grp);
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : IntStream(java.util.stream.IntStream) Scene(javafx.scene.Scene) FXCollections(javafx.collections.FXCollections) Random(java.util.Random) UUID(java.util.UUID) TableColumn(javafx.scene.control.TableColumn) Application(javafx.application.Application) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Stage(javafx.stage.Stage) TableFilter(org.controlsfx.control.table.TableFilter) TableView(javafx.scene.control.TableView) GridPane(javafx.scene.layout.GridPane) GridPane(javafx.scene.layout.GridPane) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) TableView(javafx.scene.control.TableView)

Example 80 with GridPane

use of javafx.scene.layout.GridPane in project Gargoyle by callakrsos.

the class DialogUtil method showLoginDialog.

/**
	 * login Dialog 로그인 처리 다이얼로그
	 *
	 * @param consumer
	 * @return
	 */
public static <T> Optional<Pair<String, String>> showLoginDialog(Consumer<? super Pair<String, String>> consumer) {
    // Create the custom dialog.
    Dialog<Pair<String, String>> dialog = new Dialog<>();
    dialog.setTitle("Login Dialog");
    dialog.setHeaderText("Look, a Custom Login Dialog");
    dialog.setGraphic(new ImageView(new Image("file:resources/images/login.png")));
    // Set the button types.
    ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
    ButtonType localButtonType = new ButtonType("Local", ButtonData.APPLY);
    dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, localButtonType, ButtonType.CANCEL);
    // Create the username and password labels and fields.
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));
    TextField username = new TextField();
    username.setPromptText("Username");
    PasswordField password = new PasswordField();
    password.setPromptText("Password");
    grid.add(new Label("Username:"), 0, 0);
    grid.add(username, 1, 0);
    grid.add(new Label("Password:"), 0, 1);
    grid.add(password, 1, 1);
    // Enable/Disable login button depending on whether a username was
    // entered.
    Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
    loginButton.setDisable(true);
    // Do some validation (using the Java 8 lambda syntax).
    username.textProperty().addListener((observable, oldValue, newValue) -> {
        loginButton.setDisable(newValue.trim().isEmpty());
    });
    dialog.getDialogPane().setContent(grid);
    // Request focus on the username field by default.
    Platform.runLater(() -> username.requestFocus());
    // Convert the result to a username-password-pair when the login button
    // is clicked.
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == loginButtonType) {
            return new Pair<>(username.getText(), password.getText());
        } else if (dialogButton == localButtonType) {
            return new Pair<>(MEMO_LOCAL_USER, "");
        }
        return null;
    });
    Optional<Pair<String, String>> result = dialog.showAndWait();
    result.ifPresent(consumer);
    return result;
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Node(javafx.scene.Node) Label(javafx.scene.control.Label) Image(javafx.scene.image.Image) Dialog(javafx.scene.control.Dialog) TextField(javafx.scene.control.TextField) ImageView(javafx.scene.image.ImageView) PasswordField(javafx.scene.control.PasswordField) ButtonType(javafx.scene.control.ButtonType) Pair(javafx.util.Pair)

Aggregations

GridPane (javafx.scene.layout.GridPane)147 Label (javafx.scene.control.Label)83 Insets (javafx.geometry.Insets)67 Button (javafx.scene.control.Button)46 TextField (javafx.scene.control.TextField)42 VBox (javafx.scene.layout.VBox)37 Scene (javafx.scene.Scene)36 HBox (javafx.scene.layout.HBox)26 ButtonType (javafx.scene.control.ButtonType)25 Text (javafx.scene.text.Text)24 Node (javafx.scene.Node)23 Dialog (javafx.scene.control.Dialog)23 ColumnConstraints (javafx.scene.layout.ColumnConstraints)18 Stage (javafx.stage.Stage)18 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)17 List (java.util.List)16 CheckBox (javafx.scene.control.CheckBox)16 ImageView (javafx.scene.image.ImageView)14 ActionEvent (javafx.event.ActionEvent)13 ComboBox (javafx.scene.control.ComboBox)13