| Summary: | @Preference Annotation not injected when preference node changed | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] e4 | Reporter: | Artur Kronenberg <artur.kronenberg> | ||||
| Component: | UI | Assignee: | Project Inbox <e4.ui-inbox> | ||||
| Status: | RESOLVED INVALID | QA Contact: | Oleg Besedin <ob1.eclipse> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | artur.kronenberg, ob1.eclipse, pwebster | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
We track InstanceScope, not DefaultScope. In the example try this:
Preferences node = new InstanceScope() //DefaultScope()
.getNode("test.project"); //"org.eclipsecon.e4rover.client");
and it will work.
To see where the DefaultScope chimes in, you can add a constructor:
@Inject
public TestView() {
Preferences node = new DefaultScope().getNode("test.project"); node.put("key", "2010");
}
Or to use a really modern way to set preferences value:
@Inject
public void createControl(final Composite composite, @Preference final IEclipsePreferences node) {
...
store.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
node.put("key", toStoreText.getText());
}
});
}
|
Created attachment 172223 [details] project to test the @Preference behavior Hi, it seems like annotation a method with the @Inject and @Preference("key") annotations is not being called when the preference is changed. Steps to reproduce: Create a method and annotate it with the @Inject and @Preference annotation @Inject public void preferenceChanged(@Preference("key") final String value) { System.out.println(value); } Create code to change the preference later in your program. Start program ans see if the new preference is being printed. I attach an example project to test this behavior. Kind regards, Artur