org.eclipse.core.runtime.preferences.ConfigurationScope Java Examples

The following examples show how to use org.eclipse.core.runtime.preferences.ConfigurationScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtendPreferenceStoreAccess.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("all")
@Override
public IPreferenceStore getContextPreferenceStore(Object context) {
	IProject project = getProject(context);
	if (project == null) return getPreferenceStore();
	IPreferenceStore store = super.getContextPreferenceStore(context);
	ProjectScope projectScope = new ProjectScope(project);
	FixedScopedPreferenceStore jdtStore = new FixedScopedPreferenceStore(projectScope, JavaCore.PLUGIN_ID);
	jdtStore.setSearchContexts(new IScopeContext[] {
			projectScope,
			new InstanceScope(),
			new ConfigurationScope()
	});
	return new ChainedPreferenceStore(new IPreferenceStore[] {
		store,
		jdtStore,
		PreferenceConstants.getPreferenceStore()
	});
}
 
Example #2
Source File: CcGlobalConfiguration.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initializes the plug-ins internal configuration, Call this method somewhere early.
 */
@Override
public void load() {
    preferences = ConfigurationScope.INSTANCE.getNode(CodeCheckerNature.NATURE_ID);
    validate();
    config = new ConcurrentHashMap<>();

    try {
        ConfigLogger configlogger = new ConfigLogger("Initialized GlobalConfig with:");
        for (String configKey : preferences.keys()) {
            ConfigTypes ct = ConfigTypes.getFromString(configKey);
            if (ct != null) config.put(ct, preferences.get(configKey, STR_EMPTY));
            configlogger.append(configKey + ConfigLogger.SEP + preferences.get(configKey, STR_EMPTY));
        }
        configlogger.log();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
 
Example #3
Source File: AbstractPreferencePage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Switches the search scope of the preference store to use [Project, Instance, Configuration] if values are project
 * specific, and [Instance, Configuration] otherwise. This implementation requires that the given preference store
 * is based on the Project preference store when the page is used as a Properties page. (This is done in
 * {@link #doGetPreferenceStore()}).
 */
@SuppressWarnings("deprecation")
private void handleUseProjectSettings() {
	// Note: uses the pre Eclipse 3.6 way of specifying search scopes (deprecated since 3.6)
	boolean isUseProjectSettings = useProjectSettingsButton.getSelection();
	link.setEnabled(!isUseProjectSettings);
	if (!isUseProjectSettings) {
		((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] {
				new InstanceScope(), new ConfigurationScope() });
	} else {
		((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] {
				new ProjectScope(currentProject()), new InstanceScope(), new ConfigurationScope() });
		setProjectSpecificValues();
	}
	updateFieldEditors(isUseProjectSettings);
}
 
Example #4
Source File: PreferenceStoreAccessImpl.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore(Object context) {
	lazyInitialize();
	IProject project = getProject(context);
	if (project == null) {
		return getWritablePreferenceStore();
	}
	ProjectScope projectScope = new ProjectScope(project);
	FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(projectScope, getQualifier());
	result.setSearchContexts(new IScopeContext[] {
		projectScope,
		new InstanceScope(),
		new ConfigurationScope()
	});
	return result;
}
 
Example #5
Source File: BuildUtils.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
protected static boolean isAutoBuildEnabled() {
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
	String key = "description.autobuilding";
	IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE };
	return service.getBoolean(qualifier, key, false, contexts);
}
 
Example #6
Source File: ReleaseNotes.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void setLastVersion(String version) {
	IEclipsePreferences node = ConfigurationScope.INSTANCE.getNode(ReleaseNotes.class.getName());
	node.put(Version.class.getSimpleName(), version);
	try {
		node.flush();
		return;
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
}
 
Example #7
Source File: XtendPreferenceStoreAccess.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("all")
@Override
public IPreferenceStore getPreferenceStore() {
	IPreferenceStore store = super.getPreferenceStore();
	FixedScopedPreferenceStore jdtStore = new FixedScopedPreferenceStore(new InstanceScope(), JavaCore.PLUGIN_ID);
	jdtStore.setSearchContexts(new IScopeContext[] {
			new InstanceScope(),
			new ConfigurationScope()
	});
	return new ChainedPreferenceStore(new IPreferenceStore[] {
		store,
		jdtStore,
		PreferenceConstants.getPreferenceStore()
	});
}
 
Example #8
Source File: SendPingJob.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public static TimeZone getTimeZone ()
{
    final IScopeContext[] scopeContext = new IScopeContext[] { ConfigurationScope.INSTANCE };
    final String tzId = Platform.getPreferencesService ().getString ( PLUGIN_ID, TIME_ZONE_KEY, TimeZone.getDefault ().getID (), scopeContext );
    if ( Arrays.asList ( TimeZone.getAvailableIDs () ).contains ( tzId ) )
    {
        return TimeZone.getTimeZone ( tzId );
    }
    return TimeZone.getDefault ();
}
 
Example #10
Source File: ImportPlatformWizard.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
protected boolean isAutoBuildEnabled()
{
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
	String key = "description.autobuilding";
	IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE};
	return service.getBoolean( qualifier, key, false, contexts );
}
 
Example #11
Source File: SynchronizePlatformWizard.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
protected boolean isAutoBuildEnabled()
{
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
	String key = "description.autobuilding";
	IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE};
	return service.getBoolean( qualifier, key, false, contexts );
}
 
Example #12
Source File: EclipseRefreshAndBuildHandler.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
protected boolean isAutoBuildEnabled()
{
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
	String key = "description.autobuilding";
	IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE };
	return service.getBoolean(qualifier, key, false, contexts);
}
 
Example #13
Source File: PreferenceStoreAccessImpl.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore() {
	lazyInitialize();
	FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(new InstanceScope(), getQualifier());
	result.setSearchContexts(new IScopeContext[] {
		new InstanceScope(),
		new ConfigurationScope()
	});
	return result;
}
 
Example #14
Source File: SendPingJob.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #15
Source File: PreferenceStoreAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testChainedPreferenceStore() {
	ScopedPreferenceStore configurationStore = new ScopedPreferenceStore(new ConfigurationScope(), LANGUAGE_ID);
	configurationStore.setValue("someInt", 12);
	configurationStore.setValue("anotherInt", 12);
	configurationStore.setDefault("thirdInt", 12);
	ScopedPreferenceStore instanceStore = new ScopedPreferenceStore(new InstanceScope(), LANGUAGE_ID);
	instanceStore.setValue("someInt", 13);
	instanceStore.setDefault("anotherInt", 13);
	ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { instanceStore, configurationStore });
	assertEquals(13, chainedStore.getInt("someInt"));
	assertEquals(13, chainedStore.getInt("anotherInt"));
	assertEquals(12, chainedStore.getInt("thirdInt"));
}
 
