1 /*
2 * Copyright (c) 2011, 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
82
83 // Only add this if we're on an embedded platform that supports 5-button navigation
84 if (Utils.isTwoLevelFocus()) {
85 tlFocus = new TwoLevelFocusBehavior(control); // needs to be last.
86 }
87 }
88
89 @Override public void dispose() {
90 if (tlFocus != null) tlFocus.dispose();
91 super.dispose();
92 }
93
94 /**************************************************************************
95 * *
96 * Implement TableViewBehaviorBase abstract methods *
97 * *
98 *************************************************************************/
99
100 /** {@inheritDoc} */
101 @Override protected int getItemCount() {
102 return getControl().getItems() == null ? 0 : getControl().getItems().size();
103 }
104
105 /** {@inheritDoc} */
106 @Override protected TableFocusModel getFocusModel() {
107 return getControl().getFocusModel();
108 }
109
110 /** {@inheritDoc} */
111 @Override protected TableSelectionModel<T> getSelectionModel() {
112 return getControl().getSelectionModel();
113 }
114
115 /** {@inheritDoc} */
116 @Override protected ObservableList<TablePosition> getSelectedCells() {
117 return getControl().getSelectionModel().getSelectedCells();
118 }
119
120 /** {@inheritDoc} */
121 @Override protected TablePositionBase getFocusedCell() {
122 return getControl().getFocusModel().getFocusedCell();
123 }
124
125 /** {@inheritDoc} */
126 @Override protected int getVisibleLeafIndex(TableColumnBase tc) {
127 return getControl().getVisibleLeafIndex((TableColumn)tc);
128 }
129
130 /** {@inheritDoc} */
131 @Override protected TableColumn<T,?> getVisibleLeafColumn(int index) {
132 return getControl().getVisibleLeafColumn(index);
133 }
134
135 /** {@inheritDoc} */
136 @Override protected void editCell(int row, TableColumnBase tc) {
137 getControl().edit(row, (TableColumn)tc);
138 }
139
140 /** {@inheritDoc} */
141 @Override protected ObservableList<TableColumn<T,?>> getVisibleLeafColumns() {
142 return getControl().getVisibleLeafColumns();
143 }
144
145 /** {@inheritDoc} */
146 @Override protected TablePositionBase<TableColumn<T, ?>>
147 getTablePosition(int row, TableColumnBase<T, ?> tc) {
148 return new TablePosition(getControl(), row, (TableColumn)tc);
149 }
150
151
152
153 /**************************************************************************
154 * *
155 * Modify TableViewBehaviorBase behavior *
156 * *
157 *************************************************************************/
158
159 /** {@inheritDoc} */
160 @Override protected void selectAllToFocus(boolean setAnchorToFocusIndex) {
161 // Fix for RT-31241
162 if (getControl().getEditingCell() != null) return;
163
164 super.selectAllToFocus(setAnchorToFocusIndex);
165 }
166 }
|
1 /*
2 * Copyright (c) 2011, 2015, 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
82
83 // Only add this if we're on an embedded platform that supports 5-button navigation
84 if (Utils.isTwoLevelFocus()) {
85 tlFocus = new TwoLevelFocusBehavior(control); // needs to be last.
86 }
87 }
88
89 @Override public void dispose() {
90 if (tlFocus != null) tlFocus.dispose();
91 super.dispose();
92 }
93
94 /**************************************************************************
95 * *
96 * Implement TableViewBehaviorBase abstract methods *
97 * *
98 *************************************************************************/
99
100 /** {@inheritDoc} */
101 @Override protected int getItemCount() {
102 return getNode().getItems() == null ? 0 : getNode().getItems().size();
103 }
104
105 /** {@inheritDoc} */
106 @Override protected TableFocusModel getFocusModel() {
107 return getNode().getFocusModel();
108 }
109
110 /** {@inheritDoc} */
111 @Override protected TableSelectionModel<T> getSelectionModel() {
112 return getNode().getSelectionModel();
113 }
114
115 /** {@inheritDoc} */
116 @Override protected ObservableList<TablePosition> getSelectedCells() {
117 return getNode().getSelectionModel().getSelectedCells();
118 }
119
120 /** {@inheritDoc} */
121 @Override protected TablePositionBase getFocusedCell() {
122 return getNode().getFocusModel().getFocusedCell();
123 }
124
125 /** {@inheritDoc} */
126 @Override protected int getVisibleLeafIndex(TableColumnBase tc) {
127 return getNode().getVisibleLeafIndex((TableColumn)tc);
128 }
129
130 /** {@inheritDoc} */
131 @Override protected TableColumn<T,?> getVisibleLeafColumn(int index) {
132 return getNode().getVisibleLeafColumn(index);
133 }
134
135 /** {@inheritDoc} */
136 @Override protected void editCell(int row, TableColumnBase tc) {
137 getNode().edit(row, (TableColumn)tc);
138 }
139
140 /** {@inheritDoc} */
141 @Override protected ObservableList<TableColumn<T,?>> getVisibleLeafColumns() {
142 return getNode().getVisibleLeafColumns();
143 }
144
145 /** {@inheritDoc} */
146 @Override protected TablePositionBase<TableColumn<T, ?>>
147 getTablePosition(int row, TableColumnBase<T, ?> tc) {
148 return new TablePosition(getNode(), row, (TableColumn)tc);
149 }
150
151
152
153 /**************************************************************************
154 * *
155 * Modify TableViewBehaviorBase behavior *
156 * *
157 *************************************************************************/
158
159 /** {@inheritDoc} */
160 @Override protected void selectAllToFocus(boolean setAnchorToFocusIndex) {
161 // Fix for RT-31241
162 if (getNode().getEditingCell() != null) return;
163
164 super.selectAllToFocus(setAnchorToFocusIndex);
165 }
166 }
|