Home » Eclipse Projects » Eclipse Platform » Purpose of default value for extension attribute
|
Re: Purpose of default value for extension attribute [message #326948 is a reply to message #326942] |
Thu, 03 April 2008 15:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Mark Melvin![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mark.melvin%40onsemi.com) Messages: 118 Registered: July 2009 |
Senior Member |
|
|
Hi Marko,
The short answer is - I don't think you can. As far as I know, the
default value is only used when consumers of your extension point are
adding elements to their extension to your extension point via the
plugin.xml editor. This allows the PDE to fill in a default value for the
user when they add a new element, which can be useful. So if the user
chooses not specify this attribute, it won't show up in the
IConfigurationElement at all.
The docs describe this type of use as "The attribute may be optionally
specified on it's defining element. If the attribute is not specified,
then it's value will assume the defined default value." This sort of
suggests that if the user does not provide a value, then the extension
registry will return a default - but I don't think that is what they
intend to mean here. In fact, I cannot see anywhere in the code that
default values are ever mentioned or handled, so unless I am missing
something (and others feel free to chime in and correct me here), it is
never used outside of the plugin.xml editor and the PDE.
I guess you *could* get a reference to the schema file from the extension
point itself, and then load the .xml schema and parse out the default
value that way - but I don't know why any sane person would attempt that.
;) If you really need to revert to a default, then another solution would
be to define your own default value as a constant in your code that
mirrors what is in the schema, and if getAttribute() returns null, just
revert to the default yourself. However, now you should ask yourself
whether or not this attribute should be defined as "required" instead of
default (since default implies "optional").
Mark.
On Thu, 03 Apr 2008 09:13:13 -0400, Marko T.
<Marko.Tomljenovic@de.bosch.com> wrote:
> When I define an extension point it is possible to define an attribute
> to have a default value.
>
> How can I access that attribute(s default value)?
>
> Whenever I query an extension attribute that has no concrete but a
> default value defined, ConfigurationElement.getAttribute() always
> returns null but not the default value!
>
> Am I doing something wrong?
>
> Greetings Marko
>
|
|
|
Re: Purpose of default value for extension attribute [message #326949 is a reply to message #326948] |
Thu, 03 April 2008 15:12 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: merks.ca.ibm.com
Mark,
I'm pretty sure you're right. The extension point processor has to just
know the default. If the API were more like validated DOM, the default
value would be returned and it would be possible to determine if the
value was explicitly provided rather than just being the schema default...
Mark Melvin wrote:
> Hi Marko,
>
> The short answer is - I don't think you can. As far as I know, the
> default value is only used when consumers of your extension point are
> adding elements to their extension to your extension point via the
> plugin.xml editor. This allows the PDE to fill in a default value for
> the user when they add a new element, which can be useful. So if the
> user chooses not specify this attribute, it won't show up in the
> IConfigurationElement at all.
>
> The docs describe this type of use as "The attribute may be optionally
> specified on it's defining element. If the attribute is not specified,
> then it's value will assume the defined default value." This sort of
> suggests that if the user does not provide a value, then the extension
> registry will return a default - but I don't think that is what they
> intend to mean here. In fact, I cannot see anywhere in the code that
> default values are ever mentioned or handled, so unless I am missing
> something (and others feel free to chime in and correct me here), it
> is never used outside of the plugin.xml editor and the PDE.
>
> I guess you *could* get a reference to the schema file from the
> extension point itself, and then load the .xml schema and parse out
> the default value that way - but I don't know why any sane person
> would attempt that. ;) If you really need to revert to a default,
> then another solution would be to define your own default value as a
> constant in your code that mirrors what is in the schema, and if
> getAttribute() returns null, just revert to the default yourself.
> However, now you should ask yourself whether or not this attribute
> should be defined as "required" instead of default (since default
> implies "optional").
>
> Mark.
>
> On Thu, 03 Apr 2008 09:13:13 -0400, Marko T.
> <Marko.Tomljenovic@de.bosch.com> wrote:
>
>> When I define an extension point it is possible to define an
>> attribute to have a default value.
>>
>> How can I access that attribute(s default value)?
>>
>> Whenever I query an extension attribute that has no concrete but a
>> default value defined, ConfigurationElement.getAttribute() always
>> returns null but not the default value!
>>
>> Am I doing something wrong?
>>
>> Greetings Marko
>>
>
|
|
| |
Re: Purpose of default value for extension attribute [message #326956 is a reply to message #326953] |
Thu, 03 April 2008 16:24 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: merks.ca.ibm.com
Marko,
I think the expectation is that the extension point processor itself
(the code you write) will know the default and will supply it when no
explicit value is specified.
Marko T. wrote:
> Hello Mark,
>
> I also thought that the plugin editor is then filling in the default
> values but it is not.
> Maybe somebody of you can try it out.
> I am facing this when I have an attribute with the default value of
> "." and the following characterisitcas:
>
> type is string
> deprecated is false,
> translatable is false
> no restrictions
>
|
|
|
Re: Purpose of default value for extension attribute [message #326957 is a reply to message #326956] |
Thu, 03 April 2008 16:48 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Mark Melvin![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mark.melvin%40onsemi.com) Messages: 118 Registered: July 2009 |
Senior Member |
|
|
Hi Marko,
Interesting. I just tried it and it was not filled in by the PDE for me=
=
either (sorry - I thought it was). I thought the default value was used=
=
by the PDE plugin.xml editor but it seems to only fill in values for =
"required" attributes. So, frankly I don't see the point of the "defaul=
t" =
use type at all, as the platform never uses the value you specify in you=
r =
schema as far as I can see, and neither does the extension registry. =
*And*, you don't have access to it from your extension point processor a=
s =
far as I can tell. Ed - do you know different?
The only related bug I could find so far is this one:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D211916
Perhaps a PDE guy or extension registry guru could explain the purpose o=
f =
this use type, and how it is at all different from "optional"? Or Ed, =
perhaps you can tell me what Marko and I are missing here?
Mark.
On Thu, 03 Apr 2008 12:24:59 -0400, Ed Merks <merks@ca.ibm.com> wrote:
> Marko,
>
> I think the expectation is that the extension point processor itself =
> (the code you write) will know the default and will supply it when no =
=
> explicit value is specified.
>
>
> Marko T. wrote:
>> Hello Mark,
>>
>> I also thought that the plugin editor is then filling in the default =
=
>> values but it is not.
>> Maybe somebody of you can try it out.
>> I am facing this when I have an attribute with the default value of "=
.." =
>> and the following characterisitcas:
>>
>> type is string
>> deprecated is false,
>> translatable is false
>> no restrictions
>>
|
|
|
Re: Purpose of default value for extension attribute [message #326958 is a reply to message #326957] |
Thu, 03 April 2008 16:56 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: merks.ca.ibm.com
Mark,
That bugzilla looks like the PDE's pseudo XML Schema is still using an
older syntax before XML Schema 1.0 became a recommended specification.
It's hard to argue it's wrong, when it isn't really even XML Schema.
The only point I see in specifying what the default is would be as
documentation to the user (and the extension point processor implement)
as to how the attribute will be interpreted if he doesn't provide an
explicit value. Probably Chris will read this thread at some point and
comment if we've overlooked something...
All this reminds me of the thread on the e4 mailing list today about
models for the UI. If there were an EMF model for the extension point's
schema, it would be yielding the default value properly. :-P
Mark Melvin wrote:
> Hi Marko,
>
> Interesting. I just tried it and it was not filled in by the PDE for
> me either (sorry - I thought it was). I thought the default value was
> used by the PDE plugin.xml editor but it seems to only fill in values
> for "required" attributes. So, frankly I don't see the point of the
> "default" use type at all, as the platform never uses the value you
> specify in your schema as far as I can see, and neither does the
> extension registry. *And*, you don't have access to it from your
> extension point processor as far as I can tell. Ed - do you know
> different?
>
> The only related bug I could find so far is this one:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=211916
>
> Perhaps a PDE guy or extension registry guru could explain the purpose
> of this use type, and how it is at all different from "optional"? Or
> Ed, perhaps you can tell me what Marko and I are missing here?
>
> Mark.
>
> On Thu, 03 Apr 2008 12:24:59 -0400, Ed Merks <merks@ca.ibm.com> wrote:
>
>> Marko,
>>
>> I think the expectation is that the extension point processor itself
>> (the code you write) will know the default and will supply it when no
>> explicit value is specified.
>>
>>
>> Marko T. wrote:
>>> Hello Mark,
>>>
>>> I also thought that the plugin editor is then filling in the default
>>> values but it is not.
>>> Maybe somebody of you can try it out.
>>> I am facing this when I have an attribute with the default value of
>>> "." and the following characterisitcas:
>>>
>>> type is string
>>> deprecated is false,
>>> translatable is false
>>> no restrictions
>>>
>
|
|
|
Re: Purpose of default value for extension attribute [message #326961 is a reply to message #326958] |
Thu, 03 April 2008 17:11 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Mark Melvin![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mark.melvin%40onsemi.com) Messages: 118 Registered: July 2009 |
Senior Member |
|
|
OK. Thanks, Ed.
M.
On Thu, 03 Apr 2008 12:56:32 -0400, Ed Merks <merks@ca.ibm.com> wrote:
> Mark,
>
> That bugzilla looks like the PDE's pseudo XML Schema is still using an=
=
> older syntax before XML Schema 1.0 became a recommended specification.=
=
> It's hard to argue it's wrong, when it isn't really even XML Schema.
>
> The only point I see in specifying what the default is would be as =
> documentation to the user (and the extension point processor implement=
) =
> as to how the attribute will be interpreted if he doesn't provide an =
> explicit value. Probably Chris will read this thread at some point an=
d =
> comment if we've overlooked something...
>
> All this reminds me of the thread on the e4 mailing list today about =
> models for the UI. If there were an EMF model for the extension point=
's =
> schema, it would be yielding the default value properly. :-P
>
>
> Mark Melvin wrote:
>> Hi Marko,
>>
>> Interesting. I just tried it and it was not filled in by the PDE for=
=
>> me either (sorry - I thought it was). I thought the default value wa=
s =
>> used by the PDE plugin.xml editor but it seems to only fill in values=
=
>> for "required" attributes. So, frankly I don't see the point of the =
=
>> "default" use type at all, as the platform never uses the value you =
>> specify in your schema as far as I can see, and neither does the =
>> extension registry. *And*, you don't have access to it from your =
>> extension point processor as far as I can tell. Ed - do you know =
>> different?
>>
>> The only related bug I could find so far is this one:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D211916
>>
>> Perhaps a PDE guy or extension registry guru could explain the purpos=
e =
>> of this use type, and how it is at all different from "optional"? Or=
=
>> Ed, perhaps you can tell me what Marko and I are missing here?
>>
>> Mark.
>>
>> On Thu, 03 Apr 2008 12:24:59 -0400, Ed Merks <merks@ca.ibm.com> wrote=
:
>>
>>> Marko,
>>>
>>> I think the expectation is that the extension point processor itself=
=
>>> (the code you write) will know the default and will supply it when n=
o =
>>> explicit value is specified.
>>>
>>>
>>> Marko T. wrote:
>>>> Hello Mark,
>>>>
>>>> I also thought that the plugin editor is then filling in the defaul=
t =
>>>> values but it is not.
>>>> Maybe somebody of you can try it out.
>>>> I am facing this when I have an attribute with the default value of=
=
>>>> "." and the following characterisitcas:
>>>>
>>>> type is string
>>>> deprecated is false,
>>>> translatable is false
>>>> no restrictions
>>>>
>>
|
|
|
Re: Purpose of default value for extension attribute [message #327002 is a reply to message #326948] |
Fri, 04 April 2008 12:54 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Thomas Schindl![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=tom.schindl%40bestsolution.at) Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Mark Melvin schrieb:
> Hi Marko,
>
> The short answer is - I don't think you can. As far as I know, the
> default value is only used when consumers of your extension point are
> adding elements to their extension to your extension point via the
> plugin.xml editor. This allows the PDE to fill in a default value for
> the user when they add a new element, which can be useful. So if the
> user chooses not specify this attribute, it won't show up in the
> IConfigurationElement at all.
>
> The docs describe this type of use as "The attribute may be optionally
> specified on it's defining element. If the attribute is not specified,
> then it's value will assume the defined default value." This sort of
> suggests that if the user does not provide a value, then the extension
> registry will return a default - but I don't think that is what they
> intend to mean here. In fact, I cannot see anywhere in the code that
> default values are ever mentioned or handled, so unless I am missing
> something (and others feel free to chime in and correct me here), it is
> never used outside of the plugin.xml editor and the PDE.
Well the problem is that the runtime binary often doesn't even ship the
..exsd so there's no possibility to read the default value at runtime!
You see this if you are not download the SDK from Eclipse but the
runtime binary.
Tom
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
| |
Goto Forum:
Current Time: Thu Aug 15 06:53:38 GMT 2024
Powered by FUDForum. Page generated in 0.04327 seconds
|