Search in sources :

Example 56 with GridPane

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();
}
Also used : GridPane(javafx.scene.layout.GridPane) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene)

Example 57 with GridPane

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;
}
Also used : GridPane(javafx.scene.layout.GridPane) Node(javafx.scene.Node) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label)

Example 58 with GridPane

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)));
}
Also used : Period(jgnash.time.Period) Pos(javafx.geometry.Pos) Engine(jgnash.engine.Engine) TODAY_BOLD_NEGATIVE_LABEL_ID(jgnash.uifx.skin.StyleClass.TODAY_BOLD_NEGATIVE_LABEL_ID) BigDecimal(java.math.BigDecimal) Budget(jgnash.engine.budget.Budget) MessageProperty(jgnash.engine.message.MessageProperty) DefaultDaemonThreadFactory(jgnash.util.DefaultDaemonThreadFactory) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TreeTableCell(javafx.scene.control.TreeTableCell) Point2D(javafx.geometry.Point2D) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor) TableView(javafx.scene.control.TableView) NullTableViewSelectionModel(jgnash.uifx.control.NullTableViewSelectionModel) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) MessageListener(jgnash.engine.message.MessageListener) HBox(javafx.scene.layout.HBox) NotNull(jgnash.util.NotNull) NORMAL_CELL_ID(jgnash.uifx.skin.StyleClass.NORMAL_CELL_ID) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Spinner(javafx.scene.control.Spinner) TODAY_BOLD_LABEL_ID(jgnash.uifx.skin.StyleClass.TODAY_BOLD_LABEL_ID) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) AccountGroup(jgnash.engine.AccountGroup) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) BudgetGoal(jgnash.engine.budget.BudgetGoal) TODAY_NORMAL_CELL_ID(jgnash.uifx.skin.StyleClass.TODAY_NORMAL_CELL_ID) List(java.util.List) LocalDate(java.time.LocalDate) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) BOLD_LABEL_ID(jgnash.uifx.skin.StyleClass.BOLD_LABEL_ID) ObservableList(javafx.collections.ObservableList) NumericFormats(jgnash.text.NumericFormats) Message(jgnash.engine.message.Message) WeakChangeListener(javafx.beans.value.WeakChangeListener) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) BudgetPeriodResults(jgnash.engine.budget.BudgetPeriodResults) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) EngineFactory(jgnash.engine.EngineFactory) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) TreeTableView(javafx.scene.control.TreeTableView) ResourceBundle(java.util.ResourceBundle) ThemeManager(jgnash.uifx.skin.ThemeManager) GridPane(javafx.scene.layout.GridPane) BOLD_NEGATIVE_LABEL_ID(jgnash.uifx.skin.StyleClass.BOLD_NEGATIVE_LABEL_ID) Label(javafx.scene.control.Label) Comparators(jgnash.engine.Comparators) FXMLUtils(jgnash.uifx.util.FXMLUtils) BudgetResultsModel(jgnash.engine.budget.BudgetResultsModel) CheckBox(javafx.scene.control.CheckBox) Preferences(java.util.prefs.Preferences) TimeUnit(java.util.concurrent.TimeUnit) Cursor(javafx.scene.Cursor) TreeTableColumn(javafx.scene.control.TreeTableColumn) StageUtils(jgnash.uifx.util.StageUtils) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) StyleClass(jgnash.uifx.skin.StyleClass) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) Account(jgnash.engine.Account) TODAY_NORMAL_NEGATIVE_CELL_ID(jgnash.uifx.skin.StyleClass.TODAY_NORMAL_NEGATIVE_CELL_ID) ChangeListener(javafx.beans.value.ChangeListener) NORMAL_NEGATIVE_CELL_ID(jgnash.uifx.skin.StyleClass.NORMAL_NEGATIVE_CELL_ID) ScrollBar(javafx.scene.control.ScrollBar) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) DefaultDaemonThreadFactory(jgnash.util.DefaultDaemonThreadFactory) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) FXML(javafx.fxml.FXML)

Example 59 with GridPane

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;
}
Also used : GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) MaterialDesignLabel(jgnash.uifx.resource.font.MaterialDesignLabel) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene)

Example 60 with GridPane

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);
}
Also used : Button(javafx.scene.control.Button) HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) StringBindings(org.phoenicis.javafx.utils.StringBindings) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) ContainerOverviewPanel(org.phoenicis.javafx.components.container.control.ContainerOverviewPanel) Text(javafx.scene.text.Text) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) Optional(java.util.Optional) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) GridPane(javafx.scene.layout.GridPane) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) Label(javafx.scene.control.Label) Text(javafx.scene.text.Text)

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