use of org.eclipse.e4.core.di.extensions.Preference in project portfolio by buchen.
the class Preference2EnvAddon method setAlphavantageApiKey.
@Inject
@Optional
public void setAlphavantageApiKey(@Preference(value = UIConstants.Preferences.ALPHAVANTAGE_API_KEY) String alphavantageApiKey) {
// this is a hack to pass the eclipse-based preference via environment
// to the AlphavantageQuoteFeed implementation which is not created via
// dependency injection but via Java Service Locator.
AlphavantageQuoteFeed quoteFeed = (AlphavantageQuoteFeed) Factory.getQuoteFeedProvider(AlphavantageQuoteFeed.ID);
quoteFeed.setApiKey(alphavantageApiKey);
}
use of org.eclipse.e4.core.di.extensions.Preference in project eclipse.platform.runtime by eclipse.
the class PreferencesObjectSupplier method getNodePath.
private String getNodePath(IObjectDescriptor descriptor, Class<?> requestingObject) {
if (descriptor == null)
return null;
Preference qualifier = descriptor.getQualifier(Preference.class);
String nodePath = qualifier.nodePath();
if (nodePath == null || nodePath.length() == 0) {
if (requestingObject == null)
return null;
nodePath = FrameworkUtil.getBundle(requestingObject).getSymbolicName();
}
return nodePath;
}
use of org.eclipse.e4.core.di.extensions.Preference in project eclipse.platform.runtime by eclipse.
the class InjectionPreferencesTest method testPreferencesQualifier.
@Test
public void testPreferencesQualifier() throws BackingStoreException {
setPreference(TEST_PREFS_KEY, "abc");
setPreference(TEST_PREFS_KEY, TEST_PREFS_NODE, "123");
IEclipseContext context = EclipseContextFactory.create();
InjectTarget target = ContextInjectionFactory.make(InjectTarget.class, context);
// default node
assertEquals(1, target.counter);
assertEquals("abc", target.pref);
// specific node
assertEquals(1, target.counterNode);
assertEquals("123", target.prefNode);
// optional preference
assertEquals(1, target.counterOptional);
assertNull(target.prefOptional1);
assertEquals("abc", target.prefOptional2);
// change
setPreference(TEST_PREFS_KEY, "xyz");
setPreference(TEST_PREFS_KEY, TEST_PREFS_NODE, "456");
// default node
assertEquals(2, target.counter);
assertEquals("xyz", target.pref);
// specific node
assertEquals(2, target.counterNode);
assertEquals("456", target.prefNode);
// optional preference
assertEquals(2, target.counterOptional);
assertNull(target.prefOptional1);
assertEquals("xyz", target.prefOptional2);
}
use of org.eclipse.e4.core.di.extensions.Preference in project portfolio by buchen.
the class StartupAddon method checkForUpdates.
@Inject
@Optional
public // NOSONAR
void checkForUpdates(// NOSONAR
@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event, final IWorkbench workbench, final EPartService partService, @Preference(value = UIConstants.Preferences.AUTO_UPDATE) boolean autoUpdate) {
if (autoUpdate) {
Job job = new Job(Messages.JobMsgCheckingForUpdates) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(Messages.JobMsgCheckingForUpdates, 200);
UpdateHelper updateHelper = new UpdateHelper(workbench, partService);
updateHelper.runUpdate(monitor, true);
} catch (// NOSONAR
CoreException e) {
PortfolioPlugin.log(e.getStatus());
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule(500);
}
}
Aggregations