Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Table traverse by keeping pressed an arrow down/up key is too slowly for a big table.
Table traverse by keeping pressed an arrow down/up key is too slowly for a big table. [message #62947] Thu, 19 March 2009 17:29 Go to next message
Eclipse UserFriend
Originally posted by: and_konon.mail.ru

This is a multi-part message in MIME format.
--------------090909050105060203030101
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

The Grid has some delay between focus moving for arrow down/up press and
keep traverse. This delay depends on size of the grid: the bigger, the
longer. Therefore maximized grid (e.g. 1000px height) is extremely slow,
especially if cells calculate ellipses for long stings.

The reason why it happenes is redrawing all client area for each key
press event. It could be optimized by calculating area only for previous
focused item and new focused item. It will increase performance of the Grid.

Please find a snippet for demo and patch with possible solution (based
on header_footer brunch).

I would appreciate for any comments or remarks about the issue.

Thank you in advance.

/Andrey




--------------090909050105060203030101
Content-Type: text/plain;
name="patch_for_redraw"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch_for_redraw"

### Eclipse Workspace Patch 1.0
#P org.eclipse.nebula.widgets.grid
Index: src/org/eclipse/nebula/widgets/grid/Grid.java
============================================================ =======
RCS file: /cvsroot/technology/org.eclipse.swt.nebula/org.eclipse.nebul a.widgets.grid/src/org/eclipse/nebula/widgets/grid/Grid.java ,v
retrieving revision 1.63.2.10
diff -u -r1.63.2.10 Grid.java
--- src/org/eclipse/nebula/widgets/grid/Grid.java 4 Mar 2009 22:34:23 -0000 1.63.2.10
+++ src/org/eclipse/nebula/widgets/grid/Grid.java 19 Mar 2009 17:18:17 -0000
@@ -672,6 +672,8 @@
private boolean insertMarkBefore = false;
private IRenderer insertMarkRenderer = new DefaultInsertMarkRenderer();
private boolean sizeOnEveryItemImageChange;
+
+ private boolean isTraverseEvent = false;

/**
* A range of rows in a <code>Grid</code>.
@@ -7348,6 +7350,7 @@
}
break;
case SWT.ARROW_UP :
+ isTraverseEvent = true;
if (impliedFocusItem != null)
{
newSelection = getPreviousVisibleItem(impliedFocusItem);
@@ -7367,6 +7370,7 @@

break;
case SWT.ARROW_DOWN :
+ isTraverseEvent = true;
if (impliedFocusItem != null)
{
newSelection = getNextVisibleItem(impliedFocusItem);
@@ -7486,8 +7490,12 @@
notifyListeners(SWT.Selection, selEvent);
}
}
-
- redraw();
+ if (isTraverseEvent) {
+ isTraverseEvent = false;
+ redraw(impliedFocusItem, newSelection);
+ } else {
+ redraw();
+ }
}
else
{
@@ -7512,6 +7520,36 @@
}
}

+ /**
+ * Redraw area between <code>impliedFocusItem</code> and <code>newSelection</code>
+ * @param impliedFocusItem previously focused item
+ * @param newSelection currently focused item
+ */
+ private void redraw(final GridItem impliedFocusItem, final GridItem newSelection) {
+ final Rectangle oldItemArea = getItemArea(impliedFocusItem);
+ final Rectangle newItemArea = getItemArea(newSelection);
+ int height;
+ if (oldItemArea.y > newItemArea.y) {
+ height = oldItemArea.y + oldItemArea.height - newItemArea.y;
+ } else {
+ height = newItemArea.y + newItemArea.height - oldItemArea.y;
+ }
+ redraw(oldItemArea.x, Math.min(oldItemArea.y, newItemArea.y), newItemArea.width, height, false);
+ }
+
+ /**
+ * Calculate rectangle for <code>item</code>
+ * @param item
+ * @return
+ */
+ private Rectangle getItemArea(final GridItem item) {
+ final int x = item.getBounds(0).x;
+ final int width = getClientArea().width;
+ final int y = item.getBounds(0).y;
+ final int height = item.getBounds(getColumnCount()-1).height;
+ return new Rectangle(x, y, width, height);
+ }
+
private void handleSpaceBarDown(Event event)
{
if (focusItem == null)

--------------090909050105060203030101
Content-Type: text/plain;
name="MxGridSnippetForTraverseDelay.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="MxGridSnippetForTraverseDelay.java"

package org.eclipse.swt.nebula.snippets.grid;

import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class MxGridSnippetForTraverseDelay {

public static void main (final String [] args) {
final Display display = new Display ();
final Shell shell = new Shell (display);
shell.setLayout(new FillLayout());

final Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
grid.setHeaderVisible(true);

for (int j = 0; j < 10; j++) {
final GridColumn column = new GridColumn(grid, SWT.NONE);
column.setTree(false);
column.setText("Column" + j);
column.setWidth(100);
}
for (int i = 0; i < 300; i++) {
final GridItem item1 = new GridItem(grid, SWT.NONE, 10);
for (int k = 0; k < 10; k++) {
item1.setText(k, "Text for Item Too long text for Item Too long text for Item Too long text for Item Too long text for Item Too long text for Item" + k);
}
}

shell.setSize(200,200);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

}

--------------090909050105060203030101--
Re: Table traverse by keeping pressed an arrow down/up key is too slowly for a big table. [message #62949 is a reply to message #62947] Thu, 19 March 2009 17:31 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6414
Registered: July 2009
Senior Member
Hi,

Please file a bugzilla and a patch against the header_footer branch!
I'll take a look at it after EclipseCon.

Tom

Andrey Kononenko schrieb:
> The Grid has some delay between focus moving for arrow down/up press and
> keep traverse. This delay depends on size of the grid: the bigger, the
> longer. Therefore maximized grid (e.g. 1000px height) is extremely slow,
> especially if cells calculate ellipses for long stings.
>
> The reason why it happenes is redrawing all client area for each key
> press event. It could be optimized by calculating area only for previous
> focused item and new focused item. It will increase performance of the
> Grid.
>
> Please find a snippet for demo and patch with possible solution (based
> on header_footer brunch).
>
> I would appreciate for any comments or remarks about the issue.
>
> Thank you in advance.
>
> /Andrey
>
>
>
Re: Table traverse by keeping pressed an arrow down/up key is too slowly for a big table. [message #594096 is a reply to message #62947] Thu, 19 March 2009 17:31 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6414
Registered: July 2009
Senior Member
Hi,

Please file a bugzilla and a patch against the header_footer branch!
I'll take a look at it after EclipseCon.

Tom

Andrey Kononenko schrieb:
> The Grid has some delay between focus moving for arrow down/up press and
> keep traverse. This delay depends on size of the grid: the bigger, the
> longer. Therefore maximized grid (e.g. 1000px height) is extremely slow,
> especially if cells calculate ellipses for long stings.
>
> The reason why it happenes is redrawing all client area for each key
> press event. It could be optimized by calculating area only for previous
> focused item and new focused item. It will increase performance of the
> Grid.
>
> Please find a snippet for demo and patch with possible solution (based
> on header_footer brunch).
>
> I would appreciate for any comments or remarks about the issue.
>
> Thank you in advance.
>
> /Andrey
>
>
>
Previous Topic:Table traverse by keeping pressed an arrow down/up key is too slowly for a big table.
Next Topic:Manipulate row height in CompositeTable
Goto Forum:
  


Current Time: Tue Oct 23 03:08:01 GMT 2018

Powered by FUDForum. Page generated in 0.02088 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top