Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Diagram configuration option
Diagram configuration option [message #197246] Wed, 16 July 2008 09:23 Go to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello folks,

I have to store some configuration options (server url,deploy options..)
for the diagram I'm creating with GMF. Is it possible to add a property
sheet to GMF, and moreover is it possible to persist those configuration
values in the diagram file?
Thank you in advance

Nicola
Re: Diagram configuration option [message #197361 is a reply to message #197246] Wed, 16 July 2008 10:37 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

Sure it is. ;-)
- try adding GenCustomPropertyTab as an additional tab to GenPropertySheet
in your .gmfgen model.
- modifying generated code to make your own PropertyTab edting corresponding
property of underlying notation model element

You can create and use subclass of org.eclipse.gmf.runtime.notation.Style
to store correspondig propertyies in notation model.

-----------------
Alex Shatalin
Re: Diagram configuration option [message #197400 is a reply to message #197361] Wed, 16 July 2008 12:05 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Alex,

thank you for the reply! I have some issue, can you explain further?
comments are below.

Alex Shatalin wrote:

> - try adding GenCustomPropertyTab as an additional tab to GenPropertySheet
> in your .gmfgen model.
This step was quite easy! done.

> - 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)

to edit the corresponding property that I will define in the next step
(notation style). Am I right?

> You can create and use subclass of org.eclipse.gmf.runtime.notation.Style
> to store correspondig propertyies in notation model.

This is the though part. I gave a look here:

http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.gmf.doc/howto/diagram/howto.html

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.

Thank you in advance

Nicola
Re: Diagram configuration option [message #197425 is a reply to message #197400] Wed, 16 July 2008 12:39 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
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
Re: Diagram configuration option [message #197817 is a reply to message #197425] Thu, 17 July 2008 16:41 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
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
Re: Diagram configuration option [message #197899 is a reply to message #197817] Fri, 18 July 2008 09:25 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

From the selection you'll receive EditPart instance (most probably). Using
this EditPart you can get View instance by calling (org.eclipse.gmf.runtime.notation.View)
EditPart.GetModel()
The usign View.getStyle(EClass) or View.getStyles() you'll be able to access
Style instance attached to the View of WorkflowType on step 5.

The rest is up to PropertyTab implementation - this is just a set of SWT
controls, so you can develop any UI using normal eclipse ways to create UI..

-----------------
Alex Shatalin
Re: Diagram configuration option [message #197970 is a reply to message #197899] Sat, 19 July 2008 14:28 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello Alex,

I feel like a dumb! I spent almost two days with trying to add the
property sheet with no result.
This is what I did since the last mail:

1) modified the plugin.xml in this way:

<propertySection id="property.section.conf"
tab="property.tab.conf"

class=" gsoc.ogsadai.model.diagram.sheet.ConfigurationPropertySectio n ">
<input type="gsoc.ogsadai.model.properties.PropertiesStyle">
</input>
<input type="org.eclipse.gmf.runtime.notation.View">
</input>
<input type="org.eclipse.gef.EditPart">
</input>

2) modified the generated class:

public class ConfigurationPropertySection extends AdvancedPropertySection
implements IPropertySourceProvider {

protected EAttribute getFeature() {
return PropertiesPackage.eINSTANCE.getPropertiesStyle_ServerURL();
}

private ModifyListener listener = new ModifyListener() {
public void modifyText(ModifyEvent arg0) {
EditingDomain editingDomain = getEditingDomain();
Object value = text.getText();
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain, eObject, getFeature(),value));

}
};

protected Object transformSelection(Object selected) {
..
..
for (Object style : styles) {
if (style instanceof PropertiesStyle)
return style;
}
return null;
}

public void createControls(Composite parent,
TabbedPropertySheetPage aTabbedPropertySheetPage) {

super.createControls(parent, aTabbedPropertySheetPage);
..
..
text.addModifyListener(listener);
}


Now I have two problems:

1) the call
styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); seems to
be successful, if a make a new diagram I have

<styles xmi:type="gsoc.ogsadai.model.properties:PropertiesStyle"
xmi:id="_f6v-YFWREd2ksdhDVLHUbA"/>

thus I suppose it's creating and serializing the new style in the diagram.
If I close and reopen it this is what I get:

org.eclipse.core.runtime.AssertionFailedException: null argument:
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:86)
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:74)
at
org.eclipse.gmf.runtime.diagram.ui.internal.services.editpar t.EditPartOperation. <init>(EditPartOperation.java:43)
at
org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateR ootEditPartOperation. <init>(CreateRootEditPartOperation.java:32)
at
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createRootEditPart(EditPartService.java:248)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.confi gureGraphicalViewer(DiagramEditor.java:831)
at
gsoc.ogsadai.model.diagram.part.RequestDiagramEditor.configu reGraphicalViewer(RequestDiagramEditor.java:282)

