Community
Participate
Working Groups
This was one of the best parts of the experimental component framework.
Created attachment 82919 [details] experimental, work in progress This was not hard at all. You can contribute a view like this: <extension point="org.eclipse.ui.views"> <view class="org.eclipse.ui.services.CIFactory:org.eclipse.ui.examples.di.internal.SampleView" id="org.eclipse.ui.examples.di.view1" name="Dependency Injection"> </view> </extension> ("CIFactory" stands for constructor injection factory.) public class SampleView { public SampleView(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText("Hello World"); GridLayoutFactory.swtDefaults().generateLayout(parent); } }
Tod, it should be fairly easy to create a variant of CIFactory for your Javascript experiments (at least if you use the syntax with colon for now). Something like: <extension point="org.eclipse.ui.views"> <view class="org.eclipse.ui.services.JSFactory:/js/sample_view.js" id="org.eclipse.ui.examples.js.view1" name="Javascript Example"> </view> </extension> sample_view.js: { argumentTypes : [ "org.eclipse.swt.widgets.Composite", "org.eclipse.ui.helpers.SWTFactory"], construct: function (composite, factory) { composite.setLayout(factory.createFillLayout()); var label = factory.createLabel(composite, 0); label.setText("Hello World"); } } Eval'ing this piece of Javascript should return a Javascript object from which you can get the array of argument types and the function to call.
(In reply to comment #1) > Created an attachment (id=82919) [details] > experimental, work in progress DIViewPart I think needs this line in createPartControl: implementation = factory.createObject(delegatingLocator); PW
(In reply to comment #3) > DIViewPart I think needs this line in createPartControl: > implementation = factory.createObject(delegatingLocator); Good catch!
Created attachment 82935 [details] plug-in with Javascript stuff This is a plug-in with a JavascriptFactory and a simple hello world view implemented in Javascript. I just couldn't resist... :-) I tried to get rid of SWTFactory but ran into ClassLoader issues. This is what I would like the Javascript to look like: importPackage(org.eclipse.swt); importPackage(org.eclipse.swt.widgets); importPackage(org.eclipse.swt.layout); var argumentTypes = [ "org.eclipse.swt.widgets.Composite" ]; function construct (composite) { composite.setLayout(new FillLayout()); var label = new Label(composite, SWT.NONE); label.setText("Hello World"); } It currently looks like this: var argumentTypes = [ "org.eclipse.swt.widgets.Composite", "org.eclipse.ui.js.SWTFactory"]; function construct (composite, factory) { composite.setLayout(factory.createFillLayout()); var label = factory.createLabel(composite, 0); label.setText("Hello World"); }
See also http://www.mozilla.org/rhino/ScriptingJava.html
just a test, please ignore
It is working, including callbacks and all! importPackage(Packages.org.eclipse.swt); importPackage(Packages.org.eclipse.swt.widgets); importPackage(Packages.org.eclipse.swt.layout); var argumentTypes = [ "org.eclipse.swt.widgets.Composite" ]; function construct (composite) { composite.setLayout(new FillLayout()); var label = new Label(composite, SWT.NONE); label.setText("Hello World"); var button = new Button(composite, SWT.PUSH); button.setText("Push me"); button.addListener(SWT.Selection, function(){ label.setText("pushed"); }); }
Created attachment 83300 [details] Updated plug-in for Javascript To try it yourself, you need the patch and this plug-in (contains the example view written in Javascript).
Created attachment 83549 [details] updated patch, containing the dependency injection mechanism for views
Created attachment 83554 [details] Same updated patch, with service factory This is the same updated patch, just replacing the delegating service locator with IServiceLocatorCreator and AbstractServiceFactory. The js view still shows up :-) PW
Created attachment 83588 [details] made everything internal When we introduce this, we should refactor our existing API to simplify the programming model as much as we can. I will put the interesting pieces of this in the incubator (and only leave some hooks in the main codebase).
I've released this as a tweaklet together with two example plug-ins in the incubator. I've put the necessary tweaklet hooks for views and editors into the main codebase.
The plug-ins are called: org.eclipse.ui.tweaklets.dependencyinjection org.eclipse.ui.examples.di org.eclipse.ui.examples.di.js They are available from /cvsroot/eclipse/platform-incubator/ui/tweaklets and .../examples.
Removing outdated target milestone.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. If the bug is still relevant, please remove the stalebug whiteboard tag.