Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
  
  package org.eclipse.xtext.ui.editor.preferences;
  
 import  org.eclipse.core.resources.IProject;
 import  org.eclipse.core.resources.ProjectScope;
 import  org.eclipse.core.runtime.preferences.ConfigurationScope;
 import  org.eclipse.core.runtime.preferences.IScopeContext;
 import  org.eclipse.core.runtime.preferences.InstanceScope;
 import  org.eclipse.jface.preference.IPreferenceStore;
 import  org.eclipse.ui.IFileEditorInput;
 import  org.eclipse.ui.editors.text.EditorsUI;
 import  org.eclipse.ui.texteditor.ChainedPreferenceStore;
 

Author(s):
Sven Efftinge - Initial contribution and API
 
 public class PreferenceStoreAccessImpl implements IPreferenceStoreAccess {
 
 	public IPreferenceStore getPreferenceStore() {
 		Activator activator = Activator.getDefault();
 		if (activator != null)
 			return new ChainedPreferenceStore(new IPreferenceStore[] {
 					activator.getPreferenceStore(), 
 					EditorsUI.getPreferenceStore() });
 		return new ChainedPreferenceStore(new IPreferenceStore[] {
 				EditorsUI.getPreferenceStore() });
 	}
 
 	public IPreferenceStore getContextPreferenceStore(Object context) {
 		// may be null on shutdown
 		Activator activator = Activator.getDefault();
 		if (activator != null)
 			return new ChainedPreferenceStore(new IPreferenceStore[] { 
 					activator.getPreferenceStore(),
 					EditorsUI.getPreferenceStore()});
 		return new ChainedPreferenceStore(new IPreferenceStore[] { 
 				EditorsUI.getPreferenceStore()});
 	}
 
 	@SuppressWarnings("deprecation")
 	public IPreferenceStore getWritablePreferenceStore() {
 		FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(new InstanceScope(), getQualifier());
 		result.setSearchContexts(new IScopeContext[] {
 			new InstanceScope(),
 			new ConfigurationScope()
 		});
 		return result;
 	}
 
 	@SuppressWarnings("deprecation")
 	public IPreferenceStore getWritablePreferenceStore(Object context) {
 		IProject project = getProject(context);
 		if (project == null) {
 		}
 		ProjectScope projectScope = new ProjectScope(project);
 		result.setSearchContexts(new IScopeContext[] {
 			projectScope,
 			new InstanceScope(),
 			new ConfigurationScope()
 		});
 		return result;
 	}

Since:
2.6
 
 	/* @Nullable */
 	protected IProject getProject(Object context) {
 		if (context instanceof IFileEditorInput) {
 			return ((IFileEditorInput) context).getFile().getProject();
 		}
 		if (context instanceof IProject) {
			return (IProject) context;
		}
		return null;
	}
	private String qualifier;
		this. = languageName;
	}
	protected String getQualifier() {
		return ;
	}
	private boolean initialized = false;
	protected void lazyInitialize() {
		if (!) {
			 = true;
		}
	}
New to GrepCode? Check out our FAQ X