Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » take advantage of e4 ContextFunction(compute() method didn't get called)
take advantage of e4 ContextFunction [message #904724] Tue, 28 August 2012 23:09 Go to next message
Eclipse UserFriend
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: Tue, 28 August 2012 23:11] by Moderator

Re: take advantage of e4 ContextFunction [message #904728 is a reply to message #904724] Tue, 28 August 2012 23:22 Go to previous messageGo to next message
Eclipse UserFriend
Is the bundle you have the DS-Component defined in marked as lazy - this
is required if you want the DS-Extender to pick up your bundle.

Tom

Am 29.08.12 05:10, schrieb Johnny Qin:
> 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.voxware.designer.editor.diagram.common.ui">
> <implementation
> class="com.voxware.designer.editor.diagram.common.ui.services.DiagramInputProviderFunction"/>
>
> <property name="service.context.key" type="String"
> value="com.voxware.designer.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
>
>
Re: take advantage of e4 ContextFunction [message #904738 is a reply to message #904728] Wed, 29 August 2012 00:10 Go to previous message
Eclipse UserFriend
Thanks Tom! your suggestion works, of course Smile

Best regards,
Johnny


Thomas Schindl wrote on Tue, 28 August 2012 23:22
Is the bundle you have the DS-Component defined in marked as lazy - this
is required if you want the DS-Extender to pick up your bundle.

Tom

Am 29.08.12 05:10, schrieb Johnny Qin:
> 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.voxware.designer.editor.diagram.common.ui">
> <implementation
> class="com.voxware.designer.editor.diagram.common.ui.services.DiagramInputProviderFunction"/>
>
> <property name="service.context.key" type="String"
> value="com.voxware.designer.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
>
>

Previous Topic:Focusing windows
Next Topic:E4/GWT integration
Goto Forum:
  


Current Time: Tue Jul 08 21:55:05 EDT 2025

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

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

Back to the top