Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » questions about context
questions about context [message #564578] Tue, 10 November 2009 19:07
Gary Horen is currently offline Gary HorenFriend
Messages: 19
Registered: July 2009
Junior Member
I'm playing around with contexts, and have some questions:
I see that I can get injection of services like Logger and
IPreferenceService from a context. I'm not understanding how an object (i.e.
part, in this case) instantiated by a context can expose services or
properties that others can consume.

1. From what I've read, I expected to be able to set a property in a context
and get notification of the change through injection, e.g. if I instantiate
the following part through application.xmi in the photo demo, I would expect
that when the button is clicked, the context would inject the new value into
setTextValue(). But, setTextValue is not called. I think I'm
misunderstanding the pattern -- is there an intention that a property change
in the context could be listened to through injection?

public class ButtonPart {

@In(optional=true)
public void setTextValue(String s)
{
System.out.println("s");
}

public ButtonPart(Composite parent, final IWorkspace workspace, final
IEclipseContext outputContext)
{
Button button = new Button(parent, SWT.PUSH);
button.setText("Set Text");
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
outputContext.set("TextValue", "Quack");
}

public void widgetDefaultSelected(SelectionEvent e) {
}
});

GridLayoutFactory.fillDefaults().generateLayout(parent);
}
}

2. Watching in the debugger, it seems that each instantiated part is passed
a different, parentless context (i.e.
IEclipseContext#get(IContextConstants.PARENT) returns null). I was expecting
that parts would be able to communicate with each other through the context,
i.e. that you could put a button in one part, that, when clicked, would
result in an injection into another part. If all the parts have different
and unconnected contexts though, I can't see how that would work, so I must
be misunderstanding something. Is there an intent for parts to be able to
communicate this way?

Thanks
-Gary
Previous Topic:Developin e4 in Eclipse 3.6M3
Next Topic:XWT Designer
Goto Forum:
  


Current Time: Mon Dec 22 11:32:43 GMT 2014

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

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