javafx.scene.control.TableRow Java Examples

The following examples show how to use javafx.scene.control.TableRow. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrokerConfigView.java    From kafka-message-tool with MIT License 7 votes vote down vote up
private void bindActionsToSelectedRow(KafkaClusterProxy proxy) {

        topicsTableView.setRowFactory(tableView -> {
            final TableRow<TopicAggregatedSummary> row = new TableRow<>();

            bindPopupMenuToSelectedRow(proxy, row);

            row.setOnMouseClicked(event -> {
                if (event.getClickCount() == 1 && (!row.isEmpty())) {
                    showAssignedConsumerInfo(row);
                } else if (event.getClickCount() == 2 && (!row.isEmpty())) {
                    showTopicConfigPropertiesWindow(kafkaBrokerProxyProperty.get(), row.getItem().getTopicName());
                }
            });
            return row;
        });
    }
 
Example #2
Source File: JavaFXTableViewElementScrollTest.java    From marathonv5 with Apache License 2.0 7 votes vote down vote up
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
Example #3
Source File: SpinnerTableCell.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public SpinnerTableCell(TableColumn<T, Integer> column, int min, int max) {

    spinner = new Spinner<>(min, max, 1);

    spinner.editableProperty().bind(column.editableProperty());
    spinner.disableProperty().bind(column.editableProperty().not());

    tableRowProperty().addListener(e -> {
      TableRow<?> row = getTableRow();
      if (row == null)
        return;
      ChromatogramPlotDataSet dataSet = (ChromatogramPlotDataSet) row.getItem();
      if (dataSet == null)
        return;
      spinner.getValueFactory().valueProperty().bindBidirectional(dataSet.lineThicknessProperty());

    });
  }
 
Example #4
Source File: TableViewExtra.java    From Recaf with MIT License 6 votes vote down vote up
private void recomputeVisibleIndexes() {
	firstIndex = -1;
	// Work out which of the rows are visible
	double tblViewHeight = table.getHeight();
	double headerHeight =
               table.lookup(".column-header-background").getBoundsInLocal().getHeight();
	double viewPortHeight = tblViewHeight - headerHeight;
	for(TableRow<T> r : rows) {
		if(!r.isVisible())
			continue;
		double minY = r.getBoundsInParent().getMinY();
		double maxY = r.getBoundsInParent().getMaxY();
		boolean hidden = (maxY < 0) || (minY > viewPortHeight);
		if(hidden)
			continue;
		if(firstIndex < 0 || r.getIndex() < firstIndex)
			firstIndex = r.getIndex();
	}
}
 
Example #5
Source File: AppController.java    From curly with Apache License 2.0 6 votes vote down vote up
private void updateRowHighlight(TableRow<Map<String, String>> row) {
    int r = 160;
    int g = 160;
    int b = 160;
    if (highlightedRows.isEmpty()) {
        r = 255;
        g = 255;
        b = 255;
    } else if (highlightedRows.contains(row.getIndex())) {
        r = 200;
        g = 255;
        b = 200;
    }
    if (row.getIndex() % 2 == 1) {
        r = Math.max(0, r-16);
        g = Math.max(0, g-16);
        b = Math.max(0, b-16);
    }
    row.setBackground(new Background(new BackgroundFill(Color.rgb(r, g, b), null, null)));
}
 
