Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » take advantage of e4 ContextFunction(compute() method didn't get called)
take advantage of e4 ContextFunction [message #904724] Wed, 29 August 2012 03:09 Go to next message
Johnny Qin is currently offline Johnny QinFriend
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

Re: take advantage of e4 ContextFunction [message #904728 is a reply to message #904724] Wed, 29 August 2012 03:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 04:10 Go to previous message
Johnny Qin is currently offline Johnny QinFriend
Messages: 40
Registered: April 2012
Member
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: Sat Apr 20 04:31:15 GMT 2024

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

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

Back to the top