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 302152 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/resources/PathVariableManager.java (-5 / +5 lines)
Lines 363-375 Link Here
363
	}
363
	}
364
364
365
	/**
365
	/**
366
	 * @see IPathVariableManager#convertToUserEditableFormat(String)
366
	 * @see IPathVariableManager#convertToUserEditableFormat(String, boolean)
367
	 */
367
	 */
368
	public String convertToUserEditableFormat(String value) { 
368
	public String convertToUserEditableFormat(String value, boolean locationFormat) { 
369
		return PathVariableUtil.convertToUserEditableFormatInternal(value);
369
		return PathVariableUtil.convertToUserEditableFormatInternal(value, locationFormat);
370
	}
370
	}
371
371
372
	public String convertFromUserEditableFormat(String userFormat, IResource resource) {
372
	public String convertFromUserEditableFormat(String userFormat, boolean locationFormat, IResource resource) {
373
		return PathVariableUtil.convertFromUserEditableFormatInternal(this, userFormat, resource);
373
		return PathVariableUtil.convertFromUserEditableFormatInternal(this, userFormat, locationFormat, resource);
374
	}
374
	}
375
}
375
}
(-)src/org/eclipse/core/internal/resources/PathVariableUtil.java (-90 / +96 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.core.internal.resources;
11
package org.eclipse.core.internal.resources;
12
12
13
import org.eclipse.core.runtime.IPath;
14
15
import org.eclipse.core.internal.resources.projectvariables.WorkspaceParentLocationVariableResolver;
16
13
import java.net.URI;
17
import java.net.URI;
14
import java.util.ArrayList;
18
import java.util.ArrayList;
15
import java.util.LinkedList;
19
import java.util.LinkedList;
Lines 90-95 Link Here
90
				if (variable.equals(WorkspaceLocationVariableResolver.NAME))
94
				if (variable.equals(WorkspaceLocationVariableResolver.NAME))
91
					continue; 
95
					continue; 
92
			}
96
			}
97
			if (variable.equals(WorkspaceParentLocationVariableResolver.NAME))
98
				continue;
93
			if (variable.equals(ParentVariableResolver.NAME))
99
			if (variable.equals(ParentVariableResolver.NAME))
94
				continue;
100
				continue;
95
			// find closest path to the original path
101
			// find closest path to the original path
Lines 119-124 Link Here
119
						if (variable.equals(WorkspaceLocationVariableResolver.NAME))
125
						if (variable.equals(WorkspaceLocationVariableResolver.NAME))
120
							continue;
126
							continue;
121
					}
127
					}
128
					if (variable.equals(WorkspaceParentLocationVariableResolver.NAME))
129
						continue;
122
					if (variable.equals(ParentVariableResolver.NAME))
130
					if (variable.equals(ParentVariableResolver.NAME))
123
						continue;
131
						continue;
124
					IPath value = URIUtil.toPath(pathVariableManager.getValue(variable, resource));
132
					IPath value = URIUtil.toPath(pathVariableManager.getValue(variable, resource));
Lines 158-164 Link Here
158
		return newPath;
166
		return newPath;
159
	}
167
	}
160
168
161
	private static IPath makeRelativeToVariable(IPathVariableManager pathVariableManager, IPath originalPath, IResource resource, boolean force, String variableHint, boolean generateMacro) throws CoreException {
169
	private static IPath makeRelativeToVariable(IPathVariableManager pathVariableManager, IPath originalPath, IResource resource, boolean force, String variableHint, boolean generateMacro) {
162
		IPath path = convertToProperCase(originalPath);
170
		IPath path = convertToProperCase(originalPath);
163
		IPath value = URIUtil.toPath(pathVariableManager.getValue(variableHint, resource));
171
		IPath value = URIUtil.toPath(pathVariableManager.getValue(variableHint, resource));
164
		value = convertToProperCase(URIUtil.toPath(pathVariableManager.resolveURI(URIUtil.toURI(value), resource)));
172
		value = convertToProperCase(URIUtil.toPath(pathVariableManager.resolveURI(URIUtil.toURI(value), resource)));
Lines 173-229 Link Here
173
		} 
181
		} 
174
182
175
		if (force) {
183
		if (force) {
176
			// transform "c:/foo/bar/other_child/file.txt" into "${PARENT-1-BAR_CHILD}/other_child/file.txt"
184
			if (devicesAreCompatible(path, value)) {
177
			int matchingFirstSegments = path.matchingFirstSegments(value);
185
				// transform "c:/foo/bar/other_child/file.txt" into "${PARENT-1-BAR_CHILD}/other_child/file.txt"
178
			if (matchingFirstSegments >= 0) {
186
				int matchingFirstSegments = path.matchingFirstSegments(value);
179
				String newValue = buildParentPathVariable(variableHint, valueSegmentCount - matchingFirstSegments, generateMacro);
187
				if (matchingFirstSegments >= 0) {
180
				String originalName;
188
					String originalName= buildParentPathVariable(variableHint, valueSegmentCount - matchingFirstSegments, true);
181
				if (generateMacro) 
189
					IPath tmp = Path.fromOSString(originalName);
182
					originalName = newValue;
190
					for (int j = matchingFirstSegments ;j < originalPath.segmentCount(); j++) {
183
				else {
191
						tmp = tmp.append(originalPath.segment(j));
184
					originalName = getExistingVariable(newValue, pathVariableManager, resource);
185
					if (originalName == null) {
186
						String name;
187
						if (matchingFirstSegments > 0)
188
							name = originalPath.segment(matchingFirstSegments - 1);
189
						else
190
							name = originalPath.getDevice();
191
						if (name == null)
192
							name = "ROOT"; //$NON-NLS-1$
193
						originalName = getUniqueVariableName(name, pathVariableManager, resource);
194
						pathVariableManager.setValue(originalName, resource, URIUtil.toURI(Path.fromOSString(newValue)));
195
					}
192
					}
193
					return tmp;
196
				}
194
				}
197
				IPath tmp = Path.fromOSString(originalName);
198
				for (int j = matchingFirstSegments ;j < originalPath.segmentCount(); j++) {
199
					tmp = tmp.append(originalPath.segment(j));
200
				}
201
				return tmp;
202
			}
195
			}
203
		}
196
		}
204
		return originalPath;
197
		return originalPath;
205
	}
198
	}
