1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Bug 536889 - Launchbar needs to replace slashes for launch target names

- fix LaunchTargetManager addLaunchTarget to change any
  slashes in the target name to semi-colons when forming the
  preference node name to use
- fix LaunchTargetManager initTargets method to restore slashes
  when reading the targets from preference nodes
- fix LaunchTargetManager removeLaunchTarget to change any
  slashes in the target name to semi-colons when removing
  a preference node corresponding to the launch target id

Signed-off-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
Jeff Johnston 2018-07-10 22:05:15 -04:00
parent 2801712233
commit a62d2ae89b

View file

@ -40,6 +40,8 @@ public class LaunchTargetManager implements ILaunchTargetManager {
private static final String DELIMETER1 = ","; //$NON-NLS-1$
private static final String DELIMETER2 = ":"; //$NON-NLS-1$
private static final String SLASH = "/"; //$NON-NLS-1$
private static final String SLASH_REPLACER = ";"; //$NON-NLS-1$
private Preferences getTargetsPref() {
return InstanceScope.INSTANCE.getNode(Activator.getDefault().getBundle().getSymbolicName())
@ -70,7 +72,9 @@ public class LaunchTargetManager implements ILaunchTargetManager {
String[] segments = childName.split(DELIMETER1);
if (segments.length == 2) {
String typeId = segments[0];
String name = segments[1];
// Bug 536889 - we need to restore any slashes we changed when creating
// the target node so the name will appear correct to the end-user
String name = segments[1].replaceAll(SLASH_REPLACER, SLASH);
Map<String, ILaunchTarget> type = targets.get(typeId);
if (type == null) {
@ -194,7 +198,9 @@ public class LaunchTargetManager implements ILaunchTargetManager {
try {
Preferences prefs = getTargetsPref();
String childName = typeId + DELIMETER1 + id;
// Bug 536889 - replace any slashes in the id with a replacement character
// for the child node name but still leave the id intact for the launch target
String childName = typeId + DELIMETER1 + id.replaceAll(SLASH, SLASH_REPLACER);
Preferences child;
if (prefs.nodeExists(childName)) {
child = prefs.node(childName);
@ -233,7 +239,8 @@ public class LaunchTargetManager implements ILaunchTargetManager {
// Remove the attribute node
try {
getTargetsPref().node(typeId + DELIMETER1 + target.getId()).removeNode();
// Bug 536889 - calculate the node name to remove, replacing slashes with a replacement character
getTargetsPref().node(typeId + DELIMETER1 + target.getId().replaceAll(SLASH, SLASH_REPLACER)).removeNode();
} catch (BackingStoreException e) {
Activator.log(e);
}