Tweaking EMF PropertyDescriptors [message #418786] |
Tue, 29 April 2008 16:41 |
Eclipse User |
|
|
|
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 |
Ed Merks 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 |
Eclipse User |
|
|
|
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!
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.04354 seconds