206
207
	private static String getExistingVariable(String newValue, IPathVariableManager pathVariableManager, IResource resource) {
208
		IPath resolvedNewValue = convertToProperCase(URIUtil.toPath(pathVariableManager.resolveURI(URIUtil.toURI(Path.fromOSString(newValue)), resource)));
209
		String[] existingVariables = pathVariableManager.getPathVariableNames(resource);
210
		for (int i = 0; i < existingVariables.length; i++) {
211
			String variable = existingVariables[i];
212
			URI uri = pathVariableManager.getValue(variable, resource);
213
			if (uri != null) {
214
				IPath value = URIUtil.toPath(uri);
215
				if (value != null) {
216
					if (value.toOSString().equals(newValue))
217
						return variable;
218
					IPath resolvedValue = convertToProperCase(URIUtil.toPath(pathVariableManager.resolveURI(URIUtil.toURI(value), resource)));
219
					if (resolvedValue.equals(resolvedNewValue))
220
						return variable;
221
				}
222
			}
223
		}
224
		return null;
225
	}
226
	
199
	
200
	private static boolean devicesAreCompatible(IPath path, IPath value) {
201
		return (path.getDevice() != null && value.getDevice() != null) ?
202
					(path.getDevice().equals(value.getDevice())) :
203
					(path.getDevice() == value.getDevice());
204
	}
205
227
	static private IPath convertToProperCase(IPath path) {
206
	static private IPath convertToProperCase(IPath path) {
228
		if (Platform.getOS().equals(Platform.OS_WIN32))
207
		if (Platform.getOS().equals(Platform.OS_WIN32))
229
			return Path.fromPortableString(path.toPortableString().toLowerCase());
208
			return Path.fromPortableString(path.toPortableString().toLowerCase());
Lines 270-277 Link Here
270
		return Path.fromOSString(variable).append(relativeSrcValue.removeFirstSegments(1));
249
		return Path.fromOSString(variable).append(relativeSrcValue.removeFirstSegments(1));
271
	}
250
	}
272
251
273
	public static String convertFromUserEditableFormatInternal(IPathVariableManager manager, String userFormat, IResource resource) {
252
	public static String convertFromUserEditableFormatInternal(IPathVariableManager manager, String userFormat, boolean locationFormat, IResource resource) {
274
		boolean isAbsolute = (userFormat.length() > 0) && (userFormat.charAt(0) == '/' || userFormat.charAt(0) == '\\');
253
		char pathPrefix = 0;
254
		if ((userFormat.length() > 0) && (userFormat.charAt(0) == '/' || userFormat.charAt(0) == '\\'))
255
			pathPrefix = userFormat.charAt(0);
275
		String components[] = splitPathComponents(userFormat);
256
		String components[] = splitPathComponents(userFormat);
276
		for (int i = 0; i < components.length; i++) {
257
		for (int i = 0; i < components.length; i++) {
277
			if (components[i] == null)
258
			if (components[i] == null)
Lines 297-337 Link Here
297
						if (components[j] == null)
278
						if (components[j] == null)
298
							continue;
279
							continue;
299
						String variable = extractVariable(components[j]);
280
						String variable = extractVariable(components[j]);
281
						
282
						boolean hasVariableWithMacroSyntax = true;
283
						if (variable.length() == 0 && (locationFormat && j == 0)) {
284
							variable = components[j];
285
							hasVariableWithMacroSyntax = false;
286
						}
287
						
300
						try {
288
						try {
301
							if (variable.length() > 0) {
289
							if (variable.length() > 0) {
302
								int indexOfVariable = components[j].indexOf(variable) - "${".length(); //$NON-NLS-1$
290
								String prefix = new String();
303
								String prefix = components[j].substring(0, indexOfVariable);
291
								if (hasVariableWithMacroSyntax) {
304
								String suffix = components[j].substring(indexOfVariable + "${".length() + variable.length() + "}".length()); //$NON-NLS-1$ //$NON-NLS-2$
292
									int indexOfVariable = components[j].indexOf(variable) - "${".length(); //$NON-NLS-1$
305
								if (suffix.length() != 0) {
293
									prefix = components[j].substring(0, indexOfVariable);
306
									// Create an intermediate variable, since a syntax of "${VAR}foo/../"
294
									String suffix = components[j].substring(indexOfVariable + "${".length() + variable.length() + "}".length()); //$NON-NLS-1$ //$NON-NLS-2$
307
									// can't be converted to a "${PARENT-1-VAR}foo" variable.
295
									if (suffix.length() != 0) {
308
									// So instead, an intermediate variable "VARFOO" will be created of value 
296
										// Create an intermediate variable, since a syntax of "${VAR}foo/../"
309
									// "${VAR}foo", and the string "${PARENT-1-VARFOO}" will be inserted.
297
										// can't be converted to a "${PARENT-1-VAR}foo" variable.
310
									String intermediateVariable = PathVariableUtil.getValidVariableName(variable + suffix);
298
										// So instead, an intermediate variable "VARFOO" will be created of value 
311
									IPath intermediateValue = Path.fromPortableString(components[j]);
299
										// "${VAR}foo", and the string "${PARENT-1-VARFOO}" will be inserted.
312
									int intermediateVariableIndex = 1;
300
										String intermediateVariable = PathVariableUtil.getValidVariableName(variable + suffix);
313
									String originalIntermediateVariableName = intermediateVariable;
301
										IPath intermediateValue = Path.fromPortableString(components[j]);
314
									while (manager.isDefined(intermediateVariable, resource)) {
302
										int intermediateVariableIndex = 1;
315
										IPath tmpValue = URIUtil.toPath(manager.getValue(intermediateVariable, resource));
303
										String originalIntermediateVariableName = intermediateVariable;
316
										if (tmpValue.equals(intermediateValue))
304
										while (manager.isDefined(intermediateVariable, resource)) {
317
											break;
305
											IPath tmpValue = URIUtil.toPath(manager.getValue(intermediateVariable, resource));
318
										intermediateVariable = originalIntermediateVariableName + intermediateVariableIndex;
306
											if (tmpValue.equals(intermediateValue))
307
												break;
308
											intermediateVariable = originalIntermediateVariableName + intermediateVariableIndex;
309
										}
310
										if (!manager.isDefined(intermediateVariable, resource))
311
											manager.setValue(intermediateVariable, resource, URIUtil.toURI(intermediateValue));
312
										variable = intermediateVariable;
313
										prefix = new String();
319
									}
314
									}
320
									if (!manager.isDefined(intermediateVariable, resource))
321
										manager.setValue(intermediateVariable, resource, URIUtil.toURI(intermediateValue));
322
									variable = intermediateVariable;
323
									prefix = new String();
324
								}
315
								}
325
								String newVariable = variable;
316
								String newVariable = variable;
326
								if (PathVariableUtil.isParentVariable(variable)) {
317
								if (PathVariableUtil.isParentVariable(variable)) {
327
									String argument = PathVariableUtil.getParentVariableArgument(variable);
318
									String argument = PathVariableUtil.getParentVariableArgument(variable);
328
									int count = PathVariableUtil.getParentVariableCount(variable);
319
									int count = PathVariableUtil.getParentVariableCount(variable);
329
									if (argument != null && count != -1)
320
									if (argument != null && count != -1)
330
										newVariable = PathVariableUtil.buildParentPathVariable(argument, count + parentCount, false);
321
										newVariable = PathVariableUtil.buildParentPathVariable(argument, count + parentCount, locationFormat);
331
									else
322
									else
332
										newVariable = PathVariableUtil.buildParentPathVariable(variable, parentCount, false);
323
										newVariable = PathVariableUtil.buildParentPathVariable(variable, parentCount, locationFormat);
333
								} else
324
								} else
334
									newVariable = PathVariableUtil.buildParentPathVariable(variable, parentCount, false);
325
									newVariable = PathVariableUtil.buildParentPathVariable(variable, parentCount, locationFormat);
335
								components[j] = prefix + newVariable;
326
								components[j] = prefix + newVariable;
336
								break;
327
								break;
337
							}
328
							}
Lines 346-357 Link Here
346
			}
337
			}
347
		}
338
		}
348
		StringBuffer buffer = new StringBuffer();
339
		StringBuffer buffer = new StringBuffer();
349
		if (isAbsolute)
340
		if (pathPrefix != 0)
350
			buffer.append('/');
341
			buffer.append(pathPrefix);
351
		for (int i = 0; i < components.length; i++) {
342
		for (int i = 0; i < components.length; i++) {
352
			if (components[i] != null) {
343
			if (components[i] != null) {
353
				if (i > 0)
344
				if (i > 0)
354
					buffer.append('/');
345
					buffer.append(java.io.File.separator);
355
				buffer.append(components[i]);
346
				buffer.append(components[i]);
356
			}
347
			}
357
		}
348
		}
Lines 379-404 Link Here
379
		return (String[]) list.toArray(new String[0]);
370
		return (String[]) list.toArray(new String[0]);
380
	}
371
	}
