Commits

sami...@S-HADZIC.Nellarmonia.lan  committed 77ad896

8u20- DragSelection Fixed

  • Participants
  • Parent commits 410cd36
  • Branches 8u20

Comments (0)

Files changed (3)

File controlsfx/src/main/java/impl/org/controlsfx/spreadsheet/CellView.java

         return table.getProperties().get(ANCHOR_PROPERTY_KEY) != null;
     }
 
+    static void setAnchor(Control table, TablePositionBase anchor) {
+        if (table != null && anchor == null) {
+            removeAnchor(table);
+        } else {
+            table.getProperties().put(ANCHOR_PROPERTY_KEY, anchor);
+        }
+    }
+    
+    static void removeAnchor(Control table) {
+        table.getProperties().remove(ANCHOR_PROPERTY_KEY);
+    }
     /***************************************************************************
      * * Constructor * *
      **************************************************************************/
             updateSelected(false);
         }
         if (empty && emptyRow) {
+            textProperty().unbind();
             setText(null);
             // do not nullify graphic here. Let the TableRow to control cell
             // dislay
             // clear selection, but maintain the anchor
             if (!e.isShortcutDown())
                 sm.clearSelection();
-
             if (minColumn != -1 && maxColumn != -1)
                 sm.selectRange(minRow, tableView.getColumns().get(minColumn), maxRow,
                         tableView.getColumns().get(maxColumn));
+            setAnchor(tableView, anchor);
         }
 
     }
     private final EventHandler<MouseEvent> startFullDragEventHandler = new EventHandler<MouseEvent>() {
         @Override
         public void handle(MouseEvent arg0) {
+            setAnchor(getTableView(), getTableView().getFocusModel().getFocusedCell());
             startFullDrag();
         }
     };

File controlsfx/src/main/java/impl/org/controlsfx/spreadsheet/GridViewSkin.java

 import javafx.collections.ObservableList;
 import javafx.collections.ObservableSet;
 import javafx.collections.SetChangeListener;
-import javafx.event.EventHandler;
 import javafx.geometry.HPos;
 import javafx.geometry.VPos;
 import javafx.scene.Node;
 import javafx.scene.control.TableColumn;
 import javafx.scene.control.TableColumnBase;
 import javafx.scene.control.TableFocusModel;
-import javafx.scene.control.TablePosition;
 import javafx.scene.control.TableRow;
-import javafx.scene.control.TableSelectionModel;
 import javafx.scene.control.TableView;
-import javafx.scene.input.KeyCode;
-import javafx.scene.input.KeyEvent;
 import javafx.scene.layout.Region;
 import javafx.stage.Screen;
 import javafx.util.Callback;
          * Workaround for https://javafx-jira.kenai.com/browse/RT-34042. FIXME
          * JDK8u20
          */
