Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF Editor without FileInput
GMF Editor without FileInput [message #222764] Wed, 25 March 2009 13:37 Go to next message
Eclipse UserFriend
Originally posted by: marmeladenfaust.gmx.net

Hi,

how can I change the Editor created by GMF to accept an EditorInput,
that isn't a FileEditorInput or an IFile?
I want to analyse some data and display the results with this Editor.
Editing and Saving should also be in my hands.. as the changes must be
mapped to the data and not be written into a single file.

Thanks,
Malte
Re: GMF Editor without FileInput [message #222825 is a reply to message #222764] Thu, 26 March 2009 09:04 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi,

This could help?

In your DiagramEditor, the method below opens the editor with new
EditorInput, you could change it here.

// in Diagram Editor
public static boolean openDiagram(Resource diagram)
throws PartInitException {
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
>> page.openEditor(new URIEditorInput(diagram.getURI()),
YourDiagramEditor.ID);
return true;
}


.....and make sure the DocumentProvider can handle your new Editor input.

// In Document provider

protected ElementInfo createElementInfo(Object element)
throws CoreException {
if (false == element instanceof URIEditorInput) {
...
}
IEditorInput editorInput = (IEditorInput) element;
IDiagramDocument document = (IDiagramDocument)
createDocument(editorInput);

ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
...
}

.... also here you need to hackin to set your content properly, you might
need your version of DiagramDocument


protected void setDocumentContent(IDocument document, IEditorInput element)
throws CoreException {
IDiagramDocument diagramDocument = (IDiagramDocument) document;
TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
......
EObject rootElement = resource.getEObject(uri.fragment());
if (rootElement instanceof Diagram) {
document.setContent((Diagram) rootElement);
return;
}
......





.... Of course the Resource if by default an EMF Resource with certain
characteristics. (Like XMI serialization), you could change this by
creating a ResourceFactory and tigh this factory to an extension or
protocol.

//plugin.xml

<extension point="org.eclipse.emf.ecore.extension_parser"
id="resource-factory">
<?gmfgen generated="true"?>
<parser
type="your extension"

>>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
</parser>
</extension>

....Your factory my need a custom Resource used by the document provider
to set the content.



Malte wrote:
> Hi,
>
> how can I change the Editor created by GMF to accept an EditorInput,
> that isn't a FileEditorInput or an IFile?
> I want to analyse some data and display the results with this Editor.
> Editing and Saving should also be in my hands.. as the changes must be
> mapped to the data and not be written into a single file.
>
> Thanks,
> Malte
Re: GMF Editor without FileInput [message #222882 is a reply to message #222825] Thu, 26 March 2009 15:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marmeladenfaust.gmx.net

Hi,

thank you very much for your detailed answer. I will try to get this
approach clear to my mind now.
Yesterday I tried another way to solve the problem, could you please
give some Feedback, if this could be a possible solution to the problem?:
I tried to write my own DocumentProvider, because I thought
DocumentProviders are the central point, were writing and reading of the
File happens.. My hope was: Instead of writing or loading a file at this
point, I can call my own methods in "createDocument()" or
"doSaveDocument(...)", to map the model to some file structure.. is this
correct?

I modified the Method:
public ModelDocumentProvider getDocumentProvider()
in my XXXDiagramEditorPlugIn-Class to return my customDocumentProvider.
Unfortunately looking up the EditDomain in
EditPartService.createEditPart(EditPart context, final Object model)
fails because he is looking for some Resource(-Set) in the Method
TransactionUtil.getEditingDomain(EObject eObject)
, which isn't there (because I don't want to have a persistent resource,
I want to create an Instance of Diagram myself and open the Editor to
show the Diagram). I'm afraid, that there are maybe many calls to some
resources and I currently don't now how to manage this problem.

Thanks for the patience,
Malte

Christophe Bouhier schrieb:
> Hi,
>
> This could help?
>
> In your DiagramEditor, the method below opens the editor with new
> EditorInput, you could change it here.
>
> // in Diagram Editor
> public static boolean openDiagram(Resource diagram)
> throws PartInitException {
> IWorkbenchPage page = PlatformUI.getWorkbench()
> .getActiveWorkbenchWindow().getActivePage();
> >> page.openEditor(new URIEditorInput(diagram.getURI()),
> YourDiagramEditor.ID);
> return true;
> }
>
>
> .....and make sure the DocumentProvider can handle your new Editor input.
>
> // In Document provider
>
> protected ElementInfo createElementInfo(Object element)
> throws CoreException {
> if (false == element instanceof URIEditorInput) {
> ...
> }
> IEditorInput editorInput = (IEditorInput) element;
> IDiagramDocument document = (IDiagramDocument)
> createDocument(editorInput);
>
> ResourceSetInfo info = new ResourceSetInfo(document,
> editorInput);
> ...
> }
>
> .... also here you need to hackin to set your content properly, you might
> need your version of DiagramDocument
>
>
> protected void setDocumentContent(IDocument document, IEditorInput element)
> throws CoreException {
> IDiagramDocument diagramDocument = (IDiagramDocument) document;
> TransactionalEditingDomain domain =
> diagramDocument.getEditingDomain();
> ......
> EObject rootElement = resource.getEObject(uri.fragment());
> if (rootElement instanceof Diagram) {
> document.setContent((Diagram) rootElement);
> return;
> }
> ......
>
>
>
>
>
> .... Of course the Resource if by default an EMF Resource with certain
> characteristics. (Like XMI serialization), you could change this by
> creating a ResourceFactory and tigh this factory to an extension or
> protocol.
>
> //plugin.xml
>
> <extension point="org.eclipse.emf.ecore.extension_parser"
> id="resource-factory">
> <?gmfgen generated="true"?>
> <parser
> type="your extension"
>
> >>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
> </parser>
> </extension>
>
> ....Your factory my need a custom Resource used by the document provider
> to set the content.
>
>
>
> Malte wrote:
>> Hi,
>>
>> how can I change the Editor created by GMF to accept an EditorInput,
>> that isn't a FileEditorInput or an IFile?
>> I want to analyse some data and display the results with this Editor.
>> Editing and Saving should also be in my hands.. as the changes must be
>> mapped to the data and not be written into a single file.
>>
>> Thanks,
>> Malte
Re: GMF Editor without FileInput [message #222891 is a reply to message #222882] Thu, 26 March 2009 16:46 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
A Diagram is stored in an EMF Ecore structures which is stored in a
Resource, not sure how to get around this, without your own Resource and
corresponding Factory.

can you be specific about:
"I want to create an Instance of Diagram myself"


Malte wrote:
> Hi,
>
> thank you very much for your detailed answer. I will try to get this
> approach clear to my mind now.
> Yesterday I tried another way to solve the problem, could you please
> give some Feedback, if this could be a possible solution to the problem?:
> I tried to write my own DocumentProvider, because I thought
> DocumentProviders are the central point, were writing and reading of the
> File happens.. My hope was: Instead of writing or loading a file at this
> point, I can call my own methods in "createDocument()" or
> "doSaveDocument(...)", to map the model to some file structure.. is this
> correct?
>
> I modified the Method:
> public ModelDocumentProvider getDocumentProvider()
> in my XXXDiagramEditorPlugIn-Class to return my customDocumentProvider.
> Unfortunately looking up the EditDomain in
> EditPartService.createEditPart(EditPart context, final Object model)
> fails because he is looking for some Resource(-Set) in the Method
> TransactionUtil.getEditingDomain(EObject eObject)
> , which isn't there (because I don't want to have a persistent resource,
> I want to create an Instance of Diagram myself and open the Editor to
> show the Diagram). I'm afraid, that there are maybe many calls to some
> resources and I currently don't now how to manage this problem.
>
> Thanks for the patience,
> Malte
>
> Christophe Bouhier schrieb:
>> Hi,
>>
>> This could help?
>>
>> In your DiagramEditor, the method below opens the editor with new
>> EditorInput, you could change it here.
>>
>> // in Diagram Editor
>> public static boolean openDiagram(Resource diagram)
>> throws PartInitException {
>> IWorkbenchPage page = PlatformUI.getWorkbench()
>> .getActiveWorkbenchWindow().getActivePage();
>> >> page.openEditor(new URIEditorInput(diagram.getURI()),
>> YourDiagramEditor.ID);
>> return true;
>> }
>>
>>
>> .....and make sure the DocumentProvider can handle your new Editor input.
>>
>> // In Document provider
>>
>> protected ElementInfo createElementInfo(Object element)
>> throws CoreException {
>> if (false == element instanceof URIEditorInput) {
>> ...
>> }
>> IEditorInput editorInput = (IEditorInput) element;
>> IDiagramDocument document = (IDiagramDocument)
>> createDocument(editorInput);
>>
>> ResourceSetInfo info = new ResourceSetInfo(document,
>> editorInput);
>> ... }
>>
>> .... also here you need to hackin to set your content properly, you might
>> need your version of DiagramDocument
>>
>>
>> protected void setDocumentContent(IDocument document, IEditorInput
>> element)
>> throws CoreException {
>> IDiagramDocument diagramDocument = (IDiagramDocument) document;
>> TransactionalEditingDomain domain =
>> diagramDocument.getEditingDomain();
>> ......
>> EObject rootElement = resource.getEObject(uri.fragment());
>> if (rootElement instanceof Diagram) {
>> document.setContent((Diagram) rootElement);
>> return;
>> }
>> ......
>>
>>
>>
>>
>>
>> .... Of course the Resource if by default an EMF Resource with certain
>> characteristics. (Like XMI serialization), you could change this by
>> creating a ResourceFactory and tigh this factory to an extension or
>> protocol.
>>
>> //plugin.xml
>>
>> <extension point="org.eclipse.emf.ecore.extension_parser"
>> id="resource-factory">
>> <?gmfgen generated="true"?>
>> <parser
>> type="your extension"
>>
>> >>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
>> </parser>
>> </extension>
>>
>> ....Your factory my need a custom Resource used by the document
>> provider to set the content.
>>
>>
>>
>> Malte wrote:
>>> Hi,
>>>
>>> how can I change the Editor created by GMF to accept an EditorInput,
>>> that isn't a FileEditorInput or an IFile?
>>> I want to analyse some data and display the results with this Editor.
>>> Editing and Saving should also be in my hands.. as the changes must
>>> be mapped to the data and not be written into a single file.
>>>
>>> Thanks,
>>> Malte
Re: GMF Editor without FileInput [message #222944 is a reply to message #222891] Fri, 27 March 2009 10:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marmeladenfaust.gmx.net

I was thinking about something like that:

Before calling IDE.openEditor(...):
1. calling ModelFactory.eINSTANCE.createXXXDiagram();
2. creating instances of my ModelElements (in my case:
ModelFactory.eINSTANCE.createStateShape()) and putting them into a
collection
3. create Connections between my elements (in my case:
ModelFactory.eINSTANCE.createTransitions() and setting the source and
target)
4. calling the Method eSet(int featureID, Object newValue) of my
Diagram-instance with the collection as parameter (in my case:
eSet(ModelPackage.STATE_MACHINE_DIAGRAM__STATE_SHAPES, collection) )

This Diagram should now be displayed by the Editor.
At this point I have no idea of a promising approach.

I got your answer as followed:
1. I need an URIEditorInput (but it needs a concrete file, or am I
wrong? I only have my diagram-object)
2. The createDocument() Method in my DocumentProvider must understand
this EditorInput
3. I need an own Resource and an own ResourceFactory

Is it maybe possible to extend the existing resources and just overwrite
the methods that do the save and load work?

Regards,
Malte






Christophe Bouhier schrieb:
> A Diagram is stored in an EMF Ecore structures which is stored in a
> Resource, not sure how to get around this, without your own Resource and
> corresponding Factory.
>
> can you be specific about:
> "I want to create an Instance of Diagram myself"
>
>
> Malte wrote:
>> Hi,
>>
>> thank you very much for your detailed answer. I will try to get this
>> approach clear to my mind now.
>> Yesterday I tried another way to solve the problem, could you please
>> give some Feedback, if this could be a possible solution to the problem?:
>> I tried to write my own DocumentProvider, because I thought
>> DocumentProviders are the central point, were writing and reading of
>> the File happens.. My hope was: Instead of writing or loading a file
>> at this point, I can call my own methods in "createDocument()" or
>> "doSaveDocument(...)", to map the model to some file structure.. is
>> this correct?
>>
>> I modified the Method:
>> public ModelDocumentProvider getDocumentProvider()
>> in my XXXDiagramEditorPlugIn-Class to return my customDocumentProvider.
>> Unfortunately looking up the EditDomain in
>> EditPartService.createEditPart(EditPart context, final Object model)
>> fails because he is looking for some Resource(-Set) in the Method
>> TransactionUtil.getEditingDomain(EObject eObject)
>> , which isn't there (because I don't want to have a persistent
>> resource, I want to create an Instance of Diagram myself and open the
>> Editor to show the Diagram). I'm afraid, that there are maybe many
>> calls to some resources and I currently don't now how to manage this
>> problem.
>>
>> Thanks for the patience,
>> Malte
>>
>> Christophe Bouhier schrieb:
>>> Hi,
>>>
>>> This could help?
>>>
>>> In your DiagramEditor, the method below opens the editor with new
>>> EditorInput, you could change it here.
>>>
>>> // in Diagram Editor
>>> public static boolean openDiagram(Resource diagram)
>>> throws PartInitException {
>>> IWorkbenchPage page = PlatformUI.getWorkbench()
>>> .getActiveWorkbenchWindow().getActivePage();
>>> >> page.openEditor(new URIEditorInput(diagram.getURI()),
>>> YourDiagramEditor.ID);
>>> return true;
>>> }
>>>
>>>
>>> .....and make sure the DocumentProvider can handle your new Editor
>>> input.
>>>
>>> // In Document provider
>>>
>>> protected ElementInfo createElementInfo(Object element)
>>> throws CoreException {
>>> if (false == element instanceof URIEditorInput) {
>>> ...
>>> }
>>> IEditorInput editorInput = (IEditorInput) element;
>>> IDiagramDocument document = (IDiagramDocument)
>>> createDocument(editorInput);
>>>
>>> ResourceSetInfo info = new ResourceSetInfo(document,
>>> editorInput);
>>> ... }
>>>
>>> .... also here you need to hackin to set your content properly, you
>>> might
>>> need your version of DiagramDocument
>>>
>>>
>>> protected void setDocumentContent(IDocument document, IEditorInput
>>> element)
>>> throws CoreException {
>>> IDiagramDocument diagramDocument = (IDiagramDocument) document;
>>> TransactionalEditingDomain domain =
>>> diagramDocument.getEditingDomain();
>>> ......
>>> EObject rootElement = resource.getEObject(uri.fragment());
>>> if (rootElement instanceof Diagram) {
>>> document.setContent((Diagram) rootElement);
>>> return;
>>> }
>>> ......
>>>
>>>
>>>
>>>
>>>
>>> .... Of course the Resource if by default an EMF Resource with
>>> certain characteristics. (Like XMI serialization), you could change
>>> this by
>>> creating a ResourceFactory and tigh this factory to an extension or
>>> protocol.
>>>
>>> //plugin.xml
>>>
>>> <extension point="org.eclipse.emf.ecore.extension_parser"
>>> id="resource-factory">
>>> <?gmfgen generated="true"?>
>>> <parser
>>> type="your extension"
>>>
>>> >>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
>>>
>>> </parser>
>>> </extension>
>>>
>>> ....Your factory my need a custom Resource used by the document
>>> provider to set the content.
>>>
>>>
>>>
>>> Malte wrote:
>>>> Hi,
>>>>
>>>> how can I change the Editor created by GMF to accept an EditorInput,
>>>> that isn't a FileEditorInput or an IFile?
>>>> I want to analyse some data and display the results with this
>>>> Editor. Editing and Saving should also be in my hands.. as the
>>>> changes must be mapped to the data and not be written into a single
>>>> file.
>>>>
>>>> Thanks,
>>>> Malte
Re: GMF Editor without FileInput [message #222961 is a reply to message #222944] Fri, 27 March 2009 11:08 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
See inline comments.

Malte wrote:
> I was thinking about something like that:
>
> Before calling IDE.openEditor(...):
> 1. calling ModelFactory.eINSTANCE.createXXXDiagram();
> 2. creating instances of my ModelElements (in my case:
> ModelFactory.eINSTANCE.createStateShape()) and putting them into a
> collection
> 3. create Connections between my elements (in my case:
> ModelFactory.eINSTANCE.createTransitions() and setting the source and
> target)
> 4. calling the Method eSet(int featureID, Object newValue) of my
> Diagram-instance with the collection as parameter (in my case:
> eSet(ModelPackage.STATE_MACHINE_DIAGRAM__STATE_SHAPES, collection) )
>

Your model can exist outside a resource of course, so if you build it
programmaticly, like you suggest here is all fine. This would already
be a memory representation of your model in runtime which is not
persisted to any resource, but read on below....


> This Diagram should now be displayed by the Editor.
> At this point I have no idea of a promising approach.
>
> I got your answer as followed:
> 1. I need an URIEditorInput (but it needs a concrete file, or am I
> wrong? I only have my diagram-object)
Not necessarly, it could be any type of URI which can be understood by
your Resource. The default EMF URI is indeed a file URI, as the
underlying resource is an XMLResource which serializes your model to an
XML based file. (XMI is the schema used).

The point is, whatever URI you provide to your Resource it needs to be
understood by it. It seems this is what you want to achieve?

A good example of this is the URI's defined by the Hibernate framework.
The HibernateResourceFactory creates an HibernateResource which is
stored in an RDMS like mysql etc..

See this link here:

http://www.elver.org/hibernate/hibernateresources.html


Also replacing The declarations in your plugin.xml will determine which
ResourceFactory to invoke.



> 2. The createDocument() Method in my DocumentProvider must understand
> this EditorInput
Yes, but if you stick to an URIEditorInput it will work with your custom
resource. The key here is the setContent from a resource which delivers
the ECore object exactly has here:

>>>> EObject rootElement = resource.getEObject(uri.fragment());

> 3. I need an own Resource and an own ResourceFactory
It seems so, can you share with is where you wish to persist your model?

>
> Is it maybe possible to extend the existing resources and just overwrite
> the methods that do the save and load work?
Yes, this is what I mean.

>
> Regards,
> Malte
>
>
>
>
>
>
> Christophe Bouhier schrieb:
>> A Diagram is stored in an EMF Ecore structures which is stored in a
>> Resource, not sure how to get around this, without your own Resource
>> and corresponding Factory.
>>
>> can you be specific about:
>> "I want to create an Instance of Diagram myself"
>>
>>
>> Malte wrote:
>>> Hi,
>>>
>>> thank you very much for your detailed answer. I will try to get this
>>> approach clear to my mind now.
>>> Yesterday I tried another way to solve the problem, could you please
>>> give some Feedback, if this could be a possible solution to the
>>> problem?:
>>> I tried to write my own DocumentProvider, because I thought
>>> DocumentProviders are the central point, were writing and reading of
>>> the File happens.. My hope was: Instead of writing or loading a file
>>> at this point, I can call my own methods in "createDocument()" or
>>> "doSaveDocument(...)", to map the model to some file structure.. is
>>> this correct?
>>>
>>> I modified the Method:
>>> public ModelDocumentProvider getDocumentProvider()
>>> in my XXXDiagramEditorPlugIn-Class to return my customDocumentProvider.
>>> Unfortunately looking up the EditDomain in
>>> EditPartService.createEditPart(EditPart context, final Object model)
>>> fails because he is looking for some Resource(-Set) in the Method
>>> TransactionUtil.getEditingDomain(EObject eObject)
>>> , which isn't there (because I don't want to have a persistent
>>> resource, I want to create an Instance of Diagram myself and open the
>>> Editor to show the Diagram). I'm afraid, that there are maybe many
>>> calls to some resources and I currently don't now how to manage this
>>> problem.
>>>
>>> Thanks for the patience,
>>> Malte
>>>
>>> Christophe Bouhier schrieb:
>>>> Hi,
>>>>
>>>> This could help?
>>>>
>>>> In your DiagramEditor, the method below opens the editor with new
>>>> EditorInput, you could change it here.
>>>>
>>>> // in Diagram Editor
>>>> public static boolean openDiagram(Resource diagram)
>>>> throws PartInitException {
>>>> IWorkbenchPage page = PlatformUI.getWorkbench()
>>>> .getActiveWorkbenchWindow().getActivePage();
>>>> >> page.openEditor(new URIEditorInput(diagram.getURI()),
>>>> YourDiagramEditor.ID);
>>>> return true;
>>>> }
>>>>
>>>>
>>>> .....and make sure the DocumentProvider can handle your new Editor
>>>> input.
>>>>
>>>> // In Document provider
>>>>
>>>> protected ElementInfo createElementInfo(Object element)
>>>> throws CoreException {
>>>> if (false == element instanceof URIEditorInput) {
>>>> ...
>>>> }
>>>> IEditorInput editorInput = (IEditorInput) element;
>>>> IDiagramDocument document = (IDiagramDocument)
>>>> createDocument(editorInput);
>>>>
>>>> ResourceSetInfo info = new ResourceSetInfo(document,
>>>> editorInput);
>>>> ... }
>>>>
>>>> .... also here you need to hackin to set your content properly, you
>>>> might
>>>> need your version of DiagramDocument
>>>>
>>>>
>>>> protected void setDocumentContent(IDocument document, IEditorInput
>>>> element)
>>>> throws CoreException {
>>>> IDiagramDocument diagramDocument = (IDiagramDocument) document;
>>>> TransactionalEditingDomain domain =
>>>> diagramDocument.getEditingDomain();
>>>> ......
>>>> EObject rootElement = resource.getEObject(uri.fragment());
>>>> if (rootElement instanceof Diagram) {
>>>> document.setContent((Diagram) rootElement);
>>>> return;
>>>> }
>>>> ......
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> .... Of course the Resource if by default an EMF Resource with
>>>> certain characteristics. (Like XMI serialization), you could change
>>>> this by
>>>> creating a ResourceFactory and tigh this factory to an extension or
>>>> protocol.
>>>>
>>>> //plugin.xml
>>>>
>>>> <extension point="org.eclipse.emf.ecore.extension_parser"
>>>> id="resource-factory">
>>>> <?gmfgen generated="true"?>
>>>> <parser
>>>> type="your extension"
>>>>
>>>> >>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
>>>>
>>>> </parser>
>>>> </extension>
>>>>
>>>> ....Your factory my need a custom Resource used by the document
>>>> provider to set the content.
>>>>
>>>>
>>>>
>>>> Malte wrote:
>>>>> Hi,
>>>>>
>>>>> how can I change the Editor created by GMF to accept an
>>>>> EditorInput, that isn't a FileEditorInput or an IFile?
>>>>> I want to analyse some data and display the results with this
>>>>> Editor. Editing and Saving should also be in my hands.. as the
>>>>> changes must be mapped to the data and not be written into a single
>>>>> file.
>>>>>
>>>>> Thanks,
>>>>> Malte
Re: GMF Editor without FileInput [message #222977 is a reply to message #222961] Fri, 27 March 2009 13:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marmeladenfaust.gmx.net

The model should be generated out of a given sourcecode.. very much like
UML Class Diagrams use the sourcecode as resource.

I guess I now know how to solve this problem:
I'm thinking about an URI, which represents the path to the package,
that has to be analyzed. My extended Resource overwrites load and save
methods, that in this case will do all the analyzing-stuff and use the
path uri to locate the sourcecode.
Do you think this could work out?

Best wishes,
Malte


Christophe Bouhier schrieb:
> See inline comments.
>
> Malte wrote:
>> I was thinking about something like that:
>>
>> Before calling IDE.openEditor(...):
>> 1. calling ModelFactory.eINSTANCE.createXXXDiagram();
>> 2. creating instances of my ModelElements (in my case:
>> ModelFactory.eINSTANCE.createStateShape()) and putting them into a
>> collection
>> 3. create Connections between my elements (in my case:
>> ModelFactory.eINSTANCE.createTransitions() and setting the source and
>> target)
>> 4. calling the Method eSet(int featureID, Object newValue) of my
>> Diagram-instance with the collection as parameter (in my case:
>> eSet(ModelPackage.STATE_MACHINE_DIAGRAM__STATE_SHAPES, collection) )
>>
>
> Your model can exist outside a resource of course, so if you build it
> programmaticly, like you suggest here is all fine. This would already
> be a memory representation of your model in runtime which is not
> persisted to any resource, but read on below....
>
>
>> This Diagram should now be displayed by the Editor.
>> At this point I have no idea of a promising approach.
>>
>> I got your answer as followed:
>> 1. I need an URIEditorInput (but it needs a concrete file, or am I
>> wrong? I only have my diagram-object)
> Not necessarly, it could be any type of URI which can be understood by
> your Resource. The default EMF URI is indeed a file URI, as the
> underlying resource is an XMLResource which serializes your model to an
> XML based file. (XMI is the schema used).
>
> The point is, whatever URI you provide to your Resource it needs to be
> understood by it. It seems this is what you want to achieve?
>
> A good example of this is the URI's defined by the Hibernate framework.
> The HibernateResourceFactory creates an HibernateResource which is
> stored in an RDMS like mysql etc..
>
> See this link here:
>
> http://www.elver.org/hibernate/hibernateresources.html
>
>
> Also replacing The declarations in your plugin.xml will determine which
> ResourceFactory to invoke.
>
>
>
>> 2. The createDocument() Method in my DocumentProvider must understand
>> this EditorInput
> Yes, but if you stick to an URIEditorInput it will work with your custom
> resource. The key here is the setContent from a resource which delivers
> the ECore object exactly has here:
>
> >>>> EObject rootElement = resource.getEObject(uri.fragment());
>
>> 3. I need an own Resource and an own ResourceFactory
> It seems so, can you share with is where you wish to persist your model?
>
>>
>> Is it maybe possible to extend the existing resources and just
>> overwrite the methods that do the save and load work?
> Yes, this is what I mean.
>
>>
>> Regards,
>> Malte
>>
>>
>>
>>
>>
>>
>> Christophe Bouhier schrieb:
>>> A Diagram is stored in an EMF Ecore structures which is stored in a
>>> Resource, not sure how to get around this, without your own Resource
>>> and corresponding Factory.
>>>
>>> can you be specific about:
>>> "I want to create an Instance of Diagram myself"
>>>
>>>
>>> Malte wrote:
>>>> Hi,
>>>>
>>>> thank you very much for your detailed answer. I will try to get this
>>>> approach clear to my mind now.
>>>> Yesterday I tried another way to solve the problem, could you please
>>>> give some Feedback, if this could be a possible solution to the
>>>> problem?:
>>>> I tried to write my own DocumentProvider, because I thought
>>>> DocumentProviders are the central point, were writing and reading of
>>>> the File happens.. My hope was: Instead of writing or loading a file
>>>> at this point, I can call my own methods in "createDocument()" or
>>>> "doSaveDocument(...)", to map the model to some file structure.. is
>>>> this correct?
>>>>
>>>> I modified the Method:
>>>> public ModelDocumentProvider getDocumentProvider()
>>>> in my XXXDiagramEditorPlugIn-Class to return my customDocumentProvider.
>>>> Unfortunately looking up the EditDomain in
>>>> EditPartService.createEditPart(EditPart context, final Object model)
>>>> fails because he is looking for some Resource(-Set) in the Method
>>>> TransactionUtil.getEditingDomain(EObject eObject)
>>>> , which isn't there (because I don't want to have a persistent
>>>> resource, I want to create an Instance of Diagram myself and open
>>>> the Editor to show the Diagram). I'm afraid, that there are maybe
>>>> many calls to some resources and I currently don't now how to manage
>>>> this problem.
>>>>
>>>> Thanks for the patience,
>>>> Malte
>>>>
>>>> Christophe Bouhier schrieb:
>>>>> Hi,
>>>>>
>>>>> This could help?
>>>>>
>>>>> In your DiagramEditor, the method below opens the editor with new
>>>>> EditorInput, you could change it here.
>>>>>
>>>>> // in Diagram Editor
>>>>> public static boolean openDiagram(Resource diagram)
>>>>> throws PartInitException {
>>>>> IWorkbenchPage page = PlatformUI.getWorkbench()
>>>>> .getActiveWorkbenchWindow().getActivePage();
>>>>> >> page.openEditor(new URIEditorInput(diagram.getURI()),
>>>>> YourDiagramEditor.ID);
>>>>> return true;
>>>>> }
>>>>>
>>>>>
>>>>> .....and make sure the DocumentProvider can handle your new Editor
>>>>> input.
>>>>>
>>>>> // In Document provider
>>>>>
>>>>> protected ElementInfo createElementInfo(Object element)
>>>>> throws CoreException {
>>>>> if (false == element instanceof URIEditorInput) {
>>>>> ...
>>>>> }
>>>>> IEditorInput editorInput = (IEditorInput) element;
>>>>> IDiagramDocument document = (IDiagramDocument)
>>>>> createDocument(editorInput);
>>>>>
>>>>> ResourceSetInfo info = new
>>>>> ResourceSetInfo(document, editorInput);
>>>>> ... }
>>>>>
>>>>> .... also here you need to hackin to set your content properly, you
>>>>> might
>>>>> need your version of DiagramDocument
>>>>>
>>>>>
>>>>> protected void setDocumentContent(IDocument document, IEditorInput
>>>>> element)
>>>>> throws CoreException {
>>>>> IDiagramDocument diagramDocument = (IDiagramDocument)
>>>>> document;
>>>>> TransactionalEditingDomain domain =
>>>>> diagramDocument.getEditingDomain();
>>>>> ......
>>>>> EObject rootElement = resource.getEObject(uri.fragment());
>>>>> if (rootElement instanceof Diagram) {
>>>>> document.setContent((Diagram)
>>>>> rootElement);
>>>>> return;
>>>>> }
>>>>> ......
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> .... Of course the Resource if by default an EMF Resource with
>>>>> certain characteristics. (Like XMI serialization), you could change
>>>>> this by
>>>>> creating a ResourceFactory and tigh this factory to an extension or
>>>>> protocol.
>>>>>
>>>>> //plugin.xml
>>>>>
>>>>> <extension point="org.eclipse.emf.ecore.extension_parser"
>>>>> id="resource-factory">
>>>>> <?gmfgen generated="true"?>
>>>>> <parser
>>>>> type="your extension"
>>>>>
>>>>> >>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
>>>>>
>>>>> </parser>
>>>>> </extension>
>>>>>
>>>>> ....Your factory my need a custom Resource used by the document
>>>>> provider to set the content.
>>>>>
>>>>>
>>>>>
>>>>> Malte wrote:
>>>>>> Hi,
>>>>>>
>>>>>> how can I change the Editor created by GMF to accept an
>>>>>> EditorInput, that isn't a FileEditorInput or an IFile?
>>>>>> I want to analyse some data and display the results with this
>>>>>> Editor. Editing and Saving should also be in my hands.. as the
>>>>>> changes must be mapped to the data and not be written into a
>>>>>> single file.
>>>>>>
>>>>>> Thanks,
>>>>>> Malte
Re: GMF Editor without FileInput [message #222992 is a reply to message #222977] Fri, 27 March 2009 14:29 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
not sure, it's a rather complex case... but if your model is actually
source code (or your DSL), you could consider using xtext or antlr to
make a model out of it. I am in the middle of this myself now, pretty
challenging topic. xtext would build an ecore model and editor for you.
You could serialize it back using some of the template technologies like
xpand etc..

see www.xtext.org


Malte wrote:
> The model should be generated out of a given sourcecode.. very much like
> UML Class Diagrams use the sourcecode as resource.
>
> I guess I now know how to solve this problem:
> I'm thinking about an URI, which represents the path to the package,
> that has to be analyzed. My extended Resource overwrites load and save
> methods, that in this case will do all the analyzing-stuff and use the
> path uri to locate the sourcecode.
> Do you think this could work out?
>
> Best wishes,
> Malte
>
>
> Christophe Bouhier schrieb:
>> See inline comments.
>>
>> Malte wrote:
>>> I was thinking about something like that:
>>>
>>> Before calling IDE.openEditor(...):
>>> 1. calling ModelFactory.eINSTANCE.createXXXDiagram();
>>> 2. creating instances of my ModelElements (in my case:
>>> ModelFactory.eINSTANCE.createStateShape()) and putting them into a
>>> collection
>>> 3. create Connections between my elements (in my case:
>>> ModelFactory.eINSTANCE.createTransitions() and setting the source and
>>> target)
>>> 4. calling the Method eSet(int featureID, Object newValue) of my
>>> Diagram-instance with the collection as parameter (in my case:
>>> eSet(ModelPackage.STATE_MACHINE_DIAGRAM__STATE_SHAPES, collection) )
>>>
>>
>> Your model can exist outside a resource of course, so if you build it
>> programmaticly, like you suggest here is all fine. This would already
>> be a memory representation of your model in runtime which is not
>> persisted to any resource, but read on below....
>>
>>
>>> This Diagram should now be displayed by the Editor.
>>> At this point I have no idea of a promising approach.
>>>
>>> I got your answer as followed:
>>> 1. I need an URIEditorInput (but it needs a concrete file, or am I
>>> wrong? I only have my diagram-object)
>> Not necessarly, it could be any type of URI which can be understood by
>> your Resource. The default EMF URI is indeed a file URI, as the
>> underlying resource is an XMLResource which serializes your model to
>> an XML based file. (XMI is the schema used).
>>
>> The point is, whatever URI you provide to your Resource it needs to be
>> understood by it. It seems this is what you want to achieve?
>>
>> A good example of this is the URI's defined by the Hibernate framework.
>> The HibernateResourceFactory creates an HibernateResource which is
>> stored in an RDMS like mysql etc..
>>
>> See this link here:
>>
>> http://www.elver.org/hibernate/hibernateresources.html
>>
>>
>> Also replacing The declarations in your plugin.xml will determine
>> which ResourceFactory to invoke.
>>
>>
>>
>>> 2. The createDocument() Method in my DocumentProvider must understand
>>> this EditorInput
>> Yes, but if you stick to an URIEditorInput it will work with your custom
>> resource. The key here is the setContent from a resource which
>> delivers the ECore object exactly has here:
>>
>> >>>> EObject rootElement = resource.getEObject(uri.fragment());
>>
>>> 3. I need an own Resource and an own ResourceFactory
>> It seems so, can you share with is where you wish to persist your model?
>>
>>>
>>> Is it maybe possible to extend the existing resources and just
>>> overwrite the methods that do the save and load work?
>> Yes, this is what I mean.
>>
>>>
>>> Regards,
>>> Malte
>>>
>>>
>>>
>>>
>>>
>>>
>>> Christophe Bouhier schrieb:
>>>> A Diagram is stored in an EMF Ecore structures which is stored in a
>>>> Resource, not sure how to get around this, without your own Resource
>>>> and corresponding Factory.
>>>>
>>>> can you be specific about:
>>>> "I want to create an Instance of Diagram myself"
>>>>
>>>>
>>>> Malte wrote:
>>>>> Hi,
>>>>>
>>>>> thank you very much for your detailed answer. I will try to get
>>>>> this approach clear to my mind now.
>>>>> Yesterday I tried another way to solve the problem, could you
>>>>> please give some Feedback, if this could be a possible solution to
>>>>> the problem?:
>>>>> I tried to write my own DocumentProvider, because I thought
>>>>> DocumentProviders are the central point, were writing and reading
>>>>> of the File happens.. My hope was: Instead of writing or loading a
>>>>> file at this point, I can call my own methods in "createDocument()"
>>>>> or "doSaveDocument(...)", to map the model to some file structure..
>>>>> is this correct?
>>>>>
>>>>> I modified the Method:
>>>>> public ModelDocumentProvider getDocumentProvider()
>>>>> in my XXXDiagramEditorPlugIn-Class to return my
>>>>> customDocumentProvider.
>>>>> Unfortunately looking up the EditDomain in
>>>>> EditPartService.createEditPart(EditPart context, final Object model)
>>>>> fails because he is looking for some Resource(-Set) in the Method
>>>>> TransactionUtil.getEditingDomain(EObject eObject)
>>>>> , which isn't there (because I don't want to have a persistent
>>>>> resource, I want to create an Instance of Diagram myself and open
>>>>> the Editor to show the Diagram). I'm afraid, that there are maybe
>>>>> many calls to some resources and I currently don't now how to
>>>>> manage this problem.
>>>>>
>>>>> Thanks for the patience,
>>>>> Malte
>>>>>
>>>>> Christophe Bouhier schrieb:
>>>>>> Hi,
>>>>>>
>>>>>> This could help?
>>>>>>
>>>>>> In your DiagramEditor, the method below opens the editor with new
>>>>>> EditorInput, you could change it here.
>>>>>>
>>>>>> // in Diagram Editor
>>>>>> public static boolean openDiagram(Resource diagram)
>>>>>> throws PartInitException {
>>>>>> IWorkbenchPage page = PlatformUI.getWorkbench()
>>>>>> .getActiveWorkbenchWindow().getActivePage();
>>>>>> >> page.openEditor(new URIEditorInput(diagram.getURI()),
>>>>>> YourDiagramEditor.ID);
>>>>>> return true;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> .....and make sure the DocumentProvider can handle your new Editor
>>>>>> input.
>>>>>>
>>>>>> // In Document provider
>>>>>>
>>>>>> protected ElementInfo createElementInfo(Object element)
>>>>>> throws CoreException {
>>>>>> if (false == element instanceof URIEditorInput) {
>>>>>> ...
>>>>>> }
>>>>>> IEditorInput editorInput = (IEditorInput) element;
>>>>>> IDiagramDocument document = (IDiagramDocument)
>>>>>> createDocument(editorInput);
>>>>>>
>>>>>> ResourceSetInfo info = new
>>>>>> ResourceSetInfo(document, editorInput);
>>>>>> ... }
>>>>>>
>>>>>> .... also here you need to hackin to set your content properly,
>>>>>> you might
>>>>>> need your version of DiagramDocument
>>>>>>
>>>>>>
>>>>>> protected void setDocumentContent(IDocument document, IEditorInput
>>>>>> element)
>>>>>> throws CoreException {
>>>>>> IDiagramDocument diagramDocument = (IDiagramDocument)
>>>>>> document;
>>>>>> TransactionalEditingDomain domain =
>>>>>> diagramDocument.getEditingDomain();
>>>>>> ......
>>>>>> EObject rootElement = resource.getEObject(uri.fragment());
>>>>>> if (rootElement instanceof Diagram) {
>>>>>> document.setContent((Diagram)
>>>>>> rootElement);
>>>>>> return;
>>>>>> }
>>>>>> ......
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> .... Of course the Resource if by default an EMF Resource with
>>>>>> certain characteristics. (Like XMI serialization), you could
>>>>>> change this by
>>>>>> creating a ResourceFactory and tigh this factory to an extension
>>>>>> or protocol.
>>>>>>
>>>>>> //plugin.xml
>>>>>>
>>>>>> <extension point="org.eclipse.emf.ecore.extension_parser"
>>>>>> id="resource-factory">
>>>>>> <?gmfgen generated="true"?>
>>>>>> <parser
>>>>>> type="your extension"
>>>>>>
>>>>>> >>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
>>>>>>
>>>>>> </parser>
>>>>>> </extension>
>>>>>>
>>>>>> ....Your factory my need a custom Resource used by the document
>>>>>> provider to set the content.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Malte wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> how can I change the Editor created by GMF to accept an
>>>>>>> EditorInput, that isn't a FileEditorInput or an IFile?
>>>>>>> I want to analyse some data and display the results with this
>>>>>>> Editor. Editing and Saving should also be in my hands.. as the
>>>>>>> changes must be mapped to the data and not be written into a
>>>>>>> single file.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Malte
Re: GMF Editor without FileInput [message #223012 is a reply to message #222992] Fri, 27 March 2009 15:12 Go to previous message
Eclipse UserFriend
Originally posted by: marmeladenfaust.gmx.net

Yes this whole thing seems quite challenging to me too :)
I will check the link.. Looks interesting, I never heard of that
framework before.

Thank you very much for your good help!

Christophe Bouhier schrieb:
> not sure, it's a rather complex case... but if your model is actually
> source code (or your DSL), you could consider using xtext or antlr to
> make a model out of it. I am in the middle of this myself now, pretty
> challenging topic. xtext would build an ecore model and editor for you.
> You could serialize it back using some of the template technologies like
> xpand etc..
>
> see www.xtext.org
>
>
> Malte wrote:
>> The model should be generated out of a given sourcecode.. very much
>> like UML Class Diagrams use the sourcecode as resource.
>>
>> I guess I now know how to solve this problem:
>> I'm thinking about an URI, which represents the path to the package,
>> that has to be analyzed. My extended Resource overwrites load and save
>> methods, that in this case will do all the analyzing-stuff and use the
>> path uri to locate the sourcecode.
>> Do you think this could work out?
>>
>> Best wishes,
>> Malte
>>
>>
>> Christophe Bouhier schrieb:
>>> See inline comments.
>>>
>>> Malte wrote:
>>>> I was thinking about something like that:
>>>>
>>>> Before calling IDE.openEditor(...):
>>>> 1. calling ModelFactory.eINSTANCE.createXXXDiagram();
>>>> 2. creating instances of my ModelElements (in my case:
>>>> ModelFactory.eINSTANCE.createStateShape()) and putting them into a
>>>> collection
>>>> 3. create Connections between my elements (in my case:
>>>> ModelFactory.eINSTANCE.createTransitions() and setting the source
>>>> and target)
>>>> 4. calling the Method eSet(int featureID, Object newValue) of my
>>>> Diagram-instance with the collection as parameter (in my case:
>>>> eSet(ModelPackage.STATE_MACHINE_DIAGRAM__STATE_SHAPES, collection) )
>>>>
>>>
>>> Your model can exist outside a resource of course, so if you build it
>>> programmaticly, like you suggest here is all fine. This would already
>>> be a memory representation of your model in runtime which is not
>>> persisted to any resource, but read on below....
>>>
>>>
>>>> This Diagram should now be displayed by the Editor.
>>>> At this point I have no idea of a promising approach.
>>>>
>>>> I got your answer as followed:
>>>> 1. I need an URIEditorInput (but it needs a concrete file, or am I
>>>> wrong? I only have my diagram-object)
>>> Not necessarly, it could be any type of URI which can be understood
>>> by your Resource. The default EMF URI is indeed a file URI, as the
>>> underlying resource is an XMLResource which serializes your model to
>>> an XML based file. (XMI is the schema used).
>>>
>>> The point is, whatever URI you provide to your Resource it needs to
>>> be understood by it. It seems this is what you want to achieve?
>>>
>>> A good example of this is the URI's defined by the Hibernate framework.
>>> The HibernateResourceFactory creates an HibernateResource which is
>>> stored in an RDMS like mysql etc..
>>>
>>> See this link here:
>>>
>>> http://www.elver.org/hibernate/hibernateresources.html
>>>
>>>
>>> Also replacing The declarations in your plugin.xml will determine
>>> which ResourceFactory to invoke.
>>>
>>>
>>>
>>>> 2. The createDocument() Method in my DocumentProvider must
>>>> understand this EditorInput
>>> Yes, but if you stick to an URIEditorInput it will work with your custom
>>> resource. The key here is the setContent from a resource which
>>> delivers the ECore object exactly has here:
>>>
>>> >>>> EObject rootElement = resource.getEObject(uri.fragment());
>>>
>>>> 3. I need an own Resource and an own ResourceFactory
>>> It seems so, can you share with is where you wish to persist your model?
>>>
>>>>
>>>> Is it maybe possible to extend the existing resources and just
>>>> overwrite the methods that do the save and load work?
>>> Yes, this is what I mean.
>>>
>>>>
>>>> Regards,
>>>> Malte
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Christophe Bouhier schrieb:
>>>>> A Diagram is stored in an EMF Ecore structures which is stored in a
>>>>> Resource, not sure how to get around this, without your own
>>>>> Resource and corresponding Factory.
>>>>>
>>>>> can you be specific about:
>>>>> "I want to create an Instance of Diagram myself"
>>>>>
>>>>>
>>>>> Malte wrote:
>>>>>> Hi,
>>>>>>
>>>>>> thank you very much for your detailed answer. I will try to get
>>>>>> this approach clear to my mind now.
>>>>>> Yesterday I tried another way to solve the problem, could you
>>>>>> please give some Feedback, if this could be a possible solution to
>>>>>> the problem?:
>>>>>> I tried to write my own DocumentProvider, because I thought
>>>>>> DocumentProviders are the central point, were writing and reading
>>>>>> of the File happens.. My hope was: Instead of writing or loading a
>>>>>> file at this point, I can call my own methods in
>>>>>> "createDocument()" or "doSaveDocument(...)", to map the model to
>>>>>> some file structure.. is this correct?
>>>>>>
>>>>>> I modified the Method:
>>>>>> public ModelDocumentProvider getDocumentProvider()
>>>>>> in my XXXDiagramEditorPlugIn-Class to return my
>>>>>> customDocumentProvider.
>>>>>> Unfortunately looking up the EditDomain in
>>>>>> EditPartService.createEditPart(EditPart context, final Object model)
>>>>>> fails because he is looking for some Resource(-Set) in the Method
>>>>>> TransactionUtil.getEditingDomain(EObject eObject)
>>>>>> , which isn't there (because I don't want to have a persistent
>>>>>> resource, I want to create an Instance of Diagram myself and open
>>>>>> the Editor to show the Diagram). I'm afraid, that there are maybe
>>>>>> many calls to some resources and I currently don't now how to
>>>>>> manage this problem.
>>>>>>
>>>>>> Thanks for the patience,
>>>>>> Malte
>>>>>>
>>>>>> Christophe Bouhier schrieb:
>>>>>>> Hi,
>>>>>>>
>>>>>>> This could help?
>>>>>>>
>>>>>>> In your DiagramEditor, the method below opens the editor with new
>>>>>>> EditorInput, you could change it here.
>>>>>>>
>>>>>>> // in Diagram Editor
>>>>>>> public static boolean openDiagram(Resource diagram)
>>>>>>> throws PartInitException {
>>>>>>> IWorkbenchPage page = PlatformUI.getWorkbench()
>>>>>>> .getActiveWorkbenchWindow().getActivePage();
>>>>>>> >> page.openEditor(new URIEditorInput(diagram.getURI()),
>>>>>>> YourDiagramEditor.ID);
>>>>>>> return true;
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> .....and make sure the DocumentProvider can handle your new
>>>>>>> Editor input.
>>>>>>>
>>>>>>> // In Document provider
>>>>>>>
>>>>>>> protected ElementInfo createElementInfo(Object element)
>>>>>>> throws CoreException {
>>>>>>> if (false == element instanceof URIEditorInput) {
>>>>>>> ...
>>>>>>> }
>>>>>>> IEditorInput editorInput = (IEditorInput) element;
>>>>>>> IDiagramDocument document = (IDiagramDocument)
>>>>>>> createDocument(editorInput);
>>>>>>>
>>>>>>> ResourceSetInfo info = new
>>>>>>> ResourceSetInfo(document, editorInput);
>>>>>>> ... }
>>>>>>>
>>>>>>> .... also here you need to hackin to set your content properly,
>>>>>>> you might
>>>>>>> need your version of DiagramDocument
>>>>>>>
>>>>>>>
>>>>>>> protected void setDocumentContent(IDocument document,
>>>>>>> IEditorInput element)
>>>>>>> throws CoreException {
>>>>>>> IDiagramDocument diagramDocument = (IDiagramDocument)
>>>>>>> document;
>>>>>>> TransactionalEditingDomain domain =
>>>>>>> diagramDocument.getEditingDomain();
>>>>>>> ......
>>>>>>> EObject rootElement = resource.getEObject(uri.fragment());
>>>>>>> if (rootElement instanceof Diagram) {
>>>>>>> document.setContent((Diagram)
>>>>>>> rootElement);
>>>>>>> return;
>>>>>>> }
>>>>>>> ......
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> .... Of course the Resource if by default an EMF Resource with
>>>>>>> certain characteristics. (Like XMI serialization), you could
>>>>>>> change this by
>>>>>>> creating a ResourceFactory and tigh this factory to an extension
>>>>>>> or protocol.
>>>>>>>
>>>>>>> //plugin.xml
>>>>>>>
>>>>>>> <extension point="org.eclipse.emf.ecore.extension_parser"
>>>>>>> id="resource-factory">
>>>>>>> <?gmfgen generated="true"?>
>>>>>>> <parser
>>>>>>> type="your extension"
>>>>>>>
>>>>>>> >>class=" org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y ">
>>>>>>>
>>>>>>> </parser>
>>>>>>> </extension>
>>>>>>>
>>>>>>> ....Your factory my need a custom Resource used by the document
>>>>>>> provider to set the content.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Malte wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> how can I change the Editor created by GMF to accept an
>>>>>>>> EditorInput, that isn't a FileEditorInput or an IFile?
>>>>>>>> I want to analyse some data and display the results with this
>>>>>>>> Editor. Editing and Saving should also be in my hands.. as the
>>>>>>>> changes must be mapped to the data and not be written into a
>>>>>>>> single file.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Malte
Previous Topic:Making a border invisible
Next Topic:Spline/Curved polyline
Goto Forum:
  


Current Time: Fri Apr 19 22:22:10 GMT 2024

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

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

Back to the top