it should be something related to the load operation, but I have not clue.
The ecore file is serialized using XMI.

2) The editor property editor is not working :) I followed the
http://www.eclipse.org/articles/Article-Tabbed-Properties/ta bbed_properties_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?

Sorry again for this question, but I've never used eclipse SWT so far, and
I need to use now for the project I'm working on.
Thanks in advance

Nicola

Alex Shatalin wrote:

> Hello Nicola,

> From the selection you'll receive EditPart instance (most probably). Using
> this EditPart you can get View instance by calling
(org.eclipse.gmf.runtime.notation.View)
> EditPart.GetModel()
> The usign View.getStyle(EClass) or View.getStyles() you'll be able to access
> Style instance attached to the View of WorkflowType on step 5.

> The rest is up to PropertyTab implementation - this is just a set of SWT
> controls, so you can develop any UI using normal eclipse ways to create UI..

> -----------------
> Alex Shatalin
Re: Diagram configuration option [message #198019 is a reply to message #197970] Mon, 21 July 2008 10:07 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

> diagram. If I close and reopen it this is what I get:
The reason of this excaption is - View instance associated with EditPart
(loaded form diagram file) is null...
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?

> 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;
}
AFAIKSee, parameter object should be instance of IPropertySource of be adaptable
to IItemPropertySource or should be instanceof IAdaptable...
In your situation you can either make this method working or mark it as "@generated
NOT" and modify this code to return proper instance of IPropertySource implemented
by you.

-----------------
Alex Shatalin
Re: Diagram configuration option [message #198182 is a reply to message #198019] Tue, 22 July 2008 01:36 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
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.createStringListValue Style());
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$Propert yValueWrapper
incompatible with org.eclipse.emf.ecore.EObject
at
org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getProp ertyValue(ItemPropertyDescriptor.java:1150)
at
org.eclipse.emf.edit.ui.provider.PropertySource.getPropertyV alue(PropertySource.java:92)

Do you have any working example?

Cheers

Nicola
Re: Diagram configuration option [message #198282 is a reply to message #198182] Tue, 22 July 2008 11:33 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

> if remove manually the <styles
> xmi:type="gsoc.ogsadai.model.properties:PropertiesStyle"... I'm able
> to load again the diagram.
Well, try putting a breakpoint into DiagramIOUtil.load() to see why diagram
was not loaded correctly (this method should be called from generated ???DocumentProvider.setDocumentContent())

> 1) return a Custom object implementing IPropertySource. This gives me
> and error because PropertiesStyle is not IAdaptable
If you return custom instance of IPropertySource from this method then where
is the problem (cust of PropertiesStyle to IAdaptable)?

> Do you have any working example?
You can use one of the following ISection implementations as an example:
org.eclipse.gmf.runtime.diagram.ui.properties.sections.appea rance.ShapeColorsAndFontsPropertySection
org.eclipse.gmf.runtime.diagram.ui.properties.sections.appea rance.DiagramColorsAndFontsPropertySection
org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid. RulerGridPropertySection

-----------------
Alex Shatalin
Re: Diagram configuration option [message #198504 is a reply to message #198282] Wed, 23 July 2008 11:09 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello Alex,

thank you for your last reply! I managed to solve both the problem, in a
magical way but they are solved.

> Well, try putting a breakpoint into DiagramIOUtil.load() to see why diagram
> was not loaded correctly (this method should be called from generated
>???DocumentProvider.setDocumentContent())

The first problem (diagram not loading) was related to a problem with the
properties.ecore file. It start to work when I deleted the EMF Model
plugin and regenerate model.

> If you return custom instance of IPropertySource from this method then where
> is the problem (cust of PropertiesStyle to IAdaptable)?

What I did here, was to implement IAdaptable in PropertiesStyleImpl. Then
I return a CustomProperties in the getPropertySource I return a
CustomProperty implementing IPropertySource. Now the only problem I have
(yes another one) is to access this notational style from the EMF editor.
Any idea?
I don't know if it can be useful but this is all the process I did to add
a notational style with an associated property sheet to a GMF diagram:

1) Made a Java file extending Style and marked as @model
2) Generate the Model+Edit. Be sure that the plugin register FactorImpl..
you should have something like this:

<extension point="org.eclipse.emf.ecore.extension_parser">
<parser type="properties"
class=" gsoc.ogsadai.model.properties.util.PropertiesResourceFactory Impl "/>
</extension>

2.2) modify the model class ???Impl implementing IAdaptable and add the
method:

public Object getAdapter(Class adapter) {
return Platform.getAdapterManager().getAdapter(this, adapter);
}

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. Be sure to have some inputs to the
property, otherwise it will not be called (not sure about it)

5) Modified WorkflowTypeViewFactory adding
styles.add(???Factory.eINSTANCE.createPropertiesStyle());

6) Create a class that implements IPropertySource:

final class CustomProperties implements IPropertySource {

PropertiesStyle style;

/**
*
*/
public CustomProperties(Object obj) {
style = (PropertiesStyle) obj;
}

public Object getEditableValue() {
return this;
}

public IPropertyDescriptor[] getPropertyDescriptors() {

IPropertyDescriptor[] propertyDescriptors = { new TextPropertyDescriptor(
style, "Server URL") };
return propertyDescriptors;
}

public Object getPropertyValue(Object id) {
return style.getServerURL();
}

public boolean isPropertySet(Object id) {

return false;
}

public void resetPropertyValue(Object id) {
//
}

public void setPropertyValue(Object id, Object value) {
style.setServerURL((String) value);

}

};

7) Modify the generated ???PropertySection in order to accept the new
style as input and to return the CustomProperty as propertySource:

protected Object transformSelection(Object selected) {
View view = null;
List styles;
if (selected instanceof View) {
view = ((View) selected);
} else if (selected instanceof EditPart) {
Object model = ((EditPart) selected).getModel();
view = ((View) model);
} else if (selected instanceof IAdaptable) {
view = (View) ((IAdaptable) selected).getAdapter(View.class);
}
if (view == null)
return null;
styles = view.getStyles();
for (Object style : styles) {
if (style instanceof PropertiesStyle)
return style;
}
return null;

}

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 new CustomProperties(object);
}
return null;
}

And tatan... you should have a working notational style. If there is
anything wrong in the process, tell me.
Thanks again for helping
Cheers

Nicola
Alex Shatalin wrote:

> Hello Nicola,


>> Do you have any working example?
> You can use one of the following ISection implementations as an example:
>
org.eclipse.gmf.runtime.diagram.ui.properties.sections.appea rance.ShapeColorsAndFontsPropertySection
>
org.eclipse.gmf.runtime.diagram.ui.properties.sections.appea rance.DiagramColorsAndFontsPropertySection
>
org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid. RulerGridPropertySection

