Java Code Examples for org.eclipse.ui.preferences.ScopedPreferenceStore#setValue()

The following examples show how to use org.eclipse.ui.preferences.ScopedPreferenceStore#setValue() . 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: PlottingFactory.java    From dawnsci with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Reads the extension points for the plotting systems registered and returns
 * a plotting system based on the users current preferences.
 * 
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> IPlottingSystem<T> createPlottingSystem() throws Exception {

	final ScopedPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE,"org.dawb.workbench.ui");
	String plotType = store.getString("org.dawb.plotting.system.choice");
	if (plotType.isEmpty()) plotType = System.getProperty("org.dawb.plotting.system.choice");// For Geoff et. al. can override.
	if (plotType==null) plotType = "org.dawb.workbench.editors.plotting.lightWeightPlottingSystem"; // That is usually around

	IPlottingSystem<T> system = createPlottingSystem(plotType);
	if (system!=null) return system;

	IConfigurationElement[] systems = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.dawnsci.plotting.api.plottingClass");
	if (systems.length == 0) {
		return null;
	}

	IPlottingSystem<T> ifnotfound = (IPlottingSystem<T>)systems[0].createExecutableExtension("class");
	store.setValue("org.dawb.plotting.system.choice", systems[0].getAttribute("id"));
	return ifnotfound;
}
 
Example 2
Source File: TestDebug.java    From wildwebdeveloper with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUpLaunch() throws DebugException {
	this.launchManager = DebugPlugin.getDefault().getLaunchManager();
	removeAllLaunches();
	ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.debug.ui");
	prefs.setValue("org.eclipse.debug.ui.switch_perspective_on_suspend", MessageDialogWithToggle.ALWAYS);
}
 
Example 3
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 4
Source File: UnicodeEscapeTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private IProject getProject(String encoding) throws CoreException {
	IProject project = workbenchTestHelper.getProject();
	ScopedPreferenceStore projectPreferenceStore = new ScopedPreferenceStore(new ProjectScope(project),	Platform.PI_RUNTIME);
	projectPreferenceStore.setValue(Platform.PREF_LINE_SEPARATOR, "\n");
	project.setDefaultCharset(encoding, null);
	return project;
}
 
Example 5
Source File: LineSeparatorConversionTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void testSeparator(String separator) throws Exception {
	IProject project = workbenchTestHelper.getProject();
	ScopedPreferenceStore projectPreferenceStore = new ScopedPreferenceStore(new ProjectScope(project), Platform.PI_RUNTIME);
	projectPreferenceStore.setValue(Platform.PREF_LINE_SEPARATOR, separator);
	workbenchTestHelper.createFile("Foo.xtend", "class Foo {}");
	waitForBuild();
	IFile compiledFile = project.getFile("xtend-gen/Foo.java");
	workbenchTestHelper.getFiles().add(compiledFile);
	String contents = WorkbenchTestHelper.getContentsAsString(compiledFile);
	List<String> expectedLines = ImmutableList.of("@SuppressWarnings(\"all\")", "public class Foo {", "}", "");
	String expectedContent = Joiner.on(separator).join(expectedLines);
	assertEquals(expectedContent, contents);
}
 
Example 6
Source File: AbstractProjectPreferencesPage.java    From uml2solidity with Eclipse Public License 1.0 4 votes vote down vote up
private void saveUseProjectSettings(boolean isProjectSpecific) throws IOException {
	ScopedPreferenceStore store = (ScopedPreferenceStore) getPreferenceStore();
	store.setValue(useProjectSettingsPreferenceName(), Boolean.toString(isProjectSpecific));
	store.save();
}