Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » StackOverflowError by traversing a table
StackOverflowError by traversing a table [message #60443] Mon, 17 November 2008 11:05 Go to next message
Tino is currently offline TinoFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,

I have a table with readonly columns at the first and last position of the
table and editable columns between them (as shown in the snippet).
The table has more rows than the display can show.

If I double click an editable column to activate the edit mode and press
TAB the cursor goes to the next column as expected. If I press TAB at the
end of the screen I would expect that the cursor jumps to the next (not
visible) row and makes the row visible. But the program stops with a
java.lang.StackOverflowError.

Without readonly columns the traversing works as expected.

Any reply is highly appreciated.
Thanks in advance.

Regards
Tino






import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewerEditor;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrate gy;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
import org.eclipse.nebula.jface.gridviewer.GridViewerColumn;
import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;



public class Snippet {

private class MyContentProvider implements IStructuredContentProvider {

public Object[] getElements(Object inputElement) {
return (MyModel[]) inputElement;
}

public void dispose() {
}

public void inputChanged(Viewer viewer, Object oldInput, Object
newInput) {
}
}


public class MyModel {
public int counter;

public MyModel(int counter) {
this.counter = counter;
}

public String toString() {
return "Item " + this.counter;
}
}


private class ElementEditingSupport extends EditingSupport {
private TextCellEditor cellEditor;

public ElementEditingSupport(GridTableViewer viewer) {
super(viewer);
cellEditor = new TextCellEditor(viewer.getGrid());
}

protected boolean canEdit(Object element) {
return true;
}

protected CellEditor getCellEditor(Object element) {
return cellEditor;
}

protected Object getValue(Object element) {
((GridTableViewer)getViewer()).getGrid().showSelection();
return String.valueOf(((MyModel) element).counter);
}

protected void setValue(Object element, Object value) {
((MyModel) element).counter = Integer.parseInt(value.toString());
getViewer().update(element, null);
}
}



public Snippet(Shell shell) {

final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER |
SWT.V_SCROLL | SWT.H_SCROLL);
v.setLabelProvider(new ColumnLabelProvider());
v.setContentProvider(new MyContentProvider());
v.getGrid().setCellSelectionEnabled(true);


GridViewerColumn column = new GridViewerColumn(v, SWT.NONE);
column.getColumn().setWidth(100);
column.getColumn().setText("Readonly 1");
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((MyModel) element).toString();
}

@Override
public Color getBackground(Object element) {
return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
}
});


// Writable columns
for (int i = 0; i < 3; i++) {
column = new GridViewerColumn(v, SWT.NONE);
column.getColumn().setWidth(100);
column.getColumn().setText("Editable" + i);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((MyModel) element).toString();
}
});
column.setEditingSupport(new ElementEditingSupport(v));
}


//2nd Readonly column
column = new GridViewerColumn(v, SWT.NONE);
column.getColumn().setWidth(100);
column.getColumn().setText("Readonly 2");
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((MyModel) element).toString();
}

@Override
public Color getBackground(Object element) {
return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
}
});



ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(v) {
protected boolean isEditorActivationEvent(
ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
&& event.keyCode == SWT.CR);
}
};

GridViewerEditor.create(v, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL |
ColumnViewerEditor.KEYBOARD_ACTIVATION);


MyModel[] model = createModel();
v.setInput(model);
v.getGrid().setLinesVisible(true);
v.getGrid().setHeaderVisible(true);
}


private MyModel[] createModel() {
MyModel[] elements = new MyModel[10000];

for (int i = 0; i < 10000; i++) {
elements[i] = new MyModel(i);
}

return elements;
}


