Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 202384 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/resources/Project.java (-2 / +1 lines)
Lines 15-22 Link Here
15
 *******************************************************************************/
15
 *******************************************************************************/
16
package org.eclipse.core.internal.resources;
16
package org.eclipse.core.internal.resources;
17
17
18
import java.util.LinkedHashSet;
19
20
import java.net.URI;
18
import java.net.URI;
21
import java.util.*;
19
import java.util.*;
22
import org.eclipse.core.filesystem.*;
20
import org.eclipse.core.filesystem.*;
Lines 1169-1174 Link Here
1169
		} finally {
1167
		} finally {
1170
			monitor.done();
1168
			monitor.done();
1171
		}
1169
		}
1170
		((ProjectPreferences) Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE).node(getName())).initialize();
1172
	}
1171
	}
1173
1172
1174
	/* (non-Javadoc)
1173
	/* (non-Javadoc)
(-)src/org/eclipse/core/internal/resources/ProjectPreferences.java (-16 / +14 lines)
Lines 72-78 Link Here
72
	 */
72
	 */
73
	protected static Set loadedNodes = Collections.synchronizedSet(new HashSet());
73
	protected static Set loadedNodes = Collections.synchronizedSet(new HashSet());
74
	private IFile file;
74
	private IFile file;
75
	private boolean initialized = false;
76
	/**
75
	/**
77
	 * Flag indicating that this node is currently reading values from disk,
76
	 * Flag indicating that this node is currently reading values from disk,
78
	 * to avoid flushing during a read.
77
	 * to avoid flushing during a read.
Lines 348-368 Link Here
348
			addPreferenceChangeListener(workspace.getCharsetManager().getPreferenceChangeListener());
347
			addPreferenceChangeListener(workspace.getCharsetManager().getPreferenceChangeListener());
349
		}
348
		}
350
349
351
		if (segmentCount != 2)
350
		initialize();
352
			return;
353
354
		// else segmentCount == 2 so we initialize the children
355
		if (initialized)
356
			return;
357
		try {
358
			synchronized (this) {
359
				String[] names = computeChildren();
360
				for (int i = 0; i < names.length; i++)
361
					addChild(names[i], null);
362
			}
363
		} finally {
364
			initialized = true;
365
		}
366
	}
351
	}
367
352
368
	/*
353
	/*
Lines 471-476 Link Here
471
		return new ProjectPreferences(nodeParent, nodeName);
456
		return new ProjectPreferences(nodeParent, nodeName);
472
	}
457
	}
473
458
459
	protected void initialize() {
460
		if (segmentCount == 2) {
461
			// segmentCount == 2 so we initialize the children
462
			synchronized (this) {
463
				// this node might have been already initialized so before initializing it again remove all child nodes from loaded nodes
464
				removeLoadedNodes(this);
465
				String[] names = computeChildren();
466
				for (int i = 0; i < names.length; i++)
467
					addChild(names[i], null);
468
			}
469
		}
470
	}
471
474
	protected boolean isAlreadyLoaded(IEclipsePreferences node) {
472
	protected boolean isAlreadyLoaded(IEclipsePreferences node) {
475
		return loadedNodes.contains(node.absolutePath());
473
		return loadedNodes.contains(node.absolutePath());
476
	}
474
	}
(-)src/org/eclipse/ui/internal/ide/LineDelimiterEditor.java (-15 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-24 Link Here
17
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.ProjectScope;
18
import org.eclipse.core.resources.ProjectScope;
19
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
21
import org.eclipse.core.runtime.preferences.IScopeContext;
22
import org.eclipse.core.runtime.preferences.InstanceScope;
20
import org.eclipse.core.runtime.preferences.InstanceScope;
23
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.events.SelectionAdapter;
22
import org.eclipse.swt.events.SelectionAdapter;
Lines 32-37 Link Here
32
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Group;
31
import org.eclipse.swt.widgets.Group;
34
import org.osgi.service.prefs.BackingStoreException;
32
import org.osgi.service.prefs.BackingStoreException;
33
import org.osgi.service.prefs.Preferences;
35
34
36
/**
35
/**
37
 * A class to handle editing of the Line delimiter preferences in core.
36
 * A class to handle editing of the Line delimiter preferences in core.
Lines 162-185 Link Here
162
	 * @return the currently stored encoding
161
	 * @return the currently stored encoding
163
	 */
162
	 */
164
	public String getStoredValue() {
163
	public String getStoredValue() {
165
		IScopeContext[] scopeContext = new IScopeContext[] { getScopeContext() };
164
		Preferences node = getPreferences();
166
		IEclipsePreferences node = scopeContext[0].getNode(Platform.PI_RUNTIME);
165
		try {
167
		return node.get(Platform.PREF_LINE_SEPARATOR, null);
166
			// be careful looking up for our node so not to create any nodes as side effect
167
			if (node.nodeExists(Platform.PI_RUNTIME))
168
				return node.node(Platform.PI_RUNTIME).get(
169
						Platform.PREF_LINE_SEPARATOR, null);
170
		} catch (BackingStoreException e) {
171
			// ignore
172
		}
173
		return null;
168
	}
174
	}
169
175
170
	/**
176
	/**
171
	 * Answer the <code>IScopeContext</code> for the receiver, this will be a
177
	 * Answer the <code>Preferences</code> for the receiver, this will be a
172
	 * project scope if the receiver is editing project preferences, otherwise
178
	 * project preferences if the receiver is editing project preferences, otherwise
173
	 * instance scope.
179
	 * instance preferences.
174
	 * 
180
	 * 
175
	 * @return the scope context
181
	 * @return the preferences
176
	 */
182
	 */
177
	private IScopeContext getScopeContext() {
183
	private Preferences getPreferences() {
178
		if (project != null) {
184
		if (project != null) {
179
			return new ProjectScope(project);
185
			return Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE).node(project.getName());
180
		}
186
		}
181
187
182
		return new InstanceScope();
188
		return Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE);
183
	}
189
	}
184
190
185
	/**
191
	/**
Lines 264-271 Link Here
264
			val = (String) lineSeparators.get(choiceCombo.getText());
270
			val = (String) lineSeparators.get(choiceCombo.getText());
265
		}
271
		}
266
272
267
		IEclipsePreferences node = getScopeContext().getNode(
273
		Preferences node = getPreferences().node(Platform.PI_RUNTIME);
268
				Platform.PI_RUNTIME);
269
		if (val == null) {
274
		if (val == null) {
270
			node.remove(Platform.PREF_LINE_SEPARATOR);
275
			node.remove(Platform.PREF_LINE_SEPARATOR);
271
		} else {
276
		} else {

Return to bug 202384