Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » EMF ItemProvider to PropertySource in GEF
icon5.gif  EMF ItemProvider to PropertySource in GEF [message #499130] Fri, 20 November 2009 01:08 Go to next message
Polson  is currently offline Polson Friend
Messages: 2
Registered: October 2009
Junior Member
Hi all,

i would like to provide PropertySource for my GEF editor, so that
i can use Properties view to edit my model in GEF.
I only find some threads from this forum, but it didn't fix my problem.

I tried to use adapter factory (see code below) from EMF.Edit.
My Properties view display and update (changes made in GEF)
every features correctly, but i can only edit boolean features.
String, List, custom datatype throw ClassCastException (Unhandled event loop exception).
The code below is in my EditPart for the super class of all my model elements.
I have tried various methods (see comment in the code), but it has the same effect.

Do i missed something? Please help.

Thanks
Polson
@SuppressWarnings("unchecked")
@Override
public Object getAdapter(Class key) {
	if (IPropertySource.class == key) {
		return getPropertySource();
	}
	return super.getAdapter(key);
}

protected AdapterFactoryContentProvider getAdapterFactory() {
	if (adapterFactory == null) {
//		adapterFactory = new ProtocolItemProviderAdapterFactory();
//		
//		adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
//		adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
//		adapterFactory.addAdapterFactory(new ProtocolItemProviderAdapterFactory());
//		adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
		
		adapterFactory = new AdapterFactoryContentProvider(new ProtocolItemProviderAdapterFactory());
	}
	return adapterFactory;
}

protected IPropertySource getPropertySource() {
//	if (propertySource == null) {
//		Adapter adapter = getAdapterFactory().adapt(getModel(), IItemPropertySource.class);
//		IItemPropertySource ips = (IItemPropertySource)adapter;
//		propertySource = new PropertySource(getModel(), ips);
//	}
//	return propertySource;
	return getAdapterFactory().getPropertySource(getModel());
}


java.lang.ClassCastException: org.eclipse.emf.edit.provider.ItemPropertyDescriptor$PropertyValueWrapper cannot be cast to org.eclipse.draw2d.geometry.Point
	at profab.gcf.model.impl.ProtocolFactoryImpl.convertPointToString(ProtocolFactoryImpl.java:220)
	at profab.gcf.model.impl.ProtocolFactoryImpl.convertToString(ProtocolFactoryImpl.java:109)
	at org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUtil.java:3269)
	at org.eclipse.emf.edit.ui.provider.PropertyDescriptor$EDataTypeValueHandler.toString(PropertyDescriptor.java:199)
	at org.eclipse.emf.edit.ui.provider.PropertyDescriptor$EDataTypeCellEditor.isCorrect(PropertyDescriptor.java:251)
	at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.java:853)
	at org.eclipse.ui.views.properties.PropertySheetEntry.getEditor(PropertySheetEntry.java:384)
	at org.eclipse.ui.views.properties.PropertySheetViewer.activateCellEditor(PropertySheetViewer.java:163)
	at org.eclipse.ui.views.properties.PropertySheetViewer.handleSelect(PropertySheetViewer.java:727)
	at org.eclipse.ui.views.properties.PropertySheetViewer.access$8(PropertySheetViewer.java:707)
	at org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseDown(PropertySheetViewer.java:816)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179)
	more...
java.lang.ClassCastException: org.eclipse.emf.edit.provider.ItemPropertyDescriptor$PropertyValueWrapper cannot be cast to java.util.List
	at org.eclipse.emf.edit.ui.provider.PropertyDescriptor$4.openDialogBox(PropertyDescriptor.java:495)
	at org.eclipse.jface.viewers.DialogCellEditor$2.widgetSelected(DialogCellEditor.java:244)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	more...
java.lang.ClassCastException: org.eclipse.emf.edit.provider.ItemPropertyDescriptor$PropertyValueWrapper cannot be cast to java.lang.String
	at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEStringToString(EcoreFactoryImpl.java:651)
	at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString(EcoreFactoryImpl.java:224)
	at org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUtil.java:3269)
	at org.eclipse.emf.edit.ui.provider.PropertyDescriptor$EDataTypeValueHandler.toString(PropertyDescriptor.java:199)
	at org.eclipse.emf.edit.ui.provider.PropertyDescriptor$EDataTypeCellEditor.isCorrect(PropertyDescriptor.java:251)
	at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.java:853)
	at org.eclipse.ui.views.properties.PropertySheetEntry.getEditor(PropertySheetEntry.java:384)
	at org.eclipse.ui.views.properties.PropertySheetViewer.activateCellEditor(PropertySheetViewer.java:163)
	at org.eclipse.ui.views.properties.PropertySheetViewer.handleSelect(PropertySheetViewer.java:727)
	at org.eclipse.ui.views.properties.PropertySheetViewer.access$8(PropertySheetViewer.java:707)
	at org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseDown(PropertySheetViewer.java:816)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179)
Re: EMF ItemProvider to PropertySource in GEF [message #671575 is a reply to message #499130] Wed, 18 May 2011 11:28 Go to previous messageGo to next message
Federico Tomassetti is currently offline Federico TomassettiFriend
Messages: 186
Registered: July 2009
Location: Torino
Senior Member

I am also facing the same problem. No answer?

Re: EMF ItemProvider to PropertySource in GEF [message #717773 is a reply to message #671575] Mon, 22 August 2011 09:43 Go to previous message
Arieh Bibliowicz is currently offline Arieh BibliowiczFriend
Messages: 18
Registered: June 2011
Junior Member
I coded a solution to this problem. You can find it here: www.vainolo.com/2011/08/22/creating-an-opm-gef-editor-part-16-displaying-emf-properties-in-a-gef-editor/
Previous Topic:Adding Connection as Element to its Parent Element to reflect in XML
Next Topic:GEF Properties View
Goto Forum:
  


Current Time: Sun Dec 21 04:54:40 GMT 2014

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

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