Search in sources :

Example 1 with TreeTableCell

use of javafx.scene.control.TreeTableCell in project jabref by JabRef.

the class ViewModelTreeTableCellFactory method call.

@Override
public TreeTableCell<S, T> call(TreeTableColumn<S, T> param) {
    return new TreeTableCell<S, T>() {

        @Override
        protected void updateItem(T item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || getTreeTableRow() == null || getTreeTableRow().getItem() == null) {
                setText(null);
                setGraphic(null);
                setOnMouseClicked(null);
            } else {
                S viewModel = getTreeTableRow().getItem();
                if (toText != null) {
                    setText(toText.call(viewModel));
                }
                if (toGraphic != null) {
                    setGraphic(toGraphic.call(viewModel));
                }
                if (toTooltip != null) {
                    String tooltip = toTooltip.call(viewModel);
                    if (StringUtil.isNotBlank(tooltip)) {
                        setTooltip(new Tooltip(tooltip));
                    }
                }
                if (toOnMouseClickedEvent != null) {
                    setOnMouseClicked(toOnMouseClickedEvent.call(viewModel));
                }
            }
        }
    };
}
Also used : TreeTableCell(javafx.scene.control.TreeTableCell) Tooltip(javafx.scene.control.Tooltip)

Example 2 with TreeTableCell

use of javafx.scene.control.TreeTableCell in project certmgr by hdecarne.

the class StoreController method setupStage.

