From 374059131bc64435291cee3967a7517d2821b84d Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Thu, 31 Aug 2017 11:34:17 -0400 Subject: [PATCH] Bug 521703 Add name attribute to new targets This ensure they have at least one attribute to that the child node persists (empty ones don't). Change-Id: I3bdc64a07a097882acfcc4995e1d09a0a862b197 --- .../launchbar/core/ILaunchBarListener.java | 17 +++------ .../internal/target/LaunchTargetManager.java | 35 ++++++++++++------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarListener.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarListener.java index 2db287409a0..c3d2c8fafe8 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarListener.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarListener.java @@ -1,16 +1,9 @@ /******************************************************************************* - * Copyright (c) Jan 29, 2016 QNX Software Systems. All Rights Reserved. - * - * You must obtain a written license from and pay applicable license fees to QNX - * Software Systems before you may reproduce, modify or distribute this software, - * or any work that includes all or part of this software. Free development - * licenses are available for evaluation and non-commercial purposes. For more - * information visit [http://licensing.qnx.com] or email licensing@qnx.com. - * - * This file may contain contributions from others. Please review this entire - * file for other proprietary rights or license notices, as well as the QNX - * Development Suite License Guide at [http://licensing.qnx.com/license-guide/] - * for other information. + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.eclipse.launchbar.core; 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 66df11523bb..e6ce687f956 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 @@ -192,23 +192,32 @@ public class LaunchTargetManager implements ILaunchTargetManager { targets.put(typeId, type); } - Preferences prefs = getTargetsPref(); - String childName = typeId + DELIMETER1 + id; - ILaunchTarget target = new LaunchTarget(typeId, id, prefs.node(childName)); - type.put(id, target); try { - prefs.flush(); + Preferences prefs = getTargetsPref(); + String childName = typeId + DELIMETER1 + id; + Preferences child; + if (prefs.nodeExists(childName)) { + child = prefs.node(childName); + } else { + child = prefs.node(childName); + // set the id so we have at least one attribute to save + child.put("name", id); //$NON-NLS-1$ + } + ILaunchTarget target = new LaunchTarget(typeId, id, child); + type.put(id, target); + child.flush(); + + synchronized (listeners) { + for (ILaunchTargetListener listener : listeners) { + listener.launchTargetAdded(target); + } + } + + return target; } catch (BackingStoreException e) { Activator.log(e); + return null; } - - synchronized (listeners) { - for (ILaunchTargetListener listener : listeners) { - listener.launchTargetAdded(target); - } - } - - return target; } @Override