1 /*
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
334
335 maxWidth = Math.max(maxWidth, w);
336 getChildren().remove(cell);
337 }
338 }
339
340 // dispose of the cell to prevent it retaining listeners (see RT-31015)
341 cell.updateIndex(-1);
342
343 // RT-36855 - take into account the column header text / graphic widths.
344 // Magic 10 is to allow for sort arrow to appear without text truncation.
345 TableColumnHeader header = getTableHeaderRow().getColumnHeaderFor(tc);
346 double headerTextWidth = Utils.computeTextWidth(header.label.getFont(), tc.getText(), -1);
347 Node graphic = header.label.getGraphic();
348 double headerGraphicWidth = graphic == null ? 0 : graphic.prefWidth(-1) + header.label.getGraphicTextGap();
349 double headerWidth = headerTextWidth + headerGraphicWidth + 10 + header.snappedLeftInset() + header.snappedRightInset();
350 maxWidth = Math.max(maxWidth, headerWidth);
351
352 // RT-23486
353 maxWidth += padding;
354 if(treeTableView.getColumnResizePolicy() == TreeTableView.CONSTRAINED_RESIZE_POLICY) {
355 maxWidth = Math.max(maxWidth, col.getWidth());
356 }
357
358 col.impl_setWidth(maxWidth);
359 }
360
361 /** {@inheritDoc} */
362 @Override public int getItemCount() {
363 return treeTableView.getExpandedItemCount();
364 }
365
366 /** {@inheritDoc} */
367 @Override public TreeTableRow<S> createCell() {
368 TreeTableRow<S> cell;
369
370 if (treeTableView.getRowFactory() != null) {
371 cell = treeTableView.getRowFactory().call(treeTableView);
372 } else {
373 cell = new TreeTableRow<S>();
374 }
375
376 // If there is no disclosure node, then add one of my own
377 if (cell.getDisclosureNode() == null) {
378 final StackPane disclosureNode = new StackPane();
|
1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
334
335 maxWidth = Math.max(maxWidth, w);
336 getChildren().remove(cell);
337 }
338 }
339
340 // dispose of the cell to prevent it retaining listeners (see RT-31015)
341 cell.updateIndex(-1);
342
343 // RT-36855 - take into account the column header text / graphic widths.
344 // Magic 10 is to allow for sort arrow to appear without text truncation.
345 TableColumnHeader header = getTableHeaderRow().getColumnHeaderFor(tc);
346 double headerTextWidth = Utils.computeTextWidth(header.label.getFont(), tc.getText(), -1);
347 Node graphic = header.label.getGraphic();
348 double headerGraphicWidth = graphic == null ? 0 : graphic.prefWidth(-1) + header.label.getGraphicTextGap();
349 double headerWidth = headerTextWidth + headerGraphicWidth + 10 + header.snappedLeftInset() + header.snappedRightInset();
350 maxWidth = Math.max(maxWidth, headerWidth);
351
352 // RT-23486
353 maxWidth += padding;
354 if (treeTableView.getColumnResizePolicy() == TreeTableView.CONSTRAINED_RESIZE_POLICY && treeTableView.getWidth() > 0) {
355
356 if (maxWidth > tc.getMaxWidth()) {
357 maxWidth = tc.getMaxWidth();
358 }
359
360 int size = tc.getColumns().size();
361 if (size > 0) {
362 resizeColumnToFitContent(tc.getColumns().get(size - 1), maxRows);
363 return;
364 }
365
366 resizeColumn(tc, Math.round(maxWidth - tc.getWidth()));
367 } else {
368 col.impl_setWidth(maxWidth);
369 }
370 }
371
372 /** {@inheritDoc} */
373 @Override public int getItemCount() {
374 return treeTableView.getExpandedItemCount();
375 }
376
377 /** {@inheritDoc} */
378 @Override public TreeTableRow<S> createCell() {
379 TreeTableRow<S> cell;
380
381 if (treeTableView.getRowFactory() != null) {
382 cell = treeTableView.getRowFactory().call(treeTableView);
383 } else {
384 cell = new TreeTableRow<S>();
385 }
386
387 // If there is no disclosure node, then add one of my own
388 if (cell.getDisclosureNode() == null) {
389 final StackPane disclosureNode = new StackPane();
|