@Override
protected void setupStage(Stage stage) {
    stage.getIcons().addAll(Images.STORE32, Images.STORE16);
    stage.setTitle(StoreI18N.formatSTR_STAGE_TITLE());
    this.cmdStorePreferences.disableProperty().bind(this.storeProperty.isNull());
    this.cmdCopyEntry.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
    this.cmdDeleteEntry.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
    this.cmdNewCert.disableProperty().bind(this.storeProperty.isNull());
    this.cmdRevokeCert.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
    this.cmdManageCRL.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
    this.cmdExportCert.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
    this.cmdImportCerts.disableProperty().bind(this.storeProperty.isNull());
    this.cmdStorePreferencesButton.disableProperty().bind(this.storeProperty.isNull());
    this.cmdCopyEntryButton.disableProperty().bind(this.cmdCopyEntry.disableProperty());
    this.cmdDeleteEntryButton.disableProperty().bind(this.cmdDeleteEntry.disableProperty());
    this.cmdNewCertButton.disableProperty().bind(this.cmdNewCert.disableProperty());
    this.cmdRevokeCertButton.disableProperty().bind(this.cmdRevokeCert.disableProperty());
    this.cmdManageCRLButton.disableProperty().bind(this.cmdManageCRL.disableProperty());
    this.cmdExportCertButton.disableProperty().bind(this.cmdExportCert.disableProperty());
    this.cmdImportCertsButton.disableProperty().bind(this.cmdImportCerts.disableProperty());
    ContextMenu storeEntryViewMenu = this.ctlStoreEntryView.getContextMenu();
    this.ctlStoreEntryView.setContextMenu(null);
    this.ctlStoreEntryView.setRowFactory(param -> {
        ContextMenu menu = storeEntryViewMenu;
        return new TreeTableRow<StoreEntryModel>() {

            @Override
            protected void updateItem(@Nullable StoreEntryModel item, boolean empty) {
                super.updateItem(item, empty);
                if (!empty) {
                    setContextMenu(menu);
                } else {
                    setContextMenu(null);
                }
            }
        };
    });
    Tooltip storeEntryViewTooltip = this.ctlStoreEntryView.getTooltip();
    this.ctlStoreEntryTooltipExternalCrt.managedProperty().bind(this.ctlStoreEntryTooltipExternalCrt.visibleProperty());
    this.ctlStoreEntryTooltipPublicCrt.managedProperty().bind(this.ctlStoreEntryTooltipPublicCrt.visibleProperty());
    this.ctlStoreEntryTooltipPrivateCrt.managedProperty().bind(this.ctlStoreEntryTooltipPrivateCrt.visibleProperty());
    this.ctlStoreEntryTooltipCsr.managedProperty().bind(this.ctlStoreEntryTooltipCsr.visibleProperty());
    this.ctlStoreEntryTooltipCrl.managedProperty().bind(this.ctlStoreEntryTooltipCrl.visibleProperty());
    this.ctlStoreEntryTooltipKey.managedProperty().bind(this.ctlStoreEntryTooltipKey.visibleProperty());
    this.ctlStoreEntryTooltipRevokedCrt.managedProperty().bind(this.ctlStoreEntryTooltipRevokedCrt.visibleProperty());
    this.ctlStoreEntryTooltipInvalidCrt.managedProperty().bind(this.ctlStoreEntryTooltipInvalidCrt.visibleProperty());
    this.ctlStoreEntryView.setTooltip(null);
    this.ctlStoreEntryViewId.setCellFactory(param -> {
        return new TreeTableCell<StoreEntryModel, String>() {

            Tooltip tooltip = storeEntryViewTooltip;

            @Override
            protected void updateItem(@Nullable String item, boolean empty) {
                if (!empty) {
                    setTooltip(this.tooltip);
                    setOnMouseEntered(StoreController.this::onStoreViewItemMouseEntered);
                    setText(item);
                } else {
                    setTooltip(null);
                    setOnMouseEntered(null);
                    setText(null);
                }
            }
        };
    });
    this.ctlStoreEntryViewId.setCellValueFactory(new TreeItemPropertyValueFactory<>("id"));
    this.ctlStoreEntryViewName.setCellValueFactory(new TreeItemPropertyValueFactory<>("name"));
    this.ctlStoreEntryViewSerial.setCellValueFactory(new TreeItemPropertyValueFactory<>("serial"));
    this.ctlStoreEntryViewExpires.setCellValueFactory(new TreeItemPropertyValueFactory<>("expires"));
    ContextMenu detailsViewMenu = this.ctlDetailsView.getContextMenu();
    this.ctlDetailsView.setContextMenu(null);
    this.ctlDetailsView.setRowFactory(param -> {
        ContextMenu menu = detailsViewMenu;
        return new TreeTableRow<AttributeModel>() {

            @Override
            protected void updateItem(@Nullable AttributeModel item, boolean empty) {
                super.updateItem(item, empty);
                if (!empty) {
                    setContextMenu(menu);
                } else {
                    setContextMenu(null);
                }
            }
        };
    });
    this.ctlDetailsViewName.setCellValueFactory(new TreeItemPropertyValueFactory<>("name"));
    this.ctlDetailsViewValue.setCellValueFactory(new TreeItemPropertyValueFactory<>("value"));
    this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().addListener((p, o, n) -> onStoreViewSelectionChanged(n));
    Windows.onHiding(stage, (ScheduledFuture<?> f) -> f.cancel(true), getExecutorService().scheduleAtFixedRate(PlatformHelper.runLaterRunnable(() -> onUpdateHeapStatus()), 0, 500, TimeUnit.MILLISECONDS));
}
Also used : TreeTableCell(javafx.scene.control.TreeTableCell) Tooltip(javafx.scene.control.Tooltip) ContextMenu(javafx.scene.control.ContextMenu) TreeTableRow(javafx.scene.control.TreeTableRow) Nullable(de.carne.check.Nullable) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Example 3 with TreeTableCell

use of javafx.scene.control.TreeTableCell in project JFoenix by jfoenixadmin.

the class JFXTreeTableColumn method init.

private void init() {
    this.setCellFactory(new Callback<TreeTableColumn<S, T>, TreeTableCell<S, T>>() {

        @Override
        public TreeTableCell<S, T> call(TreeTableColumn<S, T> param) {
            return new JFXTreeTableCell<S, T>() {

                @Override
                protected void updateItem(T item, boolean empty) {
                    if (item == getItem())
                        return;
                    super.updateItem(item, empty);
                    if (item == null) {
                        super.setText(null);
                        super.setGraphic(null);
                    } else if (item instanceof Node) {
                        super.setText(null);
                        super.setGraphic((Node) item);
                    } else {
                        super.setText(item.toString());
                        super.setGraphic(null);
                    }
                }
            };
        }
    });
    Platform.runLater(() -> {
        final ContextMenu contextMenu = new ContextMenu();
        //			contextMenu.setOnShowing((showing)->{
        //				System.out.println("showing");
        //			});
        //			contextMenu.setOnShown((shown)->{
        //				System.out.println("shown");
        //			});
        MenuItem item1 = new MenuItem("Group");
        item1.setOnAction((action) -> {
            ((JFXTreeTableView) getTreeTableView()).group(this);
        });
        MenuItem item2 = new MenuItem("UnGroup");
        item2.setOnAction((action) -> {
            ((JFXTreeTableView) getTreeTableView()).unGroup(this);
        });
        contextMenu.getItems().addAll(item1, item2);
        setContextMenu(contextMenu);
    });
}
Also used : TreeTableCell(javafx.scene.control.TreeTableCell) JFXTreeTableCell(com.jfoenix.controls.cells.editors.base.JFXTreeTableCell) Node(javafx.scene.Node) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) TreeTableColumn(javafx.scene.control.TreeTableColumn)

