use of javafx.scene.layout.GridPane in project Media-Library by The-Rain-Goddess.
the class ApplicationWindow method showAddWindow.
// private add window mutators
private void showAddWindow() {
// create new Stage
Stage addWindow = new Stage();
addWindow.setTitle("ADD Media");
GridPane componentLayout = getAddWindowLayout();
// add all window components to componentLayout
componentLayout.getChildren().addAll(getWindowComponents(addWindow));
// create Scene
Scene scene = new Scene(componentLayout, 550, 300);
// set Screen to show Scene
addWindow.setScene(scene);
addWindow.show();
}
use of javafx.scene.layout.GridPane in project trex-stateless-gui by cisco-system-traffic-generator.
the class StatsTableGenerator method generateXStatPane.
public GridPane generateXStatPane(boolean full, Port port, boolean notempty, String filter, boolean resetCounters) {
if (full) {
statXTable.getChildren().clear();
Util.optimizeMemory();
}
Map<String, Long> xstatsList = port.getXstats();
Map<String, Long> xstatsListPinned = port.getXstatsPinned();
String pinnedChar = "\u2716";
String notPinnedChar = "\u271a";
/*String pinnedChar = "\u2611";
String notPinnedChar = "\u2610";*/
rowIndex = 0;
addHeaderCell(statXTable, "xstats-header0", "Counter", 0, WIDTH_COL_0 * 1.5);
addHeaderCell(statXTable, "xstats-header1", "Value", 1, WIDTH_COL_1);
addHeaderCell(statXTable, "xstats-header2", "Pin", 2, WIDTH_COL_PIN);
rowIndex = 1;
odd = true;
xstatsListPinned.forEach((k, v) -> {
if (v != null) {
if (resetCounters) {
fixCounter(port.getIndex(), k, v);
}
Node check = new Label(pinnedChar);
GridPane.setHalignment(check, HPos.CENTER);
addXstatRow(statXTable, (event) -> xstatsListPinned.remove(k, v), "xstat-red", "xstat-green", new Tooltip("Click '" + pinnedChar + "' to un-pin the counter."), "xstats-val-0-" + rowIndex, k, WIDTH_COL_0 * 1.5, 0, "xstats-val-1-" + rowIndex, String.valueOf(v - getShadowCounter(port.getIndex(), k)), WIDTH_COL_1, 1, "xstats-val-2-" + rowIndex, pinnedChar, WIDTH_COL_PIN, 2);
}
});
xstatsList.forEach((k, v) -> {
if (v != null && (!notempty || (notempty && (v - getShadowCounter(port.getIndex(), k) != 0))) && xstatsListPinned.get(k) == null) {
if ((filter == null || filter.trim().length() == 0) || k.contains(filter)) {
if (resetCounters) {
fixCounter(port.getIndex(), k, v);
}
Node check = new Label(notPinnedChar);
GridPane.setHalignment(check, HPos.CENTER);
addXstatRow(statXTable, (event) -> xstatsListPinned.put(k, v), "xstat-green", "xstat-red", new Tooltip("Click '" + notPinnedChar + "' to pin the counter.\nPinned counter is always visible."), "xstats-val-0-" + rowIndex, k, WIDTH_COL_0 * 1.5, 0, "xstats-val-1-" + rowIndex, String.valueOf(v - getShadowCounter(port.getIndex(), k)), WIDTH_COL_1, 1, "xstats-val-2-" + rowIndex, notPinnedChar, WIDTH_COL_PIN, 2);
}
}
});
GridPane gp = new GridPane();
gp.setGridLinesVisible(false);
gp.add(statXTable, 1, 1, 1, 2);
return gp;
}
use of javafx.scene.layout.GridPane in project jgnash by ccavanaugh.
the class BudgetTableController method initialize.
@FXML
private void initialize() {
runningTotalsButton.selectedProperty().setValue(preferences.getBoolean(RUNNING_TOTALS, false));
rateLimitExecutor = new ScheduledThreadPoolExecutor(1, new DefaultDaemonThreadFactory("Budget View Rate Limit Executor"), new ThreadPoolExecutor.DiscardPolicy());
tableWidthChangeListener = (observable, oldValue, newValue) -> {
if (newValue != null && !oldValue.equals(newValue)) {
optimizeColumnWidths();
}
};
handleFontHeightChange();
yearSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(LocalDate.now().getYear() - YEAR_MARGIN, LocalDate.now().getYear() + YEAR_MARGIN, LocalDate.now().getYear(), 1));
accountTreeView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
accountTreeView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
accountTreeView.setShowRoot(false);
accountTreeView.setEditable(true);
accountTreeView.fixedCellSizeProperty().bind(rowHeight);
accountSummaryTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
accountSummaryTable.getStyleClass().addAll(StyleClass.HIDDEN_ROW_FOCUS);
accountSummaryTable.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
accountSummaryTable.setItems(expandedAccountList);
accountSummaryTable.fixedCellSizeProperty().bind(rowHeight);
accountSummaryTable.setSelectionModel(new NullTableViewSelectionModel<>(accountSummaryTable));
accountTypeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
accountTypeTable.getStyleClass().addAll(StyleClass.HIDDEN_COLUMN_HEADER, StyleClass.HIDDEN_ROW_FOCUS);
accountTypeTable.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
accountTypeTable.setItems(accountGroupList);
accountTypeTable.fixedCellSizeProperty().bind(rowHeight);
accountTypeTable.prefHeightProperty().bind(rowHeight.multiply(Bindings.size(accountGroupList)).add(BORDER_MARGIN));
accountTypeTable.setSelectionModel(new NullTableViewSelectionModel<>(accountTypeTable));
// widths need to be bound to the tree view widths for drag/resizing to work
accountTypeTable.minWidthProperty().bind(accountTreeView.minWidthProperty());
accountTypeTable.prefWidthProperty().bind(accountTreeView.prefWidthProperty());
accountGroupPeriodSummaryTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
accountGroupPeriodSummaryTable.getStyleClass().addAll(StyleClass.HIDDEN_COLUMN_HEADER, StyleClass.HIDDEN_ROW_FOCUS);
accountGroupPeriodSummaryTable.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
accountGroupPeriodSummaryTable.setItems(accountGroupList);
accountGroupPeriodSummaryTable.fixedCellSizeProperty().bind(rowHeight);
accountGroupPeriodSummaryTable.prefHeightProperty().bind(rowHeight.multiply(Bindings.size(accountGroupList)).add(BORDER_MARGIN));
accountGroupPeriodSummaryTable.setSelectionModel(new NullTableViewSelectionModel<>(accountGroupPeriodSummaryTable));
buildAccountTreeTable();
buildAccountTypeTable();
buildAccountSummaryTable();
buildAccountGroupSummaryTable();
accountSummaryTable.maxWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
accountGroupPeriodSummaryTable.maxWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
accountSummaryTable.minWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
accountGroupPeriodSummaryTable.minWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
accountTreeView.expandedItemCountProperty().addListener((observable, oldValue, newValue) -> JavaFXUtils.runLater(this::updateExpandedAccountList));
// Calling handleBudgetChange which works for most changes, but can trigger an exception.
// handleBudgetUpdate rate limits and prevents an exception.
final ChangeListener<Object> budgetChangeListener = (observable, oldValue, newValue) -> handleBudgetUpdate();
budget.addListener(budgetChangeListener);
yearSpinner.valueProperty().addListener(budgetChangeListener);
runningTotalsButton.selectedProperty().addListener(budgetChangeListener);
visibleColumnCount.addListener(budgetChangeListener);
runningTotalsButton.selectedProperty().addListener((observable, oldValue, newValue) -> preferences.putBoolean(RUNNING_TOTALS, newValue));
/* Setting the tables as un-managed effectively removes these tables from the GridPane. The tables are
redundant if showing the amounts as running balances. */
accountSummaryTable.managedProperty().bind(runningTotalsButton.selectedProperty().not());
accountGroupPeriodSummaryTable.managedProperty().bind(runningTotalsButton.selectedProperty().not());
horizontalScrollBar.setMin(0);
horizontalScrollBar.maxProperty().bind(periodCount.subtract(visibleColumnCount));
horizontalScrollBar.setUnitIncrement(1);
horizontalScrollBar.disableProperty().bind(periodCount.lessThanOrEqualTo(1));
// shift the table right and left with the ScrollBar value
horizontalScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
/* must be synchronized to prevent a race condition from multiple events and an out of
* bounds exception */
synchronized (this) {
/* don't try unless columns exist. This can occur if the UI is not large enough to display
* a minimum of one period of information.
*/
if (periodTable.getColumns().size() > 0) {
final int newIndex = (int) Math.round(newValue.doubleValue());
if (newIndex > index) {
while (newIndex > index) {
handleShiftRight();
}
} else if (newIndex < index) {
while (newIndex < index) {
handleShiftLeft();
}
}
}
}
});
// listen for changes in the font scale and update. Listener needs to be weak to prevent memory leaks
fontScaleListener = (observable, oldValue, newValue) -> handleFontHeightChange();
ThemeManager.fontScaleProperty().addListener(new WeakChangeListener<>(fontScaleListener));
// cursor handler
accountTreeView.setOnMouseMoved(this::handleMouseMove);
// drag handler
accountTreeView.setOnMouseDragged(this::handleDividerDrag);
// drag handler
accountTreeView.setOnMousePressed(this::handleMouseClicked);
// cursor handler
accountTypeTable.setOnMouseMoved(this::handleMouseMove);
// drag handler
accountTypeTable.setOnMouseDragged(this::handleDividerDrag);
// drag handler
accountTypeTable.setOnMousePressed(this::handleMouseClicked);
JavaFXUtils.runLater(() -> accountTreeView.setPrefWidth(preferences.getDouble(ACCOUNT_COLUMN_WIDTH, INITIAL_WIDTH * 2)));
}
use of javafx.scene.layout.GridPane in project jgnash by ccavanaugh.
the class SelectAccountSecuritiesDialog method showAndWait.
public boolean showAndWait() {
// Create the base dialog
final Stage dialog = new Stage(StageStyle.DECORATED);
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.initOwner(MainView.getPrimaryStage());
dialog.setTitle(resources.getString("Title.AccountSecurities"));
final Label availableLabel = new Label(resources.getString("Title.Available"));
availableLabel.getStyleClass().add(StyleClass.LIST_TITLE_STYLE);
final Label currentLabel = new Label(resources.getString("Title.Current"));
currentLabel.getStyleClass().add(StyleClass.LIST_TITLE_STYLE);
final GridPane gridPane = createGridPane();
gridPane.add(availableLabel, 0, 0);
gridPane.add(sourceListView, 0, 1);
gridPane.add(createButtonBox(), 1, 1);
gridPane.add(currentLabel, 2, 0);
gridPane.add(targetListView, 2, 1);
gridPane.add(createButtonBar(), 0, 2, 3, 1);
dialog.setScene(new Scene(gridPane));
ThemeManager.applyStyleSheets(dialog.getScene());
dialog.getScene().getRoot().styleProperty().bind(ThemeManager.styleProperty());
dialog.getScene().getRoot().getStyleClass().addAll("form", "dialog");
StageUtils.addBoundsListener(dialog, this.getClass(), MainView.getPrimaryStage());
dialog.showAndWait();
return result;
}
use of javafx.scene.layout.GridPane in project POL-POM-5 by PlayOnLinux.
the class ContainerOverviewPanelSkin method addInstalledShortcuts.
/**
* Adds the installed shortcuts of the container to the {@link GridPane overviewGrid}
*
* @param overviewGrid The grid containing the overview information
*/
private void addInstalledShortcuts(final GridPane overviewGrid) {
final int row = overviewGrid.getRowCount();
final Text installedShortcutsDescription = new Text(tr("Installed shortcuts:"));
installedShortcutsDescription.getStyleClass().add("captionTitle");
final Label installedShortcutsOutput = new Label();
installedShortcutsOutput.textProperty().bind(StringBindings.map(getControl().containerProperty(), container -> container.getInstalledShortcuts().stream().map(shortcutDTO -> shortcutDTO.getInfo().getName()).collect(Collectors.joining("; "))));
installedShortcutsOutput.setWrapText(true);
overviewGrid.addRow(row, installedShortcutsDescription, installedShortcutsOutput);
}
Aggregations