Alexander Wels has uploaded a new change for review.

Change subject: webadmin: resize columns
......................................................................

webadmin: resize columns

- Made resizing columns in the grid easier by increasing
  the size of the area that can be grabbed from 3 to 5 pixels.
  As well as making the area available left and right of the
  splitting line.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1037477

Change-Id: Id3d89413e5d3376b2c8ac29ecfbac58e2eead68f
Signed-off-by: Alexander Wels <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/HasResizableColumns.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ResizableHeader.java
3 files changed, 36 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/81/26581/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java
index d700cdd..82beb51 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java
@@ -365,4 +365,14 @@
         return null;
     }
 
+    @Override
+    public Column<T, ?> getPreviousColumn(Column<T, ?> column) {
+        final int columnIndex = getColumnIndex(column);
+        Column<T, ?> result = null;
+        if(columnIndex > 0) {
+            result = getColumn(columnIndex - 1);
+        }
+        return result;
+    }
+
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/HasResizableColumns.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/HasResizableColumns.java
index 84a0ba5..905bda5 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/HasResizableColumns.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/HasResizableColumns.java
@@ -57,4 +57,11 @@
      */
     int getMinimumColumnWidth(Column<T, ?> column);
 
+    /**
+     * Determine the column ahead of this column, we need this in order to 
properly resize when we attempt to
+     * resize from the left part of the passed in column (which controls the 
size of the previous column).
+     * @param column The column to use to determine the previous column.
+     * @return The column ahead of the passed in column, or null if this is 
the first column.
+     */
+    Column<T, ?> getPreviousColumn(Column<T, ?> column);
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ResizableHeader.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ResizableHeader.java
index ac289db..9cda350 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ResizableHeader.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ResizableHeader.java
@@ -22,17 +22,22 @@
 public class ResizableHeader<T> extends Header<SafeHtml> {
 
     // Width of the column header resize bar area, in pixels
-    private static final int RESIZE_BAR_WIDTH = 3;
+    private static final int RESIZE_BAR_WIDTH = 5;
 
     private final SafeHtml text;
     private final Column<T, ?> column;
+    private Column<T, ?> previousColumn;
     private final HasResizableColumns<T> table;
 
-    public ResizableHeader(SafeHtml text, Column<T, ?> column, 
HasResizableColumns<T> table) {
-        this(text, column, table, new SafeHtmlCellWithTooltip("click", 
"mousedown", "mousemove", "mouseover")); //$NON-NLS-1$ //$NON-NLS-2$ 
//$NON-NLS-3$ //$NON-NLS-4$
+    public ResizableHeader(SafeHtml text, Column<T, ?> column,
+            HasResizableColumns<T> table) {
+        this(text, column, table,
+                new SafeHtmlCellWithTooltip("click", "mousedown", 
//$NON-NLS-1$ //$NON-NLS-2$
+                        "mousemove", "mouseover")); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public ResizableHeader(SafeHtml text, Column<T, ?> column, 
HasResizableColumns<T> table, Cell<SafeHtml> cell) {
+    public ResizableHeader(SafeHtml text, Column<T, ?> column, 
HasResizableColumns<T> table,
+            Cell<SafeHtml> cell) {
         super(cell);
         this.text = text;
         this.column = column;
@@ -48,14 +53,19 @@
     public void onBrowserEvent(Context context, Element target, NativeEvent 
event) {
         super.onBrowserEvent(context, target, event);
 
+        if (previousColumn == null) {
+            previousColumn = table.getPreviousColumn(column);
+        }
         int clientX = event.getClientX();
         int absoluteLeft = target.getAbsoluteLeft();
         int offsetWidth = target.getOffsetWidth();
-        boolean mouseOverResizeBarArea = clientX > absoluteLeft + offsetWidth 
- RESIZE_BAR_WIDTH;
+        boolean mouseOverRightResizeBarArea = clientX > absoluteLeft + 
offsetWidth - RESIZE_BAR_WIDTH;
+        boolean mouseOverLeftResizeBarArea = (clientX >= absoluteLeft && 
clientX < absoluteLeft + RESIZE_BAR_WIDTH)
+                && previousColumn != null;
 
         // Update mouse cursor for the header element, using resize
         // cursor when the mouse hovers over the resize bar area
-        if (mouseOverResizeBarArea) {
+        if (mouseOverRightResizeBarArea || mouseOverLeftResizeBarArea) {
             target.getStyle().setCursor(Cursor.COL_RESIZE);
         } else {
             target.getStyle().setCursor(Cursor.DEFAULT);
@@ -64,8 +74,10 @@
         // On mouse down event, which initiates the column resize operation,
         // register a column resize handler that listens to mouse move events
         if ("mousedown".equals(event.getType())) { //$NON-NLS-1$
-            if (mouseOverResizeBarArea) {
+            if (mouseOverRightResizeBarArea) {
                 new ColumnResizeHandler<T>(target, column, table);
+            } else if (mouseOverLeftResizeBarArea) {
+                new ColumnResizeHandler<T>(target.getPreviousSiblingElement(), 
previousColumn, table);
             }
             event.preventDefault();
             event.stopPropagation();


-- 
To view, visit http://gerrit.ovirt.org/26581
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3d89413e5d3376b2c8ac29ecfbac58e2eead68f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alexander Wels <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to