Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Extend generated GMF diagram wizard
Extend generated GMF diagram wizard [message #220813] Mon, 09 March 2009 15:39 Go to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi,

I would like to know how can I extend the defualt diagram wizard generated
by GMF. I have some XMI files from which I will like to choose the ones I
will like and load the data into the newly created diagram file.

Does anyone know how can I resolve this problem? Which classes I need to
modify and is there any example that can guide me?

Thanks,

Achilleas
Re: Extend generated GMF diagram wizard [message #221003 is a reply to message #220813] Tue, 10 March 2009 14:59 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Achilleas wrote:

> Hi,

> I would like to know how can I extend the defualt diagram wizard generated
> by GMF. I have some XMI files from which I will like to choose the ones I
> will like and load the data into the newly created diagram file.

> Does anyone know how can I resolve this problem? Which classes I need to
> modify and is there any example that can guide me?

> Thanks,

> Achilleas

Hi again,

I have modify the wizard and added the pages I want to collect additional
information that I need to store in the diagram model when it is created.

The problem is that I don't know how to modify the createInitialModel
method in the MultimodelDiagramEditorUtil class, which is called from the
performFinish method of the MultimodelCreationWizard class. Basically I
want to store the additional information collected from the newly added
wizard pages to the diagram model.

I tried to do it by hard-coding some initial values to the elements
(instead of reading the values from the xmi files specified through the
wizard) using the following code:

private static Root createInitialModel() {
Root root = MultimodelFactory.eINSTANCE.createRoot();

ProductSpecification ps =
MultimodelFactory.eINSTANCE.createProductSpecification();
ps.setName("BT Home Hub");

ProductCharacteristic pc =
MultimodelFactory.eINSTANCE.createProductCharacteristic();
pc.setType("Download Speed");
pc.setValue("8Mbps");

ProductCharacteristic pc1 =
MultimodelFactory.eINSTANCE.createProductCharacteristic();
pc1.setType("Upload Speed");
pc1.setValue("2Mbps");

EStructuralFeature productSpec =
(EStructuralFeature)root.eClass().getEStructuralFeature("ProductSpecification ");
EStructuralFeature productChar =
(EStructuralFeature)root.eClass().getEStructuralFeature("ProductCharacteristic ");

root.eSet(productSpec, ps);
root.eSet(productChar, pc);
root.eSet(productChar, pc1);

return root;
}

But it does not do anything. It even does not create the diagram model
(file) if I insert this code. Is this the correct approach or i am doing
it completely wrong?

Thanks,

Achilleas
Re: Extend generated GMF diagram wizard [message #221114 is a reply to message #221003] Tue, 10 March 2009 17:06 Go to previous messageGo to next message
Peter Mising name is currently offline Peter Mising nameFriend
Messages: 95
Registered: July 2009
Member
Hi,
this definitely works. I do similar stuff with my UML Editor.
Maybe something else is wrong?
Attach the model to resource?
Save resource?


> Hi again,
>
> I have modify the wizard and added the pages I want to collect
> additional information that I need to store in the diagram model when it
> is created.
>
> The problem is that I don't know how to modify the createInitialModel
> method in the MultimodelDiagramEditorUtil class, which is called from
> the performFinish method of the MultimodelCreationWizard class.
> Basically I want to store the additional information collected from the
> newly added wizard pages to the diagram model.
>
> I tried to do it by hard-coding some initial values to the elements
> (instead of reading the values from the xmi files specified through the
> wizard) using the following code:
>
> private static Root createInitialModel() {
> Root root = MultimodelFactory.eINSTANCE.createRoot();
>
> ProductSpecification ps =
> MultimodelFactory.eINSTANCE.createProductSpecification();
> ps.setName("BT Home Hub");
>
> ProductCharacteristic pc =
> MultimodelFactory.eINSTANCE.createProductCharacteristic();
> pc.setType("Download Speed");
> pc.setValue("8Mbps");
>
> ProductCharacteristic pc1 =
> MultimodelFactory.eINSTANCE.createProductCharacteristic();
> pc1.setType("Upload Speed");
> pc1.setValue("2Mbps");
>
> EStructuralFeature productSpec =
> (EStructuralFeature)root.eClass().getEStructuralFeature("ProductSpecification ");
>
> EStructuralFeature productChar =
> (EStructuralFeature)root.eClass().getEStructuralFeature("ProductCharacteristic ");
>
>
> root.eSet(productSpec, ps);
> root.eSet(productChar, pc);
> root.eSet(productChar, pc1);
>
> return root;
> }
>
> But it does not do anything. It even does not create the diagram model
> (file) if I insert this code. Is this the correct approach or i am doing
> it completely wrong?
>
> Thanks,
>
> Achilleas
>
>
Re: Extend generated GMF diagram wizard [message #221130 is a reply to message #221114] Tue, 10 March 2009 19:24 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi,

I now know that it should work and thank you for pointing that out! But
unfortunately it does not. The problem is created at the line of code
where I use the eSet function for the first time!

I believe I must use another way to set the elements to the root. I have
read and find out something about TransactionalEditingDomain but I don't
know how to use it yet.

Any suggestions will be appreciated.

Thanks,

Achilleas
Re: Extend generated GMF diagram wizard [message #221138 is a reply to message #221130] Tue, 10 March 2009 22:49 Go to previous messageGo to next message
Peter Mising name is currently offline Peter Mising nameFriend
Messages: 95
Registered: July 2009
Member
Hi, ok thats it. The creation is done in a TransactionalCommand. So you
already use the editing domain. This is ok. I only work with uml but I
think its similar in ecore. Try to use the reference to the
childElements to add them to the root.

> Hi,
>
> I now know that it should work and thank you for pointing that out! But
> unfortunately it does not. The problem is created at the line of code
> where I use the eSet function for the first time!
>
> I believe I must use another way to set the elements to the root. I have
> read and find out something about TransactionalEditingDomain but I don't
> know how to use it yet.
>
> Any suggestions will be appreciated.
>
> Thanks,
>
> Achilleas
>
Re: Extend generated GMF diagram wizard [message #221354 is a reply to message #221138] Fri, 13 March 2009 09:45 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi Peter,

What do you mean with Try to use the reference to the childElements to add
them to the root?

Could you provide an example? I only manage to store the elements in the
diagram Resource but the view part is missing and apparently it cannot be
shown onto the figure.

Thanks,

Achilleas
Re: Extend generated GMF diagram wizard [message #221362 is a reply to message #221354] Fri, 13 March 2009 10:40 Go to previous messageGo to next message
Peter Mising name is currently offline Peter Mising nameFriend
Messages: 95
Registered: July 2009
Member
Hi Achilleas,
I only work with uml. I mean to use the corresponding method to
getPackagedElements() in your Metamodel. I only added these Elements to
the model Resource. No need to add anything on the diagram Part.

....
AbstractTransactionalCommand command = new AbstractTransactionalCommand(
editingDomain,
Messages.UMLDiagramEditorUtil_CreateDiagramCommandLabel,
Collections.EMPTY_LIST) {
protected CommandResult doExecuteWithResult( IProgressMonitor
monitor, IAdaptable info)
throws ExecutionException {

Package model = UMLFactory.eINSTANCE.createModel();
model.setName(modelName);
Package pack1 = UMLFactory.eINSTANCE.createPackage();
Package pack2 = UMLFactory.eINSTANCE.createPackage();
pack1.setName("pack1");
pack2.setName("pack2");
model.getPackagedElements().add(pack1);
model.getPackagedElements().add(pack2);

attachModelToResource(model,modelResource);
....

Peter


> Hi Peter,
>
> What do you mean with Try to use the reference to the childElements to
> add them to the root?
>
> Could you provide an example? I only manage to store the elements in the
> diagram Resource but the view part is missing and apparently it cannot
> be shown onto the figure.
>
> Thanks,
>
> Achilleas
>
Re: Extend generated GMF diagram wizard [message #221398 is a reply to message #221362] Fri, 13 March 2009 15:17 Go to previous message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi Peter,

"No need to add anything on the diagram Part."

What you said as quoted above directed me to the right way to do it.

Thanks,

Achilleas
Previous Topic:How to install latest stable build of GMF?
Next Topic:Animating a diagram editor
Goto Forum:
  


Current Time: Fri Mar 05 16:56:40 GMT 2021

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

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

Back to the top