Skip to content

Commit 6cc5af6

Browse files
author
duke
committed
Added webrev for jfx/673
1 parent 09290cf commit 6cc5af6

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

jfx/673/03/commits.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"commit":{"message":"Add space around operator and string"},"files":[{"filename":"tests\/manual\/controls\/SelectTableViewTest.java"}],"sha":"2d321087e6ccaf2acdf04709b6d710098dd0e02a"},{"commit":{"message":"Add license header and add space around operators"},"files":[{"filename":"tests\/manual\/controls\/SelectListViewTest.java"},{"filename":"tests\/manual\/controls\/SelectTableViewTest.java"}],"sha":"c7b22089802dbe6a1fbb5f5cc0ed5a49781e60aa"},{"commit":{"message":"Update ROW_COUNT to 700_000"},"files":[{"filename":"tests\/manual\/controls\/SelectTableViewTest.java"}],"sha":"8196b34899b7bd4930f22d355b684c341862c8d9"},{"commit":{"message":"Remove duplicate entry for test data"},"files":[{"filename":"tests\/manual\/controls\/SelectListViewTest.java"}],"sha":"3158acd7454aa54d199a2a33574b234637060a9f"},{"commit":{"message":"Update line ending for SelectTableViewTest"},"files":[{"filename":"tests\/manual\/controls\/SelectTableViewTest.java"}],"sha":"05f5df32da0fdc62667031fb692c6f2da8775a61"},{"commit":{"message":"Update line ending"},"files":[{"filename":"tests\/manual\/controls\/SelectListViewTest.java"},{"filename":"tests\/manual\/controls\/SelectTableViewTest.java"}],"sha":"ae4e01c76873ecca3e9f7d6a124d00866c4f336f"},{"commit":{"message":"Add manual tests"},"files":[{"filename":"tests\/manual\/controls\/SelectListViewTest.java"},{"filename":"tests\/manual\/controls\/SelectTableViewTest.java"}],"sha":"0d99eafb10d63c5470d0a23def7f88850b24e3b1"},{"commit":{"message":"8197991: Selecting many items in a TableView is very slow"},"files":[{"filename":"modules\/javafx.controls\/src\/main\/java\/com\/sun\/javafx\/scene\/control\/ReadOnlyUnbackedObservableList.java"},{"filename":"modules\/javafx.controls\/src\/main\/java\/javafx\/scene\/control\/MultipleSelectionModelBase.java"}],"sha":"145c0aa50904b5b290a4884e976b56ad301cbc74"}]

jfx/673/03/comparison.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"files":[{"patch":"@@ -116,1 +116,1 @@\n- for (int i = 0; i < size(); i++) {\n+ for (int i = 0, max = size(); i < max; i++) {\n@@ -188,2 +188,3 @@\n- Object[] arr = new Object[size()];\n- for (int i = 0; i < size(); i++) {\n+ int max = size();\n+ Object[] arr = new Object[max];\n+ for (int i = 0; i < max; i++) {\n","filename":"modules\/javafx.controls\/src\/main\/java\/com\/sun\/javafx\/scene\/control\/ReadOnlyUnbackedObservableList.java","additions":4,"deletions":3,"binary":false,"changes":7,"status":"modified"},{"patch":"@@ -640,0 +640,1 @@\n+ private int size = -1;\n@@ -708,0 +709,1 @@\n+ size = -1;\n@@ -728,0 +730,1 @@\n+ size = -1;\n@@ -805,0 +808,1 @@\n+ size = 0;\n@@ -815,0 +819,1 @@\n+ size = -1;\n@@ -870,1 +875,5 @@\n- return bitset.cardinality();\n+ if (size >= 0) {\n+ return size;\n+ }\n+ size = bitset.cardinality();\n+ return size;\n@@ -879,2 +888,34 @@\n- reset();\n- return super.indexOf(obj);\n+ if (!(obj instanceof Number)) {\n+ return -1;\n+ }\n+ Number n = (Number) obj;\n+ int index = n.intValue();\n+ if (!bitset.get(index)) {\n+ return -1;\n+ }\n+\n+ \/\/ is left most bit\n+ if (index == 0) {\n+ return 0;\n+ }\n+\n+ \/\/ is right most bit\n+ if (index == bitset.length() - 1) {\n+ return size() - 1;\n+ }\n+\n+ \/\/ count right bit\n+ if (index > bitset.length() \/ 2) {\n+ int count = 1;\n+ for (int i = bitset.nextSetBit(index+1); i >= 0; i = bitset.nextSetBit(i+1)) {\n+ count++;\n+ }\n+ return size() - count;\n+ }\n+\n+ \/\/ count left bit\n+ int count = 0;\n+ for (int i = bitset.previousSetBit(index-1); i >= 0; i = bitset.previousSetBit(i-1)) {\n+ count++;\n+ }\n+ return count;\n","filename":"modules\/javafx.controls\/src\/main\/java\/javafx\/scene\/control\/MultipleSelectionModelBase.java","additions":44,"deletions":3,"binary":false,"changes":47,"status":"modified"},{"patch":"@@ -0,0 +1,120 @@\n+\/*\n+ * Copyright (c) 2021, Oracle and\/or its affiliates. All rights reserved.\n+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n+ *\n+ * This code is free software; you can redistribute it and\/or modify it\n+ * under the terms of the GNU General Public License version 2 only, as\n+ * published by the Free Software Foundation. Oracle designates this\n+ * particular file as subject to the \"Classpath\" exception as provided\n+ * by Oracle in the LICENSE file that accompanied this code.\n+ *\n+ * This code is distributed in the hope that it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n+ * version 2 for more details (a copy is included in the LICENSE file that\n+ * accompanied this code).\n+ *\n+ * You should have received a copy of the GNU General Public License version\n+ * 2 along with this work; if not, write to the Free Software Foundation,\n+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n+ *\n+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n+ * or visit www.oracle.com if you need additional information or have any\n+ * questions.\n+ *\/\n+\n+import javafx.application.Application;\n+import javafx.collections.ObservableList;\n+import javafx.scene.Scene;\n+import javafx.scene.control.Button;\n+import javafx.scene.control.ListView;\n+import javafx.scene.control.SelectionMode;\n+import javafx.scene.layout.BorderPane;\n+import javafx.scene.layout.VBox;\n+import javafx.stage.Stage;\n+\n+public class SelectListViewTest extends Application {\n+\n+ final int ROW_COUNT = 70_000;\n+ \/\/ final int ROW_COUNT = 400_000;\n+ \/\/ final int ROW_COUNT = 10_000_000;\n+ \/\/ final int ROW_COUNT = 7_000;\n+\n+ @Override\n+ public void start(Stage stage) {\n+ ListView<String> listView = new ListView<>();\n+ listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);\n+\n+ ObservableList<String> items = listView.getItems();\n+ for(int i = 0; i < ROW_COUNT; i++) {\n+ String rec = String.valueOf(i);\n+ items.add(rec);\n+ }\n+\n+ BorderPane root = new BorderPane(listView);\n+ Button selectAll = new Button(\"selectAll\");\n+ Button clearSelection = new Button(\"clearSelection\");\n+ Button selectToStart = new Button(\"selectToStart\");\n+ Button selectToEnd = new Button(\"selectToEnd\");\n+ Button selectPrevious = new Button(\"selectPrevious\");\n+ Button selectNext= new Button(\"selectNext\");\n+\n+ selectAll.setFocusTraversable(true);\n+ clearSelection.setFocusTraversable(true);\n+ selectToStart.setFocusTraversable(true);\n+ selectToEnd.setFocusTraversable(true);\n+ selectPrevious.setFocusTraversable(true);\n+ selectNext.setFocusTraversable(true);\n+\n+ root.setRight(new VBox(6, selectAll, selectToStart, selectToEnd, selectPrevious, selectNext, clearSelection));\n+ stage.setScene(new Scene(root, 600, 600));\n+\n+ selectAll.setOnAction(e -> selectAll(listView));\n+ clearSelection.setOnAction(e -> clearSelection(listView));\n+ selectToStart.setOnAction(e -> selectToStart(listView));\n+ selectToEnd.setOnAction(e -> selectToLast(listView));\n+ selectPrevious.setOnAction(e -> selectPrevious(listView));\n+ selectNext.setOnAction(e -> selectNext(listView));\n+\n+ stage.show();\n+ }\n+\n+ private void selectAll(ListView listView) {\n+ long t = System.currentTimeMillis();\n+ listView.getSelectionModel().selectAll();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void clearSelection(ListView listView) {\n+ long t = System.currentTimeMillis();\n+ listView.getSelectionModel().clearSelection();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectToStart(ListView listView) {\n+ long t = System.currentTimeMillis();\n+ listView.getSelectionModel().selectRange(0, listView.getSelectionModel().getSelectedIndex());\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectToLast(ListView listView) {\n+ long t = System.currentTimeMillis();\n+ listView.getSelectionModel().selectRange(listView.getSelectionModel().getSelectedIndex(), listView.getItems().size());\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectPrevious(ListView listView) {\n+ long t = System.currentTimeMillis();\n+ listView.getSelectionModel().selectPrevious();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectNext(ListView listView) {\n+ long t = System.currentTimeMillis();\n+ listView.getSelectionModel().selectNext();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+ public static void main(String[] args) {\n+ Application.launch(args);\n+ }\n+}\n","filename":"tests\/manual\/controls\/SelectListViewTest.java","additions":120,"deletions":0,"binary":false,"changes":120,"status":"added"},{"patch":"@@ -0,0 +1,137 @@\n+\/*\n+ * Copyright (c) 2021, Oracle and\/or its affiliates. All rights reserved.\n+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n+ *\n+ * This code is free software; you can redistribute it and\/or modify it\n+ * under the terms of the GNU General Public License version 2 only, as\n+ * published by the Free Software Foundation. Oracle designates this\n+ * particular file as subject to the \"Classpath\" exception as provided\n+ * by Oracle in the LICENSE file that accompanied this code.\n+ *\n+ * This code is distributed in the hope that it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n+ * version 2 for more details (a copy is included in the LICENSE file that\n+ * accompanied this code).\n+ *\n+ * You should have received a copy of the GNU General Public License version\n+ * 2 along with this work; if not, write to the Free Software Foundation,\n+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n+ *\n+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n+ * or visit www.oracle.com if you need additional information or have any\n+ * questions.\n+ *\/\n+\n+import javafx.application.Application;\n+import javafx.beans.property.SimpleStringProperty;\n+import javafx.collections.ObservableList;\n+import javafx.scene.Scene;\n+import javafx.scene.control.Button;\n+import javafx.scene.control.SelectionMode;\n+import javafx.scene.control.TableColumn;\n+import javafx.scene.control.TableView;\n+import javafx.scene.layout.BorderPane;\n+import javafx.scene.layout.VBox;\n+import javafx.stage.Stage;\n+\n+public class SelectTableViewTest extends Application {\n+\n+ final int ROW_COUNT = 700_000;\n+ \/\/ final int ROW_COUNT = 80_000;\n+ \/\/ final int ROW_COUNT = 50_000;\n+ \/\/ final int ROW_COUNT = 8_000;\n+ final int COL_COUNT = 3;\n+\n+ @Override\n+ public void start(Stage stage) {\n+ TableView<String[]> tableView = new TableView<>();\n+ tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);\n+\/\/ tableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);\n+\n+ final ObservableList<TableColumn<String[], ?>> columns = tableView.getColumns();\n+ for(int i = 0; i < COL_COUNT; i++) {\n+ TableColumn<String[], String> column = new TableColumn<>(\"Col\"+i);\n+ final int colIndex=i;\n+ column.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue()[colIndex]));\n+ column.setPrefWidth(150);\n+ columns.add(column);\n+ }\n+\n+ ObservableList<String[]> items = tableView.getItems();\n+ for(int i = 0; i < ROW_COUNT; i++) {\n+ String[] rec = new String[COL_COUNT];\n+ for(int j = 0; j < rec.length; j++) {\n+ rec[j] = i + \":\" + j;\n+ }\n+ items.add(rec);\n+ }\n+\n+ BorderPane root = new BorderPane(tableView);\n+ Button selectAll = new Button(\"selectAll\");\n+ Button clearSelection = new Button(\"clearSelection\");\n+ Button selectToStart = new Button(\"selectToStart\");\n+ Button selectToEnd = new Button(\"selectToEnd\");\n+ Button selectPrevious = new Button(\"selectPrevious\");\n+ Button selectNext= new Button(\"selectNext\");\n+\n+ selectAll.setFocusTraversable(true);\n+ clearSelection.setFocusTraversable(true);\n+ selectToStart.setFocusTraversable(true);\n+ selectToEnd.setFocusTraversable(true);\n+ selectPrevious.setFocusTraversable(true);\n+ selectNext.setFocusTraversable(true);\n+\n+ root.setRight(new VBox(6, selectAll, selectToStart, selectToEnd, selectPrevious, selectNext, clearSelection));\n+ stage.setScene(new Scene(root, 600, 600));\n+\n+ selectAll.setOnAction(e -> selectAll(tableView));\n+ clearSelection.setOnAction(e -> clearSelection(tableView));\n+ selectToStart.setOnAction(e -> selectToStart(tableView));\n+ selectToEnd.setOnAction(e -> selectToLast(tableView));\n+ selectPrevious.setOnAction(e -> selectPrevious(tableView));\n+ selectNext.setOnAction(e -> selectNext(tableView));\n+\n+ stage.show();\n+ }\n+\n+ private void selectAll(TableView tableView) {\n+ long t = System.currentTimeMillis();\n+ tableView.getSelectionModel().selectAll();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void clearSelection(TableView tableView) {\n+ long t = System.currentTimeMillis();\n+ tableView.getSelectionModel().clearSelection();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectToStart(TableView tableView) {\n+ long t = System.currentTimeMillis();\n+ tableView.getSelectionModel().selectRange(0, tableView.getSelectionModel().getFocusedIndex());\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectToLast(TableView tableView) {\n+ long t = System.currentTimeMillis();\n+ tableView.getSelectionModel().selectRange(tableView.getSelectionModel().getFocusedIndex(), tableView.getItems().size());\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectPrevious(TableView tableView) {\n+ long t = System.currentTimeMillis();\n+ tableView.getSelectionModel().selectPrevious();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ private void selectNext(TableView tableView) {\n+ long t = System.currentTimeMillis();\n+ tableView.getSelectionModel().selectNext();\n+ System.out.println(\"time:\"+ (System.currentTimeMillis() - t));\n+ }\n+\n+ public static void main(String[] args) {\n+ Application.launch(args);\n+ }\n+}\n","filename":"tests\/manual\/controls\/SelectTableViewTest.java","additions":137,"deletions":0,"binary":false,"changes":137,"status":"added"}]}

jfx/673/03/metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"head":{"repo":{"full_name":"abhinayagarwal\/jfx","html_url":"https:\/\/github.com\/abhinayagarwal\/jfx"},"sha":"2d321087e6ccaf2acdf04709b6d710098dd0e02a"},"created_at":"2021-12-21T12:21:40.066670442Z","base":{"repo":{"full_name":"openjdk\/jfx","html_url":"https:\/\/git.openjdk.java.net\/jfx"},"sha":"f939d094e3f02575c77a12c3a986d5f601a65a1d"}}

0 commit comments

Comments
 (0)