247
248 for (int i = 0; i < getColumnHeaders().size(); i++) {
249 TableColumnHeader header = getColumnHeaders().get(i);
250 header.dispose();
251 }
252
253 for (Rectangle rect : dragRects.values()) {
254 if (rect != null) {
255 rect.visibleProperty().unbind();
256 }
257 }
258 dragRects.clear();
259 getChildren().clear();
260
261 changeListenerHandler.dispose();
262 }
263
264 /**
265 * Returns an unmodifiable list of the {@link TableColumnHeader} instances
266 * that are children of this NestedTableColumnHeader.
267 */
268 public final ObservableList<TableColumnHeader> getColumnHeaders() {
269 if (columnHeaders == null) {
270 columnHeaders = FXCollections.<TableColumnHeader>observableArrayList();
271 unmodifiableColumnHeaders = FXCollections.unmodifiableObservableList(columnHeaders);
272 }
273 return unmodifiableColumnHeaders;
274 }
275
276 /** {@inheritDoc} */
277 @Override protected void layoutChildren() {
278 double w = getWidth() - snappedLeftInset() - snappedRightInset();
279 double h = getHeight() - snappedTopInset() - snappedBottomInset();
280
281 int labelHeight = (int) label.prefHeight(-1);
282
283 if (label.isVisible()) {
284 // label gets to span whole width and sits at top
285 label.resize(w, labelHeight);
286 label.relocate(snappedLeftInset(), snappedTopInset());
351 }
352
353 return height + label.prefHeight(-1) + snappedTopInset() + snappedBottomInset();
354 }
355
356 /**
357 * Creates a new TableColumnHeader instance for the given TableColumnBase instance. The general pattern for
358 * implementing this method is as follows:
359 *
360 * <ul>
361 * <li>If the given TableColumnBase instance is null, has no child columns, or if the given TableColumnBase
362 * instance equals the TableColumnBase instance returned by calling {@link #getTableColumn()}, then it is
363 * suggested to return a {@link TableColumnHeader} instance comprised of the given column.</li>
364 * <li>Otherwise, we can presume that the given TableColumnBase instance has child columns, and in this case
365 * it is suggested to return a {@link NestedTableColumnHeader} instance instead.</li>
366 * </ul>
367 *
368 * <strong>Note: </strong>In most circumstances this method should not be overridden, but in some circumstances it
369 * makes sense (e.g. testing, or when extreme customization is desired).
370 *
371 * @return A new TableColumnHeader instance.
372 */
373 protected TableColumnHeader createTableColumnHeader(TableColumnBase col) {
374 return col == null || col.getColumns().isEmpty() || col == getTableColumn() ?
375 new TableColumnHeader(col) :
376 new NestedTableColumnHeader(col);
377 }
378
379
380
381 /***************************************************************************
382 * *
383 * Private Implementation *
384 * *
385 **************************************************************************/
386
387 @Override void initStyleClasses() {
388 getStyleClass().setAll(DEFAULT_STYLE_CLASS);
389 installTableColumnStyleClassListener();
390 }
|
247
248 for (int i = 0; i < getColumnHeaders().size(); i++) {
249 TableColumnHeader header = getColumnHeaders().get(i);
250 header.dispose();
251 }
252
253 for (Rectangle rect : dragRects.values()) {
254 if (rect != null) {
255 rect.visibleProperty().unbind();
256 }
257 }
258 dragRects.clear();
259 getChildren().clear();
260
261 changeListenerHandler.dispose();
262 }
263
264 /**
265 * Returns an unmodifiable list of the {@link TableColumnHeader} instances
266 * that are children of this NestedTableColumnHeader.
267 * @return the unmodifiable list of TableColumnHeader of this NestedTableColumnHeader
268 */
269 public final ObservableList<TableColumnHeader> getColumnHeaders() {
270 if (columnHeaders == null) {
271 columnHeaders = FXCollections.<TableColumnHeader>observableArrayList();
272 unmodifiableColumnHeaders = FXCollections.unmodifiableObservableList(columnHeaders);
273 }
274 return unmodifiableColumnHeaders;
275 }
276
277 /** {@inheritDoc} */
278 @Override protected void layoutChildren() {
279 double w = getWidth() - snappedLeftInset() - snappedRightInset();
280 double h = getHeight() - snappedTopInset() - snappedBottomInset();
281
282 int labelHeight = (int) label.prefHeight(-1);
283
284 if (label.isVisible()) {
285 // label gets to span whole width and sits at top
286 label.resize(w, labelHeight);
287 label.relocate(snappedLeftInset(), snappedTopInset());
352 }
353
354 return height + label.prefHeight(-1) + snappedTopInset() + snappedBottomInset();
355 }
356
357 /**
358 * Creates a new TableColumnHeader instance for the given TableColumnBase instance. The general pattern for
359 * implementing this method is as follows:
360 *
361 * <ul>
362 * <li>If the given TableColumnBase instance is null, has no child columns, or if the given TableColumnBase
363 * instance equals the TableColumnBase instance returned by calling {@link #getTableColumn()}, then it is
364 * suggested to return a {@link TableColumnHeader} instance comprised of the given column.</li>
365 * <li>Otherwise, we can presume that the given TableColumnBase instance has child columns, and in this case
366 * it is suggested to return a {@link NestedTableColumnHeader} instance instead.</li>
367 * </ul>
368 *
369 * <strong>Note: </strong>In most circumstances this method should not be overridden, but in some circumstances it
370 * makes sense (e.g. testing, or when extreme customization is desired).
371 *
372 * @param col the table column
373 * @return A new TableColumnHeader instance.
374 */
375 protected TableColumnHeader createTableColumnHeader(TableColumnBase col) {
376 return col == null || col.getColumns().isEmpty() || col == getTableColumn() ?
377 new TableColumnHeader(col) :
378 new NestedTableColumnHeader(col);
379 }
380
381
382
383 /***************************************************************************
384 * *
385 * Private Implementation *
386 * *
387 **************************************************************************/
388
389 @Override void initStyleClasses() {
390 getStyleClass().setAll(DEFAULT_STYLE_CLASS);
391 installTableColumnStyleClassListener();
392 }
|