Example 4 with TreeTableCell

use of javafx.scene.control.TreeTableCell in project certmgr by hdecarne.

the class StoreController method onStoreViewItemMouseEntered.

@SuppressWarnings("unused")
@FXML
void onStoreViewItemMouseEntered(MouseEvent evt) {
    @SuppressWarnings("unchecked") TreeTableCell<StoreEntryModel, String> cell = (TreeTableCell<StoreEntryModel, String>) evt.getSource();
    UserCertStoreEntry entry = cell.getTreeTableRow().getItem().getEntry();
    this.ctlStoreEntryTooltipExternalCrt.setVisible(entry.isExternal());
    if (entry.hasCRT()) {
        if (entry.hasKey()) {
            this.ctlStoreEntryTooltipPublicCrt.setVisible(false);
            this.ctlStoreEntryTooltipPrivateCrt.setVisible(true);
            this.ctlStoreEntryTooltipCsr.setVisible(false);
            this.ctlStoreEntryTooltipCrl.setVisible(false);
            this.ctlStoreEntryTooltipKey.setVisible(false);
        } else {
            this.ctlStoreEntryTooltipPublicCrt.setVisible(true);
            this.ctlStoreEntryTooltipPrivateCrt.setVisible(false);
            this.ctlStoreEntryTooltipCsr.setVisible(false);
            this.ctlStoreEntryTooltipCrl.setVisible(false);
            this.ctlStoreEntryTooltipKey.setVisible(false);
        }
    } else if (entry.hasCSR()) {
        this.ctlStoreEntryTooltipPublicCrt.setVisible(false);
        this.ctlStoreEntryTooltipPrivateCrt.setVisible(false);
        this.ctlStoreEntryTooltipCsr.setVisible(true);
        this.ctlStoreEntryTooltipCrl.setVisible(false);
        this.ctlStoreEntryTooltipKey.setVisible(false);
    } else if (entry.hasCRL()) {
        this.ctlStoreEntryTooltipPublicCrt.setVisible(false);
        this.ctlStoreEntryTooltipPrivateCrt.setVisible(false);
        this.ctlStoreEntryTooltipCsr.setVisible(false);
        this.ctlStoreEntryTooltipCrl.setVisible(true);
        this.ctlStoreEntryTooltipKey.setVisible(false);
    } else if (entry.hasKey()) {
        this.ctlStoreEntryTooltipPublicCrt.setVisible(false);
        this.ctlStoreEntryTooltipPrivateCrt.setVisible(false);
        this.ctlStoreEntryTooltipCsr.setVisible(false);
        this.ctlStoreEntryTooltipCrl.setVisible(false);
        this.ctlStoreEntryTooltipKey.setVisible(true);
    }
    this.ctlStoreEntryTooltipRevokedCrt.setVisible(entry.isRevoked());
    this.ctlStoreEntryTooltipInvalidCrt.setVisible(!entry.isValid());
}
Also used : TreeTableCell(javafx.scene.control.TreeTableCell) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry) FXML(javafx.fxml.FXML)

Aggregations

TreeTableCell (javafx.scene.control.TreeTableCell)4 ContextMenu (javafx.scene.control.ContextMenu)2 Tooltip (javafx.scene.control.Tooltip)2 JFXTreeTableCell (com.jfoenix.controls.cells.editors.base.JFXTreeTableCell)1 UserCertStoreEntry (de.carne.certmgr.certs.UserCertStoreEntry)1 Nullable (de.carne.check.Nullable)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 FXML (javafx.fxml.FXML)1 Node (javafx.scene.Node)1 MenuItem (javafx.scene.control.MenuItem)1 TreeTableColumn (javafx.scene.control.TreeTableColumn)1 TreeTableRow (javafx.scene.control.TreeTableRow)1