Example #16
Source File: PreferenceStoreAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testScopeWithAnotherInstance() {
	// ensure initialization
	getWritable();
	ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(new ConfigurationScope(), LANGUAGE_ID);
	assertTrue(scopedPreferenceStore.getBoolean("someBoolean"));
}
 
Example #17
Source File: TSPreferenceInitializer.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences() {
	// 设置 colors 首选项页的初始值
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_FG_COLOR, new RGB(234, 234, 234));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_BG_COLOR, new RGB(223, 112, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.WRONG_TAG_COLOR, new RGB(255, 0, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_FG_COLOR, new RGB(255, 0, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_BG_COLOR, new RGB(244, 244, 159));

	PreferenceConverter.setDefault(store, IColorPreferenceConstant.PT_COLOR, new RGB(255, 0, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.QT_COLOR, new RGB(255, 204, 204));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.MT_COLOR, new RGB(171, 217, 198));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH101_COLOR, new RGB(255, 255, 204));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH100_COLOR, new RGB(37, 168, 204));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH90_COLOR, new RGB(79, 185, 214));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH80_COLOR, new RGB(114, 199, 222));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH70_COLOR, new RGB(155, 215, 231));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH0_COLOR, new RGB(198, 240, 251));

	PreferenceConverter.setDefault(store, IColorPreferenceConstant.HIGHLIGHTED_TERM_COLOR, new RGB(170, 255, 85));

	// 设置 net.heartsome.cat.common.core 插件中的语言代码初始值
	IPreferenceStore corePreferenceStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, CoreActivator
			.getDefault().getBundle().getSymbolicName());
	corePreferenceStore.setDefault(IPreferenceConstants.LANGUAGECODE, LocaleService.getLanguageConfigAsString());

	// 设置选择路径对话框的初始值
	PlatformUI.getPreferenceStore()
			.setDefault(IPreferenceConstants.LAST_DIRECTORY, System.getProperty("user.home"));
	
	ColorConfigLoader.init();
}
 
Example #18
Source File: UpdateCheckerJobListener.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
@Override
public void done(IJobChangeEvent event) {
	if (event.getResult().isOK()) {
		Display.getDefault().syncExec(new Runnable() {
			@Override
			public void run() {
				try {
					// Wait half a second to let progress reporting complete
					// FIXME: Find a proper fix
					Thread.sleep(500);
					// Set last check for Updates Time-stamp in OSGI bundle
					// prefs
					Preferences preferences = ConfigurationScope.INSTANCE.getNode(Constants.NODE_UPDATE_HANDER);
					preferences.putLong(Constants.PREF_LAST_PROMPT_FOR_UPDATES, new Date().getTime());
					preferences.flush();
					UpdateCheckerJob.setIsJobRunning(false);
					if (isAutomaticUpdater && !updateManager.hasPossibleUpdates()) {
						// no updates - no need to open the window
						return;
					}

					UpdaterDialog dialog = new UpdaterDialog(updateManager, activeTab);
					dialog.open();
				} catch (Exception e) {
					log.error(Messages.UpdateCheckerJobListener_0, e);
				}
			}
		});
	}
}
 
