org.eclipse.core.resources.ProjectScope Java Examples
The following examples show how to use
org.eclipse.core.resources.ProjectScope.
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: AbstractProfileManager.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * Update all formatter settings with the settings of the specified profile. * * @param profile * The profile to write to the preference store */ private void writeToPreferenceStore(Profile profile, IScopeContext context) { final Map profileOptions = profile.getSettings(); for (int i = 0; i < fKeySets.length; i++) { updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions); } final IEclipsePreferences uiPrefs = context.getNode(getNodeId()); if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) { uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion()); } if (context.getName() == InstanceScope.SCOPE) { uiPrefs.put(fProfileKey, profile.getID()); } else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) { uiPrefs.put(fProfileKey, profile.getID()); } }
Example #2
Source File: OptionsConfigurationBlock.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public boolean hasProjectSpecificOptions(IProject project) { if (project != null) { IScopeContext projectContext = new ProjectScope(project); PreferenceKey[] allKeys = fAllKeys; for (int i = 0; i < allKeys.length; i++) { if (allKeys[i].getStoredValue(projectContext, fManager) != null) { return true; } } } return false; }
Example #3
Source File: UserAgentManager.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Given a project, return the list of active user agent IDs. The current implementation processes only the first * (primary) nature ID of the given project. Secondary natures may be taken into consideration at a later point in * time * * @param project * An {@link IProject}. * @return Returns an array of user agent IDs for the main mature of the given project. In case the given project is * null, an empty string array is returned. */ public String[] getActiveUserAgentIDs(IProject project) { if (project == null) { return ArrayUtil.NO_STRINGS; } // Extract the natures from the given project String[] natureIDs = getProjectNatures(project); // Look at the project-scope preferences for the active agents. ProjectScope scope = new ProjectScope(project); IEclipsePreferences node = scope.getNode(CommonEditorPlugin.PLUGIN_ID); if (node != null) { String agents = node.get(IPreferenceConstants.USER_AGENT_PREFERENCE, null); if (agents != null) { Map<String, String[]> userAgents = extractUserAgents(agents); return getActiveUserAgentIDs(userAgents, natureIDs); } } // In case we did not find any project-specific settings, use the project's nature IDs to grab the agents that // were set in the workspace settings. return getActiveUserAgentIDs(natureIDs); }
Example #4
Source File: UserAgentManager.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public void clearPreferences(IProject project) { if (project != null) { // Save to the project scope IEclipsePreferences preferences = new ProjectScope(project).getNode(CommonEditorPlugin.PLUGIN_ID); preferences.remove(IPreferenceConstants.USER_AGENT_PREFERENCE); try { preferences.flush(); } catch (BackingStoreException e) { // ignore } } }
Example #5
Source File: CodeCheckerProject.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 6 votes |
/** * Updates project related fields, and saves to the preferences. */ private void updateProjectRelated() { IScopeContext context = new ProjectScope(project); IEclipsePreferences preferences = context.getNode(CodeCheckerNature.NATURE_ID); for (ConfigTypes ctp : ConfigTypes.PROJECT_TYPE){ String value = null; switch (ctp) { case CHECKER_WORKSPACE: value = codeCheckerWorkspace.toString(); break; case IS_GLOBAL: value = Boolean.toString(isGlobal); break; default: break; } preferences.put(ctp.toString(), value); } try { preferences.flush(); } catch (BackingStoreException e) { Logger.log(IStatus.ERROR, "Preferences cannot be saved!"); e.printStackTrace(); } }
Example #6
Source File: GWTJavaEditor.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private boolean formatOnSaveEnabled(IJavaProject javaProject) { SaveParticipantRegistry spr = JavaPlugin.getDefault().getSaveParticipantRegistry(); IPostSaveListener[] listeners = spr.getEnabledPostSaveListeners(javaProject.getProject()); for (IPostSaveListener listener : listeners) { if (listener instanceof CleanUpPostSaveListener) { Map<String, String> settings = CleanUpPreferenceUtil.loadSaveParticipantOptions(new ProjectScope( javaProject.getProject())); if (settings == null) { return false; } return (CLEAN_UP_OPTION_TRUE.equals(settings.get(CleanUpConstants.FORMAT_SOURCE_CODE))); } } return false; }
Example #7
Source File: ProfileManager.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public IProfile getSelected(IProject project) { IProfile selected = fSelected.get(project); if (selected == null && project != null) { // try to resolve the selected profile PreferenceKey activeProfileKey = getActiveProfileKey(); ProjectScope scope = new ProjectScope(project); IProfile profile = findProfile(activeProfileKey.getStoredValue(scope)); if (profile != null) { fSelected.put(project, profile); selected = profile; } else { // Return the default workspace setting selected = fSelected.get(null); } } return selected; }
Example #8
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates and returns the preference store for this Java editor with the given input. * * @param input The editor input for which to create the preference store * @return the preference store for this editor * * @since 3.0 */ private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) { List<IPreferenceStore> stores= new ArrayList<IPreferenceStore>(3); IJavaProject project= EditorUtility.getJavaProject(input); if (project != null) { stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), JavaCore.PLUGIN_ID)); } stores.add(JavaPlugin.getDefault().getPreferenceStore()); stores.add(new PreferencesAdapter(JavaPlugin.getJavaCorePluginPreferences())); stores.add(EditorsUI.getPreferenceStore()); stores.add(PlatformUI.getPreferenceStore()); return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()])); }
Example #9
Source File: XtendPreferenceStoreAccess.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@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 #10
Source File: AbstractPreferencePage.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * 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 #11
Source File: ProfileManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Update all formatter settings with the settings of the specified profile. * @param profile The profile to write to the preference store */ private void writeToPreferenceStore(Profile profile, IScopeContext context) { final Map<String, String> profileOptions= profile.getSettings(); for (int i= 0; i < fKeySets.length; i++) { updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions); } final IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN); if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) { uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion()); } if (context.getName() == InstanceScope.SCOPE) { uiPrefs.put(fProfileKey, profile.getID()); } else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) { uiPrefs.put(fProfileKey, profile.getID()); } }
Example #12
Source File: CleanUpSaveParticipantPreferenceConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void performDefaults() { if (ProjectScope.SCOPE.equals(fContext.getName()) && !hasSettingsInScope(fContext)) return; enabled(true); if (ProjectScope.SCOPE.equals(fContext.getName())) { fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(InstanceScope.INSTANCE); } else { fSettings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap(); } settingsChanged(); super.performDefaults(); }
Example #13
Source File: AppEngineDeployPreferencesPanelTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testProjectSavedInPreferencesSelected() throws ProjectRepositoryException, InterruptedException, BackingStoreException { IEclipsePreferences node = new ProjectScope(project).getNode(DeployPreferences.PREFERENCE_STORE_QUALIFIER); try { node.put("project.id", "projectId1"); node.put("account.email", EMAIL_1); model = new DeployPreferences(project); initializeProjectRepository(); when(loginService.getAccounts()).thenReturn(twoAccountSet); deployPanel = createPanel(true /* requireValues */); deployPanel.latestGcpProjectQueryJob.join(); ProjectSelector projectSelector = getProjectSelector(); IStructuredSelection selection = projectSelector.getViewer().getStructuredSelection(); assertThat(selection.size(), is(1)); assertThat(((GcpProject) selection.getFirstElement()).getId(), is("projectId1")); } finally { node.clear(); } }
Example #14
Source File: AbstractLangEditor.java From goclipse with Eclipse Public License 1.0 | 6 votes |
protected IPreferenceStore createCombinedPreferenceStore(IEditorInput input) { List<IPreferenceStore> stores = new ArrayList<IPreferenceStore>(4); IProject project = EditorUtils.getAssociatedProject(input); if (project != null) { stores.add(new EclipsePreferencesAdapter(new ProjectScope(project), LangUIPlugin.PLUGIN_ID)); } stores.add(LangUIPlugin.getInstance().getPreferenceStore()); stores.add(LangUIPlugin.getInstance().getCorePreferenceStore()); alterCombinedPreferenceStores_beforeEditorsUI(stores); stores.add(EditorsUI.getPreferenceStore()); return new ChainedPreferenceStore(ArrayUtil.createFrom(stores, IPreferenceStore.class)); }
Example #15
Source File: BazelProjectSupport.java From eclipse with Apache License 2.0 | 6 votes |
private static void addSettings(IProject project, String workspaceRoot, List<String> targets, List<String> buildFlags) throws BackingStoreException { IScopeContext projectScope = new ProjectScope(project); Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID); int i = 0; for (String target : targets) { projectNode.put("target" + i, target); i++; } projectNode.put("workspaceRoot", workspaceRoot); i = 0; for (String flag : buildFlags) { projectNode.put("buildFlag" + i, flag); i++; } projectNode.flush(); }
Example #16
Source File: PreferencesLookupHelper.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public PreferencesLookupHelper(String qualifier, Optional<IProject> project) { this.qualifier = qualifier; project = MiscUtil.toOptional(project); if(project.isPresent()) { contexts = array(new ProjectScope(project.get()), InstanceScope.INSTANCE, DefaultScope.INSTANCE); } else { contexts = array(InstanceScope.INSTANCE, DefaultScope.INSTANCE); } }
Example #17
Source File: OptionsConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean hasProjectSpecificOptions(IProject project, Key[] allKeys, IWorkingCopyManager manager) { if (project != null) { IScopeContext projectContext= new ProjectScope(project); for (int i= 0; i < allKeys.length; i++) { if (allKeys[i].getStoredValue(projectContext, manager) != null) { return true; } } } return false; }
Example #18
Source File: AbstractSaveParticipantPreferenceConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ public void performDefaults() { String key= getPreferenceKey(); boolean defaultEnabled; if (ProjectScope.SCOPE.equals(fContext.getName())) { defaultEnabled= InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).getBoolean(key, false); } else { defaultEnabled= DefaultScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).getBoolean(key, false); } fContext.getNode(JavaUI.ID_PLUGIN).putBoolean(key, defaultEnabled); fEnableField.setSelection(defaultEnabled); enabled(defaultEnabled); }
Example #19
Source File: ProjectTemplateStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean hasProjectSpecificTempates(IProject project) { String pref= new ProjectScope(project).getNode(JavaUI.ID_PLUGIN).get(KEY, null); if (pref != null && pref.trim().length() > 0) { Reader input= new StringReader(pref); TemplateReaderWriter reader= new TemplateReaderWriter(); TemplatePersistenceData[] datas; try { datas= reader.read(input); return datas.length > 0; } catch (IOException e) { // ignore } } return false; }
Example #20
Source File: JavaMergeViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private ChainedPreferenceStore createChainedPreferenceStore(IJavaProject project) { ArrayList<IPreferenceStore> stores= new ArrayList<IPreferenceStore>(4); if (project != null) stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), JavaCore.PLUGIN_ID)); stores.add(JavaPlugin.getDefault().getPreferenceStore()); stores.add(new PreferencesAdapter(JavaPlugin.getJavaCorePluginPreferences())); stores.add(EditorsUI.getPreferenceStore()); return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()])); }
Example #21
Source File: CleanUpSaveParticipantPreferenceConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void performOk() { super.performOk(); if (!ProjectScope.SCOPE.equals(fContext.getName()) || hasSettingsInScope(fContext)) CleanUpPreferenceUtil.saveSaveParticipantOptions(fContext, fSettings); }
Example #22
Source File: WizardNewTypeScriptProjectCreationPage.java From typescript.java with MIT License | 5 votes |
@Override public void updateCommand(List<LineCommand> commands, final IProject project, String nodeFilePath) { if (!useEmbeddedTsRuntime) { // when TypeScript is installed when "npm install typescript" // command is terminated, update the project Eclispe preferences // to consume this installed TypeScript runtime. commands.add(new LineCommand(installTsRuntime.getNpmInstallCommand(), new TerminalCommandAdapter() { @Override public void onTerminateCommand(LineCommand lineCommand) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { IEclipsePreferences preferences = new ProjectScope(project) .getNode(TypeScriptCorePlugin.PLUGIN_ID); preferences.putBoolean(TypeScriptCorePreferenceConstants.USE_EMBEDDED_TYPESCRIPT, false); preferences.put(TypeScriptCorePreferenceConstants.INSTALLED_TYPESCRIPT_PATH, "${project_loc:node_modules/typescript}"); try { preferences.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } } }); } })); } }
Example #23
Source File: PreferencesLookupDelegate.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private IScopeContext[] getLookupScopes(IProject project) { List<IScopeContext> list = new ArrayList<IScopeContext>(3); list.add(EclipseUtil.instanceScope()); list.add(EclipseUtil.defaultScope()); if (project != null) { list.add(0, new ProjectScope(project)); } return list.toArray(new IScopeContext[list.size()]); }
Example #24
Source File: CppcheclipsePlugin.java From cppcheclipse with Apache License 2.0 | 5 votes |
public static IPersistentPreferenceStore getProjectPreferenceStore(IProject project) { // Create an overlay preference store and fill it with properties ProjectScope ps = new ProjectScope(project); ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, getId()); PreferenceInitializer.initializePropertiesDefault(scoped); return scoped; }
Example #25
Source File: DefaultResourceBlacklist.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public boolean save(IProject project, List<IResource> items) { ProjectScope projectScope = getPreferenceScope(project); IEclipsePreferences node = projectScope.getNode(SCT_RESOURCE_NODE); String blacklist = getBlacklistValue(items); node.put(SCT_BLACKLIST_KEY, blacklist); try { node.flush(); } catch (BackingStoreException e) { e.printStackTrace(); return false; } return true; }
Example #26
Source File: AbstractTypeScriptSettings.java From typescript.java with MIT License | 5 votes |
public AbstractTypeScriptSettings(IProject project, String pluginId) { this.project = project; this.projectScope = new ProjectScope(project); this.pluginId = pluginId; getProjectPreferences().addPreferenceChangeListener(this); getWorkspacePreferences().addPreferenceChangeListener(this); getWorkspaceDefaultPreferences().addPreferenceChangeListener(this); }
Example #27
Source File: TypeScriptDocumentProvider.java From typescript.java with MIT License | 5 votes |
private static IPreferenceStore createProjectSpecificPreferenceStore(IProject project) { List<IPreferenceStore> stores = new ArrayList<IPreferenceStore>(); if (project != null) { stores.add(new EclipsePreferencesAdapter(new ProjectScope(project), TypeScriptUIPlugin.PLUGIN_ID)); stores.add(new EclipsePreferencesAdapter(new ProjectScope(project), TypeScriptCorePlugin.PLUGIN_ID)); } stores.add(new ScopedPreferenceStore(InstanceScope.INSTANCE, TypeScriptUIPlugin.PLUGIN_ID)); stores.add(new ScopedPreferenceStore(InstanceScope.INSTANCE, TypeScriptCorePlugin.PLUGIN_ID)); stores.add(new ScopedPreferenceStore(DefaultScope.INSTANCE, TypeScriptUIPlugin.PLUGIN_ID)); stores.add(new ScopedPreferenceStore(DefaultScope.INSTANCE, TypeScriptCorePlugin.PLUGIN_ID)); return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()])); }
Example #28
Source File: TypeScriptEditor.java From typescript.java with MIT License | 5 votes |
@Override protected void addPreferenceStores(List stores, IEditorInput input) { IResource file = input != null ? EditorUtils.getResource(input) : null; if (file != null) { stores.add( new EclipsePreferencesAdapter(new ProjectScope(file.getProject()), TypeScriptCorePlugin.PLUGIN_ID)); stores.add( new EclipsePreferencesAdapter(new ProjectScope(file.getProject()), TypeScriptUIPlugin.PLUGIN_ID)); } stores.add(TypeScriptUIPlugin.getDefault().getPreferenceStore()); stores.add(new PreferencesAdapter(TypeScriptCorePlugin.getDefault().getPluginPreferences())); super.addPreferenceStores(stores, input); }
Example #29
Source File: TypeScriptMergeViewer.java From typescript.java with MIT License | 5 votes |
private ChainedPreferenceStore createChainedPreferenceStore(IIDETypeScriptProject project) { ArrayList<IPreferenceStore> stores = new ArrayList<>(4); if (project != null) { stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), TypeScriptCorePlugin.PLUGIN_ID)); stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), TypeScriptUIPlugin.PLUGIN_ID)); } stores.add(JavaScriptPlugin.getDefault().getPreferenceStore()); stores.add(new PreferencesAdapter(JavaScriptCore.getPlugin().getPluginPreferences())); stores.add(new PreferencesAdapter(JSDTTypeScriptUIPlugin.getDefault().getPluginPreferences())); stores.add(EditorsUI.getPreferenceStore()); return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()])); }
Example #30
Source File: BazelProjectSupport.java From eclipse with Apache License 2.0 | 5 votes |
/** * List targets configure for <code>project</code>. Each project configured for Bazel is * configured to track certain targets and this function fetch this list from the project * preferences. */ public static List<String> getTargets(IProject project) throws BackingStoreException { // Get the list of targets from the preferences IScopeContext projectScope = new ProjectScope(project); Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID); ImmutableList.Builder<String> builder = ImmutableList.builder(); for (String s : projectNode.keys()) { if (s.startsWith("target")) { builder.add(projectNode.get(s, "")); } } return builder.build(); }