> -----------------
> Alex Shatalin
Re: Diagram configuration option [message #198538 is a reply to message #198504] Wed, 23 July 2008 12:48 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

> The first problem (diagram not loading) was related to a problem with
> the properties.ecore file. It start to work when I deleted the EMF
> Model plugin and regenerate model.
Then it looks like it was something related to the meta-model registration.
Anyway, regenerating .model plugin is proper solution.

> (yes another one) is to access this notational style from the EMF
> editor.
Do you mean, openning diagram file in EMF-reflective editor and browsing
corresponding style objects (PropertiesStyle)/setting some properties to
it using EMF-based tree editor?

-----------------
Alex Shatalin
Re: Diagram configuration option [message #198562 is a reply to message #198538] Wed, 23 July 2008 13:08 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello Alex

> Do you mean, openning diagram file in EMF-reflective editor and browsing
> corresponding style objects (PropertiesStyle)/setting some properties to
> it using EMF-based tree editor?

I'm using EMF.Edit/Editor to set the attributes of my workflow model. One
of this attribute shows a dropdown list of possible choice that is
obtained from the server. So what I have to do is *just* read the
attributes (server url,login etc) in the PropertiesStyle object.
Cheers

Nicola
Re: Diagram configuration option [message #199151 is a reply to message #198562] Mon, 28 July 2008 10:36 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Sorry to bother you again.

I still don't know how to get the value of the notational property. I
suppose I have to use the transactional framework, and this is what I did:

In the GMF diagram plugin:
<extension
point="org.eclipse.emf.transaction.editingDomains">
<editingDomain
factory="org.eclipse.emf.workspace.WorkspaceEditingDomainFactory "
id="EditingDomain">
</editingDomain>
</extension>

in the RequestDocumentProvider:

private TransactionalEditingDomain createEditingDomain() {
TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory
.getInstance().createEditingDomain();

editingDomain.setID("EditingDomain"); //$NON-NLS-1$

and in my emf ActivityTypeItemProvider:

TransactionalEditingDomain editingDomain =
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "EditingDomain");
List resources = editingDomain.getResourceSet().getResources();

the editing domain returned is not null, but the resource list is empty,
thus I don't know how to retrieve the PropertiesStyle object. Please help.
I'm running short of time (and energies)
Thank you in advance

Nicola

Nicola Salvo wrote:

> Hello Alex

>> Do you mean, openning diagram file in EMF-reflective editor and browsing
>> corresponding style objects (PropertiesStyle)/setting some properties to
>> it using EMF-based tree editor?

> I'm using EMF.Edit/Editor to set the attributes of my workflow model. One
> of this attribute shows a dropdown list of possible choice that is
> obtained from the server. So what I have to do is *just* read the
> attributes (server url,login etc) in the PropertiesStyle object.
> Cheers

> Nicola
Re: Diagram configuration option [message #199167 is a reply to message #198562] Mon, 28 July 2008 10:48 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

> obtained from the server. So what I have to do is *just* read the
> attributes (server url,login etc) in the PropertiesStyle object.
Well, for this you have to define two attributes "url" and "login" in .ecore
model used to generate PropertiesStyle interface/imlementation. As a result
you'll be able to get/set corresponding attribute values just by calling
java API methods: myPtopertiesStyleInstance.getUrl()/myPtopertiesStyleInstance .getLogin().
Corresponding values will be automatically persisted into the diagram resource
on saving diagram..

BTW, I suggest you to edit .ecore file and generate code from there instead
of using annotated java. For this this (editing .ecore) way of specifying
meta-model looks more powerfull and explicit.

-----------------
Alex Shatalin
Re: Diagram configuration option [message #199220 is a reply to message #199167] Mon, 28 July 2008 12:45 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello Alex ,

thanks for the answer.

> Well, for this you have to define two attributes "url" and "login" in .ecore
> model used to generate PropertiesStyle interface/imlementation. As a result
> you'll be able to get/set corresponding attribute values just by calling
> java API methods:
myPtopertiesStyleInstance.getUrl()/myPtopertiesStyleInstance .getLogin().
> Corresponding values will be automatically persisted into the diagram
resource
> on saving diagram..

Yep is what I did. My problem is that I have to access this value form the
EMF.Edit code, meanwhile the PropertiesStyle is stored in the GMF diagram.
I tried using transaction but is not working, I tried with:

PropertiesStyle style = (PropertiesStyle)
PropertiesPackage.eINSTANCE.getPropertiesStyle();

but is not working as well.
I'm kind of desperate :D
Cheers

Nicola

I feel that I missing a detail that

> BTW, I suggest you to edit .ecore file and generate code from there instead
> of using annotated java. For this this (editing .ecore) way of specifying
> meta-model looks more powerfull and explicit.

> -----------------
> Alex Shatalin
Re: Diagram configuration option [message #199236 is a reply to message #199220] Mon, 28 July 2008 13:14 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

If you are going to create new instance of PropertiesStyle then you have
to use PropertiesFactory.eINSTANCE.createPropertiesStyle(). As a result you'll
get instance of PropertiesStyle to work with. If in the other places you
have to do something with this object you have to case EObject to PropertiesStyle
and call any methods on it..

-----------------
Alex Shatalin
Re: Diagram configuration option [message #199243 is a reply to message #199236] Mon, 28 July 2008 13:15 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Alex,

> you have to case EObject to PropertiesStyle and call any methods on it..
you have to cast EObject to PropertiesStyle and call any methods on it..

-----------------
Alex Shatalin
Re: Diagram configuration option [message #199281 is a reply to message #199236] Mon, 28 July 2008 15:23 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello Alex,

sorry but I didn't get it.

> If you are going to create new instance of PropertiesStyle then you have
> to use PropertiesFactory.eINSTANCE.createPropertiesStyle(). As a result
you'll
> get instance of PropertiesStyle to work with. If in the other places you
> have to do something with this object you have to case EObject to
PropertiesStyle
> and call any methods on it..

I don't have to create the object in my method. Is created somewhere and
the user using my property sheet will set the properties.
In the EMF.Edif having an EObject I will be easy to cast it. The problem
is that the best I can get is an EClass with
PropertiesPackage.eINSTANCE.getPropertiesStyle_ServerURL() and is not
possible to cast it.
Probably I'm missing something.

Nicola
Re: Diagram configuration option [message #199288 is a reply to message #199281] Mon, 28 July 2008 16:15 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nicola,

> In the EMF.Edif having an EObject I will be easy to cast it. The
> problem is that the best I can get is an EClass with
> PropertiesPackage.eINSTANCE.getPropertiesStyle_ServerURL() and
This is a meta-object, but you should be able to access real instance of
the PropertiesStyle interface to set appropriate value on it..

-----------------
Alex Shatalin
Previous Topic:trying to add GMF plugin
Next Topic:Can we determine incoming connections from the impl?
Goto Forum:
  


Current Time: Sat Jun 06 11:05:44 GMT 2020

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

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

Back to the top