Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » creating file
creating file [message #173646] Fri, 22 February 2008 06:48 Go to next message
Eclipse UserFriend
Originally posted by: aritz.galdos.iese.fraunhofer.de

Good afternoon!!!

I have created my own diagram editor by GMF. And now, when the users makes
an action, I have to create a diagram-file. When wou create a diagram, two
files are created: test.xxx and test.xxx_diagram. (xxx is the name that I
have given to my model).

So, is any method, or class that creates both files together? or, have I got
to create both files manually, I mean:

IFile myFile1 = myProject.getFile(test.xxx );
IFile myFile1 = myProject.getFile(test.xxx?diagram );

Because I know, that some info is stored from the beginning in one of the
files.

Thank you in advance

Aritz
Re: creating file [message #173662 is a reply to message #173646] Fri, 22 February 2008 07:05 Go to previous messageGo to next message
Eclipse UserFriend
Hello Aritz,

See generated xxxDiagramEditorUtil.createDiagram(diagramModelFilePage.getU RI(),
domainModelFilePage.getURI(), monitor)

-----------------
Alex Shatalin
Re: creating file [message #174732 is a reply to message #173662] Thu, 28 February 2008 03:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aritz.galdos.iese.fraunhofer.de

Hello!

Thank you for your answer, but now I have another problem. I can't acces to
domainModel... variables. I have imported their packages, but it doesn't
recognize it. My code is the next.

//supposedly, to create the file
Resource r =
RuntimeViewmodelDiagramEditorUtil.createDiagram(domainModelF ilePage.getURI(),
domainModelFilePage.getURI(), progressMonitor);

//getting the editor

IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();

IEditorInput myEditorInput = new FileEditorInput(myDiagramFile);

IEditorDescriptor desc =
PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or();

String myDescId = desc.getId();



try {

EditorPart myEditor = (EditorPart) page.openEditor(myEditorInput, myDescId);

DiagramDocumentEditor myDiagramDocumentEditor = (DiagramDocumentEditor)
myEditor;

Diagram myDiagram = myDiagramDocumentEditor.getDiagram();


I know that the domainModel... is defined in RuntimeViewmodelCreationWizard,
but it doesn't recognize the variable. So, what can I do to solve my
problem? I don't know if I need the other code that I have writen above, I
did it just in case.

Thank in advance, and I am sorry because of my poor English.

Aritz



"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e61e6168ca436abc20c99d@news.eclipse.org...
> Hello Aritz,
>
> See generated
> xxxDiagramEditorUtil.createDiagram(diagramModelFilePage.getU RI(),
> domainModelFilePage.getURI(), monitor)
>
> -----------------
> Alex Shatalin
>
>
Re: creating file [message #174750 is a reply to message #174732] Thu, 28 February 2008 04:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aritz.galdos.iese.fraunhofer.de

Hello again!!!

I have my URI of the diagram that I want to create, but it seems that
"xxxDiagramEditorUtil.createDiagram" method suposses that I have created a
model. So, is there any posibility to create the two files (the model and
the diagram?), instead of creating apartly? Unless, how can I create the
model, to get its URI, the second parameter of
xxxDiagramEditorUtil.createDiagram method?

Thank you in advance!!
Don't pay attention to the other question, thak you, and sorry because of my
poor English!!

Aritz


"Aritz" <aritz.galdos@iese.fraunhofer.de> wrote in message
news:fq5sa2$sh6$1@build.eclipse.org...
> Hello!
>
> Thank you for your answer, but now I have another problem. I can't acces
> to domainModel... variables. I have imported their packages, but it
> doesn't recognize it. My code is the next.
>
> //supposedly, to create the file
> Resource r =
> RuntimeViewmodelDiagramEditorUtil.createDiagram(domainModelF ilePage.getURI(),
> domainModelFilePage.getURI(), progressMonitor);
>
> //getting the editor
>
> IWorkbenchPage page =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>
> IEditorInput myEditorInput = new FileEditorInput(myDiagramFile);
>
> IEditorDescriptor desc =
> PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or();
>
> String myDescId = desc.getId();
>
>
>
> try {
>
> EditorPart myEditor = (EditorPart) page.openEditor(myEditorInput,
> myDescId);
>
> DiagramDocumentEditor myDiagramDocumentEditor = (DiagramDocumentEditor)
> myEditor;
>
> Diagram myDiagram = myDiagramDocumentEditor.getDiagram();
>
>
> I know that the domainModel... is defined in
> RuntimeViewmodelCreationWizard, but it doesn't recognize the variable. So,
> what can I do to solve my problem? I don't know if I need the other code
> that I have writen above, I did it just in case.
>
> Thank in advance, and I am sorry because of my poor English.
>
> Aritz
>
>
>
> "Alex Shatalin" <vano@borland.com> wrote in message
> news:3c3172e61e6168ca436abc20c99d@news.eclipse.org...
>> Hello Aritz,
>>
>> See generated
>> xxxDiagramEditorUtil.createDiagram(diagramModelFilePage.getU RI(),
>> domainModelFilePage.getURI(), monitor)
>>
>> -----------------
>> Alex Shatalin
>>
>>
>
>
Re: creating file [message #174854 is a reply to message #174750] Thu, 28 February 2008 11:17 Go to previous message
Eclipse UserFriend
Originally posted by: aritz.galdos.iese.fraunhofer.de

Hello again!!

I am getting my staff step by step, but now I have another problem I want to
create the diagram file and the "supporting" file. My code is the nest one:

//getting the workspace

IWorkspace myWorkspace =
org.eclipse.core.resources.ResourcesPlugin.getWorkspace();

//getting the root of the workspace

IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();


//getting the project

String projectName = uri.segment(1); //to get the name of the project

IProject myProject = myWorkspaceRoot.getProject(projectName);


//getting the files: diagram and xml

String diagramName = traceName + "." + extensionDiagram;

IFile myDiagramFile = myProject.getFile(diagramName);

String fileName = traceName + "." + extension;

IFile myFile = myProject.getFile (fileName);


//getting and creating the path to store the diagram

URI uriDiagram = URI.createPlatformResourceURI(projectName, false);

URI uriFile = URI.createPlatformResourceURI(projectName, false);

uriDiagram =
uriDiagram.appendSegment(traceName).appendFileExtension(exte nsionDiagram);

uriFile = uriFile.appendSegment(traceName).appendFileExtension(extensi on);



//creating the files

TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE.createEditingDomain();

Resource diagramResource =
editingDomain.getResourceSet().createResource(uriDiagram);

Resource fileResource =
editingDomain.getResourceSet().createResource(uriFile);


Resource rD = RuntimeViewmodelDiagramEditorUtil.createDiagram(uriDiagram,
diagramResource.getURI(), new NullProgressMonitor());

Resource rF = RuntimeViewmodelDiagramEditorUtil.createDiagram(uriFile,
fileResource.getURI(), new NullProgressMonitor());


try {

if (!RuntimeViewmodelDiagramEditorUtil.openDiagram(rD))

MessageDialog.openInformation(shell, "Error", "It is not possible to open
the diagram");

} catch (PartInitException e) {

MessageDialog.openInformation(shell, "Error", "It is not possible to open
the diagram");}


//getting the editor

IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();

IEditorInput myEditorInput = new FileEditorInput(myDiagramFile);

IEditorDescriptor desc =
PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or(diagramName);

String myDescId = desc.getId();


try {

EditorPart myEditor = (EditorPart) page.openEditor(myEditorInput, myDescId);

DiagramDocumentEditor myDiagramDocumentEditor = (DiagramDocumentEditor)
myEditor;

Diagram myDiagram = myDiagramDocumentEditor.getDiagram();


//processing domain-specific information: the referenced business model
element

EObject myUnderlyingDomainElement = myDiagram.getElement();


//implementing the listener, for the changed made in the runtime view

myUnderlyingDomainElement.eAdapters().add(new RTViewmodelListener(trace));

}

catch (Exception e) {

System.out.println("PartInitException: " + e);}







So, my problem is: when I create a diagram manually (file --> new -->
runtimeviewmodel diagram...) I can open it, modify... thee by the editor, I
mean, I can add objects to my diagram. The problem is that if I create the
diagram by the code above, I can't do anything by the editor, only open it.

Can anybody help me? Thank you very much!!! (Sorry because of my poor
English!!)

Aritz










"Aritz" <aritz.galdos@iese.fraunhofer.de> wrote in message
news:fq5tf6$1lj$1@build.eclipse.org...
> Hello again!!!
>
> I have my URI of the diagram that I want to create, but it seems that
> "xxxDiagramEditorUtil.createDiagram" method suposses that I have created a
> model. So, is there any posibility to create the two files (the model and
> the diagram?), instead of creating apartly? Unless, how can I create the
> model, to get its URI, the second parameter of
> xxxDiagramEditorUtil.createDiagram method?
>
> Thank you in advance!!
> Don't pay attention to the other question, thak you, and sorry because of
> my poor English!!
>
> Aritz
>
>
> "Aritz" <aritz.galdos@iese.fraunhofer.de> wrote in message
> news:fq5sa2$sh6$1@build.eclipse.org...
>> Hello!
>>
>> Thank you for your answer, but now I have another problem. I can't acces
>> to domainModel... variables. I have imported their packages, but it
>> doesn't recognize it. My code is the next.
>>
>> //supposedly, to create the file
>> Resource r =
>> RuntimeViewmodelDiagramEditorUtil.createDiagram(domainModelF ilePage.getURI(),
>> domainModelFilePage.getURI(), progressMonitor);
>>
>> //getting the editor
>>
>> IWorkbenchPage page =
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>>
>> IEditorInput myEditorInput = new FileEditorInput(myDiagramFile);
>>
>> IEditorDescriptor desc =
>> PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or();
>>
>> String myDescId = desc.getId();
>>
>>
>>
>> try {
>>
>> EditorPart myEditor = (EditorPart) page.openEditor(myEditorInput,
>> myDescId);
>>
>> DiagramDocumentEditor myDiagramDocumentEditor = (DiagramDocumentEditor)
>> myEditor;
>>
>> Diagram myDiagram = myDiagramDocumentEditor.getDiagram();
>>
>>
>> I know that the domainModel... is defined in
>> RuntimeViewmodelCreationWizard, but it doesn't recognize the variable.
>> So, what can I do to solve my problem? I don't know if I need the other
>> code that I have writen above, I did it just in case.
>>
>> Thank in advance, and I am sorry because of my poor English.
>>
>> Aritz
>>
>>
>>
>> "Alex Shatalin" <vano@borland.com> wrote in message
>> news:3c3172e61e6168ca436abc20c99d@news.eclipse.org...
>>> Hello Aritz,
>>>
>>> See generated
>>> xxxDiagramEditorUtil.createDiagram(diagramModelFilePage.getU RI(),
>>> domainModelFilePage.getURI(), monitor)
>>>
>>> -----------------
>>> Alex Shatalin
>>>
>>>
>>
>>
>
>
Previous Topic:Open other projects editor
Next Topic:Error while creating generator model
Goto Forum:
  


Current Time: Thu Jul 10 01:49:45 EDT 2025

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

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

Back to the top