Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8207957: TableSkinUtils should not contain actual code implementation #6

Closed
wants to merge 14 commits into from
@@ -165,7 +165,11 @@ public NestedTableColumnHeader(final TableColumnBase tc) {
if (me.getClickCount() == 2 && me.isPrimaryButtonDown()) {
// the user wants to resize the column such that its
// width is equal to the widest element in the column
header.resizeColumnToFitContent(column, -1);
TableHeaderRow tableHeader = header.getTableHeaderRow();
TableColumnHeader columnHeader = tableHeader.getColumnHeaderFor(column);
if(columnHeader != null){

This comment has been minimized.

Copy link
@nlisker

nlisker Oct 9, 2019

Contributor

Space after if and before {.

columnHeader.resizeColumnToFitContent(-1);
}
} else {
// rather than refer to the rect variable, we just grab
// it from the source to prevent a small memory leak.
@@ -533,7 +533,7 @@ private void updateScene() {
if (getTableColumn() == null || getTableColumn().getWidth() != DEFAULT_COLUMN_WIDTH || getScene() == null) {
return;
}
doColumnAutoSize(getTableColumn(), n);
doColumnAutoSize(n);
autoSizeComplete = true;
}
}
@@ -585,25 +585,27 @@ private void initUI() {
}
}

private void doColumnAutoSize(TableColumnBase<?,?> column, int cellsToMeasure) {
double prefWidth = column.getPrefWidth();
private void doColumnAutoSize(int cellsToMeasure) {
double prefWidth = getTableColumn().getPrefWidth();

// if the prefWidth has been set, we do _not_ autosize columns
if (prefWidth == DEFAULT_COLUMN_WIDTH) {
resizeColumnToFitContent(column, cellsToMeasure);
resizeColumnToFitContent(cellsToMeasure);
}
}

/**
* Resizes the given column based on the preferred width of all items contained in it. This can be potentially very
* expensive if the number of rows is large. Subclass can either call this method or override it (no need to call
* {@code super()}) to provide their custom algorithm.
* Resizes this {@code TableColumnHeader}'s column based on content of header and content of cells. This
* implementation measures the preferred width of the header, the preferred width of the first {@code maxRow} cells
* and sizes the column to the maximum width of all measured values. Subclass can either call this method or
* override it (no need to call {@code super()}) to provide their custom implementation (exclude headers, exclude
* null content, use min).
*
* @param tc the column to resize
* @param maxRows the number of rows considered when resizing. If -1 is given, all rows are considered.
* @since 12
* @since 14
This conversation was marked as resolved by kevinrushforth

This comment has been minimized.

Copy link
@Maxoudela

Maxoudela Oct 9, 2019

Author

I have put the since 14, because if merged, it will be available in OpenJFX 14 right? (It was 13 before)

This comment has been minimized.

Copy link
@kevinrushforth

This comment has been minimized.

Copy link
@nlisker

nlisker Oct 29, 2019

Contributor

The "The resulting column width for this implementation..." part might belong in an @implSpec section.

This comment has been minimized.

Copy link
@Maxoudela

Maxoudela Oct 30, 2019

Author

From https://openjdk.java.net/jeps/8068562

Implementation Specification. This is where the default implementation (or an overrideable implementation in a class) is specified. Interface implementors or class subclassers use the information here in order to decide whether it is sensible or necessary to override a particular method, and what behavior they can rely on if a method is called via super.

So maybe the whole part beginning from "The resulting column [..]width etc.)." should be in the @implSpec section.

This comment has been minimized.

Copy link
@nlisker

nlisker Oct 30, 2019

Contributor

Yes.

*/
protected void resizeColumnToFitContent(TableColumnBase<?, ?> tc, int maxRows) {
protected void resizeColumnToFitContent(int maxRows) {
TableColumnBase<?, ?> tc = getTableColumn();
if (!tc.isResizable()) return;

Object control = this.getTableSkin().getSkinnable();
@@ -672,7 +674,10 @@ protected void resizeColumnToFitContent(TableColumnBase<?, ?> tc, int maxRows) {

int size = tc.getColumns().size();
if (size > 0) {
resizeColumnToFitContent(tc.getColumns().get(size - 1), maxRows);
TableColumnHeader columnHeader = getTableHeaderRow().getColumnHeaderFor(tc.getColumns().get(size - 1));
if (columnHeader != null) {
columnHeader.resizeColumnToFitContent(maxRows);
}
return;
}

@@ -751,7 +756,10 @@ protected void resizeColumnToFitContent(TableColumnBase<?, ?> tc, int maxRows) {

int size = tc.getColumns().size();
if (size > 0) {
resizeColumnToFitContent(tc.getColumns().get(size - 1), maxRows);
TableColumnHeader columnHeader = getTableHeaderRow().getColumnHeaderFor(tc.getColumns().get(size - 1));
if (columnHeader != null) {
columnHeader.resizeColumnToFitContent(maxRows);
}
return;
}

@@ -140,7 +140,7 @@ public MyTableColumnHeader(final TableColumnBase tc) {
}

public void resizeCol() {
resizeColumnToFitContent(getTableColumn(), -1);
resizeColumnToFitContent(-1);
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.