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;
}
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);
}
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);
}
}
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();
}
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;
}
Aggregations