下面列出了org.eclipse.core.runtime.preferences.ConfigurationScope#getNode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean enroll()
{
ConfigurationScope scope = EclipseUtil.configurationScope();
boolean hasEnrolled = Platform.getPreferencesService().getBoolean(UsagePlugin.PLUGIN_ID,
IPreferenceConstants.HAS_ENROLLED, false, new IScopeContext[] { scope });
if (!hasEnrolled)
{
AnalyticsInfo info = UsagePlugin.getDefault().getAnalyticsInfoManager()
.getInfo("com.aptana.usage.analytics"); //$NON-NLS-1$
String guid = info.getAppGuid();
// only sends the enroll ping if it's Aptana Studio
if ((new DefaultAnalyticsInfo()).getAppGuid().equals(guid))
{
// @formatter:off
Map<String, String> payload = CollectionsUtil.newInOrderMap(
"guid", guid, //$NON-NLS-1$
"mid", CorePlugin.getMID()); //$NON-NLS-1$
// @formatter:on
StudioAnalytics.getInstance().sendEvent(new AnalyticsEvent(STUDIO_ENROLL, STUDIO_ENROLL, payload));
}
IEclipsePreferences store = scope.getNode(UsagePlugin.PLUGIN_ID);
store.putBoolean(IPreferenceConstants.HAS_ENROLLED, true);
try
{
store.flush();
return true;
}
catch (BackingStoreException e)
{
UsagePlugin.logError(e);
}
}
return false;
}
private boolean sendFirstRunEvent()
{
ConfigurationScope scope = EclipseUtil.configurationScope();
boolean hasRun = Platform.getPreferencesService().getBoolean(UsagePlugin.PLUGIN_ID,
IPreferenceConstants.P_IDE_HAS_RUN, false, new IScopeContext[] { scope });
if (!hasRun)
{
// checks with the previous plugin id
hasRun = Platform.getPreferencesService().getBoolean(UsagePlugin.OLD_PLUGIN_ID,
IPreferenceConstants.P_IDE_HAS_RUN, false, new IScopeContext[] { scope });
if (!hasRun)
{
StudioAnalytics.getInstance().sendEvent(new AnalyticsEvent(STUDIO_FIRST_RUN, STUDIO_FIRST_RUN, null));
IEclipsePreferences store = scope.getNode(UsagePlugin.PLUGIN_ID);
store.putBoolean(IPreferenceConstants.P_IDE_HAS_RUN, true);
try
{
store.flush();
return true;
}
catch (BackingStoreException e)
{
UsagePlugin.logError(e);
}
}
}
return false;
}
private static IEclipsePreferences getConfigurationPreferences() {
ConfigurationScope scope = new ConfigurationScope();
IEclipsePreferences configurationPrefs = scope.getNode(GdtPlugin.PLUGIN_ID);
return configurationPrefs;
}