381
372
382
	public static String convertToUserEditableFormatInternal(String value) {
373
	public static String convertToUserEditableFormatInternal(String value, boolean locationFormat) {
383
		StringBuffer buffer = new StringBuffer();
374
		StringBuffer buffer = new StringBuffer();
384
		String components[] = splitVariablesAndContent(value);
375
		if (locationFormat) {
385
		for (int i = 0; i < components.length; i++) {
376
			IPath path = Path.fromOSString(value);
386
			String variable = extractVariable(components[i]);
377
			if (path.isAbsolute())
387
			if (PathVariableUtil.isParentVariable(variable)) {
378
				return path.toOSString();
388
				String argument = PathVariableUtil.getParentVariableArgument(variable);
379
			int index = value.indexOf(java.io.File.separator);
389
				int count = PathVariableUtil.getParentVariableCount(variable);
380
			String variable = index != -1 ? value.substring(0, index): value;
390
				if (argument != null && count != -1) {
381
			convertVariableToUserFormat(buffer, variable, variable, false);
391
					buffer.append(PathVariableUtil.buildVariableMacro(Path.fromOSString(argument)));
382
			if (index != -1)
392
					for (int j = 0; j < count; j++) {
383
				buffer.append(value.substring(index));
393
						buffer.append("/.."); //$NON-NLS-1$
384
		} else {
394
					}
385
			String components[] = splitVariablesAndContent(value);
395
				} else
386
			for (int i = 0; i < components.length; i++) {
396
					buffer.append(components[i]);
387
				String variable = extractVariable(components[i]);
397
			} else
388
				convertVariableToUserFormat(buffer, components[i], variable, true);
398
				buffer.append(components[i]);
389
			}
399
		}
390
		}
400
		return buffer.toString();
391
		return buffer.toString();
401
	}
392
	}
393
394
	private static void convertVariableToUserFormat(StringBuffer buffer, String component, String variable, boolean generateMacro) {
395
		if (PathVariableUtil.isParentVariable(variable)) {
396
			String argument = PathVariableUtil.getParentVariableArgument(variable);
397
			int count = PathVariableUtil.getParentVariableCount(variable);
398
			if (argument != null && count != -1) {
399
				buffer.append(generateMacro? PathVariableUtil.buildVariableMacro(Path.fromOSString(argument)):Path.fromOSString(argument));
400
				for (int j = 0; j < count; j++) {
401
					buffer.append(java.io.File.separator + ".."); //$NON-NLS-1$
402
				}
403
			} else
404
				buffer.append(component);
405
		} else
406
			buffer.append(component);
407
	}
402
	/*
408
	/*
403
	 * Splits a value (returned by this.getValue(variable) in an array of
409
	 * Splits a value (returned by this.getValue(variable) in an array of
404
	 * string, where the array is divided between the value content and the
410
	 * string, where the array is divided between the value content and the
(-)src/org/eclipse/core/internal/resources/ProjectPathVariableManager.java (-6 / +15 lines)
Lines 177-183 Link Here
177
		} catch (CoreException e) {
177
		} catch (CoreException e) {
178
			return false;
178
			return false;
179
		}
179
		}
180
		return getWorkspaceManager().isDefined(varName);
180
		boolean value = getWorkspaceManager().isDefined(varName);
181
		if (!value) {
182
			// this is to handle variables with encoded arguments
183
			int index = varName.indexOf('-');
184
			if (index != -1) {
185
				String newVarName = varName.substring(0, index);
186
				value = isDefined(newVarName);
187
			}
188
		}
189
		return value;
181
	}
190
	}
182
191
183
	/**
192
	/**
Lines 432-445 Link Here
432
	}
441
	}
433
442
434
	/**
443
	/**
435
	 * @see IPathVariableManager#convertToUserEditableFormat(String)
444
	 * @see IPathVariableManager#convertToUserEditableFormat(String, boolean)
436
	 */
445
	 */
437
	public String convertToUserEditableFormat(String value) { 
446
	public String convertToUserEditableFormat(String value, boolean locationFormat) { 
438
		return PathVariableUtil.convertToUserEditableFormatInternal(value);
447
		return PathVariableUtil.convertToUserEditableFormatInternal(value, locationFormat);
439
	}
448
	}
440
	
449
	
441
	public String convertFromUserEditableFormat(String userFormat, IResource resource) {
450
	public String convertFromUserEditableFormat(String userFormat, boolean locationFormat, IResource resource) {
442
		return PathVariableUtil.convertFromUserEditableFormatInternal(this, userFormat, resource);
451
		return PathVariableUtil.convertFromUserEditableFormatInternal(this, userFormat, locationFormat, resource);
443
	}
452
	}
444
	
453
	
