Commits

Jonathan Giles committed 92d5be5

Removing a bit more public API from SpreadsheetView.

Comments (0)

Files changed (5)

src/main/java/impl/org/controlsfx/skin/RowHeader.java

 
 			//The Labels must be aligned with the rows
 			if(!spreadsheetView.isEmptyCells()){
-				y += spreadsheetView.getRow(0).getLocalToParentTransform().getTy();
+				y += spreadsheetViewSkin.getCell(0).getLocalToParentTransform().getTy();
 			}
 
 			int rowCount = 0;
 			final int modelRowCount = spreadsheetView.getModelRowCount();
 
 			// We iterate over the visibleRows
-			while(!spreadsheetView.isEmptyCells() && spreadsheetView.getRow(i) != null && i< modelRowCount){
+			while(!spreadsheetView.isEmptyCells() && spreadsheetViewSkin.getCell(i) != null && i< modelRowCount){
 				label = getLabel(rowCount++);
-				label.setText(String.valueOf(spreadsheetView.getRow(i).getIndexVirtualFlow()+1));
+				label.setText(String.valueOf(spreadsheetViewSkin.getCell(i).getIndexVirtualFlow()+1));
 				label.resize(prefWidth,prefHeight);
 				label.relocate(x, y);
 				//We want to highlight selected rows
 				final ObservableList<String> css = label.getStyleClass();
-				if(selectionModel.getSelectedRows().contains(spreadsheetView.getRow(i).getIndex())){
+				if(selectionModel.getSelectedRows().contains(spreadsheetViewSkin.getCell(i).getIndex())){
 					css.setAll("selected");
 				}else{
 					css.clear();
 						label.relocate(x, snappedTopInset()+prefHeight*i);
 					}
 					final ObservableList<String> css = label.getStyleClass();
-					if(selectionModel.getSelectedRows().contains(spreadsheetView.getRow(i).getIndex())){
+					if(selectionModel.getSelectedRows().contains(spreadsheetViewSkin.getCell(i).getIndex())){
 						css.setAll("selected");
 					}else{
 						css.clear();

src/main/java/impl/org/controlsfx/skin/SpreadsheetCell.java

         	if(row <= spv.getFixedRows().size()){
 	        	boolean flag = false;
 	        	for (int j = 0; j<spv.getRowCount();j++ ) {
-	                    if(spv.getRow(j) == getTableRow()){
+	                    if(SpreadsheetViewSkin.getCell(spv, j) == getTableRow()){
 	                    	flag = true;
 	                    }
 	            }
         SpreadsheetCell<?> gridCell;
         
         final SpreadsheetView spv = getSpreadsheetView();
-        final SpreadsheetRow row = spv.getRow(spv.getFixedRows().size());
+        final SpreadsheetRow row = SpreadsheetViewSkin.getCell(spv, spv.getFixedRows().size());
         
         if (!spv.isEmptyCells() && row.getIndex() <= cell.getRow()) {
-        	final SpreadsheetRow rightRow = spv.getRow(spv.getFixedRows().size()+cell.getRow() - row.getIndex());
+        	final SpreadsheetRow rightRow = SpreadsheetViewSkin.getCell(spv, spv.getFixedRows().size()+cell.getRow() - row.getIndex());
             // We want to get the top of the spanned cell, so we need
             // to access the fixedRows.size plus the difference between where we want to go and the first visibleRow (header excluded)
             if( rightRow != null) {// Sometime when scrolling fast it's null so..

src/main/java/impl/org/controlsfx/skin/SpreadsheetViewSkin.java

 import javafx.util.Callback;
 
 import org.controlsfx.control.SpreadsheetView;
-import org.controlsfx.control.SpreadsheetView.RowAccessor;
 import org.controlsfx.control.spreadsheet.model.DataRow;
 
 import com.sun.javafx.scene.control.skin.TableHeaderRow;
 // resides inside the SpreadsheetView constructor!
 public class SpreadsheetViewSkin extends TableViewSkin<DataRow> {
     
-//    // hacky, but at least it lets us hide some API
-//    public static final SpreadsheetViewSkin getSkin(SpreadsheetView spv) {
-//        return (SpreadsheetViewSkin) spv.getSkin();
-//    }
-    
     private final double DEFAULT_CELL_SIZE = 24.0;  // Height of a cell
 
     final TableView<DataRow> tableView;
-//    private RowAccessor<SpreadsheetRow> cells=null;
     
     protected RowHeader rowHeader;
     private final double rowHeaderWidth = 50;
         spreadsheetView.getFixedColumns().addListener(fixedColumnsListener);
         spreadsheetView.setHbar(getFlow().getHorizontalBar());
         spreadsheetView.setVbar(getFlow().getVerticalBar());
-        final SpreadsheetView.RowAccessor<SpreadsheetRow> lcells = new SpreadsheetView.RowAccessor<SpreadsheetRow>() {
-            @Override
-            public SpreadsheetRow get(int index) {
-                return (SpreadsheetRow) getFlow().getCells().get(index);
-            }
-
-            @Override
-            public boolean isEmpty() {
-                return getFlow().getCells().isEmpty();
-            }
-
-            @Override
-            public int size() {
-                return getFlow().getCells().size();
-            }
-
-        };
-
-//        this.cells = lcells;
-        spreadsheetView.setRows(lcells);
         /*****************************************************************
          * END MODIFIED BY NELLARMONIA
          *****************************************************************/
         return fixedColumnWidth;
     }
 
-    private VirtualFlowSpreadsheet<?> getFlow() {
+    public VirtualFlowSpreadsheet<?> getFlow() {
         return (VirtualFlowSpreadsheet<?>) flow;
     }
 
+    public SpreadsheetRow getCell(int index) {
+        return (SpreadsheetRow) getFlow().getCells().get(index);
+    }
+    
+    public int getCellsSize() {
+        return getFlow().getCells().size();
+    }
+    
+    
+    
+    
+    
+    public static SpreadsheetRow getCell(SpreadsheetView spv, int index) {
+        TableView<DataRow> tableView = (TableView<DataRow>) spv.getSkin().getNode();
+        SpreadsheetViewSkin spvSkin = (SpreadsheetViewSkin) tableView.getSkin();
+        return spvSkin.getCell(index);
+    }
 }

src/main/java/org/controlsfx/control/SpreadsheetView.java

 import org.controlsfx.control.spreadsheet.view.SpreadsheetCells;
 import org.controlsfx.control.spreadsheet.view.SpreadsheetColumn;
 
+import com.sun.javafx.scene.control.skin.VirtualFlow;
 import com.sun.javafx.scene.control.skin.VirtualScrollBar;
 
 /**
         BOTH_INVISIBLE;   	//Invisible cell, span in diagonal
     }
 
-    /**
-     * A interface to grant access to some {@link SpreadsheetRow}
-     * @param <T>
-     */
-    public static interface RowAccessor<T> {
-        T get(int index);
-        boolean isEmpty();
-        int size();
-    }
 
+    
     /***************************************************************************
      *                                                                         *
      * Private Fields                                                          *
     //Properties needed by the SpreadsheetView and managed by the skin (source is the VirtualFlow)
     private VirtualScrollBar hbar=null;
     private VirtualScrollBar vbar=null;
-    private RowAccessor<SpreadsheetRow> cells=null;
     private ObservableList<SpreadsheetColumn> columns = FXCollections.observableArrayList();
 
     /***************************************************************************
         this.vbar = vbar;
     }
 
-
-    /**
-     * Not for public use.
-     * @return
-     */
-    public SpreadsheetRow getRow(int index) {
-        return cells.get(index);
-    }
-
     // FIXME this shouldn't be here!
     /**
      * Not for public use.
      * @return
      */
     public boolean isEmptyCells() {
-        return cells.isEmpty();
-    }
-
-    // FIXME this shouldn't be here!
-    /**
-     * Not for public use.
-     * @return
-     */
-    public void setRows(RowAccessor<SpreadsheetRow> cells) {
-        this.cells = (RowAccessor<SpreadsheetRow>) cells;
+//        return cells.isEmpty();
+        return grid.getRows().isEmpty();
     }
 
     /**
      * @return
      */
     public final int getRowCount(){
-        return cells.size();
+        return grid.getRowCount();
+//        return cells.size();
     }
     
 
      * @return
      */
     private SpreadsheetRow getNonFixedRow(int index){
-        return cells.get(fixedRows.size()+index);
+//        return cells.get(fixedRows.size()+index);
+        SpreadsheetViewSkin skin = (SpreadsheetViewSkin) tableView.getSkin();
+        return skin.getCell(index);
     }
 
     /**
      * @return
      */
     private final boolean containsRow(int index){
-        for (int i =0 ;i<cells.size();++i) {
-            if(cells.get(i).getIndex() == index)
+        SpreadsheetViewSkin skin = (SpreadsheetViewSkin) tableView.getSkin();
+        int size = skin.getCellsSize();
+        for (int i = 0 ; i < size; ++i) {
+            if(skin.getCell(i).getIndex() == index)
                 return true;
         }
         return false;

src/main/java/org/controlsfx/control/spreadsheet/view/SpreadsheetCellEditor.java

 
 import impl.org.controlsfx.skin.SpreadsheetCell;
 import impl.org.controlsfx.skin.SpreadsheetRow;
+import impl.org.controlsfx.skin.SpreadsheetViewSkin;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
 
 
         
         private boolean addCell(SpreadsheetCell<?> cell){
-            SpreadsheetRow temp = spreadsheetView.getRow(spreadsheetView.getRowCount()-1-spreadsheetView.getFixedRows().size());
+            SpreadsheetRow temp = SpreadsheetViewSkin.getCell(spreadsheetView, spreadsheetView.getRowCount()-1-spreadsheetView.getFixedRows().size());
             if(temp != null){
                 temp.addCell(cell);
                 return true;