|
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 { |