/**
* @param args
*/
public static void main(String[] args) {
Display display = new Display();

Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new Snippet(shell);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

display.dispose();

}
}
Re: StackOverflowError by traversing a table [message #60465 is a reply to message #60443] Mon, 17 November 2008 13:38 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Hi,

Which version of JFace and GridViewer are you using? I think we had a
bug in JFace 3.4.0 we fixed in 3.4.1 but I could also be that I fixed
the bug in the header_footer branch of Grid where we are combining the
grid and viewer code in one code base.

Could you by chance give the header_footer branch a try else please file
a bugzilla and CC me on it then I'll fix the problem.

Tom

Tino schrieb:
> Hello,
>
> I have a table with readonly columns at the first and last position of
> the table and editable columns between them (as shown in the snippet).
> The table has more rows than the display can show.
>
> If I double click an editable column to activate the edit mode and press
> TAB the cursor goes to the next column as expected. If I press TAB at
> the end of the screen I would expect that the cursor jumps to the next
> (not visible) row and makes the row visible. But the program stops with
> a java.lang.StackOverflowError.
>
> Without readonly columns the traversing works as expected.
>
> Any reply is highly appreciated.
> Thanks in advance.
>
> Regards
> Tino
>
>
>
>
>
>
> import org.eclipse.jface.viewers.CellEditor;
> import org.eclipse.jface.viewers.ColumnLabelProvider;
> import org.eclipse.jface.viewers.ColumnViewerEditor;
> import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
> import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrate gy;
> import org.eclipse.jface.viewers.EditingSupport;
> import org.eclipse.jface.viewers.IStructuredContentProvider;
> import org.eclipse.jface.viewers.TextCellEditor;
> import org.eclipse.jface.viewers.Viewer;
> import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
> import org.eclipse.nebula.jface.gridviewer.GridViewerColumn;
> import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.Color;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
>
>
> public class Snippet {
>
> private class MyContentProvider implements IStructuredContentProvider {
>
> public Object[] getElements(Object inputElement) {
> return (MyModel[]) inputElement;
> }
>
> public void dispose() {
> }
>
> public void inputChanged(Viewer viewer, Object oldInput, Object
> newInput) {
> }
> }
>
>
> public class MyModel {
> public int counter;
>
> public MyModel(int counter) {
> this.counter = counter;
> }
>
> public String toString() {
> return "Item " + this.counter;
> }
> }
>
>
> private class ElementEditingSupport extends EditingSupport {
> private TextCellEditor cellEditor;
>
> public ElementEditingSupport(GridTableViewer viewer) {
> super(viewer);
> cellEditor = new TextCellEditor(viewer.getGrid());
> }
>
> protected boolean canEdit(Object element) {
> return true;
> }
>
> protected CellEditor getCellEditor(Object element) {
> return cellEditor;
> }
>
> protected Object getValue(Object element) {
> ((GridTableViewer)getViewer()).getGrid().showSelection();
> return String.valueOf(((MyModel) element).counter);
> }
>
> protected void setValue(Object element, Object value) {
> ((MyModel) element).counter =
> Integer.parseInt(value.toString());
> getViewer().update(element, null);
> }
> }
>
>
>
> public Snippet(Shell shell) {
>
> final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER
> | SWT.V_SCROLL | SWT.H_SCROLL);
> v.setLabelProvider(new ColumnLabelProvider());
> v.setContentProvider(new MyContentProvider());
> v.getGrid().setCellSelectionEnabled(true);
>
>
> GridViewerColumn column = new GridViewerColumn(v, SWT.NONE);
> column.getColumn().setWidth(100);
> column.getColumn().setText("Readonly 1");
> column.setLabelProvider(new ColumnLabelProvider() {
> @Override
> public String getText(Object element) {
> return ((MyModel) element).toString();
> }
>
> @Override
> public Color getBackground(Object element) {
> return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
> }
> });
>
>
> // Writable columns
> for (int i = 0; i < 3; i++) {
> column = new GridViewerColumn(v, SWT.NONE);
> column.getColumn().setWidth(100);
> column.getColumn().setText("Editable" + i);
> column.setLabelProvider(new ColumnLabelProvider() {
> @Override
> public String getText(Object element) {
> return ((MyModel) element).toString();
> }
> });
> column.setEditingSupport(new ElementEditingSupport(v));
> }
>
>
> //2nd Readonly column
> column = new GridViewerColumn(v, SWT.NONE);
> column.getColumn().setWidth(100);
> column.getColumn().setText("Readonly 2");
> column.setLabelProvider(new ColumnLabelProvider() {
> @Override
> public String getText(Object element) {
> return ((MyModel) element).toString();
> }
>
> @Override
> public Color getBackground(Object element) {
> return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
> }
> });
>
>
>
> ColumnViewerEditorActivationStrategy actSupport = new
> ColumnViewerEditorActivationStrategy(v) {
> protected boolean isEditorActivationEvent(
> ColumnViewerEditorActivationEvent event) {
> return event.eventType ==
> ColumnViewerEditorActivationEvent.TRAVERSAL
> || event.eventType ==
> ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
> || (event.eventType ==
> ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
> }
> };
>
> GridViewerEditor.create(v, actSupport,
> ColumnViewerEditor.TABBING_HORIZONTAL
> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
> | ColumnViewerEditor.TABBING_VERTICAL |
> ColumnViewerEditor.KEYBOARD_ACTIVATION);
>
>
> MyModel[] model = createModel();
> v.setInput(model);
> v.getGrid().setLinesVisible(true);
> v.getGrid().setHeaderVisible(true);
> }
>
>
> private MyModel[] createModel() {
> MyModel[] elements = new MyModel[10000];
>
> for (int i = 0; i < 10000; i++) {
> elements[i] = new MyModel(i);
> }
>
> return elements;
> }
>
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> Display display = new Display();
>
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> new Snippet(shell);
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
>
> display.dispose();
>
> }
> }
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: StackOverflowError by traversing a table [message #60485 is a reply to message #60465] Mon, 17 November 2008 15:25 Go to previous messageGo to next message
Tino is currently offline TinoFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Tom,

tnx for your fast answer. I'm using JFace 3.4.1. So, I give the
header_footer branch a try.
Do I have to use another JFace version than 3.4.1 in combination with this
branch?
Re: StackOverflowError by traversing a table [message #60504 is a reply to message #60485] Mon, 17 November 2008 15:38 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
No.

Tom

Tino schrieb:
> Hi Tom,
>
> tnx for your fast answer. I'm using JFace 3.4.1. So, I give the
> header_footer branch a try. Do I have to use another JFace version than
> 3.4.1 in combination with this branch?
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: StackOverflowError by traversing a table [message #60522 is a reply to message #60504] Tue, 18 November 2008 09:12 Go to previous message
Tino is currently offline TinoFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Tom,

I tested it with the header_footer branch, but it still doesn't work.
So, I created a bugzilla entry:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=255610

Regards
Tino
Re: StackOverflowError by traversing a table [message #592708 is a reply to message #60443] Mon, 17 November 2008 13:38 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Hi,

Which version of JFace and GridViewer are you using? I think we had a
bug in JFace 3.4.0 we fixed in 3.4.1 but I could also be that I fixed
the bug in the header_footer branch of Grid where we are combining the
grid and viewer code in one code base.

Could you by chance give the header_footer branch a try else please file
a bugzilla and CC me on it then I'll fix the problem.

Tom

Tino schrieb:
> Hello,
>
> I have a table with readonly columns at the first and last position of
> the table and editable columns between them (as shown in the snippet).
> The table has more rows than the display can show.
>
> If I double click an editable column to activate the edit mode and press
> TAB the cursor goes to the next column as expected. If I press TAB at
> the end of the screen I would expect that the cursor jumps to the next
> (not visible) row and makes the row visible. But the program stops with
> a java.lang.StackOverflowError.
>
> Without readonly columns the traversing works as expected.
>
> Any reply is highly appreciated.
> Thanks in advance.
>
> Regards
> Tino
>
>
>
>
>
>
> import org.eclipse.jface.viewers.CellEditor;
> import org.eclipse.jface.viewers.ColumnLabelProvider;
> import org.eclipse.jface.viewers.ColumnViewerEditor;
> import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
> import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrate gy;
> import org.eclipse.jface.viewers.EditingSupport;
> import org.eclipse.jface.viewers.IStructuredContentProvider;
> import org.eclipse.jface.viewers.TextCellEditor;
> import org.eclipse.jface.viewers.Viewer;
> import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
> import org.eclipse.nebula.jface.gridviewer.GridViewerColumn;
> import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.Color;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
>
>
> public class Snippet {
>
> private class MyContentProvider implements IStructuredContentProvider {
>
> public Object[] getElements(Object inputElement) {
> return (MyModel[]) inputElement;
> }
>
> public void dispose() {
> }
>
> public void inputChanged(Viewer viewer, Object oldInput, Object
> newInput) {
> }
> }
>
>
> public class MyModel {
> public int counter;
>
> public MyModel(int counter) {
> this.counter = counter;
> }
>
> public String toString() {
> return "Item " + this.counter;
> }
> }
>
>
> private class ElementEditingSupport extends EditingSupport {
> private TextCellEditor cellEditor;
>
> public ElementEditingSupport(GridTableViewer viewer) {
> super(viewer);
> cellEditor = new TextCellEditor(viewer.getGrid());
> }
>
> protected boolean canEdit(Object element) {
> return true;
> }
>
> protected CellEditor getCellEditor(Object element) {
> return cellEditor;
> }
>
> protected Object getValue(Object element) {
> ((GridTableViewer)getViewer()).getGrid().showSelection();
> return String.valueOf(((MyModel) element).counter);
> }
>
> protected void setValue(Object element, Object value) {
> ((MyModel) element).counter =
> Integer.parseInt(value.toString());
> getViewer().update(element, null);
> }
> }
>
>
>
> public Snippet(Shell shell) {
>
> final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER
> | SWT.V_SCROLL | SWT.H_SCROLL);
> v.setLabelProvider(new ColumnLabelProvider());
> v.setContentProvider(new MyContentProvider());
> v.getGrid().setCellSelectionEnabled(true);
>
>
> GridViewerColumn column = new GridViewerColumn(v, SWT.NONE);
> column.getColumn().setWidth(100);
> column.getColumn().setText("Readonly 1");
> column.setLabelProvider(new ColumnLabelProvider() {
> @Override
> public String getText(Object element) {
> return ((MyModel) element).toString();
> }
>
> @Override
> public Color getBackground(Object element) {
> return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
> }
> });
>
>
> // Writable columns
> for (int i = 0; i < 3; i++) {
> column = new GridViewerColumn(v, SWT.NONE);
> column.getColumn().setWidth(100);
> column.getColumn().setText("Editable" + i);
> column.setLabelProvider(new ColumnLabelProvider() {
> @Override
> public String getText(Object element) {
> return ((MyModel) element).toString();
> }
> });
> column.setEditingSupport(new ElementEditingSupport(v));
> }
>
>
> //2nd Readonly column
> column = new GridViewerColumn(v, SWT.NONE);
> column.getColumn().setWidth(100);
> column.getColumn().setText("Readonly 2");
> column.setLabelProvider(new ColumnLabelProvider() {
> @Override
> public String getText(Object element) {
> return ((MyModel) element).toString();
> }
>
> @Override
> public Color getBackground(Object element) {
> return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
> }
> });
>
>
>
> ColumnViewerEditorActivationStrategy actSupport = new
> ColumnViewerEditorActivationStrategy(v) {
> protected boolean isEditorActivationEvent(
> ColumnViewerEditorActivationEvent event) {
> return event.eventType ==
> ColumnViewerEditorActivationEvent.TRAVERSAL
> || event.eventType ==
> ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
> || (event.eventType ==
> ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
> }
> };
>
> GridViewerEditor.create(v, actSupport,
> ColumnViewerEditor.TABBING_HORIZONTAL
> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
> | ColumnViewerEditor.TABBING_VERTICAL |
> ColumnViewerEditor.KEYBOARD_ACTIVATION);
>
>
> MyModel[] model = createModel();
> v.setInput(model);
> v.getGrid().setLinesVisible(true);
> v.getGrid().setHeaderVisible(true);
> }
>
>
> private MyModel[] createModel() {
> MyModel[] elements = new MyModel[10000];
>
> for (int i = 0; i < 10000; i++) {
> elements[i] = new MyModel(i);
> }
>
> return elements;
> }
>
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> Display display = new Display();
>
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> new Snippet(shell);
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
>
> display.dispose();
>
> }
> }
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: StackOverflowError by traversing a table [message #592724 is a reply to message #60465] Mon, 17 November 2008 15:25 Go to previous message
Tino is currently offline TinoFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Tom,

tnx for your fast answer. I'm using JFace 3.4.1. So, I give the
header_footer branch a try.
Do I have to use another JFace version than 3.4.1 in combination with this
branch?
Re: StackOverflowError by traversing a table [message #592729 is a reply to message #60485] Mon, 17 November 2008 15:38 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
No.

Tom

Tino schrieb:
> Hi Tom,
>
> tnx for your fast answer. I'm using JFace 3.4.1. So, I give the
> header_footer branch a try. Do I have to use another JFace version than
> 3.4.1 in combination with this branch?
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: StackOverflowError by traversing a table [message #592741 is a reply to message #60504] Tue, 18 November 2008 09:12 Go to previous message
Tino is currently offline TinoFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Tom,

I tested it with the header_footer branch, but it still doesn't work.
So, I created a bugzilla entry:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=255610

Regards
Tino
Previous Topic:StackOverflowError by traversing a table
Next Topic:GalleryTreeViewer: GalleryItem description with ListItemRenderer
Goto Forum:
  


Current Time: Mon Dec 22 20:53:37 GMT 2014

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

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