[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.gmf] Re: Diagram configuration option
|
Hello Alex,
Are you sure this exception was caused by adding new style in ViewFactory?
(can you comment out this style and repeat all these steps)
Can you create new diagram and repeat this problem there?
This is the piece of code that gives me the error:
public class WorkflowTypeViewFactory extends DiagramViewFactory {
protected List createStyles(View view) {
List styles = new ArrayList();
styles.add(NotationFactory.eINSTANCE.createDiagramStyle());
styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle());
//styles.add(NotationFactory.eINSTANCE.createStringListValueStyle());
return styles;
}
If I comment the PropertiesFactory add and I use the last line, I get no
error.
This is the diagram code (just creating it):
<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:gsoc.ogsadai.model.properties="http:///gsoc/ogsadai/model/properties.ecore"
xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.1/notation"
xmlns:ns1="http://ogsadai.org.uk/namespaces/2007/04/types"
xmi:id="_7HVw8FdREd2ECtryuP4nMw" type="Request"
name="default.model_diagram" measurementUnit="Pixel">
<styles xmi:type="notation:DiagramStyle"
xmi:id="_7HXmIFdREd2ECtryuP4nMw"/>
<styles xmi:type="gsoc.ogsadai.model.properties:PropertiesStyle"
xmi:id="_7HXmIVdREd2ECtryuP4nMw"/>
<element xmi:type="ns1:WorkflowType"
href="default.model#//@request/@workflow"/>
</notation:Diagram>
if remove manually the <styles
xmi:type="gsoc.ogsadai.model.properties:PropertiesStyle"... I'm able to
load again the diagram.
I don't know if this can be useful but I changed the createDocumentRoot in
this way:
private static DocumentRoot createDocumentRoot(WorkflowType model) {
DocumentRoot docRoot = ModelFactory.eINSTANCE.createDocumentRoot();
RequestType request = ModelFactory.eINSTANCE.createRequestType();
request.setWorkflow(model);
docRoot.setRequest(request);
return docRoot;
}
I suppose is something related to the serialization, but I got no clue.
rties_view.html that uses a class implementing IPropertySource. My
class is implementing IPropertySourceProvider but the code
automaticaly generated for the methods getPropertySource return null.
Do I have to register my adapter somewhere?
Here is default implementation of getPropertySource geneated for
EcoreDiagram:
public IPropertySource getPropertySource(Object object) {
if (object instanceof IPropertySource) {
return (IPropertySource) object;
}
AdapterFactory af = getAdapterFactory(object);
if (af != null) {
IItemPropertySource ips = (IItemPropertySource) af.adapt(object,
IItemPropertySource.class);
if (ips != null) {
return new PropertySource(object, ips);
}
}
if (object instanceof IAdaptable) {
return (IPropertySource) ((IAdaptable)
object).getAdapter(IPropertySource.class);
}
return null;
}
This code is already generated automagically. I tried different solutions:
1) return a Custom object implementing IPropertySource. This gives me and
error because PropertiesStyle is not IAdaptable
2) in the second if I put:
IItemPropertySource ips = new PropertiesStyleItemProvider(af);
if (ips != null) {
return new PropertySource(object, ips);
}
this works (I'm able to see the tab with the values) but when I try to
edit them I get:
java.lang.ClassCastException:
org.eclipse.emf.edit.provider.ItemPropertyDescriptor$PropertyValueWrapper
incompatible with org.eclipse.emf.ecore.EObject
at
org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getPropertyValue(ItemPropertyDescriptor.java:1150)
at
org.eclipse.emf.edit.ui.provider.PropertySource.getPropertyValue(PropertySource.java:92)
Do you have any working example?
Cheers
Nicola