Example #6
Source File: RFXComponentTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
Example #7
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (!r.isEmpty() && r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (cell.isEmpty())
            continue;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
Example #8
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TableCell<?, ?> getVisibleCellAt(TableView<?> tableView, int row, int column) {
    Set<Node> lookupAll = getTableCells(tableView);
    TableCell<?, ?> cell = null;
    for (Node node : lookupAll) {
        TableCell<?, ?> cell1 = (TableCell<?, ?>) node;
        TableRow<?> tableRow = cell1.getTableRow();
        TableColumn<?, ?> tableColumn = cell1.getTableColumn();
        if (tableRow.getIndex() == row && tableColumn == tableView.getColumns().get(column)) {
            cell = cell1;
            break;
        }
    }
    if (cell != null) {
        return cell;
    }
    return null;
}
 
Example #9
Source File: AnimatedTableRow.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
private void moveDataWithAnimation(final TableView<Person> sourceTable,
		final TableView<Person> destinationTable,
		final Pane commonTableAncestor, final TableRow<Person> row) {
	// Create imageview to display snapshot of row:
	final ImageView imageView = createImageView(row);
	// Start animation at current row:
	final Point2D animationStartPoint = row.localToScene(new Point2D(0, 0)); // relative to Scene
	final Point2D animationEndPoint = computeAnimationEndPoint(destinationTable); // relative to Scene
	// Set start location
	final Point2D startInRoot = commonTableAncestor.sceneToLocal(animationStartPoint); // relative to commonTableAncestor
	imageView.relocate(startInRoot.getX(), startInRoot.getY());
	// Create animation
	final Animation transition = createAndConfigureAnimation(
			sourceTable, destinationTable, commonTableAncestor, row,
			imageView, animationStartPoint, animationEndPoint);
	// add animated image to display
	commonTableAncestor.getChildren().add(imageView);
	// start animation
	transition.play();
}
 
Example #10
Source File: TableSelectListener.java    From Animu-Downloaderu with MIT License 6 votes vote down vote up
@Override
public TableRow<DownloadInfo> call(TableView<DownloadInfo> view) {
	final TableRow<DownloadInfo> row = new TableRow<>();
	DownloadInfo info = view.getSelectionModel().getSelectedItem();
	initListeners(view, info);
	row.contextMenuProperty().bind(
			Bindings.when(Bindings.isNotNull(row.itemProperty())).then(rowMenu).otherwise((ContextMenu) null));

	row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
		final int index = row.getIndex();
		if (!event.isPrimaryButtonDown())
			return; // no action if it is not primary button
		if (index >= view.getItems().size() || view.getSelectionModel().isSelected(index)) {
			view.getSelectionModel().clearSelection();
			event.consume();
		}
	});
	return row;
}
 
Example #11
Source File: SpinnerTableCell.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public SpinnerTableCell(TableColumn<T, Integer> column, int min, int max) {

    spinner = new Spinner<>(min, max, 1);

    spinner.editableProperty().bind(column.editableProperty());
    spinner.disableProperty().bind(column.editableProperty().not());

    tableRowProperty().addListener(e -> {
      TableRow<?> row = getTableRow();
      if (row == null)
        return;
      MsSpectrumDataSet dataSet = (MsSpectrumDataSet) row.getItem();
      if (dataSet == null)
        return;
      spinner.getValueFactory().valueProperty().bindBidirectional(dataSet.lineThicknessProperty());
      disableProperty().bind(dataSet.renderingTypeProperty().isEqualTo(MsSpectrumType.CENTROIDED));

    });
  }
 
Example #12
Source File: BrokerConfigView.java    From kafka-message-tool with MIT License 6 votes vote down vote up
private void bindPopupMenuToSelectedRow(KafkaClusterProxy proxy, TableRow<TopicAggregatedSummary> row) {

        final MenuItem deleteTopicMenuItem = createMenuItemForDeletingTopic();
        final MenuItem createTopicMenuItem = createMenuItemForCreatingNewTopic();
        final MenuItem alterTopicMenuItem = createMenuItemForAlteringTopic();
        final MenuItem topicPropertiesMenuItem = createMenuItemForShowingTopicProperties();

        final ContextMenu contextMenu = getTopicManagementContextMenu(deleteTopicMenuItem,
                                                                      createTopicMenuItem,
                                                                      alterTopicMenuItem,
                                                                      topicPropertiesMenuItem);

        row.contextMenuProperty().bind(new ReadOnlyObjectWrapper<>(contextMenu));
        topicPropertiesMenuItem.disableProperty().bind(row.emptyProperty());

        if (proxy.isTopicDeletionEnabled() != TriStateConfigEntryValue.True) {
            deleteTopicMenuItem.setText("Delete topic (disabled by broker)");
            deleteTopicMenuItem.disableProperty().setValue(true);
        } else {
            deleteTopicMenuItem.disableProperty().bind(row.emptyProperty());
        }
        alterTopicMenuItem.disableProperty().bind(row.emptyProperty());
    }
 
