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 08:00 Go to next message
Andrej K is currently offline Andrej K
Messages: 26
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 11:26 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 26
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 11:27]

Report message to a moderator

Re: Graphiti as RCP [message #1060147 is a reply to message #1059963] Thu, 23 May 2013 10:22 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 26
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 12:03 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
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 13:11 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 26
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 09:15 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
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 07:03 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 26
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 08:02]

Report message to a moderator

Re: Graphiti as RCP [message #1060766 is a reply to message #1060576] Tue, 28 May 2013 11:45 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
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
Re: Graphiti as RCP [message #1061613 is a reply to message #1060766] Mon, 03 June 2013 09:52 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 26
Registered: March 2013
Location: germany
Junior Member
Thank you for reply!

I was tried to build my graphiti editor as an plug in, but than... I think it would be better to build all as one project. My Editor need to much different things from the main application and can't "live" alone without to write some code twice.

I have a problem, i have a Tree-view which I want to use instead of the given Palette.
I can/need to drop things from the Tree-view into my Editor.

What/How i try this:
If i drop something i open a method "dragAndDropFunktionality(kindId, accurateId)" in my extended DiagramEditor class, from there i want to call getAddFeature(?context?) like this:

this.getDiagramTypeProvider().getFeatureProvider().getAddFeature(context);

but i need the context? how can i create context myself? Or should i make this different?


Thanks in advance,

Andrej K
Re: Graphiti as RCP [message #1061842 is a reply to message #1061613] Tue, 04 June 2013 10:29 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Andrej,

you can simply create the AddContext yourself. All the infirmation it needs
(location, size...) should be either available from the drop location or
need to be set with reasonable defaults.

Michael
Re: Graphiti as RCP [message #1061980 is a reply to message #1061842] Wed, 05 June 2013 08:50 Go to previous messageGo to next message
Andrej K is currently offline Andrej K
Messages: 26
Registered: March 2013
Location: germany
Junior Member
Michael,

thank you, i can now throw elements from my existing TreeViewer, so i can hide the existing Graphiti Palette

Do you maybe know how i need to behave to load my own Icons/pictures at the beginning/run-time? Its really bad if i can have just a fixed image count
I'm trying this with ImageProvider but it load the images hard coded?
I want to "say" like: here is my Folder with pictures, load all of them. Later i need maybe to load additional images and put them in pictogramElement/shapes, is this generally possible to load images at run-time?


Thanks in advance,

Andrej K
Re: Graphiti as RCP [message #1062129 is a reply to message #1061980] Thu, 06 June 2013 07:12 Go to previous message
Andrej K is currently offline Andrej K
Messages: 26
Registered: March 2013
Location: germany
Junior Member
i was trying to write like:

public String[] myImageIdentifier= new String[xy];
public String[] path= new String[xy];
...
myImageIdentifier[0]="id1";
path[0]="/folder/something.png"

addImageFilePath(myImageIdentifier[index], path[index]);


i think it is possible to "load/create" ImageIdentifier at runtime, but how can i manipulate the path by-self?
Cause after the start i convert my Images from .svg to .png (cause i can't use svg directly), only after converting i know which images are there and only after this i can put them to my editor/pictogram elements
how can i handle this?


Thanks in advance,

Andrej K
Previous Topic:child shape inside parent shape
Next Topic:parent element and child element relationship in graphiti
Goto Forum:
  


Current Time: Sat Sep 20 12:11:48 GMT 2014

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

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