@Override public Component update(int index, Component component) { Component previousComponent = cells.get(index); if (component != previousComponent) { if (component == null) { throw new IllegalArgumentException("Component is null."); } if (component.getParent() != null) { throw new IllegalArgumentException("Component already has a parent."); } cells.update(index, component); if (tablePane != null) { tablePane.add(component); tablePane.tablePaneListeners.cellUpdated(this, index, previousComponent); tablePane.remove(previousComponent); } } return previousComponent; }
/** * Overrides the base method to check whether or not a cell component is * being removed, and fires the appropriate event in that case. * * @param index * The index at which components were removed * * @param count * The number of components removed * * @return * The sequence of components that were removed */ @Override public Sequence<Component> remove(int index, int count) { for (int i = index, n = index + count; i < n; i++) { Component component = get(i); for (Row row : rows) { if (row.indexOf(component) >= 0) { throw new UnsupportedOperationException(); } } } // Call the base method to remove the components return super.remove(index, count); }
TablePane tablePane = (TablePane)getComponent(); TablePane.RowSequence rows = tablePane.getRows(); TablePane.ColumnSequence columns = tablePane.getColumns(); && component.isVisible()) { int rowSpan = TablePane.getRowSpan(component); int columnSpan = TablePane.getColumnSpan(component);
@Override public void install(Component component) { super.install(component); TablePane tablePane = (TablePane)component; tablePane.getTablePaneListeners().add(this); tablePane.getTablePaneAttributeListeners().add(this); }
TablePane.ColumnSequence columns = tablePane.getColumns(); TablePane.Row row = tablePane.getRows().get(rowIndex); && TablePane.getRowSpan(component) == 1) { preferredHeight = Math.max(preferredHeight, component.getPreferredHeight(columnWidthsArgument[j]));
TablePane tablePane = (TablePane)getComponent(); TablePane.RowSequence rows = tablePane.getRows(); TablePane.ColumnSequence columns = tablePane.getColumns(); int columnSpan = TablePane.getColumnSpan(component);
/** * Returns the bounds of a given column. * * @param column * The column index. */ public Bounds getColumnBounds(int column) { TablePane.Skin tablePaneSkin = (TablePane.Skin)getSkin(); return tablePaneSkin.getColumnBounds(column); }
public TableViewRowEditor() { setContent(scrollPane); scrollPane.setView(cardPane); scrollPane.getViewportListeners().add(new ViewportListener.Adapter() { @Override public void scrollLeftChanged(Viewport viewport, int previousScrollLeft) { if (tableViewScrollPane != null) { tableViewScrollPane.setScrollLeft(viewport.getScrollLeft()); } } }); cardPane.add(new ImageView(rowImage)); cardPane.add(tablePane); cardPane.getCardPaneListeners().add(new CardPaneListener.Adapter() { @Override public void selectedIndexChanged(CardPane cardPaneArgument, int previousSelectedIndex) { if (previousSelectedIndex == IMAGE_CARD_INDEX) { editorRow.get(columnIndex).requestFocus(); } else { endEdit(false); } } }); tablePane.getStyles().put("horizontalSpacing", 1); tablePane.getRows().add(editorRow); }
/** * Gets the preferred width of a table pane column, which is defined as the * maximum preferred width of the column's visible components. * <p> * Because their preferred width relates to the preferred widths of other * columns, components that span multiple columns will not be considered in * this calculation (even if they live in the column directly). It is up to * the caller to factor such components into the column widths calculation. * * @param columnIndex * The index of the column whose preferred width we're calculating */ private int getPreferredColumnWidth(int columnIndex) { TablePane tablePane = (TablePane)getComponent(); TablePane.RowSequence rows = tablePane.getRows(); int preferredWidth = 0; for (int i = 0, n = rows.getLength(); i < n; i++) { TablePane.Row row = rows.get(i); if (row.getLength() > columnIndex) { Component component = row.get(columnIndex); if (component != null && component.isVisible() && TablePane.getColumnSpan(component) == 1) { preferredWidth = Math.max(preferredWidth, component.getPreferredWidth(-1)); } } } return preferredWidth; }
tablePane.store(tableRow); } else { TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns(); tablePaneColumns.remove(0, tablePaneColumns.getLength()); editorRow.remove(0, editorRow.getLength());
TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns(); tablePane.load(tableRow);
@Override public void insert(Component component, int index) { if (component == null) { throw new IllegalArgumentException("Component is null."); } if (component.getParent() != null) { throw new IllegalArgumentException("Component already has a parent."); } cells.insert(component, index); if (tablePane != null) { tablePane.add(component); tablePane.tablePaneListeners.cellInserted(this, index); } }
@Override public void rowHighlightedChanged(TablePane.Row row) { TablePane tablePane = row.getTablePane(); repaintComponent(getRowBounds(tablePane.getRows().indexOf(row))); }
@Override public void columnHighlightedChanged(TablePane.Column column) { TablePane tablePane = column.getTablePane(); repaintComponent(getColumnBounds(tablePane.getColumns().indexOf(column))); }
TablePane.ColumnSequence columns = tablePane.getColumns(); TablePane.Row row = tablePane.getRows().get(rowIndex); && TablePane.getRowSpan(component) == 1) { preferredHeight = Math.max(preferredHeight, component.getPreferredHeight(columnWidths[j]));
TablePane tablePane = (TablePane)getComponent(); TablePane.RowSequence rows = tablePane.getRows(); TablePane.ColumnSequence columns = tablePane.getColumns(); int columnSpan = TablePane.getColumnSpan(component);
/** * Returns the bounds of a given row. * * @param row * The row index. */ public Bounds getRowBounds(int row) { TablePane.Skin tablePaneSkin = (TablePane.Skin)getSkin(); return tablePaneSkin.getRowBounds(row); }
@Override public void install(Component component) { super.install(component); TablePane tablePane = (TablePane)component; tablePane.getTablePaneListeners().add(this); tablePane.getTablePaneAttributeListeners().add(this); }
public TableViewRowEditor() { setContent(scrollPane); scrollPane.setView(cardPane); scrollPane.getViewportListeners().add(new ViewportListener.Adapter() { @Override public void scrollLeftChanged(Viewport viewport, int previousScrollLeft) { if (tableViewScrollPane != null) { tableViewScrollPane.setScrollLeft(viewport.getScrollLeft()); } } }); cardPane.add(new ImageView(rowImage)); cardPane.add(tablePane); cardPane.getCardPaneListeners().add(new CardPaneListener.Adapter() { @Override public void selectedIndexChanged(CardPane cardPane, int previousSelectedIndex) { if (previousSelectedIndex == IMAGE_CARD_INDEX) { editorRow.get(columnIndex).requestFocus(); } else { endEdit(false); } } }); tablePane.getStyles().put("horizontalSpacing", 1); tablePane.getRows().add(editorRow); }
/** * Gets the preferred width of a table pane column, which is defined as the * maximum preferred width of the column's visible components. * <p> * Because their preferred width relates to the preferred widths of other * columns, components that span multiple columns will not be considered in * this calculation (even if they live in the column directly). It is up to * the caller to factor such components into the column widths calculation. * * @param columnIndex * The index of the column whose preferred width we're calculating */ private int getPreferredColumnWidth(int columnIndex) { TablePane tablePane = (TablePane)getComponent(); TablePane.RowSequence rows = tablePane.getRows(); int preferredWidth = 0; for (int i = 0, n = rows.getLength(); i < n; i++) { TablePane.Row row = rows.get(i); if (row.getLength() > columnIndex) { Component component = row.get(columnIndex); if (component != null && component.isVisible() && TablePane.getColumnSpan(component) == 1) { preferredWidth = Math.max(preferredWidth, component.getPreferredWidth(-1)); } } } return preferredWidth; }