Example #13
Source File: OLcClient.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
private ActionSourceTransformer getActionSourceTransformer() {
	return new ActionSourceTransformer() {

		@Override
		public Object getParentWidget(Object originwidget) {
			if (originwidget instanceof GanttTaskCell) {
				GanttTaskCell<?> gantttaskcell = (GanttTaskCell<?>) originwidget;
				GanttDisplay<?> parentdisplay = gantttaskcell.getParentGanttDisplay();
				return parentdisplay;
			}
			if (originwidget instanceof TableRow) {
				TableRow<?> tablerow = (TableRow<?>) originwidget;
				TableView<?> table = tablerow.getTableView();
				return table;
			}
			return originwidget;
		}
	};
}
 
Example #14
Source File: AnimatedTableRow.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private TranslateTransition createAndConfigureAnimation(
		final TableView<Person> sourceTable,
		final TableView<Person> destinationTable,
		final Pane commonTableAncestor, final TableRow<Person> row,
		final ImageView imageView, final Point2D animationStartPoint,
		Point2D animationEndPoint) {
	final TranslateTransition transition = new TranslateTransition(ANIMATION_DURATION, imageView);
	// At end of animation, actually move data, and remove animated image
	transition.setOnFinished(createAnimationFinishedHandler(sourceTable, destinationTable, commonTableAncestor, row.getItem(), imageView));
	// configure transition
	transition.setByX(animationEndPoint.getX() - animationStartPoint.getX()); // absolute translation, computed from coords relative to Scene
	transition.setByY(animationEndPoint.getY() - animationStartPoint.getY()); // absolute translation, computed from coords relative to Scene
	return transition;
}
 
Example #15
Source File: AnimatedTableRow.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private ImageView createImageView(final TableRow<Person> row) {
	final Image image = row.snapshot(null, null);
	final ImageView imageView = new ImageView(image);
       // Manage image location ourselves (don't let layout manage it)
       imageView.setManaged(false);
	return imageView;
}
 
Example #16
Source File: MsSpectrumLayersDialogController.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void initialize() {

    final ObservableList<MsSpectrumType> renderingChoices =
        FXCollections.observableArrayList(MsSpectrumType.CENTROIDED, MsSpectrumType.PROFILE);
    renderingTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(renderingChoices));

    colorColumn.setCellFactory(column -> new ColorTableCell<MsSpectrumDataSet>(column));

    lineThicknessColumn
        .setCellFactory(column -> new SpinnerTableCell<MsSpectrumDataSet>(column, 1, 5));

    intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn(
        new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat())));

    showDataPointsColumn
        .setCellFactory(column -> new CheckBoxTableCell<MsSpectrumDataSet, Boolean>() {
          {
            tableRowProperty().addListener(e -> {
              TableRow<?> row = getTableRow();
              if (row == null)
                return;
              MsSpectrumDataSet dataSet = (MsSpectrumDataSet) row.getItem();
              if (dataSet == null)
                return;
              disableProperty()
                  .bind(dataSet.renderingTypeProperty().isEqualTo(MsSpectrumType.CENTROIDED));

            });
          }
        });
  }
 
Example #17
Source File: ExpandableTableRowSkin.java    From tornadofx-controls with Apache License 2.0 5 votes vote down vote up
/**
 * Create the ExpandableTableRowSkin and listen to changes for the item this table row represents. When the
 * item is changed, the old expanded node, if any, is removed from the children list of the TableRow.
 *
 * @param tableRow The table row to apply this skin for
 * @param expander The expander column, used to retrieve the expanded node when this row is expanded
 */
