本文整理汇总了Java中javafx.scene.control.TableRow类的典型用法代码示例。如果您正苦于以下问题:Java TableRow类的具体用法?Java TableRow怎么用?Java TableRow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableRow类属于javafx.scene.control包,在下文中一共展示了TableRow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoint
import javafx.scene.control.TableRow; //导入依赖的package包/类
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;
}
示例2: VarsPanel
import javafx.scene.control.TableRow; //导入依赖的package包/类
public VarsPanel(AppSession session) {
this.session = session;
table = new TableView();
table.setPrefWidth(300);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
setCenter(table);
TableColumn nameCol = new TableColumn("Variable");
nameCol.setMinWidth(120);
nameCol.setMaxWidth(250);
nameCol.setCellValueFactory(new PropertyValueFactory("name"));
nameCol.setCellFactory(c -> new StringTooltipCell());
TableColumn typeCol = new TableColumn("Type");
typeCol.setMinWidth(45);
typeCol.setMaxWidth(60);
typeCol.setCellValueFactory(new PropertyValueFactory("type"));
TableColumn<Var, ScriptValue> valueCol = new TableColumn("Value");
valueCol.setCellValueFactory(c -> new ReadOnlyObjectWrapper(c.getValue().getValue()));
valueCol.setCellFactory(c -> new VarValueCell());
table.getColumns().addAll(nameCol, typeCol, valueCol);
table.setItems(session.getVars());
table.setRowFactory(tv -> {
TableRow<Var> row = new TableRow<>();
row.setOnMouseClicked(e -> {
if (e.getClickCount() == 2 && !row.isEmpty()) {
Var var = row.getItem();
session.logVar(var);
}
});
return row ;
});
}
示例3: getVisibleCellAt
import javafx.scene.control.TableRow; //导入依赖的package包/类
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;
}
示例4: updateItem
import javafx.scene.control.TableRow; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (!empty) {
TableView<DesignVariable> tv = getTableView();
TableRow<DesignVariable> tr = getTableRow();
if ((tv != null) && (tr != null)) {
if (tv.getItems().get(getTableRow().getIndex()).isOutput()) {
setTextFill(Color.BLUE);
} else if (tv.getItems().get(getTableRow().getIndex()).getValue().equals("INVALID")) {
setTextFill(Color.ORANGE);
} else {
setTextFill(Color.GREEN);
}
} else {
setTextFill(Color.YELLOW);
}
setText(item);
} else {
setText("");
}
}
示例5: recomputeVisibleIndexes
import javafx.scene.control.TableRow; //导入依赖的package包/类
private void recomputeVisibleIndexes() {
firstIndex = -1;
lastIndex = -1;
// Work out which of the rows are visible
double tblViewHeight = tableView.getHeight();
double headerHeight = tableView.lookup(".column-header-background").getBoundsInLocal().getHeight();
double viewPortHeight = tblViewHeight - headerHeight;
for(TableRow<T> r : rows) {
double minY = r.getBoundsInParent().getMinY();
double maxY = r.getBoundsInParent().getMaxY();
boolean hidden = (maxY < 0) || (minY > viewPortHeight);
// boolean fullyVisible = !hidden && (maxY <= viewPortHeight) && (minY >= 0);
if (!hidden) {
if (firstIndex < 0 || r.getIndex() < firstIndex) {
firstIndex = r.getIndex();
}
if (lastIndex < 0 || r.getIndex() > lastIndex) {
lastIndex = r.getIndex();
}
}
}
}
示例6: initTableRowFactory
import javafx.scene.control.TableRow; //导入依赖的package包/类
private void initTableRowFactory() {
setRowFactory(facotry -> {
final TableRow<SampServer> row = new TableRow<>();
row.setOnMouseClicked(clicked -> {
// A row has been clicked, so we want to hide the previous context menu
contextMenu.hide();
if (Objects.nonNull(row.getItem())) {
// If there is an item in this row, we want to proceed further
handleClick(row, clicked);
} else {
// Otherwise we clear the selection.
getSelectionModel().clearSelection();
}
});
return row;
});
}
示例7: call
import javafx.scene.control.TableRow; //导入依赖的package包/类
@Override
public TableRow call(TableView param) {
TableRow row = new TableRow();
row.itemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
updateRowStyle(row);
}
});
rowsToHighlight.addListener(new ListChangeListener<Integer>() {
@Override
public void onChanged(ListChangeListener.Change<? extends Integer> c) {
updateRowStyle(row);
}
});
return row;
}
示例8: shouldSinglePrimaryClickOnCellTrackInPlaylist
import javafx.scene.control.TableRow; //导入依赖的package包/类
@Test
public void shouldSinglePrimaryClickOnCellTrackInPlaylist() {
TableCell<TrackTableModel, String> tableCell = cellFactory.call(new TableColumn<>());
tableCell.setItem("trackId");
Track track = new Track("123", "Artist Name", "Artist Image", "456", "Album Name", "Album Image", 2000, "789",
"Track Name", 1, "Location", true, Arrays.asList("Genre 1", "Genre 2"));
track.setPlaylistId(999);
TrackTableModel trackTableModel = new TrackTableModel(track);
@SuppressWarnings("unchecked")
TableRow<TrackTableModel> mockTableRow = (TableRow<TrackTableModel>)mock(TableRow.class);
when(mockTableRow.getItem()).thenReturn(trackTableModel);
ReflectionTestUtils.invokeMethod(tableCell, "setTableRow", mockTableRow);
when(mockPlaylistManager.isTrackInPlaylist(anyInt(), anyString())).thenReturn(true);
tableCell.onMouseClickedProperty().get()
.handle(getMouseEvent(MouseEvent.MOUSE_CLICKED, MouseButton.PRIMARY, 1));
verify(mockPlaylistManager, never()).addTrackToPlaylist(PLAYLIST_ID_FAVOURITES, track);
verify(mockPlaylistManager, times(1)).removeTrackFromPlaylist(PLAYLIST_ID_FAVOURITES, track);
verify(getMockEventManager(), times(1)).fireEvent(Event.PLAYLIST_CONTENT_UPDATED, track.getPlaylistId());
}
示例9: shouldSinglePrimaryClickOnCellTrackNotInPlaylist
import javafx.scene.control.TableRow; //导入依赖的package包/类
@Test
public void shouldSinglePrimaryClickOnCellTrackNotInPlaylist() {
TableCell<TrackTableModel, String> tableCell = cellFactory.call(new TableColumn<>());
tableCell.setItem("trackId");
Track track = new Track("123", "Artist Name", "Artist Image", "456", "Album Name", "Album Image", 2000, "789",
"Track Name", 1, "Location", true, Arrays.asList("Genre 1", "Genre 2"));
track.setPlaylistId(999);
TrackTableModel trackTableModel = new TrackTableModel(track);
@SuppressWarnings("unchecked")
TableRow<TrackTableModel> mockTableRow = (TableRow<TrackTableModel>)mock(TableRow.class);
when(mockTableRow.getItem()).thenReturn(trackTableModel);
ReflectionTestUtils.invokeMethod(tableCell, "setTableRow", mockTableRow);
when(mockPlaylistManager.isTrackInPlaylist(anyInt(), anyString())).thenReturn(false);
tableCell.onMouseClickedProperty().get()
.handle(getMouseEvent(MouseEvent.MOUSE_CLICKED, MouseButton.PRIMARY, 1));
verify(mockPlaylistManager, times(1)).addTrackToPlaylist(PLAYLIST_ID_FAVOURITES, track);
verify(mockPlaylistManager, never()).removeTrackFromPlaylist(PLAYLIST_ID_FAVOURITES, track);
verify(getMockEventManager(), times(1)).fireEvent(Event.PLAYLIST_CONTENT_UPDATED, track.getPlaylistId());
}
示例10: moveDataWithAnimation
import javafx.scene.control.TableRow; //导入依赖的package包/类
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();
}
示例11: call
import javafx.scene.control.TableRow; //导入依赖的package包/类
@Override
public TableRow<EditableTableRowItem> call(TableView<EditableTableRowItem> p) {
final TableRow<EditableTableRowItem> row = new TableRow<EditableTableRowItem>() {
@Override
protected void updateItem(EditableTableRowItem entityWrapper, boolean empty) {
super.updateItem(entityWrapper, empty);
if (!empty && entityWrapper != null && entityWrapper.getIsSummary()) {
if (!getStyleClass().contains("summaryRow")) {
getStyleClass().add("summaryRow");
}
} else {
getStyleClass().removeAll(Collections.singleton("summaryRow"));
}
}
};
return row;
}
示例12: setTableContextMenu
import javafx.scene.control.TableRow; //导入依赖的package包/类
private void setTableContextMenu()
{
tableTrace.setRowFactory(param ->
{
TableRow<TraceLineInfo> row = new TableRow<>();
MenuItem moreGeoIPInfo = new MenuItem(" Show GeoIP results from multiple sources");
moreGeoIPInfo.setOnAction(event9 -> Main.openInBrowser(GeoIPResolver.getSecondaryGeoIpPrefix() + row.getItem().ipAddressProperty().get()));
Menu copyMenu = generateCopyMenu(row);
ContextMenu rowMenu = new ContextMenu(moreGeoIPInfo, copyMenu);
row.contextMenuProperty().bind(Bindings.when(Bindings.isNotNull(row.itemProperty())).then(rowMenu).otherwise((ContextMenu) null));
return row;
});
}
示例13: SpinnerTableCell
import javafx.scene.control.TableRow; //导入依赖的package包/类
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));
});
}
示例14: SpinnerTableCell
import javafx.scene.control.TableRow; //导入依赖的package包/类
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());
});
}
示例15: call
import javafx.scene.control.TableRow; //导入依赖的package包/类
@Override
public TableRow<File> call(TableView<File> param) {
TableRow<File> row = new TableRow<>();
row.setOnMousePressed(event -> {
if (event.isPrimaryButtonDown() && event.getClickCount() == 2 && !row.isEmpty()) {
File recentProject = row.getItem();
if (recentProject.exists()) {
DataService.getInstance().loadProject(recentProject);
if (controller.getView().getStage().isShowing()) {
controller.getView().getStage().close(); //закрываем стартовое окно
}
} else {
Alert alert = new Alert(Alert.AlertType.ERROR, "File does not exist");
alert.showAndWait();
RecentProjectsController.getInstance().removeRecentProject(recentProject);
SettingsManager.getInstance().writeRecentProjects(RecentProjectsController.getInstance().getRecentProjects());
}
}
});
return row;
}