Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] Injecting 3.x Views/Editors


We should avoid using 'ExecutableExtension' where we can...it's 'old school' and unnecessary when there's a DI engine available. The main difference is that 'createExecutableExtension' will only call the class's constructor (then it usually calls some API-defined 'init' method).

We want to go the other way IMO; allow the existing EP's 'class' specifications to be defined in a way that allows them to be created through injection directly (even though the class spec is defined in the extension).  For the most part this would mean either checking for the particular API spec for the extension (i.e. views must implement IViewPart) or by checking the specified class for annotations. If both exist (i.e. some part implementation that will run in both e4 and 3.x) then my preference would be that DI wins because it's the preferred mechanism and the author of the class had to know about both approaches in order to get into this state.

Eric


From: Tom Schindl <tom.schindl@xxxxxxxxxxxxxxx>
To: e4-dev@xxxxxxxxxxx
Date: 08/24/2012 02:01 AM
Subject: Re: [e4-dev] Injecting 3.x Views/Editors
Sent by: e4-dev-bounces@xxxxxxxxxxx





I explicitly decided against using ExecutableExtension when I designed
the e4-bridge but what you duplicated here is exactly what the e4 bridge
does already since some time with DIViewPart and DIEditorPart.

Tom

Am 24.08.12 03:40, schrieb Joseph D Carroll Jr:
> After a brief conversation with Paul on IRC, I hacked together a
> solution for grabbing the WorkbenchContext in a 3.x application.  (See
> attached)
>
> It is clearly a hack, would be better to use a lifecycle hook.  But this
> allowed me to create an injector for all of my 3.x editors and views.
>  Obviously there are things that cannot be injected even though it would
> be possible (like the composite), but I am able to inject things like
> properties.  While I haven't tested it, I have a feeling that it *could*
> be possible to inject methods like @Focus.  
> (It also gives me all the goodies like Logger and NLS injected!)
>
> I am building an application that uses a diagram editor from GMF, thus I
> have to use 3.x editors.  But with a little more finessing, I think this
> would be a good option for 3.x & 4.x interoperability in the compat
> layer.  I am just getting started on this application so maybe something
> like this already exists and I just missed it.  But I thought I would
> share...
>
> (The source files are attached)
> - I created an abstract class "InjectableExecutableExtensionFactory"
> that defines the base functionality
> - From this I extend to a "BlockDiagramPartFactory" that is capable of
> supplying the specific contexts for injection and anything else
> - Then whether old or new classes, just annotate them with  @Creatable
> and any @Inject's
> - Lastly, when I create my view/editor extension point, invoke the
> extension factory.  The factory is capable of providing context for
> specific classes or passing them through with no added context.
>
> <plugin>
>    <extension
>          point="org.eclipse.ui.editors">
>       <editor
>            
> class="braintrader.blockdiagram.ui.parts.BlockDiagramPartFactory:braintrader.blockdiagram.ui.blockdiagrameditor"
>             default="false"
>             id="braintrader.blockdiagram.ui.blockdiagrameditor"
>             name="Block Diagram Editor">
>       </editor>
>    </extension>
>    <extension
>          point="org.eclipse.ui.views">
>       <view
>            
> class="braintrader.blockdiagram.ui.parts.BlockDiagramPartFactory:braintrader.blockdiagram.ui.view.blocklibrary"
>             id="braintrader.blockdiagram.ui.view.blocklibrary"
>             name="Block Library"
>             restorable="true">
>       </view>
>    </extension>
> </plugin>
>
> Whether or not this is actually useful / beneficial, I don't know.  But
> this is going to be my approach for now, presuming I don't run into any
> major road blocks.
>
>
> Take care,
>
> JD
>
>
> _______________________________________________
> e4-dev mailing list
> e4-dev@xxxxxxxxxxx
>
https://dev.eclipse.org/mailman/listinfo/e4-dev
>


--
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                 geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
http://www.BestSolution.at                      phone    ++43 512 935834
_______________________________________________
e4-dev mailing list
e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/e4-dev




Back to the top