diff dwtx/jface/viewers/TableViewerFocusCellManager.d @ 70:46a6e0e6ccd4

Merge with d-fied sources of 3.4M7
author Frank Benoit <benoit@tionex.de>
date Thu, 22 May 2008 01:36:46 +0200
parents ea8ff534f622
children 4878bef4a38e
line wrap: on
line diff
--- a/dwtx/jface/viewers/TableViewerFocusCellManager.d	Mon May 19 13:41:06 2008 +0200
+++ b/dwtx/jface/viewers/TableViewerFocusCellManager.d	Thu May 22 01:36:46 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,9 +7,11 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ *                                                 fix in bug: 210752
  * Port to the D programming language:
  *     Frank Benoit <benoit@tionex.de>
- ******************************************************************************/
+ *******************************************************************************/
 
 module dwtx.jface.viewers.TableViewerFocusCellManager;
 
@@ -34,8 +36,27 @@
 public class TableViewerFocusCellManager : SWTFocusCellManager {
     private static const CellNavigationStrategy TABLE_NAVIGATE;
     static this(){
-        TABLE_NAVIGATE = new CellNavigationStrategy();
+    /**
+     * Create a new manager with a default navigation strategy:
+     * <ul>
+     * <li><code>DWT.ARROW_UP</code>: navigate to cell above</li>
+     * <li><code>DWT.ARROW_DOWN</code>: navigate to cell below</li>
+     * <li><code>DWT.ARROW_RIGHT</code>: navigate to next visible cell on
+     * the right</li>
+     * <li><code>DWT.ARROW_LEFT</code>: navigate to next visible cell on the
+     * left</li>
+     * </ul>
+     *
+     * @param viewer
+     *            the viewer the manager is bound to
+     * @param focusDrawingDelegate
+     *            the delegate responsible to highlight selected cell
+     */
+    public TableViewerFocusCellManager(TableViewer viewer,
+            FocusCellHighlighter focusDrawingDelegate) {
+        this(viewer, focusDrawingDelegate, TABLE_NAVIGATE);
     }
+
     /**
      * Create a new manager
      *
@@ -43,10 +64,13 @@
      *            the viewer the manager is bound to
      * @param focusDrawingDelegate
      *            the delegate responsible to highlight selected cell
+     * @param navigationStrategy
+     *            the strategy used to navigate the cells
      */
-    public this(TableViewer viewer,
-            FocusCellHighlighter focusDrawingDelegate) {
-        super(viewer, focusDrawingDelegate, TABLE_NAVIGATE);
+    public TableViewerFocusCellManager(TableViewer viewer,
+            FocusCellHighlighter focusDrawingDelegate,
+            CellNavigationStrategy navigationStrategy) {
+        super(viewer, focusDrawingDelegate, navigationStrategy);
     }
 
     override ViewerCell getInitialFocusCell() {
@@ -60,4 +84,20 @@
         return null;
     }
 
+    public ViewerCell getFocusCell() {
+        ViewerCell cell = super.getFocusCell();
+        Table t = (Table) getViewer().getControl();
+
+        // It is possible that the selection has changed under the hood
+        if (cell !is null) {
+            if (t.getSelection().length is 1
+                    && t.getSelection()[0] !is cell.getItem()) {
+                setFocusCell(getViewer().getViewerRowFromItem(
+                        t.getSelection()[0]).getCell(cell.getColumnIndex()));
+            }
+        }
+
+        return super.getFocusCell();
+    }
+
 }