Example #19
Source File: TSPreferenceInitializer.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences() {
	// 设置 colors 首选项页的初始值
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_FG_COLOR, new RGB(234, 234, 234));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_BG_COLOR, new RGB(223, 112, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.WRONG_TAG_COLOR, new RGB(255, 0, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_FG_COLOR, new RGB(255, 0, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_BG_COLOR, new RGB(244, 244, 159));

	PreferenceConverter.setDefault(store, IColorPreferenceConstant.PT_COLOR, new RGB(255, 0, 0));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.QT_COLOR, new RGB(255, 204, 204));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.MT_COLOR, new RGB(171, 217, 198));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH101_COLOR, new RGB(255, 255, 204));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH100_COLOR, new RGB(37, 168, 204));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH90_COLOR, new RGB(79, 185, 214));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH80_COLOR, new RGB(114, 199, 222));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH70_COLOR, new RGB(155, 215, 231));
	PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH0_COLOR, new RGB(198, 240, 251));

	PreferenceConverter.setDefault(store, IColorPreferenceConstant.HIGHLIGHTED_TERM_COLOR, new RGB(170, 255, 85));

	// 设置 net.heartsome.cat.common.core 插件中的语言代码初始值
	IPreferenceStore corePreferenceStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, CoreActivator
			.getDefault().getBundle().getSymbolicName());
	corePreferenceStore.setDefault(IPreferenceConstants.LANGUAGECODE, LocaleService.getLanguageConfigAsString());

	// 设置选择路径对话框的初始值
	PlatformUI.getPreferenceStore()
			.setDefault(IPreferenceConstants.LAST_DIRECTORY, System.getProperty("user.home"));
	
	ColorConfigLoader.init();
}
 
Example #20
Source File: PreferenceResolver.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve the given scheme to a preference scope.
 * 
 * @param scheme the preference scheme
 * @return the corresponding preference scope
 * @throws IllegalArgumentException if unable to resolve the scheme to a preference scope
 */
private static IScopeContext resolveScopeContext(String scheme) throws IllegalArgumentException {
  switch (scheme) {
    case "instance":
      return InstanceScope.INSTANCE;
    case "configuration":
      return ConfigurationScope.INSTANCE;
    default:
      throw new IllegalArgumentException("Unknown scheme: " + scheme);
  }
}
 
Example #21
Source File: DotActivatorEx.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public static Preferences dotUiPreferences() {
	return ConfigurationScope.INSTANCE
			.getNode(getInstance().getBundle().getSymbolicName());
}
 
Example #22
Source File: GdtPreferences.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
private static IEclipsePreferences getConfigurationPreferences() {
  ConfigurationScope scope = new ConfigurationScope();
  IEclipsePreferences configurationPrefs = scope.getNode(GdtPlugin.PLUGIN_ID);
  return configurationPrefs;
}
 
Example #23
Source File: ReleaseNotes.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected String getLastVersion() {
	IEclipsePreferences node = ConfigurationScope.INSTANCE.getNode(ReleaseNotes.class.getName());
	return node.get(Version.class.getSimpleName(), "");
}
 
Example #24
Source File: TraceTypePreferences.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static IEclipsePreferences getEclipsePreference() {
    IEclipsePreferences configurationPreferences = ConfigurationScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    return configurationPreferences;
}
 
Example #25
Source File: DotActivatorEx.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public static IPreferenceStore dotUiPreferenceStore() {
	return new ScopedPreferenceStore(ConfigurationScope.INSTANCE,
			getInstance().getBundle().getSymbolicName());
}
 
Example #26
Source File: RailroadViewPreferences.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public RailroadViewPreferences() {
	preferenceStore = new ScopedPreferenceStore(new ConfigurationScope(), "Xtext Grammar View");
}
 
Example #27
Source File: PreferenceStoreAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testScope() {
	ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(new ConfigurationScope(), "org");
	assertFalse("partial keys are not supported", scopedPreferenceStore.getBoolean("xtext.MyLanguage.someBoolean"));
}
 
Example #28
Source File: AnalyticsPreferences.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
static IEclipsePreferences getPreferenceNode() {
  return ConfigurationScope.INSTANCE.getNode(PREFERENCE_PATH);
}
 
Example #29
Source File: AnalyticsPreferences.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
static IPreferenceStore getPreferenceStore() {
  return new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PREFERENCE_PATH);
}
 
Example #30
Source File: Saros.java    From saros with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the global {@link Preferences} with {@link ConfigurationScope} for this plug-in or null
 * if the node couldn't be determined.
 *
 * <p>The returned Preferences can be accessed concurrently by multiple threads of the same JVM
 * without external synchronization. If they are used by multiple JVMs no guarantees can be made
 * concerning data consistency (see {@link Preferences} for details).
 *
 * @return the preferences node for this plug-in containing global preferences that are visible
 *     for all workspaces of this eclipse installation
 */
public synchronized Preferences getGlobalPreferences() {
  // TODO Singleton-Pattern code smell: ConfigPrefs should be a @component
  if (globalPreferences == null) {
    globalPreferences = ConfigurationScope.INSTANCE.getNode(PLUGIN_ID);
  }
  return globalPreferences;
}