445
	public void addChangeListener(IPathVariableChangeListener listener) {
454
	public void addChangeListener(IPathVariableChangeListener listener) {
(-)src/org/eclipse/core/internal/resources/Workspace.java (+4 lines)
Lines 13-18 Link Here
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.core.internal.resources;
14
package org.eclipse.core.internal.resources;
15
15
16
import org.eclipse.core.internal.resources.projectvariables.WorkspaceParentLocationVariableResolver;
17
16
import java.io.IOException;
18
import java.io.IOException;
17
import java.io.InputStream;
19
import java.io.InputStream;
18
import java.net.URI;
20
import java.net.URI;
Lines 877-882 Link Here
877
		for (int i = 0; i < variables.length; i++) {
879
		for (int i = 0; i < variables.length; i++) {
878
			if (variables[i].equals(WorkspaceLocationVariableResolver.NAME))
880
			if (variables[i].equals(WorkspaceLocationVariableResolver.NAME))
879
				continue;
881
				continue;
882
			if (variables[i].equals(WorkspaceParentLocationVariableResolver.NAME))
883
				continue;
880
			if (variables[i].equals(ParentVariableResolver.NAME))
884
			if (variables[i].equals(ParentVariableResolver.NAME))
881
				continue;
885
				continue;
882
			IPath resolveDestVariable = URIUtil.toPath(destPathVariableManager
886
			IPath resolveDestVariable = URIUtil.toPath(destPathVariableManager
(-)src/org/eclipse/core/resources/IPathVariableManager.java (-9 / +11 lines)
Lines 369-393 Link Here
369
369
370
	/**
370
	/**
371
	 * Converts the internal format of the linked resource location if the PARENT
371
	 * Converts the internal format of the linked resource location if the PARENT
372
	 * variables is used.  For example, if the value is "${PARENT-2-VAR}/foo", the
372
	 * variables is used.  For example, if the value is "${PARENT-2-VAR}\foo", the
373
	 * converted result is "${VAR}/../../foo".
373
	 * converted result is "${VAR}\..\..\foo".
374
	 * @param value
374
	 * @param value the value encoded using OS string (as returned from Path.toOSString())
375
	 * @param locationFormat indicates whether the value contains a string that is stored in the linked resource location rather than in the path variable value
375
	 * @return the converted path variable value
376
	 * @return the converted path variable value
376
	 * @since 3.6
377
	 * @since 3.6
377
	 */
378
	 */
378
	public String convertToUserEditableFormat(String value);
379
	public String convertToUserEditableFormat(String value, boolean locationFormat);
379
380
380
	/**
381
	/**
381
	 * Converts the user editable format to the internal format.
382
	 * Converts the user editable format to the internal format.
382
	 * For example, if the value is "${VAR}/../../foo", the
383
	 * For example, if the value is "${VAR}\..\..\foo", the
383
	 * converted result is "${PARENT-2-VAR}/foo".
384
	 * converted result is "${PARENT-2-VAR}\foo".
384
	 * If the string is not directly convertible to a ${PARENT-COUNT-VAR}
385
	 * If the string is not directly convertible to a ${PARENT-COUNT-VAR}
385
	 * syntax (for example, the editable string "${FOO}bar/../../"), intermediate
386
	 * syntax (for example, the editable string "${FOO}bar\..\..\"), intermediate
386
	 * path variables will be created.
387
	 * path variables will be created.
387
	 * @param userFormat The user editable string
388
	 * @param value the value encoded using OS string (as returned from Path.toOSString())
389
	 * @param locationFormat indicates whether the value contains a string that is stored in the linked resource location rather than in the path variable value
388
	 * @param resource the resource for which this variable is resolved  
390
	 * @param resource the resource for which this variable is resolved  
389
	 * @return the converted path variable value
391
	 * @return the converted path variable value
390
	 * @since 3.6
392
	 * @since 3.6
391
	 */
393
	 */
392
	public String convertFromUserEditableFormat(String userFormat, IResource resource);
394
	public String convertFromUserEditableFormat(String value, boolean locationFormat, IResource resource);
393
}
395
}
(-)src/org/eclipse/core/tests/resources/IPathVariableTest.java (-15 / +3 lines)
Lines 550-559 Link Here
550
		} catch (CoreException e) {
550
		} catch (CoreException e) {
551
			fail("3.1", e);
551
			fail("3.1", e);
552
		}
552
		}
553
		expected = new Path("foo/other/file.txt");
553
		expected = new Path("PARENT-1-ONE/other/file.txt");
554
		assertEquals("4.0", expected, actual);
554
		assertEquals("4.0", expected, actual);
555
		assertTrue("4.1", manager.isDefined("foo"));
556
		assertEquals("4.2", manager.getValue("foo").toOSString(), "${PARENT-1-ONE}");
557
555
558
		// the second time should be re-using "FOO"
556
		// the second time should be re-using "FOO"
559
		try {
557
		try {
Lines 561-576 Link Here
561
		} catch (CoreException e) {
559
		} catch (CoreException e) {
562
			fail("4.3", e);
560
			fail("4.3", e);
563
		}
561
		}
564
		expected = new Path("foo/other/file.txt");
562
		expected = new Path("PARENT-1-ONE/other/file.txt");
565
		assertEquals("5.0", expected, actual);
563
		assertEquals("5.0", expected, actual);
566
		assertTrue("5.1", manager.isDefined("foo"));
567
		assertEquals("5.2", manager.getValue("foo").toOSString(), "${PARENT-1-ONE}");
568
569
		try {
570
			manager.setValue("foo", null);
571
		} catch (CoreException e) {
572
			fail("5.3", e);
573
		}
574
564
575
		try {
565
		try {
576
			actual = convertToRelative(manager, file, true, "TWO");
566
			actual = convertToRelative(manager, file, true, "TWO");
Lines 616-625 Link Here
616
		} catch (CoreException e) {
606
		} catch (CoreException e) {
617
			fail("9.1", e);
607
			fail("9.1", e);
618
		}
608
		}
619
		expected = new Path("foo/other/file.txt");
609
		expected = new Path("PARENT-1-ONE/other/file.txt");
620
		assertEquals("10.0", expected, actual);
610
		assertEquals("10.0", expected, actual);
621
		assertTrue("10.1", manager.isDefined("foo"));
622
		assertEquals("10.2", manager.getValue("foo").toOSString(), "${PARENT-1-ONE}");
623
	}
611
	}