public ExpandableTableRowSkin(TableRow<S> tableRow, TableRowExpanderColumn<S> expander) {
    super(tableRow);
    this.tableRow = tableRow;
    this.expander = expander;
    tableRow.itemProperty().addListener((observable, oldValue, newValue) -> {
        if (oldValue != null) {
            Node expandedNode = this.expander.getExpandedNode(oldValue);
            if (expandedNode != null) getChildren().remove(expandedNode);
        }
    });
}
 
Example #18
Source File: AirBaseController.java    From logbook-kai with MIT License 5 votes vote down vote up
@Override
protected void updateItem(Integer count, boolean empty) {
    super.updateItem(count, empty);

    this.getStyleClass().removeAll("lowsupply");

    if (!empty) {
        if (count != null) {
            @SuppressWarnings("unchecked")
            TableRow<Plane> row = this.getTableRow();
            if (row != null) {
                Plane plane = row.getItem();
                if (plane != null && plane.getPlaneInfo() != null) {
                    PlaneInfo planeInfo = plane.getPlaneInfo();
                    if (planeInfo.getCount() != null && !planeInfo.getCount().equals(planeInfo.getMaxCount())) {
                        this.getStyleClass().add("lowsupply");
                    }
                }
            }
            this.setText(String.valueOf(count));
        } else {
            this.setText(null);
        }
    } else {
        this.setText(null);
    }
}
 
Example #19
Source File: TableViewExtra.java    From Recaf with MIT License 5 votes vote down vote up
/**
 * @param tableView
 * 		Table to wrap.
 */
public TableViewExtra(TableView<T> tableView) {
	this.table = tableView;
	// Callback to monitor row creation and to identify visible screen rows
	final Callback<TableView<T>, TableRow<T>> rf = tableView.getRowFactory();
	final Callback<TableView<T>, TableRow<T>> modifiedRowFactory = param -> {
		TableRow<T> r = rf != null ? rf.call(param) : new TableRow<>();
		// Save row, this implementation relies on JaxaFX re-using TableRow efficiently
		rows.add(r);
		return r;
	};
	tableView.setRowFactory(modifiedRowFactory);
}
 
Example #20
Source File: AirBaseController.java    From logbook-kai with MIT License 5 votes vote down vote up
@Override
protected void updateItem(Integer itemId, boolean empty) {
    super.updateItem(itemId, empty);

    this.getStyleClass().removeAll("change");

    if (!empty) {
        Map<Integer, SlotItem> itemMap = SlotItemCollection.get()
                .getSlotitemMap();

        SlotItem item = itemMap.get(itemId);

        if (item != null) {
            this.setGraphic(new ImageView(Items.itemImage(item)));
            this.setText(Items.name(item));
        } else {
            this.setGraphic(null);
            this.setText("未配備");
        }

        @SuppressWarnings("unchecked")
        TableRow<Plane> row = this.getTableRow();
        if (row != null) {
            Plane plane = row.getItem();
            if (plane != null && plane.getPlaneInfo() != null) {
                PlaneInfo planeInfo = plane.getPlaneInfo();
                if (planeInfo.getState() != 1) {
                    this.getStyleClass().add("change");
                }
            }
        }
    } else {
        this.setGraphic(null);
        this.setText(null);
    }
}
 
Example #21
Source File: JobViewer.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void updateItem(final Boolean ignored, final boolean empty)
{
    super.updateItem(ignored, empty);

    boolean running = ! empty;

    TableRow<JobInfo> row = null;
    if (running)
    {
        row = getTableRow();
        if (row == null)
            running = false;
    }

    if (running)
    {
        setAlignment(Pos.CENTER_RIGHT);
        final JobInfo info = row.getItem();
        final Button cancel = new Button(Messages.JobCancel, new ImageView(ABORT));
        cancel.setOnAction(event -> info.job.cancel());
        cancel.setMaxWidth(Double.MAX_VALUE);
        setGraphic(cancel);
    }
    else
        setGraphic(null);
}
 
