Getting a component's name [message #122998] |
Thu, 13 April 2006 04:59  |
Eclipse User |
|
|
|
Originally posted by: patrick.gill.gft.com
Hello.
I was just wondering, given that I've got an EditPart for a component in
the VE, how can I retrieve the name ('field name') given to that
component? I can't see how to get it from the EditPart,
IJavaObjectInstance or IBeanProxy... Thank you.
Regards,
Patrick
|
|
|
Re: Getting a component's name [message #123057 is a reply to message #122998] |
Thu, 13 April 2006 10:02  |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
The safest way is:
IPropertySource modelPS = (IPropertySource)
editpart.getAdapter(IPropertySource.class);
if (modelPS != null) {
IPropertyDescriptor[] descrs = modelPS.getPropertyDescriptors();
for (int i = 0; i < descrs.length; i++) {
if (descrs[i].getId() ==
NameInCompositionPropertyDescriptor.NAME_IN_COMPOSITION_KEY) {
IPropertyDescriptor nameDesc = descrs[i];
if (!(nameDesc instanceof ICommandPropertyDescriptor && nameDesc
instanceof ISourcedPropertyDescriptor)){
break; // Not a valid descriptor, or no descriptor, so no name.
} else {
String name = (String) ((ISourcedPropertyDescriptor)
nameDesc).getValue(modelPS));
... do what you want with name ...
break;
}
}
}
}
Patrick Gill wrote:
> Hello.
>
> I was just wondering, given that I've got an EditPart for a component in
> the VE, how can I retrieve the name ('field name') given to that
> component? I can't see how to get it from the EditPart,
> IJavaObjectInstance or IBeanProxy... Thank you.
>
> Regards,
>
> Patrick
>
--
Thanks,
Rich Kulp
|
|
|
Re: Getting a component's name [message #612628 is a reply to message #122998] |
Thu, 13 April 2006 10:02  |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
The safest way is:
IPropertySource modelPS = (IPropertySource)
editpart.getAdapter(IPropertySource.class);
if (modelPS != null) {
IPropertyDescriptor[] descrs = modelPS.getPropertyDescriptors();
for (int i = 0; i < descrs.length; i++) {
if (descrs[i].getId() ==
NameInCompositionPropertyDescriptor.NAME_IN_COMPOSITION_KEY) {
IPropertyDescriptor nameDesc = descrs[i];
if (!(nameDesc instanceof ICommandPropertyDescriptor && nameDesc
instanceof ISourcedPropertyDescriptor)){
break; // Not a valid descriptor, or no descriptor, so no name.
} else {
String name = (String) ((ISourcedPropertyDescriptor)
nameDesc).getValue(modelPS));
... do what you want with name ...
break;
}
}
}
}
Patrick Gill wrote:
> Hello.
>
> I was just wondering, given that I've got an EditPart for a component in
> the VE, how can I retrieve the name ('field name') given to that
> component? I can't see how to get it from the EditPart,
> IJavaObjectInstance or IBeanProxy... Thank you.
>
> Regards,
>
> Patrick
>
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.03230 seconds