< prev index next >

modules/javafx.controls/src/main/java/javafx/scene/control/skin/NestedTableColumnHeader.java

Print this page
rev 10061 : 8166025: TableColumnHeader: loses custom style classes


  50 /**
  51  * <p>This class is used to construct the header of a TableView. We take the approach
  52  * that every TableView header is nested - even if it isn't. This allows for us
  53  * to use the same code for building a single row of TableColumns as we would
  54  * with a heavily nested sequences of TableColumns. Because of this, the
  55  * TableHeaderRow class consists of just one instance of a NestedTableColumnHeader.
  56  *
  57  * @since 9
  58  * @see TableColumnHeader
  59  * @see TableHeaderRow
  60  * @see TableColumnBase
  61  */
  62 public class NestedTableColumnHeader extends TableColumnHeader {
  63 
  64     /***************************************************************************
  65      *                                                                         *
  66      * Static Fields                                                           *
  67      *                                                                         *
  68      **************************************************************************/
  69 


  70     private static final int DRAG_RECT_WIDTH = 4;
  71 
  72     private static final String TABLE_COLUMN_KEY = "TableColumn";
  73     private static final String TABLE_COLUMN_HEADER_KEY = "TableColumnHeader";
  74 
  75 
  76 
  77     /***************************************************************************
  78      *                                                                         *
  79      * Private Fields                                                          *
  80      *                                                                         *
  81      **************************************************************************/
  82 
  83     /**
  84      * Represents the actual columns directly contained in this nested column.
  85      * It does NOT include ANY of the children of these columns, if any exist.
  86      */
  87     private ObservableList<? extends TableColumnBase> columns;
  88 
  89     private TableColumnHeader label;


 101     boolean updateColumns = true;
 102 
 103 
 104 
 105     /***************************************************************************
 106      *                                                                         *
 107      * Constructor                                                             *
 108      *                                                                         *
 109      **************************************************************************/
 110 
 111     /**
 112      * Creates a new NestedTableColumnHeader instance to visually represent the given
 113      * {@link TableColumnBase} instance.
 114      *
 115      * @param skin The skin used by the UI control.
 116      * @param tc The table column to be visually represented by this instance.
 117      */
 118     public NestedTableColumnHeader(final TableViewSkinBase skin, final TableColumnBase tc) {
 119         super(skin, tc);
 120 
 121         getStyleClass().setAll("nested-column-header");
 122         setFocusTraversable(false);
 123 
 124         // init UI
 125         label = createTableColumnHeader(getTableColumn());
 126         label.setTableHeaderRow(getTableHeaderRow());
 127         label.setParentHeader(getParentHeader());
 128         label.setNestedColumnHeader(this);
 129 
 130         if (getTableColumn() != null) {
 131             changeListenerHandler.registerChangeListener(getTableColumn().textProperty(), e ->
 132                     label.setVisible(getTableColumn().getText() != null && ! getTableColumn().getText().isEmpty()));
 133         }
 134 
 135         changeListenerHandler.registerChangeListener(TableSkinUtils.columnResizePolicyProperty(skin), e -> updateContent());
 136     }
 137 
 138 
 139 
 140     /***************************************************************************
 141      *                                                                         *




  50 /**
  51  * <p>This class is used to construct the header of a TableView. We take the approach
  52  * that every TableView header is nested - even if it isn't. This allows for us
  53  * to use the same code for building a single row of TableColumns as we would
  54  * with a heavily nested sequences of TableColumns. Because of this, the
  55  * TableHeaderRow class consists of just one instance of a NestedTableColumnHeader.
  56  *
  57  * @since 9
  58  * @see TableColumnHeader
  59  * @see TableHeaderRow
  60  * @see TableColumnBase
  61  */
  62 public class NestedTableColumnHeader extends TableColumnHeader {
  63 
  64     /***************************************************************************
  65      *                                                                         *
  66      * Static Fields                                                           *
  67      *                                                                         *
  68      **************************************************************************/
  69 
  70     static final String DEFAULT_STYLE_CLASS = "nested-column-header";
  71 
  72     private static final int DRAG_RECT_WIDTH = 4;
  73 
  74     private static final String TABLE_COLUMN_KEY = "TableColumn";
  75     private static final String TABLE_COLUMN_HEADER_KEY = "TableColumnHeader";
  76 
  77 
  78 
  79     /***************************************************************************
  80      *                                                                         *
  81      * Private Fields                                                          *
  82      *                                                                         *
  83      **************************************************************************/
  84 
  85     /**
  86      * Represents the actual columns directly contained in this nested column.
  87      * It does NOT include ANY of the children of these columns, if any exist.
  88      */
  89     private ObservableList<? extends TableColumnBase> columns;
  90 
  91     private TableColumnHeader label;


 103     boolean updateColumns = true;
 104 
 105 
 106 
 107     /***************************************************************************
 108      *                                                                         *
 109      * Constructor                                                             *
 110      *                                                                         *
 111      **************************************************************************/
 112 
 113     /**
 114      * Creates a new NestedTableColumnHeader instance to visually represent the given
 115      * {@link TableColumnBase} instance.
 116      *
 117      * @param skin The skin used by the UI control.
 118      * @param tc The table column to be visually represented by this instance.
 119      */
 120     public NestedTableColumnHeader(final TableViewSkinBase skin, final TableColumnBase tc) {
 121         super(skin, tc);
 122 
 123         getStyleClass().setAll(DEFAULT_STYLE_CLASS);
 124         setFocusTraversable(false);
 125 
 126         // init UI
 127         label = createTableColumnHeader(getTableColumn());
 128         label.setTableHeaderRow(getTableHeaderRow());
 129         label.setParentHeader(getParentHeader());
 130         label.setNestedColumnHeader(this);
 131 
 132         if (getTableColumn() != null) {
 133             changeListenerHandler.registerChangeListener(getTableColumn().textProperty(), e ->
 134                     label.setVisible(getTableColumn().getText() != null && ! getTableColumn().getText().isEmpty()));
 135         }
 136 
 137         changeListenerHandler.registerChangeListener(TableSkinUtils.columnResizePolicyProperty(skin), e -> updateContent());
 138     }
 139 
 140 
 141 
 142     /***************************************************************************
 143      *                                                                         *


< prev index next >