Example #22
Source File: DirectChoiceBoxTableCell.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void updateItem(final T value, final boolean empty)
{
    super.updateItem(value, empty);

    if (empty)
        setGraphic(null);
    else
    {
        choicebox.setValue(value);
        setGraphic(choicebox);

        choicebox.setOnAction(event ->
        {
            // 'onAction' is invoked from setValue as called above,
            // but also when table updates its cells.
            // Ignore those.
            // Also ignore dummy updates to null which happen
            // when the list of choices changes
            if (! choicebox.isShowing() ||
                choicebox.getValue() == null)
                return;

            final TableRow<S> row = getTableRow();
            if (row == null)
                return;

            // Fire 'onEditCommit'
            final TableView<S> table = getTableView();
            final TableColumn<S, T> col = getTableColumn();
            final TablePosition<S, T> pos = new TablePosition<>(table, row.getIndex(), col);
            Objects.requireNonNull(col.getOnEditCommit(), "Must define onEditCommit handler")
                   .handle(new CellEditEvent<>(table, pos, TableColumn.editCommitEvent(), choicebox.getValue()));
        });
    }
}
 
Example #23
Source File: SampleView.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void updateItem(final String item, final boolean empty)
{
    super.updateItem(item, empty);
    final TableRow<PlotSample> row = getTableRow();
    if (empty  ||  row == null  ||  row.getItem() == null)
        setText("");
    else
    {
        setText(item);
        setTextFill(SeverityColors.getTextColor(org.phoebus.core.vtypes.VTypeHelper.getSeverity(row.getItem().getVType())));
    }
}
 
Example #24
Source File: SnapshotTable.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
SelectionTableColumn() {
    super("", "Include this PV when restoring values", 30, 30, false);
    setCellValueFactory(new PropertyValueFactory<>("selected"));
    //for those entries, which have a read-only property, disable the checkbox
    setCellFactory(column -> {
        TableCell<TableEntry, Boolean> cell = new CheckBoxTableCell<>(null,null);
        cell.itemProperty().addListener((a, o, n) -> {
            cell.getStyleClass().remove("check-box-table-cell-disabled");
            TableRow<?> row = cell.getTableRow();
            if (row != null) {
                TableEntry item = (TableEntry) row.getItem();
                if (item != null) {
                    cell.setEditable(!item.readOnlyProperty().get());
                    if (item.readOnlyProperty().get()) {
                        cell.getStyleClass().add("check-box-table-cell-disabled");
                    }
                }
            }
        });
        return cell;
    });
    setEditable(true);
    setSortable(false);
    selectAllCheckBox = new CheckBox();
    selectAllCheckBox.setSelected(false);
    selectAllCheckBox.setOnAction(e -> getItems().stream().filter(te -> !te.readOnlyProperty().get())
            .forEach(te -> te.selectedProperty().setValue(selectAllCheckBox.isSelected())));
    setGraphic(selectAllCheckBox);
    MenuItem inverseMI = new MenuItem("Inverse Selection");
    inverseMI.setOnAction(e -> getItems().stream().filter(te -> !te.readOnlyProperty().get())
            .forEach(te -> te.selectedProperty().setValue(!te.selectedProperty().get())));
    final ContextMenu contextMenu = new ContextMenu(inverseMI);
    selectAllCheckBox.setOnMouseReleased(e -> {
        if (e.getButton() == MouseButton.SECONDARY) {
            contextMenu.show(selectAllCheckBox, e.getScreenX(), e.getScreenY());
        }
    });
}
 
Example #25
Source File: PVTable.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** @param node Node
 *  @return <code>true</code> if node is in a table cell, and not the table header
 */
private static boolean isTableCell(Node node)
{
    while (node != null)
    {
        if (node instanceof TableRow<?>)
            return true;
        node = node.getParent();
    }
    return false;
}
 
Example #26
Source File: ConsumerGroupView.java    From kafka-message-tool with MIT License 5 votes vote down vote up
private void bindActionsToSelectedRow() {

        consumerGroupNameTable.setRowFactory((TableView<ConsumerGroupName> tableView) -> {
            final TableRow<ConsumerGroupName> row = new TableRow<>();

            row.setOnMouseClicked(event -> {
                if (event.getClickCount() == 1 && (!row.isEmpty())) {
                    fillConsumerGroupDetailsViewForName(row.getItem().getName());
                }
            });
            return row;
        });
    }
 
Example #27
Source File: BrokerConfigView.java    From kafka-message-tool with MIT License 5 votes vote down vote up
private void showAssignedConsumerInfo(TableRow<TopicAggregatedSummary> row) {
    final String topicName = row.getItem().getTopicName();
    final KafkaClusterProxy currentProxy = kafkaBrokerProxyProperty.get();
    final Set<AssignedConsumerInfo> consumers = currentProxy.getConsumersForTopic(topicName);
    assignedConsumerListTableView.getItems().clear();
    assignedConsumerListTableView.setItems(FXCollections.observableArrayList(consumers));
    TableUtils.autoResizeColumns(assignedConsumerListTableView);
}
 
Example #28
Source File: CGrid.java    From Open-Lowcode with Eclipse Public License 2.0 5 votes vote down vote up
private TableView<CObjectGridLine<String>> generateTableViewModel() {
	TableView<CObjectGridLine<String>> returntable = new TableView<CObjectGridLine<String>>();
	Collections.sort(arraycolumns);
	for (int i = 0; i < arraycolumns.size(); i++) {
		TableColumn<CObjectGridLine<String>, String> thiscolumn = arraycolumns.get(i).column;
		logger.fine("  GTVM --- " + thiscolumn.getId());
		ObservableList<TableColumn<CObjectGridLine<String>, ?>> subcolumns = thiscolumn.getColumns();
		for (int k = 0; k < subcolumns.size(); k++)
			logger.fine("    GTVM     ++ " + subcolumns.get(k).getId());
		returntable.getColumns().add(thiscolumn);
	}
	double finalheightinpixel = 29;
	returntable.setRowFactory(tv -> new TableRow<CObjectGridLine<String>>() {

		@Override
		public void updateItem(CObjectGridLine<String> object, boolean empty) {
			super.updateItem(object, empty);
			this.setMaxHeight(finalheightinpixel);
			this.setMinHeight(finalheightinpixel);
			this.setPrefHeight(finalheightinpixel);
			this.setTextOverrun(OverrunStyle.ELLIPSIS);
			this.setEllipsisString("...");
		}
	});
	returntable.getSelectionModel().setCellSelectionEnabled(true);
	returntable.setTooltip(tooltip);
	return returntable;
}
 
Example #29
Source File: MainController.java    From cate with MIT License 4 votes vote down vote up
private void initializeTransactionList() {
    txList.setItems(transactions);
    txList.setRowFactory(value ->{
        final TableRow<WalletTransaction> row = new TableRow<>();
        final ContextMenu rowMenu = new ContextMenu();
        final MenuItem transactionIdItem = new MenuItem(resources.getString("menuItem.copyTransactionId"));
        final MenuItem explorerItem = new MenuItem(resources.getString("menuItem.showOnExplorer"));
        final MenuItem detailsItem = new MenuItem(resources.getString("menuItem.txDetails"));
        final MenuItem receivingAddressItem = new MenuItem(resources.getString("menuItem.receivingAddress"));

        transactionIdItem.setOnAction(action -> GenericUtils.copyToClipboard(row.getItem().getTransaction().getHashAsString()));
        explorerItem.setOnAction(action -> openBlockExplorer(row.getItem()));
        detailsItem.setOnAction(action -> showTxDetailsDialog(row.getItem()));

        receivingAddressItem.setOnAction(action -> GenericUtils.copyToClipboard(
                TransactionFormatter.getRelevantOutputs(row.getItem()).get(0).getScriptPubKey().getToAddress(
                        row.getItem().getParams()).toString()));

        rowMenu.getItems().addAll(transactionIdItem, receivingAddressItem, detailsItem, explorerItem);

        row.contextMenuProperty().set(rowMenu);

        row.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2 && (!row.isEmpty())) {
                showTxDetailsDialog(row.getItem());
            }
        });

        return row;
    });
    txNetworkColumn.setCellValueFactory(dataFeatures -> {
        return dataFeatures.getValue().networkNameProperty();
    });
    txDateColumn.setCellValueFactory(dataFeatures -> {
        return dataFeatures.getValue().dateProperty();
    });
    txAmountColumn.setCellValueFactory(dataFeatures -> {
        return dataFeatures.getValue().amountProperty();
    });
    txMemoColumn.setCellValueFactory(dataFeatures -> {
        return dataFeatures.getValue().memoProperty();
    });
}
 
