Home » Eclipse Projects » Eclipse Platform » Properties view question - what about bad values?
Properties view question - what about bad values? [message #307118] |
Mon, 14 August 2006 13:07  |
Eclipse User |
|
|
|
Originally posted by: combs.edgedynamics.com
I'd appreciate any help on the following:
I've got a TreeViewer that's showing a number of objects
that I want to adjust through the Properties view. I've
set things up so that the properties show correctly in
the Properties view. What I'm wondering is how, if at all,
the Properties view (through the 'setPropertyValue' method
on the IPropertySource) allows the IPropertySource object
to indicate that the value the user entered isn't valid?
For example, if I have a property that's a text entry but
is expecting the user to type in an integer and they don't,
is there any current mechanism to show an error, or blow
the value away, or otherwise let the IPropertySource say
"hey, that entry isn't good"?
Thanks for any help on this one!
Dave Combs
|
|
| | |
Re: Properties view question - what about bad values? [message #307124 is a reply to message #307122] |
Mon, 14 August 2006 13:54   |
Eclipse User |
|
|
|
Originally posted by: combs.edgedynamics.com
vikram wrote:
This is the type of solution I had implemented for myself in
the Swing app that this Eclipse app is being ported from.
One other question, though--if I do decide to reset/ignore
the property change in setPropertyValue and display an error
message, is the property view smart enough to notice that the
value the user had typed in was not stored and to display
whatever value is really there when the setPropertyValue()
call is completed? I'll experiment, but was curious if anybody
knows already.
Thanks for the help--much appreciated!
Dave
> You could also do the validations in the setPropertyValue method.
> If a prop val is invalid, you could reset it and display a message in
> the status bar
>
> Dave Combs wrote:
>
>> I'd appreciate any help on the following:
>>
>> I've got a TreeViewer that's showing a number of objects
>> that I want to adjust through the Properties view. I've
>> set things up so that the properties show correctly in
>> the Properties view. What I'm wondering is how, if at all,
>> the Properties view (through the 'setPropertyValue' method
>> on the IPropertySource) allows the IPropertySource object
>> to indicate that the value the user entered isn't valid?
>> For example, if I have a property that's a text entry but
>> is expecting the user to type in an integer and they don't,
>> is there any current mechanism to show an error, or blow
>> the value away, or otherwise let the IPropertySource say
>> "hey, that entry isn't good"?
>>
>> Thanks for any help on this one!
>> Dave Combs
>>
|
|
|
Re: Properties view question - what about bad values? [message #307130 is a reply to message #307124] |
Mon, 14 August 2006 14:12   |
Eclipse User |
|
|
|
Originally posted by: vik_ram.hotmail.com
The getPropertyValue is always invoked after the setPropertyValue ( if I
remember correctly ). So, the value displayed will be whatever you
return in the getter.
Let's say your model variable is m_model, you could do something like this.
Object getPropertyValue(Object id)
{
if(id.equals("NAME")
{
return m_model.getName();
}
}
void setPropertyValue(Object id, Object val)
{
if(id.equals("NAME")
{
String name = (String)val;
if(isValid(name) )
{
m_model.setValue(name);
}
else
m_model.setValue("");
}
}
Dave Combs wrote:
> vikram wrote:
>
> This is the type of solution I had implemented for myself in
> the Swing app that this Eclipse app is being ported from.
>
> One other question, though--if I do decide to reset/ignore
> the property change in setPropertyValue and display an error
> message, is the property view smart enough to notice that the
> value the user had typed in was not stored and to display
> whatever value is really there when the setPropertyValue()
> call is completed? I'll experiment, but was curious if anybody
> knows already.
>
> Thanks for the help--much appreciated!
> Dave
>
>
>>You could also do the validations in the setPropertyValue method.
>>If a prop val is invalid, you could reset it and display a message in
>>the status bar
>>
>>Dave Combs wrote:
>>
>>
>>>I'd appreciate any help on the following:
>>>
>>>I've got a TreeViewer that's showing a number of objects
>>>that I want to adjust through the Properties view. I've
>>>set things up so that the properties show correctly in
>>>the Properties view. What I'm wondering is how, if at all,
>>>the Properties view (through the 'setPropertyValue' method
>>>on the IPropertySource) allows the IPropertySource object
>>>to indicate that the value the user entered isn't valid?
>>>For example, if I have a property that's a text entry but
>>>is expecting the user to type in an integer and they don't,
>>>is there any current mechanism to show an error, or blow
>>>the value away, or otherwise let the IPropertySource say
>>>"hey, that entry isn't good"?
>>>
>>>Thanks for any help on this one!
>>>Dave Combs
>>>
>
>
|
|
|
Re: Properties view question - what about bad values? [message #307132 is a reply to message #307130] |
Mon, 14 August 2006 14:17  |
Eclipse User |
|
|
|
Originally posted by: combs.edgedynamics.com
Excellent! That's exactly the behavior I was hoping for.
Thanks,
Dave
vikram wrote:
>
>
> The getPropertyValue is always invoked after the setPropertyValue ( if I
> remember correctly ). So, the value displayed will be whatever you
> return in the getter.
>
> Let's say your model variable is m_model, you could do something like
> this.
>
>
> Object getPropertyValue(Object id)
> {
> if(id.equals("NAME")
> {
> return m_model.getName();
> }
>
> }
>
> void setPropertyValue(Object id, Object val)
> {
> if(id.equals("NAME")
> {
> String name = (String)val;
> if(isValid(name) )
> {
> m_model.setValue(name);
> }
> else
> m_model.setValue("");
> }
>
> }
>
> Dave Combs wrote:
>
>> vikram wrote:
>>
>> This is the type of solution I had implemented for myself in
>> the Swing app that this Eclipse app is being ported from.
>>
>> One other question, though--if I do decide to reset/ignore
>> the property change in setPropertyValue and display an error
>> message, is the property view smart enough to notice that the
>> value the user had typed in was not stored and to display
>> whatever value is really there when the setPropertyValue()
>> call is completed? I'll experiment, but was curious if anybody
>> knows already.
>>
>> Thanks for the help--much appreciated!
>> Dave
>>
>>
>>>You could also do the validations in the setPropertyValue method.
>>>If a prop val is invalid, you could reset it and display a message in
>>>the status bar
>>>
>>>Dave Combs wrote:
>>>
>>>
>>>>I'd appreciate any help on the following:
>>>>
>>>>I've got a TreeViewer that's showing a number of objects
>>>>that I want to adjust through the Properties view. I've
>>>>set things up so that the properties show correctly in
>>>>the Properties view. What I'm wondering is how, if at all,
>>>>the Properties view (through the 'setPropertyValue' method
>>>>on the IPropertySource) allows the IPropertySource object
>>>>to indicate that the value the user entered isn't valid?
>>>>For example, if I have a property that's a text entry but
>>>>is expecting the user to type in an integer and they don't,
>>>>is there any current mechanism to show an error, or blow
>>>>the value away, or otherwise let the IPropertySource say
>>>>"hey, that entry isn't good"?
>>>>
>>>>Thanks for any help on this one!
>>>>Dave Combs
>>>>
>>
>>
|
|
|
Goto Forum:
Current Time: Wed May 07 14:04:06 EDT 2025
Powered by FUDForum. Page generated in 0.06054 seconds
|