Skip to main content


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 QuirogaFriend
Messages: 67
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 FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
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 QuirogaFriend
Messages: 67
Registered: July 2009
Location: Mexico
Member

Hi Ivan
Many Thanks, it worked!!
Previous Topic:Customer getting 404
Next Topic:TabFolders in RAP crash
Goto Forum:
  


Current Time: Tue Mar 19 02:57:41 GMT 2024

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

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

Back to the top