Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Graphiti as RCP
Graphiti as RCP [message #1059920] Wed, 22 May 2013 04:00 Go to next message
Andrej K is currently offline Andrej K
Messages: 16
Registered: March 2013
Location: germany
Junior Member
Hello!

I've build kind of prototype Editor with Graphiti, where I tried out how this and that works and what is possible.
Now i want to build my prototype in existing or leastwise as new RCP application. I'm new at RCP.

I have an RCP application with a menu where i should load my editor in my running rcp. (This menu works, i can write into console if I press this menu).
I made an extension in graphiti editor and extension in my RCP application + few dependencies to graphiti editor and graphiti self like: org.eclipse.graphiti

My question is how can I open my graphiti editor in rcp application? I had red this post:
http://satreth.blogspot.ch/2011/08/using-graphiti-in-eclipse-rcp.html
(but it don't really works or I'm using it wrong)
closely to say „opening a diagram", but "DiagramEditorFactory" doesn't work anymore (has been renamed to DiagramEditorInputFactory)

Can somebody give me an idea or code snippet how i can open my editor in/as RCP application? Unfortunately i find through internet investigation just this code snippet

Thanks in advance,

Andrej K
Re: Graphiti as RCP [message #1059963 is a reply to message #1059920] Wed, 22 May 2013 07:26 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 16
Registered: March 2013
Location: germany
Junior Member
for now my code is looking like this:
public Object execute(ExecutionEvent event) throws ExecutionException {
	System.out.println("trying to open Graphiti Editor");
		
	File f = new File("C:\\...\\myDiagram.diagram");
        
        IPath ipath = new Path(f.getAbsolutePath());
        IFileStore fileLocation = EFS.getLocalFileSystem().getStore(ipath);
        FileStoreEditorInput input = new FileStoreEditorInput(
                                    fileLocation);
        
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        try {
              page.openEditor(input, "org.eclipse.graphiti.ui.editor.DiagramEditor");
              
        } catch (PartInitException e) {
               e.printStackTrace();
        }		 
		return null;
}

myDiagram.diagram was created with graphiti editor
I get NullPointerException in my try-catch block

what I'm doing wrong to open the editor?


Thanks in advance,

Andrej K

[Updated on: Wed, 22 May 2013 07:27]

Report message to a moderator

Re: Graphiti as RCP [message #1060147 is a reply to message #1059963] Thu, 23 May 2013 06:22 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 16
Registered: March 2013
Location: germany
Junior Member
answer on my own question, just here the code:
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        
        URI fileURI = URI.createFileURI("C:\\...\\myDiagram.diagram");
        URIEditorInput editorInput = new URIEditorInput(fileURI);
        
        try {
              page.openEditor(editorInput, 
            		  "org.eclipse.graphiti.ui.editor.DiagramEditor");
        } catch (PartInitException e) {
               e.printStackTrace();
        }
	return null;
}
Re: Graphiti as RCP [message #1060177 is a reply to message #1060147] Thu, 23 May 2013 08:03 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1275
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Can you provide the NPE you get?

Michael
Re: Graphiti as RCP [message #1060198 is a reply to message #1060177] Thu, 23 May 2013 09:11 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 16
Registered: March 2013
Location: germany
Junior Member
I don't clearly understand what do you mean?(or the post are coming really late here)
I resolved NPE problem, with the code of my last post
Re: Graphiti as RCP [message #1060354 is a reply to message #1060198] Fri, 24 May 2013 05:15 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1275
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Sorry, either I or my newsreader missed that...

Michael
Re: Graphiti as RCP [message #1060576 is a reply to message #1060354] Mon, 27 May 2013 03:03 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 16
Registered: March 2013
Location: germany
Junior Member
Hello!
Have one more question, how can I "say" to my RCP application that I saved my graphiti editor?
I've extended DiagramEditor and overwritten doSave method and would to say to my rcp-application that i saved my/this diagram.

I've tried to Export an package which a class which i want to call at graphiti and imported this class in my graphiti project, but i get a cycle

How i should procedure?



Thanks in advance,

Andrej K

[Updated on: Mon, 27 May 2013 04:02]

Report message to a moderator

Re: Graphiti as RCP [message #1060766 is a reply to message #1060576] Tue, 28 May 2013 07:45 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1275
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Andrej,

not sure if that is what you mean: if you want the '*' on the editor tab to
disappear after saving, that is controlled in the editor's isDirty method.
Returning false there will hide the *. A call to that method should be
triggered after saving by firing a prop-dirty-event (simply call
firePropertyChange(IEditorPart.PROP_DIRTY) on your editor). The default save
implementation does exactly that.

Michael
Previous Topic:Graphiti and EMF Properties View
Next Topic:How to keep active the model outline
Goto Forum:
  


Current Time: Tue May 28 14:14:19 EDT 2013

Powered by FUDForum. Page generated in 0.01644 seconds