TreeEditor problems [message #85734] |
Thu, 01 May 2008 14:48  |
Eclipse User |
|
|
|
Hi,
When calling the following snippet from ViewPart.createPartControl() we
encounter 2 problems:
1) The "editor box" appears in the upper left corner of the tree
(instead of over the doubleclicked item)
2) After the first modification, we get a stack trace (see below)
stating "The control was not added to this control holder." So there
seems to be a problem with text.dispose()
We don't get this behavior in RCP.
Any ideas? Should we file a bug report?
Thanks
Benoit
-------- SNIPPET ---------
private void addDoubleClickListener(TreeViewer treeViewer)
{
final Tree tree = treeViewer.getTree();
for (int i = 0; i < 16; i++)
{
TreeItem itemI = new TreeItem(tree, SWT.NONE);
itemI.setText("Item " + i);
for (int j = 0; j < 16; j++)
{
TreeItem itemJ = new TreeItem(itemI, SWT.NONE);
itemJ.setText("Item " + j);
}
}
final TreeEditor editor = new TreeEditor(tree);
// The editor must have the same size as the cell and must
// not be any smaller than 50 pixels.
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;
editor.verticalAlignment = SWT.CENTER;
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null && !oldEditor.isDisposed()) {
oldEditor.dispose();
}
// Identify the selected row
TreeItem[] selection = tree.getSelection();
final TreeItem item = selection[0];
if (item == null) {
return;
}
// The control that will be the editor must be a
// child of the Tree
final Text newEditor = new Text(tree, SWT.NONE);
newEditor.setText(item.getText());
editor.setEditor(newEditor, item);
newEditor.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
if (!newEditor.isDisposed()) {
newEditor.dispose();
}
}
});
newEditor.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
if (event.type == SWT.Modify) {
Text text = (Text) editor.getEditor();
if (null != text) {
editor.getItem().setText(text.getText());
}
}
}
});
newEditor.addListener(SWT.DefaultSelection, new Listener() {
@Override
public void handleEvent(Event event) {
if (event.type == SWT.DefaultSelection) {
if (!newEditor.isDisposed()) {
newEditor.dispose();
}
}
}
});
newEditor.selectAll();
newEditor.setFocus();
}
});
}
-------- /SNIPPET ---------
-------- STACK TRACE ------
java.lang.IllegalArgumentException: The control was not added to this
control holder.
at org.eclipse.swt.widgets.ControlHolder.remove(ControlHolder.j ava:62)
at org.eclipse.swt.widgets.Composite.removeControl(Composite.ja va:715)
at org.eclipse.swt.widgets.Control.releaseParent(Control.java:1 543)
at org.eclipse.swt.widgets.Widget.dispose(Widget.java:611)
at
ca.dictio.nnaire.ui.eclipse.ve.views.FavorisView$1$1.focusLo st(FavorisView.java:141)
at org.eclipse.swt.events.FocusEvent.dispatchToObserver(FocusEv ent.java:68)
at org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:114)
at org.eclipse.swt.widgets.Display.setFocusControl(Display.java :242)
at org.eclipse.swt.widgets.Display.access$1(Display.java:237)
at
org.eclipse.swt.widgets.Display$DisplayAdapter.setFocusContr ol(Display.java:1000)
at org.eclipse.swt.widgets.Control.setFocusControl(Control.java :1609)
at org.eclipse.swt.widgets.Control.releaseWidget(Control.java:1 563)
at org.eclipse.swt.widgets.Widget.dispose(Widget.java:612)
at
ca.dictio.nnaire.ui.eclipse.ve.views.FavorisView$1.doubleCli ck(FavorisView.java:112)
at
org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:781)
at org.eclipse.jface.util.SafeRunnable$3.run(SafeRunnable.java: 154)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:19 3)
at
org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:779)
at
org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1379)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1155)
at
org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:226)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:223)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:284)
at
org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatc hEvent(UntypedEventAdapter.java:306)
at
org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetD efaultSelected(UntypedEventAdapter.java:67)
at
org.eclipse.swt.events.SelectionEvent.dispatchToObserver(Sel ectionEvent.java:177)
at org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:114)
at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.jav a:154)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.readAndDispa tch(RWTLifeCycle.java:243)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :682)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2311)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2274)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:373)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:154)
at
ca.dictio.nnaire.ui.eclipse.rap.VeWorkbench.createUI(VeWorkb ench.java:42)
at
org.eclipse.rwt.internal.lifecycle.EntryPointManager.createU I(EntryPointManager.java:92)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWT LifeCycle.java:230)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadCont roller.run(RWTLifeCycle.java:116)
at java.lang.Thread.run(Thread.java:619)
-------- STACK TRACE ------
|
|
|
Re: TreeEditor problems [message #85761 is a reply to message #85734] |
Fri, 02 May 2008 07:27   |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
seems to be that there is some infrastructure in RWT missing/behaving
wrong - yes, please file a bug, thank you.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Benoit Mercier [mailto:benoit.mercier@usherbrooke.ca]
Bereitgestellt: Donnerstag, 1. Mai 2008 20:49
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: TreeEditor problems
Betreff: TreeEditor problems
Hi,
When calling the following snippet from ViewPart.createPartControl() we
encounter 2 problems:
1) The "editor box" appears in the upper left corner of the tree
(instead of over the doubleclicked item)
2) After the first modification, we get a stack trace (see below)
stating "The control was not added to this control holder." So there
seems to be a problem with text.dispose()
We don't get this behavior in RCP.
Any ideas? Should we file a bug report?
Thanks
Benoit
-------- SNIPPET ---------
private void addDoubleClickListener(TreeViewer treeViewer) { final Tree
tree = treeViewer.getTree();
for (int i = 0; i < 16; i++)
{
TreeItem itemI = new TreeItem(tree, SWT.NONE);
itemI.setText("Item " + i);
for (int j = 0; j < 16; j++)
{
TreeItem itemJ = new TreeItem(itemI, SWT.NONE);
itemJ.setText("Item " + j);
}
}
final TreeEditor editor = new TreeEditor(tree); // The editor must have
the same size as the cell and must // not be any smaller than 50 pixels.
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;
editor.verticalAlignment = SWT.CENTER;
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null && !oldEditor.isDisposed()) {
oldEditor.dispose();
}
// Identify the selected row
TreeItem[] selection = tree.getSelection();
final TreeItem item = selection[0];
if (item == null) {
return;
}
// The control that will be the editor must be a
// child of the Tree
final Text newEditor = new Text(tree, SWT.NONE);
newEditor.setText(item.getText());
editor.setEditor(newEditor, item);
newEditor.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
if (!newEditor.isDisposed()) {
newEditor.dispose();
}
}
});
newEditor.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
if (event.type == SWT.Modify) {
Text text = (Text) editor.getEditor();
if (null != text) {
editor.getItem().setText(text.getText());
}
}
}
});
newEditor.addListener(SWT.DefaultSelection, new Listener() {
@Override
public void handleEvent(Event event) {
if (event.type == SWT.DefaultSelection) {
if (!newEditor.isDisposed()) {
newEditor.dispose();
}
}
}
});
newEditor.selectAll();
newEditor.setFocus();
}
});
}
-------- /SNIPPET ---------
-------- STACK TRACE ------
java.lang.IllegalArgumentException: The control was not added to this
control holder.
at
org.eclipse.swt.widgets.ControlHolder.remove(ControlHolder.j ava:62)
at
org.eclipse.swt.widgets.Composite.removeControl(Composite.ja va:715)
at
org.eclipse.swt.widgets.Control.releaseParent(Control.java:1 543)
at org.eclipse.swt.widgets.Widget.dispose(Widget.java:611)
at
ca.dictio.nnaire.ui.eclipse.ve.views.FavorisView$1$1.focusLo st(FavorisVi
ew.java:141)
at
org.eclipse.swt.events.FocusEvent.dispatchToObserver(FocusEv ent.java:68)
at
org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
at
org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:114)
at
org.eclipse.swt.widgets.Display.setFocusControl(Display.java :242)
at org.eclipse.swt.widgets.Display.access$1(Display.java:237)
at
org.eclipse.swt.widgets.Display$DisplayAdapter.setFocusContr ol(Display.j
ava:1000)
at
org.eclipse.swt.widgets.Control.setFocusControl(Control.java :1609)
at
org.eclipse.swt.widgets.Control.releaseWidget(Control.java:1 563)
at org.eclipse.swt.widgets.Widget.dispose(Widget.java:612)
at
ca.dictio.nnaire.ui.eclipse.ve.views.FavorisView$1.doubleCli ck(FavorisVi
ew.java:112)
at
org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:7
81)
at
org.eclipse.jface.util.SafeRunnable$3.run(SafeRunnable.java: 154)
at
org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:19 3)
at
org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredVie
wer.java:779)
at
org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(Abstract
TreeViewer.java:1379)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(Struc
turedViewer.java:1155)
at
org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrate
gy.java:226)
at
org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:223)
at
org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:284)
at
org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatc hEvent(Untyp
edEventAdapter.java:306)
at
org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetD efaultSelect
ed(UntypedEventAdapter.java:67)
at
org.eclipse.swt.events.SelectionEvent.dispatchToObserver(Sel ectionEvent.
java:177)
at
org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
at
org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:114)
at
org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.jav a:154)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.readAndDispa tch(RWTLifeC
ycle.java:243)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :682)
at
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2311)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2274)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:3
73)
at
org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:154)
at
ca.dictio.nnaire.ui.eclipse.rap.VeWorkbench.createUI(VeWorkb ench.java:42
)
at
org.eclipse.rwt.internal.lifecycle.EntryPointManager.createU I(EntryPoint
Manager.java:92)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWT LifeCycle.ja
va:230)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadCont roller.run(R
WTLifeCycle.java:116)
at java.lang.Thread.run(Thread.java:619)
-------- STACK TRACE ------
|
|
|
Re: TreeEditor problems [message #85776 is a reply to message #85761] |
Fri, 02 May 2008 07:46   |
Eclipse User |
|
|
|
Originally posted by: ifurnadjiev.innoopract.com
Hi,
for the problem 1) there is already a bug filed in bugzilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=219374
Best,
Ivan
Frank Appel wrote:
> Hi,
>
> seems to be that there is some infrastructure in RWT missing/behaving
> wrong - yes, please file a bug, thank you.
>
>
>
> Ciao
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Benoit Mercier [mailto:benoit.mercier@usherbrooke.ca]
> Bereitgestellt: Donnerstag, 1. Mai 2008 20:49
> Bereitgestellt in: eclipse.technology.rap
> Unterhaltung: TreeEditor problems
> Betreff: TreeEditor problems
>
>
> Hi,
>
> When calling the following snippet from ViewPart.createPartControl() we
> encounter 2 problems:
>
> 1) The "editor box" appears in the upper left corner of the tree
> (instead of over the doubleclicked item)
>
> 2) After the first modification, we get a stack trace (see below)
> stating "The control was not added to this control holder." So there
> seems to be a problem with text.dispose()
>
> We don't get this behavior in RCP.
>
> Any ideas? Should we file a bug report?
>
> Thanks
>
> Benoit
>
> -------- SNIPPET ---------
> private void addDoubleClickListener(TreeViewer treeViewer) { final Tree
> tree = treeViewer.getTree();
>
> for (int i = 0; i < 16; i++)
> {
> TreeItem itemI = new TreeItem(tree, SWT.NONE);
> itemI.setText("Item " + i);
> for (int j = 0; j < 16; j++)
> {
> TreeItem itemJ = new TreeItem(itemI, SWT.NONE);
> itemJ.setText("Item " + j);
> }
> }
>
> final TreeEditor editor = new TreeEditor(tree); // The editor must have
> the same size as the cell and must // not be any smaller than 50 pixels.
> editor.horizontalAlignment = SWT.LEFT;
> editor.grabHorizontal = true;
> editor.minimumWidth = 50;
> editor.verticalAlignment = SWT.CENTER;
>
> treeViewer.addDoubleClickListener(new IDoubleClickListener() {
>
> @Override
> public void doubleClick(DoubleClickEvent event) {
> // Clean up any previous editor control
> Control oldEditor = editor.getEditor();
> if (oldEditor != null && !oldEditor.isDisposed()) {
> oldEditor.dispose();
> }
>
> // Identify the selected row
> TreeItem[] selection = tree.getSelection();
> final TreeItem item = selection[0];
> if (item == null) {
> return;
> }
>
> // The control that will be the editor must be a
> // child of the Tree
> final Text newEditor = new Text(tree, SWT.NONE);
> newEditor.setText(item.getText());
> editor.setEditor(newEditor, item);
>
> newEditor.addFocusListener(new FocusListener() {
> @Override
> public void focusGained(FocusEvent e) {
>
> }
>
> @Override
> public void focusLost(FocusEvent e) {
> if (!newEditor.isDisposed()) {
> newEditor.dispose();
> }
> }
> });
>
> newEditor.addListener(SWT.Modify, new Listener() {
>
> @Override
> public void handleEvent(Event event) {
> if (event.type == SWT.Modify) {
> Text text = (Text) editor.getEditor();
> if (null != text) {
> editor.getItem().setText(text.getText());
> }
> }
> }
> });
>
> newEditor.addListener(SWT.DefaultSelection, new Listener() {
>
> @Override
> public void handleEvent(Event event) {
> if (event.type == SWT.DefaultSelection) {
> if (!newEditor.isDisposed()) {
> newEditor.dispose();
> }
> }
> }
> });
>
> newEditor.selectAll();
> newEditor.setFocus();
> }
>
> });
> }
> -------- /SNIPPET ---------
>
> -------- STACK TRACE ------
>
> java.lang.IllegalArgumentException: The control was not added to this
> control holder.
> at
> org.eclipse.swt.widgets.ControlHolder.remove(ControlHolder.j ava:62)
> at
> org.eclipse.swt.widgets.Composite.removeControl(Composite.ja va:715)
> at
> org.eclipse.swt.widgets.Control.releaseParent(Control.java:1 543)
> at org.eclipse.swt.widgets.Widget.dispose(Widget.java:611)
> at
> ca.dictio.nnaire.ui.eclipse.ve.views.FavorisView$1$1.focusLo st(FavorisVi
> ew.java:141)
> at
> org.eclipse.swt.events.FocusEvent.dispatchToObserver(FocusEv ent.java:68)
> at
> org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
> at
> org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:114)
> at
> org.eclipse.swt.widgets.Display.setFocusControl(Display.java :242)
> at org.eclipse.swt.widgets.Display.access$1(Display.java:237)
> at
> org.eclipse.swt.widgets.Display$DisplayAdapter.setFocusContr ol(Display.j
> ava:1000)
> at
> org.eclipse.swt.widgets.Control.setFocusControl(Control.java :1609)
> at
> org.eclipse.swt.widgets.Control.releaseWidget(Control.java:1 563)
> at org.eclipse.swt.widgets.Widget.dispose(Widget.java:612)
> at
> ca.dictio.nnaire.ui.eclipse.ve.views.FavorisView$1.doubleCli ck(FavorisVi
> ew.java:112)
> at
> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:7
> 81)
> at
> org.eclipse.jface.util.SafeRunnable$3.run(SafeRunnable.java: 154)
> at
> org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:19 3)
> at
> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredVie
> wer.java:779)
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(Abstract
> TreeViewer.java:1379)
> at
> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(Struc
> turedViewer.java:1155)
> at
> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrate
> gy.java:226)
> at
> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:223)
> at
> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:284)
> at
> org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatc hEvent(Untyp
> edEventAdapter.java:306)
> at
> org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetD efaultSelect
> ed(UntypedEventAdapter.java:67)
> at
> org.eclipse.swt.events.SelectionEvent.dispatchToObserver(Sel ectionEvent.
> java:177)
> at
> org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
> at
> org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:114)
> at
> org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.jav a:154)
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.readAndDispa tch(RWTLifeC
> ycle.java:243)
> at
> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :682)
> at
> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2311)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2274)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:3
> 73)
> at
> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:154)
> at
> ca.dictio.nnaire.ui.eclipse.rap.VeWorkbench.createUI(VeWorkb ench.java:42
> )
> at
> org.eclipse.rwt.internal.lifecycle.EntryPointManager.createU I(EntryPoint
> Manager.java:92)
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWT LifeCycle.ja
> va:230)
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadCont roller.run(R
> WTLifeCycle.java:116)
> at java.lang.Thread.run(Thread.java:619)
> -------- STACK TRACE ------
>
>
|
|
|
Re: TreeEditor problems [message #85806 is a reply to message #85761] |
Fri, 02 May 2008 16:21  |
Eclipse User |
|
|
|
Hi,
Bug filed. Thank you.
Benoit
> Hi,
>
> seems to be that there is some infrastructure in RWT missing/behaving
> wrong - yes, please file a bug, thank you.
>
>
>
> Ciao
> Frank
>
|
|
|
Powered by
FUDForum. Page generated in 0.04140 seconds