take advantage of e4 ContextFunction [message #904724] |
Wed, 29 August 2012 03:09 |
Johnny Qin Messages: 40 Registered: April 2012 |
Member |
|
|
I was learning e4 ContextFunction to implement a diagram editor in a similar way that SimpleIDE does for text editor, binding its DocumentInput implementation to the interface.
Here's my practice.
1. created an interface named DiagramInput that extends a third party interface (org.eclipse.graphiti.ui.editor.IDiagramEditorInput)
2. created class DiagramInputProviderFunction that extends org.eclipse.e4.core.contexts.ContextFunction. put debug info in compute(IEclipseContext context).
3. created a component definition file as below
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.xxx.editor.diagram.common.ui">
<implementation class="com.xxx.editor.diagram.common.ui.services.DiagramInputProviderFunction"/>
<property name="service.context.key" type="String" value="com.xxx.editor.diagram.common.ui.DiagramInput"/>
<service>
<provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
</service>
</scr:component>
4. created a diagram editor class that expects to consume DiagramInput in constructor.
@Inject
public DialogDiagramEditor(Composite parent, DiagramInput input) {
System.out.println("DialogDiagramEditor constructor satisfied.");
}
I thought when e4 tries to do the di for DiagramInput to satisfy the constructor of DialogDiagramEditor. It can read component definition file and call the compute() in my DiagramInputProviderFunction. However, debugging tells that compute() didn't get called.
What am I missing here? I don't think I need to set DiagramInput to ContextFunction in code...
Thanks,
Johnny
[Updated on: Wed, 29 August 2012 03:11] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03269 seconds