|
|
|
Re: How to scroll a table to its end [message #458963 is a reply to message #458960] |
Wed, 27 July 2005 13:26 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Vincent,
Which platform do you see this on? Do you have a snippet that shows it
happening? I did a quick experiment (snippet below) on win32, gtk and
motif, and could not get any of them to cut off the last item, even with
various Table heights. Using Table.setTopIndex() with a large value (eg.-
setTopIndex(table.getItemCount() - 1)) _should_ do what you want.
public class Main {
static int TABLE_HEIGHT = 195;
static int TABLE_ITEMCOUNT = 100;
public static void main(String[] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
shell.setBounds(10,10,300,300);
final Table table = new Table(shell, SWT.NONE);
table.setBounds(10,10,200,TABLE_HEIGHT);
for (int i = 0; i < TABLE_ITEMCOUNT; i++) {
new TableItem (table, SWT.NONE).setText("item " + i);
}
shell.open();
shell.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
TableItem lastItem = table.getItem(TABLE_ITEMCOUNT - 1);
table.showItem(lastItem);
//table.setTopIndex(TABLE_ITEMCOUNT - 1);
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
Grant
"Vincent Etter" <vincent.etter@gmail.com> wrote in message
news:dc80d6$tbf$1@news.eclipse.org...
> Yves Harms wrote:
> > Hi,
> > try mytable.getItem(table.getItemCount()-1).showItem()
> > or newItem.showItem() if you already have a reference to the new item.
> >
> > Yves
>
> Thanks for your answer ! The right code is :
>
> TableItem lastItem = myTable.getItem(restoreItemsTable.getItemCount() -
1);
> myTable.showItem(lastItem);
>
> But unfortunately the result is the same as with setTopIndex() : the
> last item is most of the time "cut" :(...
|
|
|
|
|
Re: How to scroll a table to its end [message #458971 is a reply to message #458968] |
Wed, 27 July 2005 14:53 |
Vincent Etter Messages: 72 Registered: July 2009 |
Member |
|
|
Grant Gayed wrote:
> There's something strange happening with the TableEditor (just logged
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=105316 ), though I have not
> replicated your problem. If you have a stand-alone snippet that shows it
> happening then it would be easier to determine what's happening in your
> case.
>
> Grant
My problem is the same as the one you reported. The stand-alone snippet
I made shows the same than your screenshot in the bug report. Here it is :
public class Main {
static int TABLE_HEIGHT = 195;
static int TABLE_ITEMCOUNT = 100;
public static void main(String[] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
shell.setBounds(10,10,300,300);
final Table table = new Table(shell, SWT.NONE);
table.setBounds(10,10,200,TABLE_HEIGHT);
new TableColumn(table, SWT.NONE).setWidth(75);
new TableColumn(table, SWT.NONE).setWidth(75);
for (int i = 0; i < TABLE_ITEMCOUNT; i++) {
TableItem item = new TableItem(table, SWT.NONE);
Label label = new Label(table, SWT.NONE);
label.setText("item " + i);
label.setBackground(Display.getCurrent().getSystemColor(SWT. COLOR_WHITE));
label.pack();
TableEditor editor = new TableEditor(table);
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(label, item, 0);
Button remove = new Button(table, SWT.PUSH);
remove.setText("Remove");
remove.pack();
editor = new TableEditor(table);
editor.minimumWidth = remove.getSize().x;
editor.setEditor(remove, item, 1);
table.getColumn(1).setWidth(remove.getSize().x + 5);
}
shell.open();
shell.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
TableItem lastItem = table.getItem(TABLE_ITEMCOUNT - 1);
table.showItem(lastItem);
//table.setTopIndex(TABLE_ITEMCOUNT - 1);
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
Look at the labels : you can see that the scrollbar seems to scroll but
the content of the table does not move ! Screenshot :
http://img61.imageshack.us/img61/1639/screenshot20cg.jpg
|
|
|
Powered by
FUDForum. Page generated in 0.01900 seconds