Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem running the Editor for Directed Graphs as RCP application
Problem running the Editor for Directed Graphs as RCP application [message #249200] Thu, 04 June 2009 23:40 Go to next message
Andrea Mazzario is currently offline Andrea Mazzario
Messages: 10
Registered: July 2009
Junior Member
I am trying to run the Editor for Directed Graphs example, Step 17, as an
RCP application, and while I can create the directed graph in the editor
(i.e., add nodes and connections), I cannot delete anything: the keys
DELETE, UNDO (Ctl-z) and REDO (Ctl-y) have no effect.

Everything works fine if I start the Editor by selecting a file .par in
the Eclipse environment, so I assume the problem is in the way I start the
Editor in the RCP environment, but I followed exactly the example given
for the Digraph example, by adding corresponding classes GraphApplication,
GraphPerspective, GraphWorkbenchAdvisor, GraphWorkbenchWindowAdvisor, and
corresponding Extensions.

I also tried to replace the Text Editor with the Directed Graph Editor in
the RCP Text Editor example, and I obtain exactly the same behavior.

Can anybody tell me what is needed to have a GEF Editor fully work in an
RCP application?

Thanks in advance for any help
Andrea

Here is the code of the classes and the plugin.xml file:

public class GraphApplication implements IApplication {
public Object start(IApplicationContext context) throws Exception {
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display,
new GraphWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}
public void stop() {
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench == null)
return;
final Display display = workbench.getDisplay();
display.syncExec(new Runnable() {
public void run() {
if (!display.isDisposed())
workbench.close();
}
});
}
public class GraphPerspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
}
}
public class GraphWorkbenchAdvisor extends WorkbenchAdvisor {
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer configurer) {
return new GraphWorkbenchWindowAdvisor(configurer);
}
public String getInitialWindowPerspectiveId() {
return "org.jbpm.graph.perspective";
}
}
public class GraphWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
public GraphWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer
configurer) {
super(configurer);
}
public void postWindowCreate() {
try {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
new Path("/project/file.par"));
getWindowConfigurer().getWindow().getActivePage().openEditor (
new FileInPlaceEditorInput(file),
"org.jbpm.graph.editor");
} catch (PartInitException e) {
e.printStackTrace();
}
super.postWindowCreate();
}
public void preWindowOpen() {
getWindowConfigurer().setInitialSize(new Point(450, 300));
getWindowConfigurer().setShowCoolBar(false);
getWindowConfigurer().setShowStatusLine(false);
getWindowConfigurer().setShowMenuBar(false);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.ui.editors">
<editor
class="org.jbpm.graph.GraphEditor"
extensions="par"
icon="icons/graph.gif"
id="org.jbpm.graph.editor"
name="First jBPM Graph Editor"
contributorClass="org.jbpm.graph.ActionBarContributor">
</editor>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
class="org.jbpm.graph.rcp.GraphPerspective"
fixed="true"
icon="icons/graph.gif"
id="org.jbpm.graph.perspective"
name="%Perspective-Name">
</perspective>
</extension>
<extension
id="id1"
point="org.eclipse.core.runtime.applications">
<application
cardinality="singleton-global"
thread="main"
visible="true">
<run
class="org.jbpm.graph.rcp.GraphApplication">
</run>
</application>
</extension>
</plugin>
Re: Problem running the Editor for Directed Graphs as RCP application [message #249216 is a reply to message #249200] Mon, 08 June 2009 08:19 Go to previous messageGo to next message
Thomas Porcham is currently offline Thomas Porcham
Messages: 14
Registered: July 2009
Junior Member
Hi,

I think your problem is not specific to GEF.
You could post the question in the newsgroup "eclipse.platform.rcp".

Have a look at the "RCP Mail Template" application.
To do this create a new Plug-In Project. Select the Radio button to create
a RCP application
and select the "RCP Mail Template".

The method makeActions in class ApplicationActionBarAdvisor creates the
actions and registers the key bindings.
You should create an register the UNDO REDO and DELETE Action here.
This works for me in my RCP GEF editor.

Cheers,

Thomas


package rcpmailexample;

/**
* An action bar advisor is responsible for creating, adding, and
disposing of the
* actions added to a workbench window. Each window will be populated with
* new actions.
*/
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

// Actions - important to allocate these only in makeActions, and then
use them
// in the fill methods. This ensures that the actions aren't recreated
// when fillActionBars is called with FILL_PROXY.
private IWorkbenchAction exitAction;
private IWorkbenchAction aboutAction;
private IWorkbenchAction newWindowAction;
private OpenViewAction openViewAction;
private Action messagePopupAction;


public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}

protected void makeActions(final IWorkbenchWindow window) {
// Creates the actions and registers them.
// Registering is needed to ensure that key bindings work.
// The corresponding commands keybindings are defined in the
plugin.xml file.
// Registering also provides automatic disposal of the actions when
// the window is closed.

exitAction = ActionFactory.QUIT.create(window);
register(exitAction);

aboutAction = ActionFactory.ABOUT.create(window);
register(aboutAction);

newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);
register(newWindowAction);

openViewAction = new OpenViewAction(window, "Open Another Message
View", View.ID);
register(openViewAction);

messagePopupAction = new MessagePopupAction("Open Message",
window);
register(messagePopupAction);
}
/* .... */
}
Re: Problem running the Editor for Directed Graphs as RCP application [message #249220 is a reply to message #249216] Mon, 08 June 2009 23:54 Go to previous message
Andrea Mazzario is currently offline Andrea Mazzario
Messages: 10
Registered: July 2009
Junior Member
Yes, that solved my problem. Thank you a lot!!!
Previous Topic:How to add ScrollingGraphicalViewer to Formpage
Next Topic:[Announce] GEF 3.5.0RC4 is available
Goto Forum:
  


Current Time: Sat Oct 25 07:14:45 GMT 2014

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

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