modules/controls/src/main/java/javafx/scene/control/skin/TreeTableCellSkin.java
Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -21,49 +21,102 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package com.sun.javafx.scene.control.skin;
+package javafx.scene.control.skin;
+import com.sun.javafx.scene.control.behavior.BehaviorBase;
import com.sun.javafx.scene.control.behavior.TreeTableCellBehavior;
import java.util.Map;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.scene.Node;
+import javafx.scene.control.Button;
import javafx.scene.control.Control;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableCell;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableRow;
import javafx.scene.control.TreeTableView;
/**
+ * Default skin implementation for the {@link TreeTableCell} control.
+ *
+ * @see TreeTableCell
+ * @since 9
+ */
+public class TreeTableCellSkin<S,T> extends TableCellSkinBase<TreeTableCell<S,T>> {
+
+ /***************************************************************************
+ * *
+ * Private Fields *
+ * *
+ **************************************************************************/
+
+ private final BehaviorBase<TreeTableCell<S,T>> behavior;
+
+
+
+ /***************************************************************************
+ * *
+ * Constructors *
+ * *
+ **************************************************************************/
+
+ /**
+ * Creates a new TreeTableCellSkin instance, installing the necessary child
+ * nodes into the Control {@link Control#getChildren() children} list, as
+ * well as the necessary input mappings for handling key, mouse, etc events.
+ *
+ * @param control The control that this skin should be installed onto.
*/
-public class TreeTableCellSkin<S,T> extends TableCellSkinBase<TreeTableCell<S,T>, TreeTableCellBehavior<S,T>> {
+ public TreeTableCellSkin(TreeTableCell<S,T> control) {
+ super(control);
+
+ // install default input map for the TreeTableCell control
+ behavior = new TreeTableCellBehavior<>(control);
+// control.setInputMap(behavior.getInputMap());
+ }
+
- private final TreeTableCell<S,T> treeTableCell;
- private final TreeTableColumn<S,T> tableColumn;
- public TreeTableCellSkin(TreeTableCell<S,T> treeTableCell) {
- super(treeTableCell, new TreeTableCellBehavior<S,T>(treeTableCell));
+ /***************************************************************************
+ * *
+ * Public API *
+ * *
+ **************************************************************************/
- this.treeTableCell = treeTableCell;
- this.tableColumn = treeTableCell.getTableColumn();
+ /** {@inheritDoc} */
+ @Override public void dispose() {
+ super.dispose();
- super.init(treeTableCell);
+ if (behavior != null) {
+ behavior.dispose();
}
+ }
+
+
+
+ /***************************************************************************
+ * *
+ * Private implementation *
+ * *
+ **************************************************************************/
- @Override protected BooleanProperty columnVisibleProperty() {
- return tableColumn.visibleProperty();
+ /** {@inheritDoc} */
+ @Override BooleanProperty columnVisibleProperty() {
+ return getSkinnable().getTableColumn().visibleProperty();
}
- @Override protected ReadOnlyDoubleProperty columnWidthProperty() {
- return tableColumn.widthProperty();
+ /** {@inheritDoc} */
+ @Override ReadOnlyDoubleProperty columnWidthProperty() {
+ return getSkinnable().getTableColumn().widthProperty();
}
- @Override protected double leftLabelPadding() {
+ /** {@inheritDoc} */
+ @Override double leftLabelPadding() {
double leftPadding = super.leftLabelPadding();
// RT-27167: we must take into account the disclosure node and the
// indentation (which is not taken into account by the LabeledSkinBase.
final double height = getCellSize();
@@ -109,10 +162,11 @@
leftPadding += graphic == null ? 0 : graphic.prefWidth(height);
return leftPadding;
}
+ /** {@inheritDoc} */
@Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
if (isDeferToParentForPrefWidth) {
// RT-27167: we must take into account the disclosure node and the
// indentation (which is not taken into account by the LabeledSkinBase.
return super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset);