changeset 135:8d6e25f7e160

RT-18442: Remove mostly redundant Runnable* and Function* classes
author jgiles
date Fri, 09 Dec 2011 15:13:33 +1000
parents a75cdc37b987
children 2053e699ee06
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PositionMapper.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualFlow.java javafx-ui-controls/test/com/sun/javafx/scene/control/skin/VirtualFlowTest.java
diffstat 6 files changed, 26 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java	Fri Dec 09 08:45:22 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java	Fri Dec 09 15:13:33 2011 +1000
@@ -37,7 +37,6 @@
 import javafx.scene.control.SelectionModel;
 import javafx.scene.input.MouseEvent;
 
-import com.sun.javafx.runnable.Runnable0;
 import com.sun.javafx.scene.control.WeakListChangeListener;
 import com.sun.javafx.scene.control.behavior.ListViewBehavior;
 import javafx.util.Callback;
@@ -59,8 +58,8 @@
         flow.setPannable(false);
         flow.setVertical(getSkinnable().getOrientation() == Orientation.VERTICAL);
         flow.setFocusTraversable(getSkinnable().isFocusTraversable());
-        flow.setCreateCell(new Runnable0<ListCell>() {
-            @Override public ListCell run() {
+        flow.setCreateCell(new Callback<VirtualFlow, ListCell>() {
+            @Override public ListCell call(VirtualFlow flow) {
                 return ListViewSkin.this.createCell();
             }
         });
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PositionMapper.java	Fri Dec 09 08:45:22 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PositionMapper.java	Fri Dec 09 15:13:33 2011 +1000
@@ -26,13 +26,13 @@
 package com.sun.javafx.scene.control.skin;
 
 import com.sun.javafx.Utils;
-import com.sun.javafx.runnable.Runnable1;
 import javafx.beans.property.DoubleProperty;
 import javafx.beans.property.IntegerProperty;
 import javafx.beans.property.ReadOnlyDoubleProperty;
 import javafx.beans.property.ReadOnlyDoubleWrapper;
 import javafx.beans.property.SimpleDoubleProperty;
 import javafx.beans.property.SimpleIntegerProperty;
+import javafx.util.Callback;
 
 /**
  * Base implementation of a helper class used by virtualized Controls such as
@@ -121,9 +121,9 @@
      * item size would be the height of the cell, whereas in a horizontal
      * list the item size would be the width of the cell.
      */
-    private Runnable1<Double, Integer> itemSize;
-    private Runnable1<Double, Integer> getItemSize() { return itemSize; }
-    public void setGetItemSize(Runnable1<Double, Integer> itemSize) {
+    private Callback<Integer, Double> itemSize;
+    private Callback<Integer, Double> getItemSize() { return itemSize; }
+    public void setGetItemSize(Callback<Integer, Double> itemSize) {
         this.itemSize = itemSize;
     }
 
@@ -140,7 +140,7 @@
         double fractionalPosition = p * count;
         int cellIndex = (int) fractionalPosition;
         double fraction = fractionalPosition - cellIndex;
-        double cellSize = getItemSize().run(cellIndex);
+        double cellSize = getItemSize().call(cellIndex);
         double pixelOffset = cellSize * fraction;
         double viewportOffset = getViewportSize() * p;
         return pixelOffset - viewportOffset;
@@ -191,7 +191,7 @@
         double fractionalPosition = getPosition() * count;
         int cellIndex = (int) fractionalPosition;
         if (forward && cellIndex == count) return;
-        double cellSize = getItemSize().run(cellIndex);
+        double cellSize = getItemSize().call(cellIndex);
         double fraction = fractionalPosition - cellIndex;
         double pixelOffset = cellSize * fraction;
 
@@ -225,7 +225,7 @@
         while (n > remaining && ((forward && cellIndex < count - 1) || (! forward && cellIndex > 0))) {
             if (forward) cellIndex++; else cellIndex--;
             n -= remaining;
-            cellSize = getItemSize().run(cellIndex);
+            cellSize = getItemSize().call(cellIndex);
             start = computeOffsetForCell(cellIndex);
             end = cellSize + computeOffsetForCell(cellIndex + 1);
             remaining = end - start;
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java	Fri Dec 09 08:45:22 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java	Fri Dec 09 15:13:33 2011 +1000
@@ -37,7 +37,6 @@
 import javafx.event.EventHandler;
 import javafx.geometry.Insets;
 import javafx.scene.Node;
-import javafx.scene.control.IndexedCell;
 import javafx.scene.control.Label;
 import javafx.scene.control.SelectionModel;
 import javafx.scene.control.TableColumn;
@@ -49,7 +48,6 @@
 import javafx.scene.layout.StackPane;
 import javafx.util.Callback;
 
-import com.sun.javafx.runnable.Runnable0;
 import com.sun.javafx.scene.control.behavior.TableViewBehavior;
 import com.sun.javafx.scene.control.WeakListChangeListener;
 import com.sun.javafx.scene.control.skin.resources.ControlResources;
@@ -65,8 +63,8 @@
         flow = new VirtualFlow();
         flow.setPannable(false);
         flow.setFocusTraversable(getSkinnable().isFocusTraversable());
-        flow.setCreateCell(new Runnable0<TableRow>() {
-            @Override public TableRow run() {
+        flow.setCreateCell(new Callback<VirtualFlow, TableRow>() {
+            @Override public TableRow call(VirtualFlow flow) {
                 return TableViewSkin.this.createCell();
             }
         });
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java	Fri Dec 09 08:45:22 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java	Fri Dec 09 15:13:33 2011 +1000
@@ -26,11 +26,8 @@
 package com.sun.javafx.scene.control.skin;
 
 import javafx.event.EventHandler;
-import javafx.geometry.Pos;
 import javafx.scene.Node;
 import javafx.scene.control.IndexedCell;
-import javafx.scene.control.Label;
-import javafx.scene.control.SelectionModel;
 import javafx.scene.control.TreeCell;
 import javafx.scene.control.TreeItem;
 import javafx.scene.control.TreeItem.TreeModificationEvent;
@@ -39,8 +36,6 @@
 import javafx.scene.layout.HBox;
 import javafx.scene.layout.StackPane;
 
-import com.sun.javafx.runnable.Runnable0;
-import com.sun.javafx.runnable.Runnable1;
 import com.sun.javafx.scene.control.WeakEventHandler;
 import com.sun.javafx.scene.control.behavior.TreeViewBehavior;
 import java.lang.ref.WeakReference;
@@ -56,8 +51,8 @@
         flow = new VirtualFlow();
         flow.setPannable(false);
         flow.setFocusTraversable(getSkinnable().isFocusTraversable());
-        flow.setCreateCell(new Runnable0<TreeCell>() {
-            @Override public TreeCell run() {
+        flow.setCreateCell(new Callback<VirtualFlow, TreeCell>() {
+            @Override public TreeCell call(VirtualFlow flow) {
                 return TreeViewSkin.this.createCell();
             }
         });
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualFlow.java	Fri Dec 09 08:45:22 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualFlow.java	Fri Dec 09 15:13:33 2011 +1000
@@ -49,8 +49,7 @@
 import javafx.scene.layout.StackPane;
 import javafx.scene.shape.Rectangle;
 
-import com.sun.javafx.runnable.Runnable0;
-import com.sun.javafx.runnable.Runnable1;
+import javafx.util.Callback;
 
 /**
  * Implementation of a virtualized container using a cell based mechanism.
@@ -266,9 +265,9 @@
      * IndexedCell. The VirtualFlow attempts to reuse cells whenever possible
      * and only creates the minimal number of cells necessary.
      */
-    private Runnable0<? extends IndexedCell> createCell;
-    public Runnable0<? extends IndexedCell> getCreateCell() { return createCell; }
-    protected void setCreateCell(Runnable0<? extends IndexedCell> cc) {
+    private Callback<VirtualFlow, ? extends IndexedCell> createCell;
+    public Callback<VirtualFlow, ? extends IndexedCell> getCreateCell() { return createCell; }
+    protected void setCreateCell(Callback<VirtualFlow, ? extends IndexedCell> cc) {
         this.createCell = cc;
 
         if (createCell != null) {
@@ -471,8 +470,8 @@
 
     public VirtualFlow() {
         mapper = new PositionMapper();
-        mapper.setGetItemSize(new Runnable1<Double, Integer>() {
-            @Override public Double run(Integer itemIndex) {
+        mapper.setGetItemSize(new Callback<Integer, Double>() {
+            @Override public Double call(Integer itemIndex) {
                 return getCellLength(itemIndex);
             }
         });
@@ -1364,7 +1363,7 @@
 
         // We need to use the accumCell and return that
         if (accumCell == null && getCreateCell() != null) {
-            accumCell = getCreateCell().run();
+            accumCell = getCreateCell().call(this);
             accumCellParent.getChildren().add(accumCell);
         }
         setCellIndex(accumCell, index);
@@ -1497,7 +1496,7 @@
             if (pile.size() > 0) {
                 cell = pile.removeFirst();
             } else {
-                cell = createCell.run();
+                cell = createCell.call(this);
             }
         }
         
--- a/javafx-ui-controls/test/com/sun/javafx/scene/control/skin/VirtualFlowTest.java	Fri Dec 09 08:45:22 2011 +1000
+++ b/javafx-ui-controls/test/com/sun/javafx/scene/control/skin/VirtualFlowTest.java	Fri Dec 09 15:13:33 2011 +1000
@@ -21,11 +21,10 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
-import com.sun.javafx.runnable.Runnable0;
-import com.sun.javafx.runnable.Runnable1;
 import com.sun.javafx.scene.CSSFlags;
 import com.sun.javafx.scene.control.skin.VirtualFlow.ArrayLinkedList;
 import java.util.List;
+import javafx.util.Callback;
 
 /**
  * Tests for the VirtualFlow class. VirtualFlow is the guts of the ListView,
@@ -53,8 +52,8 @@
         flow = new VirtualFlow();
 //        flow.setManaged(false);
         flow.setVertical(true);
-        flow.setCreateCell(new Runnable0<IndexedCell>() {
-            @Override public IndexedCell run() {
+        flow.setCreateCell(new Callback<VirtualFlow, IndexedCell>() {
+            @Override public IndexedCell call(VirtualFlow p) {
                 return new CellStub(flow) {
                     @Override protected double computeMinWidth(double height) { return computePrefWidth(height); }
                     @Override protected double computeMaxWidth(double height) { return computePrefWidth(height); }
@@ -838,8 +837,8 @@
         assertFalse(flow.isNeedsLayout());
         flow.getCellLength(49); // forces accum cell to be created
         assertNotNull("Accum cell was null", flow.accumCell);
-        flow.setCreateCell(new Runnable0<IndexedCell>() {
-            @Override public IndexedCell run() {
+        flow.setCreateCell(new Callback<VirtualFlow, IndexedCell>() {
+            @Override public IndexedCell call(VirtualFlow p) {
                 return new CellStub(flow);
             }
         });