Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Tweaking EMF PropertyDescriptors
Tweaking EMF PropertyDescriptors [message #418786] Tue, 29 April 2008 16:41 Go to next message
Eclipse UserFriend
Originally posted by: j4r0d.hotmail.com

Hi everybody,

In my model, some object's properties depend on other objects. I would like
to add some PropertyDescriptor "on the fly" just like this:


public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null)
super.getPropertyDescriptors(object);

if (((FrameType) object).eContainer().eContainer() instanceof MenuType)
{
if (itemPropertyDescriptorsMenu.size() == 0) {
itemPropertyDescriptorsMenu.add(itemPropertyDescriptors);
addBackgroundEffectPropertyDescriptor(object);
addBackgroundEffectFactorPropertyDescriptor(object);
addMenuNamePropertyDescriptor(object);
}
return itemPropertyDescriptorsMenu;
}

return itemPropertyDescriptors;
}

But this is not working, I always have the same exception:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to
org.eclipse.emf.edit.provider.IItemPropertyDescriptor
at
org.eclipse.emf.edit.ui.provider.PropertySource.getPropertyD escriptors(PropertySource.java:76)
at
org.eclipse.ui.views.properties.PropertySheetEntry.computeMe rgedPropertyDescriptors(PropertySheetEntry.java:168)
at
org.eclipse.ui.views.properties.PropertySheetEntry.createChi ldEntries(PropertySheetEntry.java:237)
at
org.eclipse.ui.views.properties.PropertySheetEntry.getChildE ntries(PropertySheetEntry.java:342)
....

Since itemPropertyDescriptors and itemPropertyDescriptorsMenu have the same
type, I have no idea about where this exception come from.
Do you know if this "trick" is possible? Please help!

--
J.
Re: Tweaking EMF PropertyDescriptors [message #418787 is a reply to message #418786] Tue, 29 April 2008 17:21 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Jarod,

Comments below.

Jarod Mills wrote:
> Hi everybody,
>
> In my model, some object's properties depend on other objects. I would like
> to add some PropertyDescriptor "on the fly" just like this:
>
>
> public List getPropertyDescriptors(Object object) {
> if (itemPropertyDescriptors == null)
> super.getPropertyDescriptors(object);
>
> if (((FrameType) object).eContainer().eContainer() instanceof MenuType)
> {
> if (itemPropertyDescriptorsMenu.size() == 0) {
> itemPropertyDescriptorsMenu.add(itemPropertyDescriptors);
>
Using Java 5.0 would help prevent this kind of problem. You're adding
the entire list of descriptors as a single item. Probably you intended
to do an addAll...
> addBackgroundEffectPropertyDescriptor(object);
> addBackgroundEffectFactorPropertyDescriptor(object);
> addMenuNamePropertyDescriptor(object);
> }
> return itemPropertyDescriptorsMenu;
> }
>
> return itemPropertyDescriptors;
> }
>
> But this is not working, I always have the same exception:
> java.lang.ClassCastException: java.util.ArrayList cannot be cast to
> org.eclipse.emf.edit.provider.IItemPropertyDescriptor
> at
> org.eclipse.emf.edit.ui.provider.PropertySource.getPropertyD escriptors(PropertySource.java:76)
> at
> org.eclipse.ui.views.properties.PropertySheetEntry.computeMe rgedPropertyDescriptors(PropertySheetEntry.java:168)
> at
> org.eclipse.ui.views.properties.PropertySheetEntry.createChi ldEntries(PropertySheetEntry.java:237)
> at
> org.eclipse.ui.views.properties.PropertySheetEntry.getChildE ntries(PropertySheetEntry.java:342)
> ....
>
> Since itemPropertyDescriptors and itemPropertyDescriptorsMenu have the same
> type, I have no idea about where this exception come from.
> Do you know if this "trick" is possible? Please help!
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Tweaking EMF PropertyDescriptors [message #418788 is a reply to message #418787] Tue, 29 April 2008 17:20 Go to previous message
Eclipse UserFriend
Originally posted by: j4r0d.hotmail.com

Shame on me, thanks again dear Ed ;)

> Jarod,
>
> Comments below.
>
> Jarod Mills wrote:
>> Hi everybody,
>>
>> In my model, some object's properties depend on other objects. I would
>> like to add some PropertyDescriptor "on the fly" just like this:
>>
>>
>> public List getPropertyDescriptors(Object object) {
>> if (itemPropertyDescriptors == null)
>> super.getPropertyDescriptors(object);
>>
>> if (((FrameType) object).eContainer().eContainer() instanceof
>> MenuType) {
>> if (itemPropertyDescriptorsMenu.size() == 0) {
>> itemPropertyDescriptorsMenu.add(itemPropertyDescriptors);
>>
> Using Java 5.0 would help prevent this kind of problem. You're adding the
> entire list of descriptors as a single item. Probably you intended to do
> an addAll...
>> addBackgroundEffectPropertyDescriptor(object);
>> addBackgroundEffectFactorPropertyDescriptor(object);
>> addMenuNamePropertyDescriptor(object);
>> }
>> return itemPropertyDescriptorsMenu;
>> }
>>
>> return itemPropertyDescriptors;
>> }
>>
>> But this is not working, I always have the same exception:
>> java.lang.ClassCastException: java.util.ArrayList cannot be cast to
>> org.eclipse.emf.edit.provider.IItemPropertyDescriptor
>> at
>> org.eclipse.emf.edit.ui.provider.PropertySource.getPropertyD escriptors(PropertySource.java:76)
>> at
>> org.eclipse.ui.views.properties.PropertySheetEntry.computeMe rgedPropertyDescriptors(PropertySheetEntry.java:168)
>> at
>> org.eclipse.ui.views.properties.PropertySheetEntry.createChi ldEntries(PropertySheetEntry.java:237)
>> at
>> org.eclipse.ui.views.properties.PropertySheetEntry.getChildE ntries(PropertySheetEntry.java:342)
>> ....
>>
>> Since itemPropertyDescriptors and itemPropertyDescriptorsMenu have the
>> same type, I have no idea about where this exception come from.
>> Do you know if this "trick" is possible? Please help!
>>
>>
Previous Topic:XML Schema vs. XML Schema for XMI
Next Topic:Global Change Listener without containment
Goto Forum:
  


Current Time: Wed Sep 25 00:51:50 GMT 2024

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

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

Back to the top