Home » Eclipse Projects » Eclipse Platform » Remove button from TableViewer Item
| |
Re: Remove button from TableViewer Item [message #325524 is a reply to message #325503] |
Thu, 21 February 2008 05:28 |
Eclipse User |
|
|
|
Originally posted by: chinfo.michiganreview.org
This is a multi-part message in MIME format.
--------------070201090400040805010609
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hello,
I'm having a similar problem, but disposing of the editor didn't seem to
do the trick. Any thoughts on what I'm missing?
In my case, I remove elements from the model, refresh the TableViewer,
get a reduced number of cell labels, but the original set of native
controls remain in the viewer.
I've copied the pertinent code below, and attached the full class
(adapted from the ExampleTableViewerWithNativeControls snippet).
Thanks in advance for your help.
-Christoph
------------------------------------------------
final TableEditor editor = new TableEditor(item.getParent());
Composite comp = new Composite(item.getParent(),SWT.NONE);
comp.setBackground(item.getParent().getBackground());
comp.setBackgroundMode(SWT.INHERIT_DEFAULT);
RowLayout l = new RowLayout();
l.marginHeight=0;
l.marginWidth=0;
l.marginTop=0;
l.marginBottom=0;
comp.setLayout(l);
Button button = new Button(comp, SWT.PUSH);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
System.out.println("Selection Event on: " + item);
}
});
button.setText("Push Me");
item.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
editor.dispose();
}
});
editor.grabHorizontal=true;
editor.setEditor(comp, item, 1);
Tom Schindl wrote:
> You need to dispose the editor for the item. The best idea IMHO is to
> install a dispose listener on the item and dispose the Editor if the
> item is diposed.
>
> Activating multiple editors will eat up your native handles you are
> running into resource problems. That's why I normally suggest not to use
> multiple editors at once but fake the button using an image which can be
> reused. It by the way doesn't look good if your application runs on OS-X
> because buttons there can not be made small than a certain size!
>
> Tom
>
> J
|
|
|
Re: Remove button from TableViewer Item [message #325531 is a reply to message #325524] |
Thu, 21 February 2008 08:43 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
It seems that you also have to dipose the underlying control:
editor.getEditor().dispose();
Tom
Christoph Hoashi-Erhardt schrieb:
> Hello,
>
> I'm having a similar problem, but disposing of the editor didn't seem to
> do the trick. Any thoughts on what I'm missing?
>
> In my case, I remove elements from the model, refresh the TableViewer,
> get a reduced number of cell labels, but the original set of native
> controls remain in the viewer.
>
> I've copied the pertinent code below, and attached the full class
> (adapted from the ExampleTableViewerWithNativeControls snippet).
>
> Thanks in advance for your help.
>
> -Christoph
>
> ------------------------------------------------
>
> final TableEditor editor = new TableEditor(item.getParent());
> Composite comp = new Composite(item.getParent(),SWT.NONE);
>
> comp.setBackground(item.getParent().getBackground());
> comp.setBackgroundMode(SWT.INHERIT_DEFAULT);
> RowLayout l = new RowLayout();
> l.marginHeight=0;
> l.marginWidth=0;
> l.marginTop=0;
> l.marginBottom=0;
> comp.setLayout(l);
> Button button = new Button(comp, SWT.PUSH);
>
> button.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent event) {
> System.out.println("Selection Event on: " + item);
> }
> });
> button.setText("Push Me");
> item.addDisposeListener(new DisposeListener() {
> public void widgetDisposed(DisposeEvent event) {
> editor.dispose();
> }
> });
>
> editor.grabHorizontal=true;
> editor.setEditor(comp, item, 1);
>
>
>
> Tom Schindl wrote:
>> You need to dispose the editor for the item. The best idea IMHO is to
>> install a dispose listener on the item and dispose the Editor if the
>> item is diposed.
>>
>> Activating multiple editors will eat up your native handles you are
>> running into resource problems. That's why I normally suggest not to
>> use multiple editors at once but fake the button using an image which
>> can be reused. It by the way doesn't look good if your application
>> runs on OS-X because buttons there can not be made small than a
>> certain size!
>>
>> Tom
>>
>> Jörg schrieb:
>>> Hello,
>>>
>>> i have an TableViewer with Button on some cells. The following code
>>> creates them for me.
>>>
>>> for(int i =0; i<items.length;i++) {
>>> TableItem item = items[i];
>>> TableEditor editor = new TableEditor(table);
>>> Button button = new Button(table, SWT.PUSH);
>>> button.setText("add");
>>> button.pack();
>>> editor.minimumWidth = button.getSize().x;
>>> editor.horizontalAlignment = SWT.LEFT;
>>> editor.setEditor(button, item, Layer.getMaxColumn());
>>> buttonListener BL = new buttonListener(i);
>>> button.addSelectionListener(BL);
>>> }
>>>
>>> Now i change the number of columns in my view. Here i want to remove
>>> these "old" buttons from the cells. How can i do this?
>>> viewer.getTable.clearAll() removes only the text from the cells, but
>>> not the buttons. And the javadoc from item and table doesn't really
>>> helped me here.
>>>
>>> Greetrings
>>
>>
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
Re: Remove button from TableViewer Item [message #325535 is a reply to message #325531] |
Thu, 21 February 2008 10:21 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi,
I've updated the snippet to dispose the created editors when needed.
Tom
Tom Schindl schrieb:
> It seems that you also have to dipose the underlying control:
>
> editor.getEditor().dispose();
>
> Tom
>
> Christoph Hoashi-Erhardt schrieb:
>> Hello,
>>
>> I'm having a similar problem, but disposing of the editor didn't seem
>> to do the trick. Any thoughts on what I'm missing?
>>
>> In my case, I remove elements from the model, refresh the TableViewer,
>> get a reduced number of cell labels, but the original set of native
>> controls remain in the viewer.
>>
>> I've copied the pertinent code below, and attached the full class
>> (adapted from the ExampleTableViewerWithNativeControls snippet).
>>
>> Thanks in advance for your help.
>>
>> -Christoph
>>
>> ------------------------------------------------
>>
>> final TableEditor editor = new TableEditor(item.getParent());
>> Composite comp = new Composite(item.getParent(),SWT.NONE);
>>
>> comp.setBackground(item.getParent().getBackground());
>> comp.setBackgroundMode(SWT.INHERIT_DEFAULT);
>> RowLayout l = new RowLayout();
>> l.marginHeight=0;
>> l.marginWidth=0;
>> l.marginTop=0;
>> l.marginBottom=0;
>> comp.setLayout(l);
>> Button button = new Button(comp, SWT.PUSH);
>> button.addSelectionListener(new SelectionAdapter() {
>> public void widgetSelected(SelectionEvent event) {
>> System.out.println("Selection Event on: " + item);
>> }
>> });
>> button.setText("Push Me");
>> item.addDisposeListener(new DisposeListener() {
>> public void widgetDisposed(DisposeEvent event) {
>> editor.dispose();
>> }
>> });
>> editor.grabHorizontal=true;
>> editor.setEditor(comp, item, 1);
>>
>>
>>
>> Tom Schindl wrote:
>>> You need to dispose the editor for the item. The best idea IMHO is to
>>> install a dispose listener on the item and dispose the Editor if the
>>> item is diposed.
>>>
>>> Activating multiple editors will eat up your native handles you are
>>> running into resource problems. That's why I normally suggest not to
>>> use multiple editors at once but fake the button using an image which
>>> can be reused. It by the way doesn't look good if your application
>>> runs on OS-X because buttons there can not be made small than a
>>> certain size!
>>>
>>> Tom
>>>
>>> Jörg schrieb:
>>>> Hello,
>>>>
>>>> i have an TableViewer with Button on some cells. The following code
>>>> creates them for me.
>>>>
>>>> for(int i =0; i<items.length;i++) {
>>>> TableItem item = items[i];
>>>> TableEditor editor = new TableEditor(table);
>>>> Button button = new Button(table, SWT.PUSH);
>>>> button.setText("add");
>>>> button.pack();
>>>> editor.minimumWidth = button.getSize().x;
>>>> editor.horizontalAlignment = SWT.LEFT;
>>>> editor.setEditor(button, item, Layer.getMaxColumn());
>>>> buttonListener BL = new buttonListener(i);
>>>> button.addSelectionListener(BL);
>>>> }
>>>>
>>>> Now i change the number of columns in my view. Here i want to remove
>>>> these "old" buttons from the cells. How can i do this?
>>>> viewer.getTable.clearAll() removes only the text from the cells, but
>>>> not the buttons. And the javadoc from item and table doesn't really
>>>> helped me here.
>>>>
>>>> Greetrings
>>>
>>>
>>
>
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
| |
Re: Remove button from TableViewer Item [message #325563 is a reply to message #325535] |
Fri, 22 February 2008 03:48 |
Christoph Messages: 55 Registered: July 2009 |
Member |
|
|
Thanks so much for your help.
-Christoph
Tom Schindl wrote:
> Hi,
>
> I've updated the snippet to dispose the created editors when needed.
>
> Tom
>
> Tom Schindl schrieb:
>> It seems that you also have to dipose the underlying control:
>>
>> editor.getEditor().dispose();
>>
>> Tom
>>
>> Christoph Hoashi-Erhardt schrieb:
>>> Hello,
>>>
>>> I'm having a similar problem, but disposing of the editor didn't seem
>>> to do the trick. Any thoughts on what I'm missing?
>>>
>>> In my case, I remove elements from the model, refresh the
>>> TableViewer, get a reduced number of cell labels, but the original
>>> set of native controls remain in the viewer.
>>>
>>> I've copied the pertinent code below, and attached the full class
>>> (adapted from the ExampleTableViewerWithNativeControls snippet).
>>>
>>> Thanks in advance for your help.
>>>
>>> -Christoph
>>>
>>> ------------------------------------------------
>>>
>>> final TableEditor editor = new TableEditor(item.getParent());
>>> Composite comp = new Composite(item.getParent(),SWT.NONE);
>>>
>>> comp.setBackground(item.getParent().getBackground());
>>> comp.setBackgroundMode(SWT.INHERIT_DEFAULT);
>>> RowLayout l = new RowLayout();
>>> l.marginHeight=0;
>>> l.marginWidth=0;
>>> l.marginTop=0;
>>> l.marginBottom=0;
>>> comp.setLayout(l);
>>> Button button = new Button(comp, SWT.PUSH);
>>> button.addSelectionListener(new SelectionAdapter() {
>>> public void widgetSelected(SelectionEvent event) {
>>> System.out.println("Selection Event on: " + item);
>>> }
>>> });
>>> button.setText("Push Me");
>>> item.addDisposeListener(new DisposeListener() {
>>> public void widgetDisposed(DisposeEvent event) {
>>> editor.dispose();
>>> }
>>> });
>>> editor.grabHorizontal=true;
>>> editor.setEditor(comp, item, 1);
>>>
>>>
>>>
>>> Tom Schindl wrote:
>>>> You need to dispose the editor for the item. The best idea IMHO is
>>>> to install a dispose listener on the item and dispose the Editor if
>>>> the item is diposed.
>>>>
>>>> Activating multiple editors will eat up your native handles you are
>>>> running into resource problems. That's why I normally suggest not to
>>>> use multiple editors at once but fake the button using an image
>>>> which can be reused. It by the way doesn't look good if your
>>>> application runs on OS-X because buttons there can not be made small
>>>> than a certain size!
>>>>
>>>> Tom
>>>>
>>>> Jörg schrieb:
>>>>> Hello,
>>>>>
>>>>> i have an TableViewer with Button on some cells. The following code
>>>>> creates them for me.
>>>>>
>>>>> for(int i =0; i<items.length;i++) {
>>>>> TableItem item = items[i];
>>>>> TableEditor editor = new TableEditor(table);
>>>>> Button button = new Button(table, SWT.PUSH);
>>>>> button.setText("add");
>>>>> button.pack();
>>>>> editor.minimumWidth = button.getSize().x;
>>>>> editor.horizontalAlignment = SWT.LEFT;
>>>>> editor.setEditor(button, item, Layer.getMaxColumn());
>>>>> buttonListener BL = new buttonListener(i);
>>>>> button.addSelectionListener(BL);
>>>>> }
>>>>>
>>>>> Now i change the number of columns in my view. Here i want to
>>>>> remove these "old" buttons from the cells. How can i do this?
>>>>> viewer.getTable.clearAll() removes only the text from the cells,
>>>>> but not the buttons. And the javadoc from item and table doesn't
>>>>> really helped me here.
>>>>>
>>>>> Greetrings
>>>>
>>>>
>>>
>>
>>
>
>
|
|
|
Goto Forum:
Current Time: Sat Nov 09 03:29:49 GMT 2024
Powered by FUDForum. Page generated in 0.25612 seconds
|