-        getSkinnable().addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
-            @Override
-            public void handle(KeyEvent keyEvent) {
-                if (keyEvent.getCode() == KeyCode.LEFT) {
-                    if (keyEvent.isShortcutDown()) {
-                        getFocusModel().focusLeftCell();
-                    } else {
-                        selectLeft();
-                    }
-                    keyEvent.consume();
-                    scrollHorizontally();
-                } else if (keyEvent.getCode() == KeyCode.RIGHT) {
-                    if (keyEvent.isShortcutDown()) {
-                        getFocusModel().focusRightCell();
-                    } else {
-                        selectRight();
-                    }
-                    keyEvent.consume();
-                    scrollHorizontally();
-                }
-            }
-        });
+//        getSkinnable().addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
+//            @Override
+//            public void handle(KeyEvent keyEvent) {
+//                if (keyEvent.getCode() == KeyCode.LEFT) {
+//                    if (keyEvent.isShortcutDown()) {
+//                        getFocusModel().focusLeftCell();
+//                    } else {
+//                        selectLeft();
+//                    }
+//                    keyEvent.consume();
+//                    scrollHorizontally();
+//                } else if (keyEvent.getCode() == KeyCode.RIGHT) {
+//                    if (keyEvent.isShortcutDown()) {
+//                        getFocusModel().focusRightCell();
+//                    } else {
+//                        selectRight();
+//                    }
+//                    keyEvent.consume();
+//                    scrollHorizontally();
+//                }
+//            }
+//        });
     }
 
     protected final ObservableSet<Integer> getCurrentlyFixedRow() {
     /**
      * Select the Right cell.
      */
-    private void selectRight() {
-        TableSelectionModel sm = getSelectionModel();
-        if (sm == null)
-            return;
-
-        TableFocusModel fm = getFocusModel();
-        if (fm == null)
-            return;
-
-        TablePosition focusedCell = getFocusedCell();
-        int currentColumn = getVisibleLeafIndex(focusedCell.getTableColumn());
-        if (currentColumn == getVisibleLeafColumns().size() - 1)
-            return;
-
-        TableColumnBase tc = focusedCell.getTableColumn();
-        tc = getVisibleLeafColumn(currentColumn + 1);
-
-        int row = focusedCell.getRow();
-        sm.clearAndSelect(row, tc);
-    }
-
-    /**
-     * Select the left cell.
-     */
-    private void selectLeft() {
-        TableSelectionModel sm = getSelectionModel();
-        if (sm == null)
-            return;
-
-        TableFocusModel fm = getFocusModel();
-        if (fm == null)
-            return;
-
-        TablePosition focusedCell = getFocusedCell();
-        int currentColumn = getVisibleLeafIndex(focusedCell.getTableColumn());
-        if (currentColumn == 0)
-            return;
-
-        TableColumnBase tc = focusedCell.getTableColumn();
-        tc = getVisibleLeafColumn(currentColumn - 1);
-
-        int row = focusedCell.getRow();
-        sm.clearAndSelect(row, tc);
-    }
+//    private void selectRight() {
+//        TableSelectionModel sm = getSelectionModel();
+//        if (sm == null)
+//            return;
+//
+//        TableFocusModel fm = getFocusModel();
+//        if (fm == null)
+//            return;
+//
+//        TablePosition focusedCell = getFocusedCell();
+//        int currentColumn = getVisibleLeafIndex(focusedCell.getTableColumn());
+//        if (currentColumn == getVisibleLeafColumns().size() - 1)
+//            return;
+//
+//        TableColumnBase tc = focusedCell.getTableColumn();
+//        tc = getVisibleLeafColumn(currentColumn + 1);
+//
+//        int row = focusedCell.getRow();
+//        sm.clearAndSelect(row, tc);
+//    }
+//
+//    /**
+//     * Select the left cell.
+//     */
+//    private void selectLeft() {
+//        TableSelectionModel sm = getSelectionModel();
+//        if (sm == null)
+//            return;
+//
+//        TableFocusModel fm = getFocusModel();
+//        if (fm == null)
+//            return;
+//
+//        TablePosition focusedCell = getFocusedCell();
+//        int currentColumn = getVisibleLeafIndex(focusedCell.getTableColumn());
+//        if (currentColumn == 0)
+//            return;
+//
+//        TableColumnBase tc = focusedCell.getTableColumn();
+//        tc = getVisibleLeafColumn(currentColumn - 1);
+//
+//        int row = focusedCell.getRow();
+//        sm.clearAndSelect(row, tc);
+//    }
 
     /**
      * Return a BitSet of the rows that needs layout all the time. This

File controlsfx/src/main/java/impl/org/controlsfx/spreadsheet/HorizontalHeader.java

 
         if (working && gridViewSkin != null
                 && gridViewSkin.spreadsheetView != null
-                && gridViewSkin.spreadsheetView.showRowHeaderProperty().get()) {
+                && gridViewSkin.spreadsheetView.showRowHeaderProperty().get()
+                && gridViewSkin.verticalHeader != null) {
             padding += gridViewSkin.verticalHeader.getVerticalHeaderWidth();
         }