leave preference page with invalid values [message #313564] |
Mon, 19 March 2007 11:57  |
Eclipse User |
|
|
|
Hi all
I've a preference page and I fill in some invalid value. Then I want to
switch to a second preference page with an implicit 'cancel' of the invalid
value.
Currently, I've to cancel the page explicitly with the button and then
reopen the preference dialog and start again navigating to the page I want
to change.
How is it possible to switch to a second page with implicit cancel?
Thanks,
Martin
|
|
|
|
|
Re: leave preference page with invalid values [message #313624 is a reply to message #313614] |
Tue, 20 March 2007 14:31  |
Eclipse User |
|
|
|
Originally posted by: vb.prismtech.com
I guess you are right. isValid() does get called before okToLeave();
What if you overrode the isValid() to validate , fix and always return true.
eg
Let's say you had a StringFieldEditor sc.
You would have something like this:
public boolean isValid() {
if( notValid (sc.getStringValue() )
sc.setStringValue(validValue);
return true;
}
I havent tested this and seems a bit crude :) . If you find something, do
post it.
Thanks
"Martin Skorsky" <Martin.Skorsky@softwareag.com> wrote in message
news:etp3o4$41o$1@utils.eclipse.org...
> My first guess: great, that's exactly what I want. Thanks!
>
> second guess (after debugging and experimenting):
> isValid() is called before okToLeave().
> And if isValid() returns false, obToLeave() is not called.
> Are these methods blocking each other?
> AFAIK isValid should be set to false whenever invalid values are detected.
> But then I don't have a chance to ignore the invalid values in okToLeave()
> and cancel the input.
>
> "Vikram" <vb@prismtech.com> wrote in message
> news:etmlrd$s2i$1@utils.eclipse.org...
>> The PreferencePage class has a method called
>> public boolean okToLeave() {
>> return isValid();
>> }
>> which validates your page when you switch.
>> Overriding this might help. ie; If the values are invalid, you could
>> clear them out and return true.
>>
>>
>>
>>
>> "Martin Skorsky" <Martin.Skorsky@softwareag.com> wrote in message
>> news:etmbtn$qlh$1@utils.eclipse.org...
>>> Hi all
>>>
>>> I've a preference page and I fill in some invalid value. Then I want to
>>> switch to a second preference page with an implicit 'cancel' of the
>>> invalid value.
>>>
>>> Currently, I've to cancel the page explicitly with the button and then
>>> reopen the preference dialog and start again navigating to the page I
>>> want to change.
>>>
>>> How is it possible to switch to a second page with implicit cancel?
>>>
>>> Thanks,
>>>
>>> Martin
>>>
>>>
>>>
>>
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.22990 seconds