Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Getting a component's name
Getting a component's name [message #122998] Thu, 13 April 2006 08:59 Go to next message
Eclipse UserFriend
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 14:02 Go to previous message
Eclipse UserFriend
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 14:02 Go to previous message
Eclipse UserFriend
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
Previous Topic:Getting VE to show up
Next Topic:CTabItems doesn't directly appear
Goto Forum:
  


Current Time: Sun Jul 07 08:08:31 GMT 2024

Powered by FUDForum. Page generated in 0.02990 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top