624
612
625
	/**
613
	/**
(-)src/org/eclipse/core/tests/resources/LinkedResourceWithPathVariableTest.java (-103 / +52 lines)
Lines 431-439 Link Here
431
		}
431
		}
432
		assertExistsInWorkspace("3,1", newFile);
432
		assertExistsInWorkspace("3,1", newFile);
433
		assertTrue("3,2", !newFile.getLocation().equals(newFile.getRawLocation()));
433
		assertTrue("3,2", !newFile.getLocation().equals(newFile.getRawLocation()));
434
		assertTrue("3,3", newFile.getRawLocation().equals(variableBasedLocation));
434
		assertEquals("3,3", newFile.getLocation(), resolvedPath);
435
		assertTrue("3,4", newFile.getRawLocation().equals(variableBasedLocation));
436
		assertEquals("3,5", newFile.getLocation(), resolvedPath);
437
	}
435
	}
438
436
439
	private IPath convertToRelative(IPathVariableManager manager, IPath path, IResource res, boolean force, String variableHint) throws CoreException {
437
	private IPath convertToRelative(IPathVariableManager manager, IPath path, IResource res, boolean force, String variableHint) throws CoreException {
Lines 1355-1461 Link Here
1355
	public void testConvertToUserEditableFormat() {
1353
	public void testConvertToUserEditableFormat() {
1356
		IPathVariableManager pathVariableManager = existingProject.getPathVariableManager();
1354
		IPathVariableManager pathVariableManager = existingProject.getPathVariableManager();
1357
1355
1358
		String result = pathVariableManager.convertToUserEditableFormat("C:\\foo\\bar");
1356
		String[][] table = { // format: {internal-format, user-editable-format [, internal-format-reconverted]
1359
		assertEquals("1.0", "C:\\foo\\bar", result);
1357
		{"C:\\foo\\bar", "C:\\foo\\bar"}, //
1360
1358
				{"C:/foo/bar", "C:/foo/bar"}, //
1361
		result = pathVariableManager.convertToUserEditableFormat("C:/foo/bar");
1359
				{"VAR/foo/bar", "VAR/foo/bar"}, //
1362
		assertEquals("1.1", "C:/foo/bar", result);
1360
				{"${VAR}/foo/bar", "${VAR}/foo/bar"}, //
1363
1361
				{"${VAR}/../foo/bar", "${VAR}/../foo/bar", "${PARENT-1-VAR}/foo/bar"}, //
1364
		result = pathVariableManager.convertToUserEditableFormat("VAR/foo/bar");
1362
				{"${PARENT-1-VAR}/foo/bar", "${VAR}/../foo/bar"}, //
1365
		assertEquals("1.2", "VAR/foo/bar", result);
1363
				{"${PARENT-0-VAR}/foo/bar", "${VAR}/foo/bar", "${VAR}/foo/bar"}, //
1366
1364
				{"${PARENT-VAR}/foo/bar", "${PARENT-VAR}/foo/bar"}, //
1367
		result = pathVariableManager.convertToUserEditableFormat("${VAR}/foo/bar");
1365
				{"${PARENT-2}/foo/bar", "${PARENT-2}/foo/bar"}, //
1368
		assertEquals("1.3", "${VAR}/foo/bar", result);
1366
				{"${PARENT}/foo/bar", "${PARENT}/foo/bar"}, //
1369
1367
				{"${PARENT-2-VAR}/foo/bar", "${VAR}/../../foo/bar"}, //
1370
		result = pathVariableManager.convertToUserEditableFormat("${VAR}/../foo/bar");
1368
				{"${PARENT-2-VAR}/foo/${PARENT-4-BAR}", "${VAR}/../../foo/${BAR}/../../../.."}, //
1371
		assertEquals("1.4", "${VAR}/../foo/bar", result);
1369
				{"${PARENT-2-VAR}/foo${PARENT-4-BAR}", "${VAR}/../../foo${BAR}/../../../.."}, //
1372
1370
				{"${PARENT-2-VAR}/${PARENT-4-BAR}/foo", "${VAR}/../../${BAR}/../../../../foo"}, //
1373
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-1-VAR}/foo/bar");
1371
				{"${PARENT-2-VAR}/f${PARENT-4-BAR}/oo", "${VAR}/../../f${BAR}/../../../../oo"} //
1374
		assertEquals("1.5", "${VAR}/../foo/bar", result);
1372
		};
1375
1373
1376
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-0-VAR}/foo/bar");
1374
		for (int i = 0; i < table.length; i++) {
1377
		assertEquals("1.6", "${VAR}/foo/bar", result);
1375
			String result = pathVariableManager.convertToUserEditableFormat(toOS(table[i][0]), false);
1378
1376
			assertEquals("1." + i, toOS(table[i][1]), result);
1379
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-VAR}/foo/bar");
1377
			String original = pathVariableManager.convertFromUserEditableFormat(result, false, existingProject);
1380
		assertEquals("1.7", "${PARENT-VAR}/foo/bar", result);
1378
			assertEquals("2." + i, toOS(table[i].length == 2 ? table[i][0] : table[i][2]), original);
1381
1379
		}
1382
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-2}/foo/bar");
1380
1383
		assertEquals("1.8", "${PARENT-2}/foo/bar", result);
1381
		String[][] tableLocationFormat = { // format: {internal-format, user-editable-format [, internal-format-reconverted]
1384
1382
		{"C:\\foo\\bar", "C:\\foo\\bar"}, //
1385
		result = pathVariableManager.convertToUserEditableFormat("${PARENT}/foo/bar");
1383
				{"C:/foo/bar", "C:/foo/bar"}, //
1386
		assertEquals("1.9", "${PARENT}/foo/bar", result);
1384
				{"VAR/foo/bar", "VAR/foo/bar"}, //
1387
1385
				{"${VAR}/../foo/bar", "${VAR}/../foo/bar", "PARENT-1-VAR/foo/bar"}, //
1388
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-2-VAR}/foo/bar");
1386
				{"PARENT-1-VAR/foo/bar", "VAR/../foo/bar"}, //
1389
		assertEquals("2.0", "${VAR}/../../foo/bar", result);
1387
				{"PARENT-0-VAR/foo/bar", "VAR/foo/bar", "VAR/foo/bar"}, //
1390
1388
				{"PARENT-VAR/foo/bar", "PARENT-VAR/foo/bar"}, //
1391
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-2-VAR}/foo/${PARENT-4-BAR}");
1389
				{"PARENT-2/foo/bar", "PARENT-2/foo/bar"}, //
1392
		assertEquals("2.1", "${VAR}/../../foo/${BAR}/../../../..", result);
1390
				{"PARENT/foo/bar", "PARENT/foo/bar"}, //
1393
1391
				{"PARENT-2-VAR/foo/bar", "VAR/../../foo/bar"}, //
1394
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-2-VAR}/foo${PARENT-4-BAR}");
1392
				{"PARENT-2-VAR/foo/PARENT-4-BAR", "VAR/../../foo/PARENT-4-BAR"}, //
1395
		assertEquals("2.2", "${VAR}/../../foo${BAR}/../../../..", result);
1393
				{"PARENT-2-VAR/fooPARENT-4-BAR", "VAR/../../fooPARENT-4-BAR"}, //
1396
1394
				{"PARENT-2-VAR/PARENT-4-BAR/foo", "VAR/../../PARENT-4-BAR/foo"}, //
1397
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-2-VAR}/${PARENT-4-BAR}/foo");
1395
				{"PARENT-2-VAR/fPARENT-4-BAR/oo", "VAR/../../fPARENT-4-BAR/oo"}, //
1398
		assertEquals("2.3", "${VAR}/../../${BAR}/../../../../foo", result);
1396
				{"/foo/bar", "/foo/bar"}, //
1399
1397
		};
1400
		result = pathVariableManager.convertToUserEditableFormat("${PARENT-2-VAR}/f${PARENT-4-BAR}/oo");
1398
1401
		assertEquals("2.4", "${VAR}/../../f${BAR}/../../../../oo", result);
1399
		for (int i = 0; i < table.length; i++) {
1402
1400
			String result = pathVariableManager.convertToUserEditableFormat(toOS(tableLocationFormat[i][0]), true);
1403
		result = pathVariableManager.convertToUserEditableFormat("/foo/bar");
1401
			assertEquals("3." + i, toOS(tableLocationFormat[i][1]), result);
1404
		assertEquals("2.5", "/foo/bar", result);
1402
			String original = pathVariableManager.convertFromUserEditableFormat(result, true, existingProject);
1403
			assertEquals("4." + i, toOS(tableLocationFormat[i].length == 2 ? tableLocationFormat[i][0] : tableLocationFormat[i][2]), original);
1404
		}
1405
	}
1405
	}
1406
1406
1407
	public void testConvertFromUserEditableFormat() {
1407
	private String toOS(String path) {
1408
		IPathVariableManager manager = existingProject.getPathVariableManager();
1408
		return path.replace("/", File.separator);
1409
1410
		String result = manager.convertFromUserEditableFormat("C:\\foo\\bar", existingProject);
1411
		assertEquals("1.0", "C:/foo/bar", result);
1412
1413
		result = manager.convertFromUserEditableFormat("C:/foo/bar", existingProject);
1414
		assertEquals("1.1", "C:/foo/bar", result);
1415
1416
		result = manager.convertFromUserEditableFormat("VAR/foo/bar", existingProject);
1417
		assertEquals("1.2", "VAR/foo/bar", result);
1418
1419
		result = manager.convertFromUserEditableFormat("${VAR}/foo/bar", existingProject);
1420
		assertEquals("1.3", "${VAR}/foo/bar", result);
1421
1422
		result = manager.convertFromUserEditableFormat("${VAR}/../foo/bar", existingProject);
1423
		assertEquals("1.4", "${PARENT-1-VAR}/foo/bar", result);
1424
1425
		result = manager.convertFromUserEditableFormat("${PARENT-1-VAR}/foo/bar", existingProject);
1426
		assertEquals("1.5", "${PARENT-1-VAR}/foo/bar", result);
1427
1428
		result = manager.convertFromUserEditableFormat("${PARENT-VAR}/foo/bar", existingProject);
1429
		assertEquals("1.6", "${PARENT-VAR}/foo/bar", result);
1430
1431
		result = manager.convertFromUserEditableFormat("${PARENT-2}/foo/bar", existingProject);
1432
		assertEquals("1.7", "${PARENT-2}/foo/bar", result);
1433
1434
		result = manager.convertFromUserEditableFormat("${PARENT}/foo/bar", existingProject);
1435
		assertEquals("1.8", "${PARENT}/foo/bar", result);
1436
1437
		result = manager.convertFromUserEditableFormat("${VAR}/../../foo/bar", existingProject);
1438
		assertEquals("1.9", "${PARENT-2-VAR}/foo/bar", result);
1439
1440
		result = manager.convertFromUserEditableFormat("${VAR}/../../foo/${BAR}/../../../../", existingProject);
1441
		assertEquals("2.0", "${PARENT-2-VAR}/foo/${PARENT-4-BAR}", result);
1442
1443
		result = manager.convertFromUserEditableFormat("${VAR}/../../foo${BAR}/../../../../", existingProject);
1444
		assertEquals("2.1", "${PARENT-2-VAR}/foo${PARENT-4-BAR}", result);
1445
1446
		result = manager.convertFromUserEditableFormat("${VAR}/../../${BAR}foo/../../../../", existingProject);
1447
		assertEquals("2.2", "${PARENT-2-VAR}/${PARENT-4-BARfoo}", result);
1448
1449
		IPath intermeiateValue = manager.getValue("BARfoo");
1450
		assertEquals("2.3", "${BAR}foo", intermeiateValue.toPortableString());
1451
1452
		result = manager.convertFromUserEditableFormat("${VAR}/../../f${BAR}oo/../../../../", existingProject);
1453
		assertEquals("2.4", "${PARENT-2-VAR}/${PARENT-4-BARoo}", result);
1454
1455
		intermeiateValue = manager.getValue("BARoo");
1456
		assertEquals("2.5", "f${BAR}oo", intermeiateValue.toPortableString());
1457
1458
		result = manager.convertFromUserEditableFormat("/foo/bar", existingProject);
1459
		assertEquals("2.6", "/foo/bar", result);
1460
	}
1409
	}
1461
}
1410
}
(-)src/org/eclipse/ui/internal/ide/dialogs/IDEResourceInfoUtils.java (-1 / +3 lines)
Lines 21-26 Link Here
21
import org.eclipse.core.filesystem.EFS;
21
import org.eclipse.core.filesystem.EFS;
22
import org.eclipse.core.filesystem.IFileInfo;
22
import org.eclipse.core.filesystem.IFileInfo;
23
import org.eclipse.core.filesystem.IFileStore;
23
import org.eclipse.core.filesystem.IFileStore;
24
import org.eclipse.core.filesystem.URIUtil;
24
import org.eclipse.core.resources.IFile;
25
import org.eclipse.core.resources.IFile;
25
import org.eclipse.core.resources.IProject;
26
import org.eclipse.core.resources.IProject;
26
import org.eclipse.core.resources.IResource;
27
import org.eclipse.core.resources.IResource;
Lines 255-261 Link Here
255
			}
256
			}
256
		}
257
		}
257
		if (isLinked && isPathVariable) {
258
		if (isLinked && isPathVariable) {
258
			return resource.getRawLocationURI().toString();
259
			String tmp = URIUtil.toPath(resource.getRawLocationURI()).toOSString();
260
			return resource.getProject().getPathVariableManager().convertToUserEditableFormat(tmp, true);
259
		}
261
		}
260
		if (store != null) {
262
		if (store != null) {
261
			return store.toString();
263
			return store.toString();
(-)src/org/eclipse/ui/internal/ide/dialogs/LinkedResourceEditor.java (-13 / +20 lines)
Lines 275-281 Link Here
275
				else {
275
				else {
276
					IPath rawLocation = ((IResource) obj).getRawLocation();
276
					IPath rawLocation = ((IResource) obj).getRawLocation();
277
					if (rawLocation != null)
277
					if (rawLocation != null)
278
						return rawLocation.toPortableString();
278
						return rawLocation.toOSString();
279
				}
279
				}
280
			} else if ((obj instanceof String) && index == 0)
280
			} else if ((obj instanceof String) && index == 0)
281
				return (String) obj;
281
				return (String) obj;
Lines 522-529 Link Here
522
												res.getProjectRelativePath()
522
												res.getProjectRelativePath()
523
														.toPortableString(),
523
														.toPortableString(),
524
												res.getRawLocation()
524
												res.getRawLocation()
525
														.toPortableString(),
525
														.toOSString(),
526
												location.toPortableString() }));
526
												location.toOSString() }));
527
			} catch (CoreException e) {
527
			} catch (CoreException e) {
528
				report
528
				report
529
						.add(NLS
529
						.add(NLS
Lines 642-650 Link Here
642
													res
642
													res
643
															.getProjectRelativePath()
643
															.getProjectRelativePath()
644
															.toPortableString(),
644
															.toPortableString(),
645
													location.toPortableString(),
645
													location.toOSString(),
646
													newLocation
646
													newLocation
647
															.toPortableString() }));
647
															.toOSString() }));
648
				}
648
				}
649
			} catch (CoreException e) {
649
			} catch (CoreException e) {
650
				remaining.add(res);
650
				remaining.add(res);
Lines 667-673 Link Here
667
			for (int i = 0; i < variables.length; i++) {
667
			for (int i = 0; i < variables.length; i++) {
668
				IPath resolvePath = URIUtil.toPath(fProject
668
				IPath resolvePath = URIUtil.toPath(fProject
669
				.getPathVariableManager().resolveURI(
669
				.getPathVariableManager().resolveURI(
670
						URIUtil.toURI(Path.fromPortableString(variables[i])), res));
670
						URIUtil.toURI(Path.fromOSString(variables[i])), res));
671
				if (resolvePath
671
				if (resolvePath
672
						.isPrefixOf(convertToProperCase(location))) {
672
						.isPrefixOf(convertToProperCase(location))) {
673
					int count = location
673
					int count = location
Lines 691-699 Link Here
691
													res
691
													res
692
															.getProjectRelativePath()
692
															.getProjectRelativePath()
693
															.toPortableString(),
693
															.toPortableString(),
694
													location.toPortableString(),
694
													location.toOSString(),
695
													newLocation
695
													newLocation
696
															.toPortableString() }));
696
															.toOSString() }));
697
				} catch (CoreException e) {
697
				} catch (CoreException e) {
698
					variable = -1;
698
					variable = -1;
699
				}
699
				}
Lines 737-743 Link Here
737
									.bind(
737
									.bind(
738
											IDEWorkbenchMessages.LinkedResourceEditor_unableToCreateVariable,
738
											IDEWorkbenchMessages.LinkedResourceEditor_unableToCreateVariable,
739
											variableName, commonPath
739
											variableName, commonPath
740
													.toPortableString()));
740
													.toOSString()));
741
				}
741
				}
742
				it = resources.iterator();
742
				it = resources.iterator();
743
				while (it.hasNext()) {
743
				while (it.hasNext()) {
Lines 758-766 Link Here
758
																.getProjectRelativePath()
758
																.getProjectRelativePath()
759
																.toPortableString(),
759
																.toPortableString(),
760
														location
760
														location
761
																.toPortableString(),
761
																.toOSString(),
762
														newLocation
762
														newLocation
763
																.toPortableString() }));
763
																.toOSString() }));
764
					} catch (CoreException e) {
764
					} catch (CoreException e) {
765
						report
765
						report
766
								.add(NLS
766
								.add(NLS
Lines 808-815 Link Here
808
										new Object[] {
808
										new Object[] {
809
												res.getProjectRelativePath()
809
												res.getProjectRelativePath()
810
														.toPortableString(),
810
														.toPortableString(),
811
												location.toPortableString(),
811
												location.toOSString(),
812
												newLocation.toPortableString() }));
812
												newLocation.toOSString() }));
813
			} catch (CoreException e) {
813
			} catch (CoreException e) {
814
				report
814
				report
815
						.add(NLS
815
						.add(NLS
Lines 827-832 Link Here
827
827
828
	private String getSuitablePathVariable(IPath commonPath) {
828
	private String getSuitablePathVariable(IPath commonPath) {
829
		String variableName = commonPath.lastSegment();
829
		String variableName = commonPath.lastSegment();
830
		if (variableName == null) {
831
			variableName = commonPath.getDevice();
832
			if (variableName == null)
833
				variableName = "ROOT"; //$NON-NLS-1$
834
			else
835
				variableName = variableName.substring(0, variableName.length() -1); // remove the tailing ':'
836
		}
830
		StringBuffer buf = new StringBuffer();
837
		StringBuffer buf = new StringBuffer();
831
		for (int i = 0; i < variableName.length(); i++) {
838
		for (int i = 0; i < variableName.length(); i++) {
832
			char c = variableName.charAt(i);
839
			char c = variableName.charAt(i);
(-)src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java (-9 / +9 lines)
Lines 382-391 Link Here
382
        if (currentResource != null) {
382
        if (currentResource != null) {
383
        	IPathVariableManager pathVariableManager2 = currentResource.getProject().getPathVariableManager();
383
        	IPathVariableManager pathVariableManager2 = currentResource.getProject().getPathVariableManager();
384
			String[] variables = pathVariableManager2.getPathVariableNames(currentResource);
384
			String[] variables = pathVariableManager2.getPathVariableNames(currentResource);
385
    		String internalFormat = pathVariableManager2.convertFromUserEditableFormat(variableValue, currentResource);
385
    		String internalFormat = pathVariableManager2.convertFromUserEditableFormat(variableValue, operationMode == EDIT_LINK_LOCATION, currentResource);
386
    		URI uri = URIUtil.toURI(Path.fromPortableString(internalFormat));
386
    		URI uri = URIUtil.toURI(Path.fromOSString(internalFormat));
387
        	URI resolvedURI = pathVariableManager2.resolveURI(uri, currentResource);
387
        	URI resolvedURI = pathVariableManager2.resolveURI(uri, currentResource);
388
        	String resolveValue = URIUtil.toPath(resolvedURI).toPortableString();
388
        	String resolveValue = URIUtil.toPath(resolvedURI).toOSString();
389
        	// Delete intermediate variables that might have been created as
389
        	// Delete intermediate variables that might have been created as
390
        	// as a side effect of converting arbitrary relative paths to an internal string. 
390
        	// as a side effect of converting arbitrary relative paths to an internal string. 
391
        	String[] newVariables = pathVariableManager2.getPathVariableNames(currentResource);
391
        	String[] newVariables = pathVariableManager2.getPathVariableNames(currentResource);
Lines 474-483 Link Here
474
            String[] variableNames = (String[]) dialog.getResult();
474
            String[] variableNames = (String[]) dialog.getResult();
475
            if (variableNames != null && variableNames.length == 1) {
475
            if (variableNames != null && variableNames.length == 1) {
476
                String newValue = variableNames[0];
476
                String newValue = variableNames[0];
477
            	IPath path = Path.fromPortableString(newValue);
477
            	IPath path = Path.fromOSString(newValue);
478
                if (operationMode != EDIT_LINK_LOCATION && currentResource != null && !path.isAbsolute() && path.segmentCount() > 0) {
478
                if (operationMode != EDIT_LINK_LOCATION && currentResource != null && !path.isAbsolute() && path.segmentCount() > 0) {
479
                	path = buildVariableMacro(path);
479
                	path = buildVariableMacro(path);
480
                	newValue = path.toPortableString();
480
                	newValue = path.toOSString();
481
                }
481
                }
482
                variableValue = newValue;
482
                variableValue = newValue;
483
                variableValueField.setText(newValue);
483
                variableValueField.setText(newValue);
Lines 593-599 Link Here
593
            // contain macros such as "${foo}\etc"
593
            // contain macros such as "${foo}\etc"
594
            allowFinish = true;
594
            allowFinish = true;
595
            String resolvedValue = getVariableResolvedValue();
595
            String resolvedValue = getVariableResolvedValue();
596
            IPath resolvedPath = Path.fromPortableString(resolvedValue);
596
            IPath resolvedPath = Path.fromOSString(resolvedValue);
597
            if (!IDEResourceInfoUtils.exists(resolvedPath.toOSString())) {
597
            if (!IDEResourceInfoUtils.exists(resolvedPath.toOSString())) {
598
                // the path does not exist (warning)
598
                // the path does not exist (warning)
599
                message = IDEWorkbenchMessages.PathVariableDialog_pathDoesNotExistMessage;
599
                message = IDEWorkbenchMessages.PathVariableDialog_pathDoesNotExistMessage;
Lines 655-661 Link Here
655
     */
