Eclipse e4 Kepler: IEclipsePreferences read/write -
i using di
(dependency injection) access ieclipsepreferences
handlers. need access same ieclipsepreferences
other code parts save/load these settings.
this example how preferences , show em in dialog:
import java.lang.reflect.invocationtargetexception; import javax.inject.inject; import javax.inject.named; import org.eclipse.core.runtime.preferences.ieclipsepreferences; import org.eclipse.e4.core.di.annotations.execute; import org.eclipse.e4.core.di.extensions.preference; import org.eclipse.e4.ui.model.application.mapplication; import org.eclipse.e4.ui.services.iserviceconstants; import org.eclipse.jface.dialogs.messagedialog; import org.eclipse.swt.widgets.shell; import org.osgi.service.prefs.backingstoreexception; public class pojoshowpersistencepreferenceshandler { @inject @preference ieclipsepreferences preferences; @inject mapplication application; @execute public void execute(@named(iserviceconstants.active_shell) shell shell ) throws invocationtargetexception, interruptedexception { system.out.println(getclass().getsimplename() + ".execute()"); system.out.println("preferences: " + preferences); system.out.println("application: " + application); try { string msg = "driver:\t" + preferences.get("jdbc_driver", "404") + "\n" + // "url:\t" + preferences.get("jdbc_url", "404") + "\n" + // "user:\t" + preferences.get("jdbc_user", "404") + "\n" + // "password:\t" + preferences.get("jdbc_pwd", "404"); preferences.flush(); messagedialog.openinformation(shell, "info :: save persistence preferences",msg // ); system.out.println(msg); } catch (backingstoreexception e) { e.printstacktrace(); } }
}
a) how can same without using handler
? b) need set these values code without di
or handler parameters, can called programmatically
i've been trying this (vogella) article somehow cannot find values stored in these (instance
, configuration
) scopes, stored, shown handler
!
note: using 3.x plugin
style, using old style not problem.
try this:
@preference(nodepath = "com.example.e4.rcp.todo")
this may reason why not find preferences.
Comments
Post a Comment