From a62d2ae89bd3db4f8cfc8aa07aaf1fc57459b075 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 10 Jul 2018 22:05:15 -0400 Subject: [PATCH] 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 --- .../core/internal/target/LaunchTargetManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java index fe6631c46bc..d2e27ea2887 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java @@ -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 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); }