655
     */
656
    public String getVariableValue() {
656
    public String getVariableValue() {
657
    	if (currentResource != null) {
657
    	if (currentResource != null) {
658
    		String internalFormat = getPathVariableManager().convertFromUserEditableFormat(variableValue, currentResource);
658
    		String internalFormat = getPathVariableManager().convertFromUserEditableFormat(variableValue, operationMode == EDIT_LINK_LOCATION, currentResource);
659
    		return internalFormat;
659
    		return internalFormat;
660
    	}
660
    	}
661
    	return variableValue;
661
    	return variableValue;
Lines 677-683 Link Here
677
     * @param variable the new variable value
677
     * @param variable the new variable value
678
     */
678
     */
679
    public void setVariableValue(String variable) {
679
    public void setVariableValue(String variable) {
680
    	String userEditableString = getPathVariableManager().convertToUserEditableFormat(variable);
680
    	String userEditableString = getPathVariableManager().convertToUserEditableFormat(variable, operationMode == EDIT_LINK_LOCATION);
681
        variableValue = userEditableString;
681
        variableValue = userEditableString;
682
    }
682
    }
683
683
Lines 692-698 Link Here
692
     * @param location
692
     * @param location
693
     */
693
     */
694
    public void setLinkLocation(IPath location) {
694
    public void setLinkLocation(IPath location) {
695
    	String userEditableString = getPathVariableManager().convertToUserEditableFormat(location.toPortableString());
695
    	String userEditableString = getPathVariableManager().convertToUserEditableFormat(location.toOSString(), operationMode == EDIT_LINK_LOCATION);
696
        variableValue = userEditableString;
696
        variableValue = userEditableString;
697
    }
697
    }
698
698
(-)src/org/eclipse/ui/internal/ide/dialogs/PathVariablesGroup.java (-1 / +1 lines)
Lines 571-577 Link Here
571
     * @return the converted value
571
     * @return the converted value
572
     */
572
     */
573
    private String removeParentVariable(String value) {
573
    private String removeParentVariable(String value) {
574
    	return pathVariableManager.convertToUserEditableFormat(value);
574
    	return pathVariableManager.convertToUserEditableFormat(value, false);
575
    }
575
    }
576
    
576
    
577
    /**
577
    /**
(-)src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java (-2 / +4 lines)
Lines 286-292 Link Here
286
	protected void editLinkLocation() {
286
	protected void editLinkLocation() {
287
		IResource resource = (IResource) getElement().getAdapter(
287
		IResource resource = (IResource) getElement().getAdapter(
288
				IResource.class);
288
				IResource.class);
289
		IPath location = Path.fromPortableString(locationValue.getText());
289
		String locationFormat = resource.getProject().getPathVariableManager().convertFromUserEditableFormat(locationValue.getText(), true, resource);
290
		IPath location = Path.fromOSString(locationFormat);
290
291
291
		PathVariableDialog dialog = new PathVariableDialog(getShell(),
292
		PathVariableDialog dialog = new PathVariableDialog(getShell(),
292
				PathVariableDialog.EDIT_LINK_LOCATION, resource.getType(),
293
				PathVariableDialog.EDIT_LINK_LOCATION, resource.getType(),
Lines 306-312 Link Here
306
		IResource resource = (IResource) getElement().getAdapter(
307
		IResource resource = (IResource) getElement().getAdapter(
307
				IResource.class);
308
				IResource.class);
308
309
309
		locationValue.setText(newResourceLocation.toPortableString());
310
		String userEditableFormat = resource.getProject().getPathVariableManager().convertToUserEditableFormat(newResourceLocation.toOSString(), true);
311
		locationValue.setText(userEditableFormat);
310
312
311
		URI resolvedURI = resource.getProject().getPathVariableManager()
313
		URI resolvedURI = resource.getProject().getPathVariableManager()
312
				.resolveURI(URIUtil.toURI(newResourceLocation), resource);
314
				.resolveURI(URIUtil.toURI(newResourceLocation), resource);

Return to bug 302152