|Re: Treeviewer/-column, celleditor [message #549914 is a reply to message #549730]
||Wed, 28 July 2010 12:58
| Daniel KrÃ¼gler
Registered: July 2009
On 27.07.2010 20:17, Mark wrote:|
> Hi All,
> still new in SWT and still some troubles. And I really hope for some help.
> For my current project I use a treeviewer/-column to display a tree in a
> table. Now, I want to add in the table a button, to give the user the
> possibility, to delete one row / data record.
> A long search through the web didn't result in anything. Can somebody
> give me a hint, how to do this?
The general idea is:
a) Use a label provider that returns an image of the corresponding
image, in your case the image of normal (non-checkbox) button. Follow
PersonLabelProvider#getColumnImage for further reference (You probably
will use a CellLabelProvider, but the key point is, where to return the
b) Provide an EditingSupport that acts on booleans (reflecting the
two diffent states (Search for PersonEditingSupport), here you need
to provide a reasonable CellEditor. I suggest to start with
TextCellEditor, but change the Text widget to a Button. Search for
BooleanCellEditor for a better approximation of that (You find
references to it in jface snippets), or just use
http://www.devdaily.com/java/jwarehouse/eclipse/org.eclipse. jface.snippets/Eclipse-JFace-Snippets/org/eclipse/jface/snip pets/viewers/BooleanCellEditor.java.shtml
With the setValue override of your EditingSupport class you will
finally need to remove the wanted data rows. I suggest to do this in
a) Let your data model provide a remove method and call this function
which again sends a model change notification.
b) Let your data model provide registration for model changes and
register your content provider for that. Insider the handler call
viewer.refresh in the UI thread.
For not very advanced situations you can shorten (a) + (b) to:
a') Remove the data from your data model and invoke Viewer.refresh
HTH & Greetings from Bremen,
Powered by FUDForum
. Page generated in 0.02510 seconds