Example #30
Source File: PersonsCellFactory.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
 public TableCell<Person, String> call(TableColumn<Person, String> param) {

     return new TextFieldTableCell<Person, String>(new DefaultStringConverter()) {      
     	
     	{
         	ContextMenu cm = new ContextMenu();
         	MenuItem deletePersonsMenuItem = new MenuItem("Delete");
         	deletePersonsMenuItem.setOnAction( PersonsCellFactory.this.deletePersonsHandler );
         	cm.getItems().add(deletePersonsMenuItem);
         	this.setContextMenu(cm);      
     	}
     	
         @Override
         public void updateItem(String arg0, boolean empty) {
         	
             super.updateItem(arg0, empty);
             
             if( !empty ) {
                 this.setText( arg0 );
             } else {
                 this.setText( null );  // clear from recycled obj
             }
         }

@SuppressWarnings("unchecked")
@Override
public void commitEdit(String newValue) {
	super.commitEdit(newValue);
	TableRow<Person> row = this.getTableRow();
	Person p = row.getItem();
	
	String msg = p.validate();
	if( logger.isLoggable(Level.FINE) ) {
		logger.fine("[COMMIT EDIT] validate=" + msg);
	}
		
	if( msg == null || msg.isEmpty() ) {
		if( logger.isLoggable(Level.FINE) ) {
			logger.fine("[COMMIT EDIT] validation passed");
		}
		Task<Void> task = new Task<Void>() {
			@Override
			protected Void call() {
				dao.updatePerson(p);  // updates AR too
				return null;
			}
		};
		new Thread(task).start();
	} else {
		
		System.out.println("layoutBounds=" + this.getLayoutBounds());
		System.out.println("boundsInLocal=" + this.getBoundsInLocal());
		System.out.println("boundsInParent=" + this.getBoundsInParent());
		System.out.println("boundsInParent (Scene)=" + this.localToScene(this.getBoundsInParent()));
		System.out.println("boundsInParent (Screen)=" + this.localToScreen(this.getBoundsInParent()));

		System.out.println("row layoutBounds=" + row.getLayoutBounds());
		System.out.println("row boundsInLocal=" + row.getBoundsInLocal());
		System.out.println("row boundsInParent=" + row.getBoundsInParent());
		System.out.println("row boundsInParent (Scene)=" + row.localToScene(this.getBoundsInParent()));
		System.out.println("row boundsInParent (Screen)=" + row.localToScreen(this.getBoundsInParent()));

		VBox vbox = new VBox();
		vbox.setPadding(new Insets(10.0d));
		vbox.setStyle("-fx-background-color: white; -fx-border-color: red");
		vbox.getChildren().add( new Label(msg));
		//vbox.setEffect(new DropShadow());
		
		Popup popup = new Popup();
		popup.getContent().add( vbox );
		popup.setAutoHide(true);
		popup.setOnShown((evt) -> {
			
			System.out.println("vbox layoutBounds=" + vbox.getLayoutBounds());
			System.out.println("vbox boundsInLocal=" + vbox.getBoundsInLocal());
			System.out.println("vbox boundsInParent=" + vbox.getBoundsInParent());
			System.out.println("vbox boundsInParent (Scene)=" + vbox.localToScene(this.getBoundsInParent()));
			System.out.println("vbox boundsInParent (Screen)=" + vbox.localToScreen(this.getBoundsInParent()));

		});
		popup.show( row, 
				row.localToScreen(row.getBoundsInParent()).getMinX(), 
				row.localToScreen(row.getBoundsInParent()).getMaxY());					
	}
}
     };
 }