[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Diagram configuration option

Hello Alex,

sorry to bother you again but I'm stuck :(
So what I'd like to do is to add a tab to the property view, that allow me to set some attributes and save them. I cannot save directly in the domain model because the XML schema is already defined and I cannot modify it.
What I did is:


1) Made a Java file extending Style and marked as @model
2) Generated the Model+Edit
3) Modified the GenModel in order to add a Custom Property configuration
4) Regenerate the code, and now I have the plugin.xml updated and a new class ConfigurationPropertySection
5) Modified WorkflowTypeViewFactory adding styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle());


At this point I don't know how to continue, I'm learning by example and unfortunately I haven't found any. I suppose I have to modify the class at point 4 to get the object I add to the style in point 5, but I have no idea how to do it. Can you please help me?
Thank you in advance


Nicola

Alex Shatalin wrote:

Hello Nicola,

- modifying generated code to make your own PropertyTab edting
corresponding property of underlying notation model element
Here I suppose I need to modify:
protected Object transformSelection(Object selected)
Well, I'm not sure abot the code generated by GMF will be applicable for your custom property tab, so here we usually implement whole property tab using custom code.. If you feel it's ok to use GMF-generated content, but only change transformSelection() method it's ok.

but I really have no clue of what to do. Do I have to define a new
model just for the notational style? Please help.
Yes. In general you have to define your own .ecore model with only one
EClass
"CustomPropertiesStyle" extending "Style" from notation.ecore. Then you can generate code for this model (i think model code is enough). Then you can use API generated by EMF to instantiate CustomPropertiesStyle and then you can assign this style to the newly created objects (using custom code in corresponding ???ViewFactory.createStyles() method).

In case you have to store some primitive type properties
(String/int/boolean..)
in a notation model you can use one of existing subclasses of NamedStyle. (BooleanValueStyle/StringValueStyle) then you can skip new .ecore notation model extension definition + code generation steps.

BTW, do you really need to store these properties in a notation model? As an option you can modify domain model and introduce corresponding properties there.

-----------------
Alex Shatalin