mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 18:15:23 +02:00
Add method to ILaunchTarget to get all the attributes.
This is used by CDT, for example, to be able to map targets to toolchains. Change-Id: I98d7463d512299c43c405fd474bb8e128a81663f
This commit is contained in:
parent
f5264933cf
commit
80c6a9694e
5 changed files with 44 additions and 4 deletions
|
@ -14,6 +14,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.launchbar.core.internal.messages"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.launchbar.core.internal.messages"; //$NON-NLS-1$
|
||||||
|
public static String ILaunchTarget_notSupported;
|
||||||
public static String LaunchBarManager_0;
|
public static String LaunchBarManager_0;
|
||||||
public static String LaunchBarManager_1;
|
public static String LaunchBarManager_1;
|
||||||
public static String LaunchBarManager_2;
|
public static String LaunchBarManager_2;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
LaunchBarManager_1=Active descriptor must be in the map of descriptors
|
|
||||||
LaunchBarManager_2=Mode is not supported by descriptor
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (c) 2014 QNX Software Systems and others.
|
# Copyright (c) 2014 QNX Software Systems and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
|
@ -10,7 +8,9 @@ LaunchBarManager_2=Mode is not supported by descriptor
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Doug Schaefer
|
# Doug Schaefer
|
||||||
################################################################################
|
################################################################################
|
||||||
|
ILaunchTarget_notSupported=getWorkingCopy is not supported for NULL_TARGET
|
||||||
LaunchBarManager_0=Launch Bar Initialization
|
LaunchBarManager_0=Launch Bar Initialization
|
||||||
|
LaunchBarManager_1=Active descriptor must be in the map of descriptors
|
||||||
|
LaunchBarManager_2=Mode is not supported by descriptor
|
||||||
LocalTarget_name=Local
|
LocalTarget_name=Local
|
||||||
OK=OK
|
OK=OK
|
||||||
|
|
|
@ -7,9 +7,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.launchbar.core.internal.target;
|
package org.eclipse.launchbar.core.internal.target;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
import org.eclipse.launchbar.core.internal.Activator;
|
||||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||||
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
|
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
|
||||||
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
import org.osgi.service.prefs.Preferences;
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
public class LaunchTarget extends PlatformObject implements ILaunchTarget {
|
public class LaunchTarget extends PlatformObject implements ILaunchTarget {
|
||||||
|
@ -59,6 +64,22 @@ public class LaunchTarget extends PlatformObject implements ILaunchTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getAttributes() {
|
||||||
|
Map<String, String> attrs = new HashMap<>();
|
||||||
|
try {
|
||||||
|
for (String key : attributes.keys()) {
|
||||||
|
String value = attributes.get(key, null);
|
||||||
|
if (value != null) {
|
||||||
|
attrs.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
Activator.log(e);
|
||||||
|
}
|
||||||
|
return attrs;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
|
|
@ -61,6 +61,13 @@ public class LaunchTargetWorkingCopy extends PlatformObject implements ILaunchTa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getAttributes() {
|
||||||
|
Map<String, String> attrs = original.getAttributes();
|
||||||
|
attrs.putAll(changes);
|
||||||
|
return attrs;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttribute(String key, String value) {
|
public void setAttribute(String key, String value) {
|
||||||
changes.put(key, value);
|
changes.put(key, value);
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.launchbar.core.target;
|
package org.eclipse.launchbar.core.target;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.launchbar.core.internal.Messages;
|
||||||
import org.eclipse.launchbar.core.internal.target.LaunchTarget;
|
import org.eclipse.launchbar.core.internal.target.LaunchTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +32,7 @@ public interface ILaunchTarget extends IAdaptable {
|
||||||
public static final ILaunchTarget NULL_TARGET = new LaunchTarget("null", "---") { //$NON-NLS-1$ //$NON-NLS-2$
|
public static final ILaunchTarget NULL_TARGET = new LaunchTarget("null", "---") { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
@Override
|
@Override
|
||||||
public ILaunchTargetWorkingCopy getWorkingCopy() {
|
public ILaunchTargetWorkingCopy getWorkingCopy() {
|
||||||
throw new UnsupportedOperationException("getWorkingCopy is not supported for NULL_TARGET");
|
throw new UnsupportedOperationException(Messages.ILaunchTarget_notSupported);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,6 +72,14 @@ public interface ILaunchTarget extends IAdaptable {
|
||||||
*/
|
*/
|
||||||
String getAttribute(String key, String defValue);
|
String getAttribute(String key, String defValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a read-only map of the attributes.
|
||||||
|
*
|
||||||
|
* @return the attributes for this target
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
Map<String, String> getAttributes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a working copy of this launch target to allow setting of attributes. It also allows
|
* Create a working copy of this launch target to allow setting of attributes. It also allows
|
||||||
* changing the id, which results in a new launch target when saved.
|
* changing the id, which results in a new launch target when saved.
|
||||||
|
|
Loading…
Add table
Reference in a new issue