Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Common Navigator + EMF + Properties View
Common Navigator + EMF + Properties View [message #416494] Tue, 05 February 2008 14:11 Go to next message
Eclipse UserFriend
Originally posted by: oemer.yildiz.semanticedge.com

Hi,

I want the user to be able to modify properties of model objects, which
are shown in the Project Explorer using the Common Navigator Framework.
The Properties View displays their properties, but modifing a particular
type of property does not work. When the user tries to modify a
property, which is defined as a multi-line String in the genmodel and it
already contains a string, he's getting this exception:

java.lang.ClassCastException:
org.eclipse.emf.edit.provider.ItemPropertyDescriptor$Propert yValueWrapper
cannot be cast to java.lang.String
at
org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEStringTo String(EcoreFactoryImpl.java:654)
at
org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString( EcoreFactoryImpl.java:224)
at
org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUt il.java:3112)
at
org.eclipse.emf.edit.ui.provider.PropertyDescriptor$EDataTyp eValueHandler.toString(PropertyDescriptor.java:199)
at
org.eclipse.emf.edit.ui.provider.PropertyDescriptor$2.openDi alogBox(PropertyDescriptor.java:293)
at
org.eclipse.jface.viewers.DialogCellEditor$2.widgetSelected( DialogCellEditor.java:244)
....


Any hints to fix this issue?

Best regards,
Ömer Yildiz
Re: Common Navigator + EMF + Properties View [message #416508 is a reply to message #416494] Tue, 05 February 2008 22:08 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Hi Omer,

EMF's ItemPropertyDescriptors implement getPropertyValue() to actually
wrap the values they return in instances of PropertyValueWrapper. I must
admit that I don't totally understand everything that's going on here,
but it seems somehow to facilitate nesting of properties.

I believe that clients should be calling getEditableValue() on the
IPropertySource, which then calls getEditableValue() on the
PropertyValueWrapper, yielding the actual string value. I observe this
happening in Eclipse's PropertySheetEntry.setValues() when I use an
EMF-generated editor. Then, in getEditor(), the PropertySheetEntry
passes that unwrapped value to the cell editor via setValue(). The
DialogCellEditor records it in doSetValue() for use by openDialogBox(),
at PropertyDescriptor.java:239, in your trace. So, I expect that it
should actually be passing a string to EDataTypeValueHandler.toString().

Could it be that, in your use, IPropertySource.getEditableValue() is not
being called? I've never worked with the Common Navigator Framework
before. Can you do some debugging to see what's happening?

Cheers,
Dave


Ömer Yildiz wrote:
> Hi,
>
> I want the user to be able to modify properties of model objects, which
> are shown in the Project Explorer using the Common Navigator Framework.
> The Properties View displays their properties, but modifing a particular
> type of property does not work. When the user tries to modify a
> property, which is defined as a multi-line String in the genmodel and it
> already contains a string, he's getting this exception:
>
> java.lang.ClassCastException:
> org.eclipse.emf.edit.provider.ItemPropertyDescriptor$Propert yValueWrapper
> cannot be cast to java.lang.String
> at
> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEStringTo String(EcoreFactoryImpl.java:654)
>
> at
> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString( EcoreFactoryImpl.java:224)
>
> at
> org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUt il.java:3112)
> at
> org.eclipse.emf.edit.ui.provider.PropertyDescriptor$EDataTyp eValueHandler.toString(PropertyDescriptor.java:199)
>
> at
> org.eclipse.emf.edit.ui.provider.PropertyDescriptor$2.openDi alogBox(PropertyDescriptor.java:293)
>
> at
> org.eclipse.jface.viewers.DialogCellEditor$2.widgetSelected( DialogCellEditor.java:244)
>
> ...
>
>
> Any hints to fix this issue?
>
> Best regards,
> Ömer Yildiz
Re: Common Navigator + EMF + Properties View [message #416599 is a reply to message #416508] Thu, 07 February 2008 12:50 Go to previous message
Eclipse UserFriend
Originally posted by: oemer.yildiz.semanticedge.com

Hi Dave,

I've solved the problem by contributing my property sheets using the
org.eclipse.ui.views.properties.tabbed.* extension points.

My original approach consisted of defining an Eclipse IAdapterFactory
capable of adapting an instance of a domain model element to
IPropertySource:

public Object getAdapter(Object adaptableObject, Class adapterType) {
...
IItemPropertySource source = adapterFactory.adapt(adaptableObject,
IItemPropertySource.class);

PropertySource ps = new PropertySource(adaptableObject, source);
return new TransactionalPropertySource(domain, ps);
}
(PropertySource class is defined in org.eclipse.emf.edit.ui.provider)

This actually works as long as I avoid editing multi-line Strings.


In the new approach using the modern tabbed properties view my "property
section" (see extension point
org.eclipse.ui.views.properties.tabbed.propertySections)
looks like this:

void createControls(Composite parent, TabbedPropertySheetPage
tabbedPropertySheetPage) {
...
page = new ExtendedPropertySheetPage(domain);
...
page.setPropertySourceProvider(this);
}

It also implements IPropertySourceProvider whose getPropertySource
method contains essentially the same code as the IAdapterFactory
implementation, i.e. it returns an IPropertySource for a given domain
model element instance.

Unlike in the first approach I can explicitly specify what kind of
PropertySheetPage I want to use in the second approach, namely the EMF
provided ExtendedPropertySheetPage. Perhaps the problem has something to
do with this difference, but I don't have the time to dig deeper into it.

Cheers
Ömer

Dave Steinberg schrieb:
> Hi Omer,
>
> EMF's ItemPropertyDescriptors implement getPropertyValue() to actually
> wrap the values they return in instances of PropertyValueWrapper. I must
> admit that I don't totally understand everything that's going on here,
> but it seems somehow to facilitate nesting of properties.
>
> I believe that clients should be calling getEditableValue() on the
> IPropertySource, which then calls getEditableValue() on the
> PropertyValueWrapper, yielding the actual string value. I observe this
> happening in Eclipse's PropertySheetEntry.setValues() when I use an
> EMF-generated editor. Then, in getEditor(), the PropertySheetEntry
> passes that unwrapped value to the cell editor via setValue(). The
> DialogCellEditor records it in doSetValue() for use by openDialogBox(),
> at PropertyDescriptor.java:239, in your trace. So, I expect that it
> should actually be passing a string to EDataTypeValueHandler.toString().
>
> Could it be that, in your use, IPropertySource.getEditableValue() is not
> being called? I've never worked with the Common Navigator Framework
> before. Can you do some debugging to see what's happening?
>
> Cheers,
> Dave
>
>
> Ömer Yildiz wrote:
>> Hi,
>>
>> I want the user to be able to modify properties of model objects,
>> which are shown in the Project Explorer using the Common Navigator
>> Framework. The Properties View displays their properties, but modifing
>> a particular type of property does not work. When the user tries to
>> modify a property, which is defined as a multi-line String in the
>> genmodel and it already contains a string, he's getting this exception:
>>
>> java.lang.ClassCastException:
>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor$Propert yValueWrapper
>> cannot be cast to java.lang.String
>> at
>> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEStringTo String(EcoreFactoryImpl.java:654)
>>
>> at
>> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString( EcoreFactoryImpl.java:224)
>>
>> at
>> org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUt il.java:3112)
>> at
>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor$EDataTyp eValueHandler.toString(PropertyDescriptor.java:199)
>>
>> at
>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor$2.openDi alogBox(PropertyDescriptor.java:293)
>>
>> at
>> org.eclipse.jface.viewers.DialogCellEditor$2.widgetSelected( DialogCellEditor.java:244)
>>
>> ...
>>
>>
>> Any hints to fix this issue?
>>
>> Best regards,
>> Ömer Yildiz
Previous Topic:Complex Map Modeling
Next Topic:Referencing model elements (generated editor vs. editor on the fly)
Goto Forum:
  


Current Time: Sat Apr 20 00:26:14 GMT 2024

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

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

Back to the top