下面列出了怎么用org.eclipse.ui.preferences.ScopedPreferenceStore的API类实例代码及写法,或者点击链接到github查看源代码。
public DartboardLanguageServerStreamProvider() {
ScopedPreferenceStore globalPreferences = DartPreferences.getPreferenceStore();
List<String> commands = new ArrayList<>();
String dartLocation;
if (globalPreferences.getBoolean(GlobalConstants.P_FLUTTER_ENABLED)) {
String flutterSDK = globalPreferences.getString(GlobalConstants.P_SDK_LOCATION_FLUTTER);
dartLocation = flutterSDK + "/bin/cache/dart-sdk"; //$NON-NLS-1$
} else {
dartLocation = globalPreferences.getString(GlobalConstants.P_SDK_LOCATION_DART);
}
commands.add(dartLocation + "/bin/dart"); //$NON-NLS-1$
commands.add(dartLocation + "/bin/snapshots/analysis_server.dart.snapshot"); //$NON-NLS-1$
setWorkingDirectory(System.getProperty("user.dir")); //$NON-NLS-1$
setCommands(commands);
commands.add("--lsp"); //$NON-NLS-1$
}
@Before
public void setUpProject() throws Exception {
ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.nanoTime());
project.create(null);
project.open(null);
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IViewReference ref : activePage.getViewReferences()) {
activePage.hideView(ref);
}
}
@Before
public void setUpProject() throws Exception {
ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.nanoTime());
project.create(null);
project.open(null);
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IViewReference ref : activePage.getViewReferences()) {
activePage.hideView(ref);
}
}
@Override
protected void starting(Description description) {
super.starting(description);
IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro();
if (intro != null) {
PlatformUI.getWorkbench().getIntroManager().closeIntro(intro);
}
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IViewReference ref : activePage.getViewReferences()) {
activePage.hideView(ref);
}
ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
clearProjects();
}
public BuilderPreferences () {
IPreferenceStore preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE,
Activator.PLUGIN_ID);
String schedulingRuleName = preferenceStore.getString(PREF_SCHEDULING_RULE);
if (schedulingRuleName.isEmpty()) {
schedulingOption = SchedulingOption.WORKSPACE;
} else {
schedulingOption = SchedulingOption.valueOf(schedulingRuleName);
}
preferenceStore.addPropertyChangeListener(e -> {
if (PREF_SCHEDULING_RULE.equals(e.getProperty())) {
schedulingOption = SchedulingOption.valueOf(e.getNewValue().toString());
}
});
}
/**
* 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;
}
public static Color getEclipseEditorForeground( )
{
ScopedPreferenceStore preferenceStore = new ScopedPreferenceStore( InstanceScope.INSTANCE,
"org.eclipse.ui.editors" );//$NON-NLS-1$
Color color = null;
if ( preferenceStore != null )
{
color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT ) ? null
: createColor( preferenceStore,
AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
Display.getCurrent( ) );
}
if ( color == null )
{
color = Display.getDefault( )
.getSystemColor( SWT.COLOR_LIST_FOREGROUND );
}
return color;
}
public static Color getEclipseEditorBackground( )
{
ScopedPreferenceStore preferenceStore = new ScopedPreferenceStore( InstanceScope.INSTANCE,
"org.eclipse.ui.editors" );//$NON-NLS-1$
Color color = null;
if ( preferenceStore != null )
{
color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT ) ? null
: createColor( preferenceStore,
AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
Display.getCurrent( ) );
}
if ( color == null )
{
color = Display.getDefault( )
.getSystemColor( SWT.COLOR_LIST_BACKGROUND );
}
return color;
}
@Override
public boolean performOk() {
boolean ok = super.performOk();
try {
((ScopedPreferenceStore) getPreferenceStore()).save();
} catch (IOException e) {
BonitaStudioLog.error(e);
}
if (newLocale != null && !newLocale.isEmpty()) {
changeLocale(newLocale);
if (MessageDialog.openQuestion(getShell(),
Messages.bind(Messages.restartQuestion_title, new Object[] { bonitaStudioModuleName }),
Messages.bind(Messages.restartQuestion_msg, new Object[] { bonitaStudioModuleName }))) {
PlatformUI.getWorkbench().restart();
}
}
return ok;
}
public AngularLanguageServer() {
ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
this.isLoggingToFileEnabled = scopedPreferenceStore.getBoolean(LOG_TO_FILE_ANGULAR_LS_PREFERENCE);
this.isLoggingToConsoleEnabled = scopedPreferenceStore.getBoolean(LOG_TO_CONSOLE_ANGULAR_LS_PREFERENCE);
List<String> commands = new ArrayList<>();
commands.add(InitializeLaunchConfigurations.getNodeJsLocation());
try {
URL url = FileLocator.toFileURL(getClass().getResource("/node_modules/@angular/language-server/index.js"));
commands.add(new java.io.File(url.getPath()).getAbsolutePath());
File nodeModules = new File(url.getPath()).getParentFile().getParentFile().getParentFile();
commands.add("--ngProbeLocations");
commands.add(new File(nodeModules, "@angular/language-service").getAbsolutePath());
commands.add("--tsProbeLocations");
commands.add(new File(nodeModules, "typescript").getAbsolutePath());
commands.add("--stdio");
if (isLoggingToFileEnabled) {
commands.add("--logFile");
commands.add(Platform.getLogFileLocation().removeLastSegments(1)
.append("angular-language-server.log").toFile()
.getAbsolutePath());
}
commands.add("--logVerbosity");
commands.add("terse");
setCommands(commands);
setWorkingDirectory(System.getProperty("user.dir"));
} catch (IOException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e));
}
}
@Before
public void setUpProject() throws Exception {
ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.nanoTime());
project.create(null);
project.open(null);
// Setup ESLint configuration and dependencies
IFile eslintConfig = project.getFile(".eslintrc");
eslintConfig.create(getClass().getResourceAsStream("/testProjects/eslint/.eslintrc"), true, null);
IFile tsConfig = project.getFile("tsconfig.json");
tsConfig.create(getClass().getResourceAsStream("/testProjects/eslint/tsconfig.json"), true, null);
IFile packageJson = project.getFile("package.json");
packageJson.create(getClass().getResourceAsStream("/testProjects/eslint/package.json"), true, null);
Process dependencyInstaller = new ProcessBuilder(TestAngular.getNpmLocation(), "install")
.directory(project.getLocation().toFile()).start();
assertEquals("npm install didn't complete properly", 0, dependencyInstaller.waitFor());
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IViewReference ref : activePage.getViewReferences()) {
activePage.hideView(ref);
}
}
@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);
}
@Before
public void setUp2() throws Exception {
preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, N4JSActivator.ORG_ECLIPSE_N4JS_N4JS);
comparer = new IOutlineNodeComparer.Default();
// when using in XPECT, XPECT already creates the project structure
if (shouldCreateProjectStructure()) {
createProjectStructure();
}
//
openXtextDocument();
openOutlineView();
}
@Test
public void userDefinedEditorColorTest() throws Exception {
String testColorVal = "255,128,0";
Color testColor = new Color(Display.getCurrent(), 255, 128, 0);
IPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.editors");
prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, testColorVal);
prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND, testColorVal);
prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, false);
f = File.createTempFile("test" + System.currentTimeMillis(), ".ts");
editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), f.toURI(),
editorDescriptor.getId(), true);
StyledText styledText = (StyledText) editor.getAdapter(Control.class);
String themeId = manager.getDefaultTheme().getId();
ITheme theme = manager.getThemeById(themeId);
assertEquals("Default light theme isn't set", themeId, SolarizedLight);
assertEquals("Background color should be user defined", styledText.getBackground(), testColor);
assertEquals("Foreground colors should be ", theme.getEditorForeground(), styledText.getForeground());
assertEquals("Selection background color should be user defined", theme.getEditorSelectionBackground(),
testColor);
assertNull("Selection foreground should be System default (null)", theme.getEditorSelectionForeground());
Color lineHighlight = ColorManager.getInstance()
.getPreferenceEditorColor(EDITOR_CURRENTLINE_HIGHLIGHT);
assertNotNull("Highlight shouldn't be a null", lineHighlight);
assertEquals("Line highlight should be from preferences (because of user defined background)", lineHighlight,
theme.getEditorCurrentLineHighlight());
}
/**
* Resolve a path like <code>instance://org.example.bundle/path/to/boolean</code> to an
* {@link IPreferenceStore}.
*
* @param preferenceUri the preference path
* @return the corresponding store
* @throws IllegalArgumentException if unable to resolve the URI
*/
public static IPreferenceStore resolve(URI preferenceUri) throws IllegalArgumentException {
IScopeContext context = resolveScopeContext(preferenceUri.getScheme());
String path = preferenceUri.getHost();
if (preferenceUri.getPath() != null) {
path += preferenceUri.getPath();
}
return new ScopedPreferenceStore(context, path);
}
@Test
public void testResolveInstance() throws IllegalArgumentException, URISyntaxException {
IPreferenceStore store = PreferenceResolver.resolve(new URI("instance://com.google.test/foo"));
assertTrue(store instanceof ScopedPreferenceStore);
IEclipsePreferences[] nodes = ((ScopedPreferenceStore) store).getPreferenceNodes(false);
assertEquals(1, nodes.length);
assertEquals("/instance/com.google.test/foo", nodes[0].absolutePath());
}
@Test
public void testResolveConfig() throws IllegalArgumentException, URISyntaxException {
IPreferenceStore store =
PreferenceResolver.resolve(new URI("configuration://com.google.test/foo"));
assertTrue(store instanceof ScopedPreferenceStore);
IEclipsePreferences[] nodes = ((ScopedPreferenceStore) store).getPreferenceNodes(false);
assertEquals(1, nodes.length);
assertEquals("/configuration/com.google.test/foo", nodes[0].absolutePath());
}
@SuppressWarnings("deprecation")
@Test public void testScopeWithAnotherInstance() {
// ensure initialization
getWritable();
ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(new ConfigurationScope(), LANGUAGE_ID);
assertTrue(scopedPreferenceStore.getBoolean("someBoolean"));
}
@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"));
}
@SuppressWarnings("deprecation")
@Override
public void setUp() throws Exception {
super.setUp();
preferenceStore = new ScopedPreferenceStore(new InstanceScope(), getEditorId());
comparer = new IOutlineNodeComparer.Default();
modelAsText = "one { two {} three {} } four {}";
file = IResourcesSetupUtil.createFile("test/test.outlinetestlanguage", modelAsText);
editor = openEditor(file);
document = editor.getDocument();
outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
executeAsyncDisplayJobs();
Object adapter = editor.getAdapter(IContentOutlinePage.class);
assertTrue(adapter instanceof SyncableOutlinePage);
outlinePage = (SyncableOutlinePage) adapter;
outlinePage.resetSyncer();
try {
outlinePage.waitForUpdate(EXPECTED_TIMEOUT);
} catch (TimeoutException e) {
System.out.println("Expected timeout exceeded: "+EXPECTED_TIMEOUT);// timeout is OK here
}
treeViewer = outlinePage.getTreeViewer();
assertSelected(treeViewer);
assertExpanded(treeViewer);
assertTrue(treeViewer.getInput() instanceof IOutlineNode);
IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
List<IOutlineNode> children = rootNode.getChildren();
assertEquals(1, children.size());
modelNode = children.get(0);
assertEquals(2, modelNode.getChildren().size());
oneNode = modelNode.getChildren().get(0);
assertEquals(2, oneNode.getChildren().size());
twoNode = oneNode.getChildren().get(0);
threeNode = oneNode.getChildren().get(1);
fourNode = modelNode.getChildren().get(1);
}
@Test
public void testIsParallelBuildEnabledInWorkspace() {
// preference and constant ResourcesPlugin#PREF_MAX_CONCURRENT_BUILDS only available on o.e.core.resources >= 3.13
if (Platform.getBundle(ResourcesPlugin.PI_RESOURCES).getVersion().compareTo(new Version(3,13,0)) < 0) {
return; // running on too old platform
}
int maxConcurrentProjectBuilds = new ScopedPreferenceStore(InstanceScope.INSTANCE, ResourcesPlugin.PI_RESOURCES).getInt("maxConcurrentBuilds");
assertEquals("parallel build was not enabled", 8, maxConcurrentProjectBuilds);
}
public static IPreferenceStore getPreferenceStore(IProject project) {
if (project != null) {
IPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID);
if(store.getBoolean(PreferenceConstants.GENERATOR_PROJECT_SETTINGS))
return store;
}
return new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);//Activator.PLUGIN_ID);
}
public static IPreferenceStore getPreferenceStore(IProject project) {
if (project != null) {
IPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID);
if(store.getBoolean(PreferenceConstants.COMPILER_PROJECT_SETTINGS)|| store.getBoolean(PreferenceConstants.BUILDER_PROJECT_SETTINGS))
return store;
}
return new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);//Activator.PLUGIN_ID);
}
public PreferenceStoreWrapper providePreferenceStore() {
IPreferenceStore[] preferenceStores = new IPreferenceStore[2];
preferenceStores[0] = Activator.getDefault().getPreferenceStore();
ScopedPreferenceStore jdtCorePreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.jdt.core");
if (currentJavaProject.isPresent()) { // if we are in a project add to search scope
jdtCorePreferenceStore.setSearchContexts(new IScopeContext[] { new ProjectScope(currentJavaProject.get().getProject()), InstanceScope.INSTANCE });
}
preferenceStores[1] = jdtCorePreferenceStore;
return new PreferenceStoreWrapper(new ChainedPreferenceStore(preferenceStores));
}
private void initPreferencesStore(IProject currProject) {
workspaceStore = new ScopedPreferenceStore(new InstanceScope(), FindbugsPlugin.PLUGIN_ID);
if (currProject != null) {
projectStore = new ScopedPreferenceStore(new ProjectScope(currProject), FindbugsPlugin.PLUGIN_ID);
projectPropsInitiallyEnabled = FindbugsPlugin.isProjectSettingsEnabled(currProject);
if (!projectPropsInitiallyEnabled) {
// use workspace properties instead
currProject = null;
}
setPreferenceStore(projectStore);
} else {
setPreferenceStore(workspaceStore);
}
loadPreferences(currProject);
}
public static boolean isProjectSettingsEnabled(IProject project) {
// fast path: read from session, if available
Boolean enabled;
try {
enabled = (Boolean) project.getSessionProperty(SESSION_PROPERTY_SETTINGS_ON);
} catch (CoreException e) {
enabled = null;
}
if (enabled != null) {
return enabled.booleanValue();
}
// legacy support: before 1.3.8, there was ONLY project preferences in
// .fbprefs
// so check if the file is there...
IFile file = getUserPreferencesFile(project);
boolean projectPropsEnabled = file.isAccessible();
if (projectPropsEnabled) {
ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), PLUGIN_ID);
// so if the file is there, we can check if after 1.3.8 the flag is
// set
// to use workspace properties instead
projectPropsEnabled = !store.contains(FindBugsConstants.PROJECT_PROPS_DISABLED)
|| !store.getBoolean(FindBugsConstants.PROJECT_PROPS_DISABLED);
}
// remember in the session to speedup access, don't touch the store
setProjectSettingsEnabled(project, null, projectPropsEnabled);
return projectPropsEnabled;
}
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;
}
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);
}
/**
* Instantiates a new valid preference page for a given Xtext language.
*
* @param languageName
* the language name
* @param fileExtensions
* the file extensions
*/
@Inject
public AbstractValidPreferencePage(@Named(Constants.LANGUAGE_NAME) final String languageName, @Named(Constants.FILE_EXTENSIONS) final String fileExtensions) {
super();
this.languageName = languageName;
this.fileExtensions = fileExtensions;
preferences = new ScopedPreferenceStore(InstanceScope.INSTANCE, getPreferenceStoreName());
setPreferenceStore(preferences);
}
/**
* Retrieves preference store with the project scope
* @return a store instance
*/
public static IPreferenceStore getProjectPreferenceStore(IProject project)
{
ProjectScope scope = new ProjectScope(project);
ScopedPreferenceStore store = new ScopedPreferenceStore(scope, Activator.PLUGIN_ID /*Activator.getDefault().getBundle().getSymbolicName()*/);
return store;
}