Community
Participate
Working Groups
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
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()); } }); }