[JFace] tristate tree viewer [message #334836] |
Mon, 02 March 2009 13:04  |
Eclipse User |
|
|
|
Originally posted by: alamothe.ptt.yu
Hi,
I'm unsuccessfully trying to get a tristate behaviour in CheckboxTreeViewer,
that is an item can be checked, grayed or unchecked. Is this the limitation
of JFace, SWT Tree control or I'm doing something wrong??
|
|
|
|
|
|
Re: [JFace] tristate tree viewer [message #334849 is a reply to message #334843] |
Tue, 03 March 2009 06:28   |
Eclipse User |
|
|
|
It should be possible to work around this.I thought I'll share this - hope
it helps.
It is possible to add a ICheckStateListener and manipulate the state, for
example :
chkBoxViewer.addCheckStateListener(new ICheckStateListener(){
public void checkStateChanged(CheckStateChangedEvent event) {
MyModel item=(MyModel) event.getElement();
switch (item.state) {
case 0:{
chkBoxViewer.setGrayChecked(item, true);
break;
}
case 1:{
chkBoxViewer.setGrayed(item, false);
chkBoxViewer.setChecked(item, true);
break;
}
case 2:{
chkBoxViewer.setGrayChecked(item, false);
break;
}
}
item.state=++item.state%3;
}
});
Hitesh
Nikola Mihajlovic wrote:
> While I can programatically set one of the three states, a user cannot cycle
> between three states with a mouse click, but only between two. Since it's a
> problem with SWT, I've posted this on their newsgroup (the same problem
> exists with a regular checkbox, that is not inside the Tree)
> Mircea Luchian wrote:
>> Use "checkboxTreeViewer.setChecked()" and
>> "checkboxTreeViewer.setGrayChecked()". This will give you the tristate
>> behavior.
>>
>> Mircea
>>
>> Nikola Mihajlovic wrote:
>>> It appears to be a limitation of SWT...
>>>
>>> Nikola Mihajlovic wrote:
>>>
>>>> Hi,
>>>> I'm unsuccessfully trying to get a tristate behaviour in
>>>> CheckboxTreeViewer, that is an item can be checked, grayed or
>>>> unchecked. Is this the limitation of JFace, SWT Tree control or I'm
>>>> doing something wrong??
|
|
|
Re: [JFace] tristate tree viewer [message #334850 is a reply to message #334849] |
Tue, 03 March 2009 08:13  |
Eclipse User |
|
|
|
Originally posted by: alamothe.ptt.yu
Thanks! It's exactly how I solved this problem :-)
Hitesh wrote:
> It should be possible to work around this.I thought I'll share this -
> hope it helps.
> It is possible to add a ICheckStateListener and manipulate the state,
> for example :
>
> chkBoxViewer.addCheckStateListener(new ICheckStateListener(){
> public void checkStateChanged(CheckStateChangedEvent event) {
>
> MyModel item=(MyModel) event.getElement();
> switch (item.state) {
> case 0:{
> chkBoxViewer.setGrayChecked(item, true);
> break;
> }
> case 1:{
> chkBoxViewer.setGrayed(item, false);
> chkBoxViewer.setChecked(item, true);
> break;
> }
> case 2:{
> chkBoxViewer.setGrayChecked(item, false);
> break;
> }
> }
> item.state=++item.state%3;
> }
> });
>
>
> Hitesh
>
> Nikola Mihajlovic wrote:
>
>> While I can programatically set one of the three states, a user
>> cannot cycle between three states with a mouse click, but only
>> between two. Since it's a problem with SWT, I've posted this on
>> their newsgroup (the same problem exists with a regular checkbox,
>> that is not inside the Tree)
>
>> Mircea Luchian wrote:
>>> Use "checkboxTreeViewer.setChecked()" and
>>> "checkboxTreeViewer.setGrayChecked()". This will give you the
>>> tristate behavior.
>>>
>>> Mircea
>>>
>>> Nikola Mihajlovic wrote:
>>>> It appears to be a limitation of SWT...
>>>>
>>>> Nikola Mihajlovic wrote:
>>>>
>>>>> Hi,
>>>>> I'm unsuccessfully trying to get a tristate behaviour in
>>>>> CheckboxTreeViewer, that is an item can be checked, grayed or
>>>>> unchecked. Is this the limitation of JFace, SWT Tree control or
>>>>> I'm doing something wrong??
|
|
|
Powered by
FUDForum. Page generated in 0.03230 seconds