Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Table setTopIndex() problem
Table setTopIndex() problem [message #1063285] Wed, 12 June 2013 22:19 Go to next message
Jesus   Luna Quiroga is currently offline Jesus Luna Quiroga
Messages: 63
Registered: July 2009
Location: Mexico
Member

Hi,
I'm having problems using the setTopIndex() method of the Table widget, the problem is the following: when I want to display a row that is not showing in a table the setTopIndex() works fine, but if the table has TableEditor in its rows it behaves oddly, it scrolls its scrollbar but the elements don't.

This code should show the problem:
final Table table = new Table(this, SWT.BORDER | SWT.MULTI);
table.setSize(200, 200);
TableColumn tc = new TableColumn(table, SWT.NONE);
tc.setText("Column 1");
tc.setWidth(200);
for (int i = 0; i < 100; i++) {
      TableItem item = new TableItem(table, SWT.NONE);
      Text text = new Text(table, SWT.NONE);
      text.setText( "item " + i);
      TableEditor editor = new TableEditor (table);
      editor.grabHorizontal = true;				
      editor.setEditor(text, item, 0);
      editor.layout();	
}
Button btn = new Button(this, SWT.NONE);
btn.setText("Click");
btn.addSelectionListener(new SelectionListener(){
      public void widgetSelected(SelectionEvent e) {
	   table.setTopIndex(95);
      }
      public void widgetDefaultSelected(SelectionEvent e) {}		
});


I've tried to do a workaround but nothing worked, I've tried to scroll the table, use its layout() and so on. Also I've seen this is a common problem in SWT.

So can you help me with this, does a workaround exists? or is it a bug?

Thanks in advance.

Re: Table setTopIndex() problem [message #1063515 is a reply to message #1063285] Thu, 13 June 2013 10:50 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1800
Registered: July 2009
Senior Member
Hi,
in ControlEditor there are listeners registered on Table/Tree scrollbars
which do the layout of the editor control when scrollbar selection
changes. These listeners are not notified in both RAP and SWT when
setTopIndex method is used. You could try to notify these listeners
manually:
....
table.setTopIndex( index );
ScrollBar vBar = table.getVerticalBar();
if( vBar != null ) {
vBar.notifyListeners( SWT.Selection, new Event() );
}
....
HTH,
Ivan

On 6/13/2013 1:19 AM, Jesus Luna Quiroga wrote:
> Hi, I'm having problems using the setTopIndex() method of the Table
> widget, the problem is the following: when I want to display a row
> that is not showing in a table the setTopIndex() works fine, but if
> the table has TableEditor in its rows it behaves oddly, it scrolls its
> scrollbar but the elements don't.
>
> This code should show the problem:
>
> final Table table = new Table(this, SWT.BORDER | SWT.MULTI);
> table.setSize(200, 200);
> TableColumn tc = new TableColumn(table, SWT.NONE);
> tc.setText("Column 1");
> tc.setWidth(200);
> for (int i = 0; i < 100; i++) {
> TableItem item = new TableItem(table, SWT.NONE);
> Text text = new Text(table, SWT.NONE);
> text.setText( "item " + i);
> TableEditor editor = new TableEditor (table);
> editor.grabHorizontal = true;
> editor.setEditor(text, item, 0);
> editor.layout();
> }
> Button btn = new Button(this, SWT.NONE);
> btn.setText("Click");
> btn.addSelectionListener(new SelectionListener(){
> public void widgetSelected(SelectionEvent e) {
> table.setTopIndex(95);
> }
> public void widgetDefaultSelected(SelectionEvent e) {}
> });
>
>
> I've tried to do a workaround but nothing worked, I've tried to scroll
> the table, use its layout() and so on. Also I've seen this is a common
> problem in SWT.
>
> So can you help me with this, does a workaround exists? or is it a bug?
>
> Thanks in advance.
>
>

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Table setTopIndex() problem [message #1063673 is a reply to message #1063515] Thu, 13 June 2013 17:15 Go to previous message
Jesus   Luna Quiroga is currently offline Jesus Luna Quiroga
Messages: 63
Registered: July 2009
Location: Mexico
Member

Hi Ivan
Many Thanks, it worked!!
Previous Topic:TabFolders in RAP crash
Next Topic:Import the Incubator Projects
Goto Forum:
  


Current Time: Tue Sep 02 23:58:08 GMT 2014

Powered by FUDForum. Page generated in 0.06586 seconds