mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
Bug 481352 - reintroduce ILaunchTarget as target selector.
Replace IRemoteConnection with ILaunchTarget. Launch target providers that want to use IRemoteConnection can adapt to it. Also removes IHoverProvider since tools tips on the target selector use the status message for the target. Change-Id: I117745e61789ef780c742da9b73bded2b598915c
This commit is contained in:
parent
edd5f69a87
commit
3c6d66259a
49 changed files with 1490 additions and 502 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -2,15 +2,15 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LaunchBar Core
|
||||
Bundle-SymbolicName: org.eclipse.launchbar.core;singleton:=true
|
||||
Bundle-Version: 1.0.1.qualifier
|
||||
Bundle-Version: 2.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.launchbar.core.internal.Activator
|
||||
Bundle-Vendor: Eclipse CDT
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
org.eclipse.debug.core,
|
||||
org.eclipse.core.filesystem,
|
||||
org.eclipse.remote.core;bundle-version="2.0.0",
|
||||
org.eclipse.core.expressions
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.launchbar.core,
|
||||
org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui"
|
||||
org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui",
|
||||
org.eclipse.launchbar.core.target,
|
||||
org.eclipse.launchbar.core.target.launch
|
||||
|
|
|
@ -3,4 +3,5 @@ output.. = bin/
|
|||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
about.html
|
||||
about.html,\
|
||||
schema/
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension-point id="launchBarContributions" name="Launch Bar Contributions" schema="schema/launchBarContributions.exsd"/>
|
||||
<extension-point id="launchTargetTypes" name="Launch Target Types" schema="schema/launchTargetTypes.exsd"/>
|
||||
<extension
|
||||
point="org.eclipse.launchbar.core.launchBarContributions">
|
||||
<objectProvider
|
||||
|
@ -25,5 +26,12 @@
|
|||
</enablement>
|
||||
</configProvider>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.launchbar.core.launchTargetTypes">
|
||||
<launchTargetType
|
||||
id="org.eclipse.launchbar.core.launchTargetType.local"
|
||||
provider="org.eclipse.launchbar.core.internal.target.LocalLaunchTargetProvider">
|
||||
</launchTargetType>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.launchbar.core</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
109
bundles/org.eclipse.launchbar.core/schema/launchTargetTypes.exsd
Normal file
109
bundles/org.eclipse.launchbar.core/schema/launchTargetTypes.exsd
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.launchbar.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.eclipse.launchbar.core" id="launchTargetTypes" name="Launch Target Types"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="launchTargetType" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="launchTargetType">
|
||||
<complexType>
|
||||
<attribute name="id" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="provider" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.launchbar.core.target.ILaunchTargetProvider"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter the first release in which this extension point appears.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
|
@ -17,7 +17,7 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
|
|||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.launchbar.core.internal.Activator;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
/**
|
||||
* Common launch config provider. Manages creating launch configurations and
|
||||
|
@ -28,7 +28,7 @@ public abstract class AbstractLaunchConfigProvider implements ILaunchConfigurati
|
|||
private static final String ATTR_ORIGINAL_NAME = Activator.PLUGIN_ID + ".originalName"; //$NON-NLS-1$
|
||||
private static final String ATTR_PROVIDER_CLASS = Activator.PLUGIN_ID + ".providerClass"; //$NON-NLS-1$
|
||||
|
||||
protected ILaunchConfiguration createLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
protected ILaunchConfiguration createLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
||||
String name = launchManager.generateLaunchConfigurationName(descriptor.getName());
|
||||
|
@ -40,7 +40,7 @@ public abstract class AbstractLaunchConfigProvider implements ILaunchConfigurati
|
|||
return workingCopy.doSave();
|
||||
}
|
||||
|
||||
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target,
|
||||
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
|
||||
ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
|
||||
// Leave our breadcrumb
|
||||
workingCopy.setAttribute(ATTR_ORIGINAL_NAME, workingCopy.getName());
|
||||
|
|
|
@ -13,7 +13,8 @@ package org.eclipse.launchbar.core;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
|
||||
/**
|
||||
* The launch config provider for the default descriptor which is the launch
|
||||
|
@ -25,23 +26,19 @@ import org.eclipse.remote.core.IRemoteConnection;
|
|||
public class DefaultLaunchConfigProvider implements ILaunchConfigurationProvider {
|
||||
|
||||
@Override
|
||||
public boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
|
||||
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
|
||||
// Only supports Local connection
|
||||
if (target != null && target.getConnectionType().getId().equals("org.eclipse.remote.LocalServices")) { //$NON-NLS-1$
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return target != null && target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
return descriptor.getAdapter(ILaunchConfiguration.class).getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
return descriptor.getAdapter(ILaunchConfiguration.class);
|
||||
}
|
||||
|
@ -68,7 +65,7 @@ public class DefaultLaunchConfigProvider implements ILaunchConfigurationProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public void launchTargetRemoved(IRemoteConnection target) throws CoreException {
|
||||
public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ package org.eclipse.launchbar.core;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
/**
|
||||
* The provider of launch configurations of a given type for a given descriptor
|
||||
|
@ -34,7 +34,7 @@ public interface ILaunchConfigurationProvider {
|
|||
* @param target
|
||||
* @return true if target is supported, false otherwise.
|
||||
*/
|
||||
boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException;
|
||||
boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException;
|
||||
|
||||
/**
|
||||
* Return the launch configuation type for the descriptor and target.
|
||||
|
@ -45,7 +45,7 @@ public interface ILaunchConfigurationProvider {
|
|||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException;
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ public interface ILaunchConfigurationProvider {
|
|||
* @return launch configuration
|
||||
* @throws CoreException
|
||||
*/
|
||||
ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException;
|
||||
|
||||
/**
|
||||
|
@ -108,6 +108,6 @@ public interface ILaunchConfigurationProvider {
|
|||
* @param target
|
||||
* @throws CoreException
|
||||
*/
|
||||
void launchTargetRemoved(IRemoteConnection target) throws CoreException;
|
||||
void launchTargetRemoved(ILaunchTarget target) throws CoreException;
|
||||
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ import java.util.Map.Entry;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.launchbar.core.internal.Activator;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfigProvider {
|
||||
private final Map<ILaunchDescriptor, Map<IRemoteConnection, ILaunchConfiguration>> configMap = new HashMap<>();
|
||||
private final Map<ILaunchDescriptor, Map<ILaunchTarget, ILaunchConfiguration>> configMap = new HashMap<>();
|
||||
private final Map<ILaunchDescriptor, ILaunchConfiguration> defaultConfigs = new HashMap<>();
|
||||
private final Collection<ILaunchConfiguration> ownedConfigs = new LinkedHashSet<>();
|
||||
|
||||
|
@ -32,10 +32,10 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
if (target != null) {
|
||||
Map<IRemoteConnection, ILaunchConfiguration> targetMap = configMap.get(descriptor);
|
||||
Map<ILaunchTarget, ILaunchConfiguration> targetMap = configMap.get(descriptor);
|
||||
if (targetMap != null) {
|
||||
ILaunchConfiguration config = targetMap.get(target);
|
||||
if (config != null) {
|
||||
|
@ -56,7 +56,7 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
|
||||
protected abstract ILaunchDescriptor getLaunchDescriptor(ILaunchConfiguration configuration) throws CoreException;
|
||||
|
||||
protected abstract IRemoteConnection getLaunchTarget(ILaunchConfiguration configuration) throws CoreException;
|
||||
protected abstract ILaunchTarget getLaunchTarget(ILaunchConfiguration configuration) throws CoreException;
|
||||
|
||||
protected boolean providesForNullTarget() {
|
||||
return false;
|
||||
|
@ -68,7 +68,7 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
return false;
|
||||
}
|
||||
|
||||
IRemoteConnection target = getLaunchTarget(configuration);
|
||||
ILaunchTarget target = getLaunchTarget(configuration);
|
||||
if (target == null) {
|
||||
if (providesForNullTarget()) {
|
||||
defaultConfigs.put(desc, configuration);
|
||||
|
@ -76,7 +76,7 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
Map<IRemoteConnection, ILaunchConfiguration> targetMap = configMap.get(desc);
|
||||
Map<ILaunchTarget, ILaunchConfiguration> targetMap = configMap.get(desc);
|
||||
if (targetMap == null) {
|
||||
targetMap = new HashMap<>();
|
||||
configMap.put(desc, targetMap);
|
||||
|
@ -117,8 +117,8 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
@Override
|
||||
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
|
||||
ownedConfigs.remove(configuration);
|
||||
for (Entry<ILaunchDescriptor, Map<IRemoteConnection, ILaunchConfiguration>> descEntry : configMap.entrySet()) {
|
||||
for (Entry<IRemoteConnection, ILaunchConfiguration> targetEntry : descEntry.getValue().entrySet()) {
|
||||
for (Entry<ILaunchDescriptor, Map<ILaunchTarget, ILaunchConfiguration>> descEntry : configMap.entrySet()) {
|
||||
for (Entry<ILaunchTarget, ILaunchConfiguration> targetEntry : descEntry.getValue().entrySet()) {
|
||||
if (targetEntry.getValue().equals(configuration)) {
|
||||
descEntry.getValue().remove(targetEntry.getKey());
|
||||
if (descEntry.getValue().isEmpty()) {
|
||||
|
@ -133,7 +133,7 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
|
||||
@Override
|
||||
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
|
||||
Map<IRemoteConnection, ILaunchConfiguration> map = configMap.remove(descriptor);
|
||||
Map<ILaunchTarget, ILaunchConfiguration> map = configMap.remove(descriptor);
|
||||
if (map != null) {
|
||||
for (ILaunchConfiguration config : map.values()) {
|
||||
ownedConfigs.remove(config);
|
||||
|
@ -150,11 +150,11 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
}
|
||||
|
||||
@Override
|
||||
public void launchTargetRemoved(IRemoteConnection target) throws CoreException {
|
||||
for (Iterator<Entry<ILaunchDescriptor, Map<IRemoteConnection, ILaunchConfiguration>>> iterator = configMap
|
||||
public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
|
||||
for (Iterator<Entry<ILaunchDescriptor, Map<ILaunchTarget, ILaunchConfiguration>>> iterator = configMap
|
||||
.entrySet().iterator(); iterator.hasNext();) {
|
||||
Entry<ILaunchDescriptor, Map<IRemoteConnection, ILaunchConfiguration>> descEntry = iterator.next();
|
||||
Map<IRemoteConnection, ILaunchConfiguration> map = descEntry.getValue();
|
||||
Entry<ILaunchDescriptor, Map<ILaunchTarget, ILaunchConfiguration>> descEntry = iterator.next();
|
||||
Map<ILaunchTarget, ILaunchConfiguration> map = descEntry.getValue();
|
||||
ILaunchConfiguration config = map.remove(target);
|
||||
if (config != null) {
|
||||
// remove all auto-configs associated with target
|
||||
|
|
|
@ -16,17 +16,17 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.launchbar.core.internal.Activator;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
public abstract class ProjectPerTargetLaunchConfigProvider extends PerTargetLaunchConfigProvider {
|
||||
|
||||
@Override
|
||||
public boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
|
||||
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
|
||||
return (descriptor.getAdapter(IProject.class) != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target,
|
||||
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
|
||||
ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
|
||||
super.populateLaunchConfiguration(descriptor, target, workingCopy);
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.eclipse.core.runtime.Platform;
|
|||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.launchbar.core.internal.target.LaunchTargetManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
|
@ -27,6 +29,7 @@ public class Activator extends Plugin {
|
|||
public void start(BundleContext bundleContext) throws Exception {
|
||||
super.start(bundleContext);
|
||||
plugin = this;
|
||||
bundleContext.registerService(ILaunchTargetManager.class, new LaunchTargetManager(), null);
|
||||
bundleContext.registerService(ILaunchBarManager.class, new LaunchBarManager(), null);
|
||||
}
|
||||
|
||||
|
@ -42,7 +45,8 @@ public class Activator extends Plugin {
|
|||
/**
|
||||
* Return the OSGi service with the given service interface.
|
||||
*
|
||||
* @param service service interface
|
||||
* @param service
|
||||
* service interface
|
||||
* @return the specified service or null if it's not registered
|
||||
*/
|
||||
public static <T> T getService(Class<T> service) {
|
||||
|
@ -70,8 +74,7 @@ public class Activator extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
private static final String DEBUG_ONE =
|
||||
PLUGIN_ID + "/debug/launchbar"; //$NON-NLS-1$
|
||||
private static final String DEBUG_ONE = PLUGIN_ID + "/debug/launchbar"; //$NON-NLS-1$
|
||||
|
||||
public static void trace(String str) {
|
||||
if (plugin == null || (plugin.isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption(DEBUG_ONE)))) //$NON-NLS-1$
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.launchbar.core.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
@ -40,31 +41,32 @@ import org.eclipse.launchbar.core.ILaunchConfigurationProvider;
|
|||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
||||
import org.eclipse.launchbar.core.ILaunchObjectProvider;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetListener;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* The brains of the launch bar.
|
||||
*/
|
||||
public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionChangeListener {
|
||||
public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListener {
|
||||
|
||||
// TODO make these more fine grained or break them into more focused
|
||||
// listeners
|
||||
public interface Listener {
|
||||
void activeLaunchDescriptorChanged();
|
||||
default void activeLaunchDescriptorChanged() {
|
||||
}
|
||||
|
||||
void activeLaunchModeChanged();
|
||||
default void activeLaunchModeChanged() {
|
||||
}
|
||||
|
||||
void activeLaunchTargetChanged();
|
||||
default void activeLaunchTargetChanged() {
|
||||
}
|
||||
|
||||
void launchDescriptorRemoved(ILaunchDescriptor descriptor);
|
||||
default void launchDescriptorRemoved(ILaunchDescriptor descriptor) {
|
||||
}
|
||||
|
||||
void launchTargetsChanged();
|
||||
default void launchTargetsChanged() {
|
||||
}
|
||||
}
|
||||
|
||||
private final List<Listener> listeners = new LinkedList<>();
|
||||
|
@ -88,11 +90,11 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
// Map of launch objects to launch descriptors
|
||||
private final Map<Object, ILaunchDescriptor> objectDescriptorMap = new HashMap<>();
|
||||
|
||||
private final IRemoteServicesManager remoteServicesManager = getRemoteServicesManager();
|
||||
private ILaunchTargetManager launchTargetManager;
|
||||
|
||||
private ILaunchDescriptor activeLaunchDesc;
|
||||
private ILaunchMode activeLaunchMode;
|
||||
private IRemoteConnection activeLaunchTarget;
|
||||
private ILaunchTarget activeLaunchTarget;
|
||||
|
||||
// private static final String PREF_ACTIVE_CONFIG_DESC = "activeConfigDesc";
|
||||
private static final String PREF_ACTIVE_LAUNCH_MODE = "activeLaunchMode"; //$NON-NLS-1$
|
||||
|
@ -107,8 +109,8 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
|
||||
// called from unit tests to ensure everything is inited
|
||||
LaunchBarManager(boolean doInit) {
|
||||
remoteServicesManager.addRemoteConnectionChangeListener(this);
|
||||
|
||||
launchTargetManager = getLaunchTargetManager();
|
||||
launchTargetManager.addListener(this);
|
||||
if (doInit) {
|
||||
new Job(Messages.LaunchBarManager_0) {
|
||||
@Override
|
||||
|
@ -124,11 +126,6 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
}
|
||||
}
|
||||
|
||||
// To allow override by tests
|
||||
IRemoteServicesManager getRemoteServicesManager() {
|
||||
return Activator.getService(IRemoteServicesManager.class);
|
||||
}
|
||||
|
||||
// To allow override by tests
|
||||
IExtensionPoint getExtensionPoint() throws CoreException {
|
||||
return Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launchBarContributions"); //$NON-NLS-1$
|
||||
|
@ -139,6 +136,10 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
return DebugPlugin.getDefault().getLaunchManager();
|
||||
}
|
||||
|
||||
ILaunchTargetManager getLaunchTargetManager() {
|
||||
return Activator.getService(ILaunchTargetManager.class);
|
||||
}
|
||||
|
||||
// When testing, call this after setting up the mocks.
|
||||
void init() throws CoreException {
|
||||
try {
|
||||
|
@ -293,8 +294,8 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
return new Pair<String, String>(getDescriptorTypeId(descriptor.getType()), descriptor.getName());
|
||||
}
|
||||
|
||||
private Pair<String, String> getTargetId(IRemoteConnection target) {
|
||||
return new Pair<String, String>(target.getConnectionType().getId(), target.getName());
|
||||
private Pair<String, String> getTargetId(ILaunchTarget target) {
|
||||
return new Pair<String, String>(target.getTypeId(), target.getName());
|
||||
}
|
||||
|
||||
private void addDescriptor(Object launchObject, ILaunchDescriptor descriptor) throws CoreException {
|
||||
|
@ -303,7 +304,7 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
setActiveLaunchDescriptor(descriptor);
|
||||
}
|
||||
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
if (descriptor == null)
|
||||
return null;
|
||||
|
@ -478,13 +479,10 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
String activeTargetId = getPerDescriptorStore().get(PREF_ACTIVE_LAUNCH_TARGET, null);
|
||||
if (activeTargetId != null) {
|
||||
Pair<String, String> id = toId(activeTargetId);
|
||||
IRemoteConnectionType remoteServices = remoteServicesManager.getConnectionType(id.getFirst());
|
||||
if (remoteServices != null) {
|
||||
IRemoteConnection storedTarget = remoteServices.getConnection(id.getSecond());
|
||||
if (storedTarget != null && supportsTarget(activeLaunchDesc, storedTarget)) {
|
||||
setActiveLaunchTarget(storedTarget);
|
||||
return;
|
||||
}
|
||||
ILaunchTarget storedTarget = launchTargetManager.getLaunchTarget(id.getFirst(), id.getSecond());
|
||||
if (storedTarget != null && supportsTarget(activeLaunchDesc, storedTarget)) {
|
||||
setActiveLaunchTarget(storedTarget);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// default target for descriptor
|
||||
|
@ -641,12 +639,12 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
}
|
||||
}
|
||||
|
||||
public List<IRemoteConnection> getLaunchTargets(ILaunchDescriptor descriptor) throws CoreException {
|
||||
public List<ILaunchTarget> getLaunchTargets(ILaunchDescriptor descriptor) {
|
||||
if (descriptor == null)
|
||||
return remoteServicesManager.getAllRemoteConnections();
|
||||
return Arrays.asList(launchTargetManager.getLaunchTargets());
|
||||
|
||||
List<IRemoteConnection> targets = new ArrayList<>();
|
||||
for (IRemoteConnection target : remoteServicesManager.getAllRemoteConnections()) {
|
||||
List<ILaunchTarget> targets = new ArrayList<>();
|
||||
for (ILaunchTarget target : launchTargetManager.getLaunchTargets()) {
|
||||
if (supportsTarget(descriptor, target)) {
|
||||
targets.add(target);
|
||||
}
|
||||
|
@ -655,7 +653,7 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
return targets;
|
||||
}
|
||||
|
||||
boolean supportsTarget(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
|
||||
boolean supportsTarget(ILaunchDescriptor descriptor, ILaunchTarget target) {
|
||||
String descriptorTypeId = getDescriptorTypeId(descriptor.getType());
|
||||
for (LaunchConfigProviderInfo providerInfo : configProviders.get(descriptorTypeId)) {
|
||||
try {
|
||||
|
@ -671,7 +669,7 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
return false;
|
||||
}
|
||||
|
||||
public IRemoteConnection getActiveLaunchTarget() {
|
||||
public ILaunchTarget getActiveLaunchTarget() {
|
||||
return activeLaunchTarget;
|
||||
}
|
||||
|
||||
|
@ -682,7 +680,7 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
* @param target
|
||||
* @throws CoreException
|
||||
*/
|
||||
public void setLaunchTarget(ILaunchDescriptor desc, IRemoteConnection target) throws CoreException {
|
||||
public void setLaunchTarget(ILaunchDescriptor desc, ILaunchTarget target) throws CoreException {
|
||||
if (desc == activeLaunchDesc) {
|
||||
setActiveLaunchTarget(target);
|
||||
} else {
|
||||
|
@ -690,7 +688,7 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
}
|
||||
}
|
||||
|
||||
public void setActiveLaunchTarget(IRemoteConnection target) throws CoreException {
|
||||
public void setActiveLaunchTarget(ILaunchTarget target) throws CoreException {
|
||||
if (activeLaunchTarget == target) {
|
||||
return;
|
||||
}
|
||||
|
@ -700,7 +698,7 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
fireActiveLaunchTargetChanged(); // notify listeners
|
||||
}
|
||||
|
||||
private void storeLaunchTarget(ILaunchDescriptor desc, IRemoteConnection target) {
|
||||
private void storeLaunchTarget(ILaunchDescriptor desc, ILaunchTarget target) {
|
||||
if (target == null) {
|
||||
// no point storing null, if stored id is invalid it won't be used
|
||||
// anyway
|
||||
|
@ -722,8 +720,8 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
}
|
||||
}
|
||||
|
||||
private IRemoteConnection getDefaultLaunchTarget(ILaunchDescriptor descriptor) throws CoreException {
|
||||
List<IRemoteConnection> targets = getLaunchTargets(descriptor);
|
||||
private ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) {
|
||||
List<ILaunchTarget> targets = getLaunchTargets(descriptor);
|
||||
return targets.isEmpty() ? null : targets.get(0);
|
||||
}
|
||||
|
||||
|
@ -731,7 +729,7 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
return getLaunchConfiguration(activeLaunchDesc, activeLaunchTarget);
|
||||
}
|
||||
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
if (descriptor == null) {
|
||||
return null;
|
||||
|
@ -847,32 +845,6 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionChanged(RemoteConnectionChangeEvent event) {
|
||||
switch (event.getType()) {
|
||||
case RemoteConnectionChangeEvent.CONNECTION_ADDED:
|
||||
try {
|
||||
launchTargetAdded(event.getConnection());
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
break;
|
||||
case RemoteConnectionChangeEvent.CONNECTION_REMOVED:
|
||||
try {
|
||||
launchTargetRemoved(event.getConnection());
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
break;
|
||||
case RemoteConnectionChangeEvent.CONNECTION_RENAMED:
|
||||
fireLaunchTargetsChanged();
|
||||
break;
|
||||
default:
|
||||
fireLaunchTargetsChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void fireLaunchTargetsChanged() {
|
||||
if (!initialized)
|
||||
return;
|
||||
|
@ -885,22 +857,32 @@ public class LaunchBarManager implements ILaunchBarManager, IRemoteConnectionCha
|
|||
}
|
||||
}
|
||||
|
||||
private void launchTargetAdded(IRemoteConnection target) throws CoreException {
|
||||
@Override
|
||||
public void launchTargetAdded(ILaunchTarget target) {
|
||||
if (!initialized)
|
||||
return;
|
||||
fireLaunchTargetsChanged();
|
||||
// if we added new target we probably want to use it
|
||||
if (activeLaunchDesc == null || supportsTarget(activeLaunchDesc, target)) {
|
||||
setActiveLaunchTarget(target);
|
||||
try {
|
||||
setActiveLaunchTarget(target);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void launchTargetRemoved(IRemoteConnection target) throws CoreException {
|
||||
@Override
|
||||
public void launchTargetRemoved(ILaunchTarget target) {
|
||||
if (!initialized)
|
||||
return;
|
||||
fireLaunchTargetsChanged();
|
||||
if (activeLaunchTarget == target) {
|
||||
setActiveLaunchTarget(getDefaultLaunchTarget(activeLaunchDesc));
|
||||
try {
|
||||
setActiveLaunchTarget(getDefaultLaunchTarget(activeLaunchDesc));
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,19 +70,28 @@ public class LaunchConfigProviderInfo {
|
|||
return priority;
|
||||
}
|
||||
|
||||
public ILaunchConfigurationProvider getProvider() throws CoreException {
|
||||
public ILaunchConfigurationProvider getProvider() {
|
||||
if (provider == null) {
|
||||
provider = (ILaunchConfigurationProvider) element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
element = null;
|
||||
try {
|
||||
provider = (ILaunchConfigurationProvider) element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
element = null;
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
public boolean enabled(Object element) throws CoreException {
|
||||
public boolean enabled(Object element) {
|
||||
if (expression == null)
|
||||
return true;
|
||||
EvaluationResult result = expression.evaluate(new EvaluationContext(null, element));
|
||||
return (result == EvaluationResult.TRUE);
|
||||
try {
|
||||
EvaluationResult result = expression.evaluate(new EvaluationContext(null, element));
|
||||
return (result == EvaluationResult.TRUE);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,8 @@ public class Messages extends NLS {
|
|||
public static String LaunchBarManager_1;
|
||||
public static String LaunchBarManager_2;
|
||||
public static String LocalTarget_name;
|
||||
public static String OK;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
|
|
|
@ -12,4 +12,5 @@ LaunchBarManager_2=Mode is not supported by descriptor
|
|||
################################################################################
|
||||
|
||||
LaunchBarManager_0=Launch Bar Initialization
|
||||
LocalTarget_name=Local Machine
|
||||
LocalTarget_name=Local
|
||||
OK=OK
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.internal.target;
|
||||
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
public class LaunchTarget extends PlatformObject implements ILaunchTarget {
|
||||
|
||||
private final String typeId;
|
||||
private final String name;
|
||||
|
||||
public LaunchTarget(String typeId, String name) {
|
||||
this.typeId = typeId;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((typeId == null) ? 0 : typeId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
LaunchTarget other = (LaunchTarget) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (typeId == null) {
|
||||
if (other.typeId != null)
|
||||
return false;
|
||||
} else if (!typeId.equals(other.typeId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.internal.target;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.launchbar.core.internal.Activator;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetListener;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
|
||||
import org.eclipse.launchbar.core.target.TargetStatus;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class LaunchTargetManager implements ILaunchTargetManager {
|
||||
|
||||
private Map<String, Map<String, ILaunchTarget>> targets;
|
||||
private Map<String, IConfigurationElement> typeElements;
|
||||
private Map<String, ILaunchTargetProvider> typeProviders = new HashMap<>();
|
||||
private List<ILaunchTargetListener> listeners = new LinkedList<>();
|
||||
|
||||
private static final String DELIMETER = ","; //$NON-NLS-1$
|
||||
|
||||
private Preferences getTargetsPref() {
|
||||
return InstanceScope.INSTANCE.getNode(Activator.getDefault().getBundle().getSymbolicName())
|
||||
.node(getClass().getSimpleName());
|
||||
}
|
||||
|
||||
private synchronized void initTargets() {
|
||||
if (targets == null) {
|
||||
// load target type elements from registry
|
||||
typeElements = new HashMap<>();
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint point = registry
|
||||
.getExtensionPoint(Activator.getDefault().getBundle().getSymbolicName() + ".launchTargetTypes"); //$NON-NLS-1$
|
||||
for (IExtension extension : point.getExtensions()) {
|
||||
for (IConfigurationElement element : extension.getConfigurationElements()) {
|
||||
String id = element.getAttribute("id"); //$NON-NLS-1$
|
||||
if (id != null) {
|
||||
typeElements.put(id, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load targets from preference store
|
||||
targets = new HashMap<>();
|
||||
Preferences prefs = getTargetsPref();
|
||||
try {
|
||||
for (String typeId : prefs.keys()) {
|
||||
Map<String, ILaunchTarget> type = targets.get(typeId);
|
||||
if (type == null) {
|
||||
type = new HashMap<>();
|
||||
targets.put(typeId, type);
|
||||
}
|
||||
|
||||
for (String name : prefs.get(typeId, "").split(DELIMETER)) { //$NON-NLS-1$
|
||||
type.put(name, new LaunchTarget(typeId, name));
|
||||
}
|
||||
}
|
||||
} catch (BackingStoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
|
||||
// Call the provider's init
|
||||
// TODO check enablement so we don't call them if we don't need to
|
||||
for (String typeId : typeElements.keySet()) {
|
||||
ILaunchTargetProvider provider = getProvider(typeId);
|
||||
if (provider != null) {
|
||||
provider.init(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ILaunchTargetProvider getProvider(String typeId) {
|
||||
ILaunchTargetProvider provider = typeProviders.get(typeId);
|
||||
if (provider == null) {
|
||||
IConfigurationElement element = typeElements.get(typeId);
|
||||
if (element != null) {
|
||||
try {
|
||||
provider = (ILaunchTargetProvider) element.createExecutableExtension("provider"); //$NON-NLS-1$
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (provider == null) {
|
||||
provider = new ILaunchTargetProvider() {
|
||||
@Override
|
||||
public void init(ILaunchTargetManager targetManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetStatus getStatus(ILaunchTarget target) {
|
||||
return TargetStatus.OK_STATUS;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget[] getLaunchTargets() {
|
||||
initTargets();
|
||||
List<ILaunchTarget> targetList = new ArrayList<>();
|
||||
for (Map<String, ILaunchTarget> type : targets.values()) {
|
||||
targetList.addAll(type.values());
|
||||
}
|
||||
return targetList.toArray(new ILaunchTarget[targetList.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget[] getLaunchTargetsOfType(String typeId) {
|
||||
initTargets();
|
||||
Map<String, ILaunchTarget> type = targets.get(typeId);
|
||||
if (type != null) {
|
||||
return type.values().toArray(new ILaunchTarget[type.size()]);
|
||||
}
|
||||
return new ILaunchTarget[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget getLaunchTarget(String typeId, String name) {
|
||||
initTargets();
|
||||
Map<String, ILaunchTarget> type = targets.get(typeId);
|
||||
if (type != null) {
|
||||
return type.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetStatus getStatus(ILaunchTarget target) {
|
||||
return getProvider(target.getTypeId()).getStatus(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget addLaunchTarget(String typeId, String name) {
|
||||
initTargets();
|
||||
Map<String, ILaunchTarget> type = targets.get(typeId);
|
||||
if (type == null) {
|
||||
type = new HashMap<>();
|
||||
targets.put(typeId, type);
|
||||
}
|
||||
|
||||
ILaunchTarget target = new LaunchTarget(typeId, name);
|
||||
type.put(name, target);
|
||||
getTargetsPref().put(typeId, String.join(DELIMETER, type.keySet()));
|
||||
|
||||
for (ILaunchTargetListener listener : listeners) {
|
||||
listener.launchTargetAdded(target);
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLaunchTarget(ILaunchTarget target) {
|
||||
initTargets();
|
||||
Map<String, ILaunchTarget> type = targets.get(target.getTypeId());
|
||||
if (type != null) {
|
||||
type.remove(target.getName());
|
||||
if (type.isEmpty()) {
|
||||
targets.remove(target.getTypeId());
|
||||
getTargetsPref().remove(target.getTypeId());
|
||||
} else {
|
||||
getTargetsPref().put(target.getTypeId(), String.join(DELIMETER, type.keySet()));
|
||||
}
|
||||
|
||||
for (ILaunchTargetListener listener : listeners) {
|
||||
listener.launchTargetRemoved(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void targetStatusChanged(ILaunchTarget target) {
|
||||
for (ILaunchTargetListener listener : listeners) {
|
||||
listener.launchTargetStatusChanged(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ILaunchTargetListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ILaunchTargetListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.internal.target;
|
||||
|
||||
import org.eclipse.launchbar.core.internal.Messages;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
|
||||
import org.eclipse.launchbar.core.target.TargetStatus;
|
||||
|
||||
public class LocalLaunchTargetProvider implements ILaunchTargetProvider {
|
||||
|
||||
@Override
|
||||
public void init(ILaunchTargetManager targetManager) {
|
||||
if (targetManager.getLaunchTarget(ILaunchTargetManager.localLaunchTargetTypeId,
|
||||
Messages.LocalTarget_name) == null) {
|
||||
targetManager.addLaunchTarget(ILaunchTargetManager.localLaunchTargetTypeId, Messages.LocalTarget_name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetStatus getStatus(ILaunchTarget target) {
|
||||
return TargetStatus.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.target;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
||||
/**
|
||||
* A launch target is a thing that a launch will run on. Launch targets are
|
||||
* simple objects with the intention that the launch delegates and launches will
|
||||
* adapt this object to an object that will assist in performing the launch.
|
||||
*
|
||||
* @noimplement not to be implemented by clients
|
||||
*/
|
||||
public interface ILaunchTarget extends IAdaptable {
|
||||
|
||||
/**
|
||||
* The name of the target.
|
||||
*
|
||||
* @return name of the target
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* The type of the target.
|
||||
*
|
||||
* @return type of the target
|
||||
*/
|
||||
String getTypeId();
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.target;
|
||||
|
||||
/**
|
||||
* A listener to changes in the list and status of launch targets.
|
||||
*/
|
||||
public interface ILaunchTargetListener {
|
||||
|
||||
/**
|
||||
* A launch target was added.
|
||||
*
|
||||
* @param target
|
||||
* the new launch target
|
||||
*/
|
||||
default void launchTargetAdded(ILaunchTarget target) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A launch target was removed.
|
||||
*
|
||||
* @param target
|
||||
* the target about to be removed.
|
||||
*/
|
||||
default void launchTargetRemoved(ILaunchTarget target) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The status of a target has changed. Query the target to find out what the
|
||||
* new status is.
|
||||
*
|
||||
* @param target
|
||||
* the target whose status has changed
|
||||
*/
|
||||
default void launchTargetStatusChanged(ILaunchTarget target) {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.target;
|
||||
|
||||
/**
|
||||
* The manager for the launch targets. It is registered as an OSGi service.
|
||||
*
|
||||
* @noimplement not to be implemented by clients
|
||||
*/
|
||||
public interface ILaunchTargetManager {
|
||||
|
||||
/**
|
||||
* The type id for the local launch target type. It is the default launch
|
||||
* target type. It represents launching on the underlying machine on which
|
||||
* we are running. There is only one launch target of this type which
|
||||
* represents that machine.
|
||||
*/
|
||||
final String localLaunchTargetTypeId = "org.eclipse.launchbar.core.launchTargetType.local"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The list of all launch targets.
|
||||
*
|
||||
* @return list of launch targets
|
||||
*/
|
||||
ILaunchTarget[] getLaunchTargets();
|
||||
|
||||
/**
|
||||
* The list of launch targets with a given type id.
|
||||
*
|
||||
* @param typeId
|
||||
* the launch target type id
|
||||
* @return list of launch targets
|
||||
*/
|
||||
ILaunchTarget[] getLaunchTargetsOfType(String typeId);
|
||||
|
||||
/**
|
||||
* Return the launch target with the given typeId and name
|
||||
*
|
||||
* @param typeId
|
||||
* type of the launch target
|
||||
* @param name
|
||||
* name of the launch target
|
||||
* @return the launch target
|
||||
*/
|
||||
ILaunchTarget getLaunchTarget(String typeId, String name);
|
||||
|
||||
/**
|
||||
* Return the status of the launch target.
|
||||
*
|
||||
* @param target
|
||||
* the launch target
|
||||
* @return status
|
||||
*/
|
||||
TargetStatus getStatus(ILaunchTarget target);
|
||||
|
||||
/**
|
||||
* Add a launch target with the given typeId and name.
|
||||
*
|
||||
* @param typeId
|
||||
* type id of the launch target
|
||||
* @param name
|
||||
* name of the launch target
|
||||
* @return the created launch target
|
||||
*/
|
||||
ILaunchTarget addLaunchTarget(String typeId, String name);
|
||||
|
||||
/**
|
||||
* Removes a launch target.
|
||||
*
|
||||
* @param target
|
||||
* the launch target to remove
|
||||
*/
|
||||
void removeLaunchTarget(ILaunchTarget target);
|
||||
|
||||
/**
|
||||
* The status of the launch target has changed.
|
||||
*
|
||||
* @param target
|
||||
*/
|
||||
void targetStatusChanged(ILaunchTarget target);
|
||||
|
||||
/**
|
||||
* Add a listener.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void addListener(ILaunchTargetListener listener);
|
||||
|
||||
/**
|
||||
* Remove a listener.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void removeListener(ILaunchTargetListener listener);
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.eclipse.launchbar.core.target;
|
||||
|
||||
/**
|
||||
* A launch target provider is responsible for managing the list and status of
|
||||
* launch targets. Providers are associated with launch target types in the
|
||||
* launchTargetTypes extension point.
|
||||
*/
|
||||
public interface ILaunchTargetProvider {
|
||||
|
||||
/**
|
||||
* Called by the launch target manager when it first sees a target of the
|
||||
* type. Or on startup if the provider is enabled. It is expected the
|
||||
* provider will sync the list of targets with it's internal list and alert
|
||||
* the manager of any non-OK statuses.
|
||||
*
|
||||
* @param targetManager
|
||||
*/
|
||||
void init(ILaunchTargetManager targetManager);
|
||||
|
||||
/**
|
||||
* Fetch the status for the launch target.
|
||||
*
|
||||
* @param target
|
||||
* the launch target
|
||||
* @return status of the launch target
|
||||
*/
|
||||
TargetStatus getStatus(ILaunchTarget target);
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.eclipse.launchbar.core.target;
|
||||
|
||||
import org.eclipse.launchbar.core.internal.Messages;
|
||||
|
||||
/**
|
||||
* The status for a launch target.
|
||||
*/
|
||||
public class TargetStatus {
|
||||
|
||||
public enum Code {
|
||||
OK, WARNING, ERROR
|
||||
}
|
||||
|
||||
private final TargetStatus.Code code;
|
||||
private final String message;
|
||||
|
||||
public static final TargetStatus OK_STATUS = new TargetStatus(Code.OK, Messages.OK);
|
||||
|
||||
public TargetStatus(TargetStatus.Code code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public TargetStatus.Code getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.target.launch;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
/**
|
||||
* An ILaunchConfigurationDelegate2 converted to take ILaunchTarget as an
|
||||
* additional parameter.
|
||||
*/
|
||||
public interface ILaunchConfigurationTargetedDelegate extends ILaunchConfigurationDelegate {
|
||||
|
||||
/**
|
||||
* Returns a launch object to use when launching the given launch
|
||||
* configuration in the given mode, or <code>null</code> if a new default
|
||||
* launch object should be created by the debug platform. If a launch object
|
||||
* is returned, its launch mode must match that of the mode specified in
|
||||
* this method call.
|
||||
*
|
||||
* @param configuration
|
||||
* the configuration being launched
|
||||
* @param mode
|
||||
* the mode the configuration is being launched in
|
||||
* @return a launch object or <code>null</code>
|
||||
* @throws CoreException
|
||||
* if unable to launch
|
||||
*/
|
||||
public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
|
||||
throws CoreException;
|
||||
|
||||
/**
|
||||
* Optionally performs any required building before launching the given
|
||||
* configuration in the specified mode, and returns whether the debug
|
||||
* platform should perform an incremental workspace build before the launch
|
||||
* continues. If <code>false</code> is returned the launch will proceed
|
||||
* without further building, and if <code>true</code> is returned an
|
||||
* incremental build will be performed on the workspace before launching.
|
||||
* <p>
|
||||
* This method is only called if the launch is invoked with flag indicating
|
||||
* building should take place before the launch. This is done via the method
|
||||
* <code>ILaunchConfiguration.launch(String mode, IProgressMonitor monitor, boolean build)</code>
|
||||
* .
|
||||
* </p>
|
||||
*
|
||||
* @param configuration
|
||||
* the configuration being launched
|
||||
* @param mode
|
||||
* the mode the configuration is being launched in
|
||||
* @param monitor
|
||||
* progress monitor, or <code>null</code>. A cancelable progress
|
||||
* monitor is provided by the Job framework. It should be noted
|
||||
* that the setCanceled(boolean) method should never be called on
|
||||
* the provided monitor or the monitor passed to any delegates
|
||||
* from this method; due to a limitation in the progress monitor
|
||||
* framework using the setCanceled method can cause entire
|
||||
* workspace batch jobs to be canceled, as the canceled flag is
|
||||
* propagated up the top-level parent monitor. The provided
|
||||
* monitor is not guaranteed to have been started.
|
||||
* @return whether the debug platform should perform an incremental
|
||||
* workspace build before the launch
|
||||
* @throws CoreException
|
||||
* if an exception occurs while building
|
||||
*/
|
||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
|
||||
IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns whether a launch should proceed. This method is called after
|
||||
* <code>preLaunchCheck()</code> and <code>buildForLaunch()</code> providing
|
||||
* a final chance for this launch delegate to abort a launch if required.
|
||||
* For example, a delegate could cancel a launch if it discovered
|
||||
* compilation errors that would prevent the launch from succeeding.
|
||||
*
|
||||
* @param configuration
|
||||
* the configuration being launched
|
||||
* @param mode
|
||||
* launch mode
|
||||
* @param monitor
|
||||
* progress monitor, or <code>null</code>. A cancelable progress
|
||||
* monitor is provided by the Job framework. It should be noted
|
||||
* that the setCanceled(boolean) method should never be called on
|
||||
* the provided monitor or the monitor passed to any delegates
|
||||
* from this method; due to a limitation in the progress monitor
|
||||
* framework using the setCanceled method can cause entire
|
||||
* workspace batch jobs to be canceled, as the canceled flag is
|
||||
* propagated up the top-level parent monitor. The provided
|
||||
* monitor is not guaranteed to have been started.
|
||||
* @return whether the launch should proceed
|
||||
* @throws CoreException
|
||||
* if an exception occurs during final checks
|
||||
*/
|
||||
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
|
||||
IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns whether a launch should proceed. This method is called first in
|
||||
* the launch sequence providing an opportunity for this launch delegate to
|
||||
* abort the launch.
|
||||
*
|
||||
* @param configuration
|
||||
* configuration being launched
|
||||
* @param mode
|
||||
* launch mode
|
||||
* @param monitor
|
||||
* progress monitor, or <code>null</code>. A cancelable progress
|
||||
* monitor is provided by the Job framework. It should be noted
|
||||
* that the setCanceled(boolean) method should never be called on
|
||||
* the provided monitor or the monitor passed to any delegates
|
||||
* from this method; due to a limitation in the progress monitor
|
||||
* framework using the setCanceled method can cause entire
|
||||
* workspace batch jobs to be canceled, as the canceled flag is
|
||||
* propagated up the top-level parent monitor. The provided
|
||||
* monitor is not guaranteed to have been started.
|
||||
* @return whether the launch should proceed
|
||||
* @throws CoreException
|
||||
* if an exception occurs while performing pre-launch checks
|
||||
*/
|
||||
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
|
||||
IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.target.launch;
|
||||
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
/**
|
||||
* A launch that knows what target it's running on.
|
||||
*/
|
||||
public interface ITargetedLaunch extends ILaunch {
|
||||
|
||||
/**
|
||||
* The target this launch will or is running on.
|
||||
*
|
||||
* @return launch target
|
||||
*/
|
||||
ILaunchTarget getLaunchTarget();
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LaunchBar UI
|
||||
Bundle-SymbolicName: org.eclipse.launchbar.ui;singleton:=true
|
||||
Bundle-Version: 1.0.1.qualifier
|
||||
Bundle-Version: 2.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.launchbar.ui.internal.Activator
|
||||
Bundle-Vendor: Eclipse CDT
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
|
@ -14,14 +14,9 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.osgi.services,
|
||||
org.eclipse.launchbar.core,
|
||||
org.eclipse.debug.ui,
|
||||
org.eclipse.ui.workbench,
|
||||
org.eclipse.ui.ide,
|
||||
org.eclipse.swt,
|
||||
org.eclipse.ui.navigator,
|
||||
org.eclipse.remote.core;bundle-version="2.0.0",
|
||||
org.eclipse.remote.ui;bundle-version="1.1.0",
|
||||
org.eclipse.e4.core.contexts
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Localization: plugin
|
||||
Export-Package: org.eclipse.launchbar.ui,
|
||||
|
|
|
@ -5,4 +5,5 @@ bin.includes = META-INF/,\
|
|||
plugin.xml,\
|
||||
icons/,\
|
||||
plugin.properties,\
|
||||
about.html
|
||||
about.html,\
|
||||
schema/
|
||||
|
|
BIN
bundles/org.eclipse.launchbar.ui/icons/localTarget.png
Normal file
BIN
bundles/org.eclipse.launchbar.ui/icons/localTarget.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 452 B |
|
@ -2,6 +2,7 @@
|
|||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension-point id="launchBarUIContributions" name="launchBar UI Contributions" schema="schema/launchBarUIContributions.exsd"/>
|
||||
<extension-point id="launchTargetTypeUI" name="Launch Target Type UI" schema="schema/launchTargetTypeUI.exsd"/>
|
||||
<extension
|
||||
id="launchBarInjector"
|
||||
point="org.eclipse.e4.workbench.model">
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.launchbar.ui</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
112
bundles/org.eclipse.launchbar.ui/schema/launchTargetTypeUI.exsd
Normal file
112
bundles/org.eclipse.launchbar.ui/schema/launchTargetTypeUI.exsd
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.launchbar.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.eclipse.launchbar.ui" id="launchTargetTypeUI" name="Launch Target Type UI"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="launchTargetTypeUI" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="launchTargetTypeUI">
|
||||
<complexType>
|
||||
<attribute name="id" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="identifier" basedOn="org.eclipse.launchbar.core.launchTargetTypes/launchTargetType/@id"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="labelProvider" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.jface.viewers.ILabelProvider"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter the first release in which this extension point appears.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
|
@ -1,36 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 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
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Schaefer
|
||||
*******************************************************************************/
|
||||
package org.eclipse.launchbar.ui;
|
||||
|
||||
/**
|
||||
* An extension to allow different object types to provide fancy hovers.
|
||||
*
|
||||
* TODO this does lead to inconsistency when different types provide different hover UI
|
||||
* which can confuse users. We should provide good UI out of the box.
|
||||
*/
|
||||
public interface IHoverProvider {
|
||||
|
||||
/**
|
||||
* Display the hover item.
|
||||
*
|
||||
* @return true if hover item was displayed, otherwise false
|
||||
*/
|
||||
public abstract boolean displayHover(Object element);
|
||||
|
||||
/**
|
||||
* Dismiss the hover item.
|
||||
*
|
||||
* @param immediate
|
||||
* if true, the hover item will be immediately dismissed, otherwise it may be be dismissed at a later time.
|
||||
*/
|
||||
public abstract void dismissHover(Object element, boolean immediate);
|
||||
|
||||
}
|
|
@ -24,6 +24,8 @@ import org.eclipse.jface.resource.ImageDescriptor;
|
|||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.launchbar.ui.internal.target.LaunchTargetUIManager;
|
||||
import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
@ -45,6 +47,7 @@ public class Activator extends AbstractUIPlugin {
|
|||
public static final String IMG_BUTTON_BUILD = "build"; //$NON-NLS-1$
|
||||
public static final String IMG_BUTTON_LAUNCH = "launch"; //$NON-NLS-1$
|
||||
public static final String IMG_BUTTON_STOP = "stop"; //$NON-NLS-1$
|
||||
public static final String IMG_LOCAL_TARGET = "localTarget"; //$NON-NLS-1$
|
||||
|
||||
// Command ids
|
||||
public static final String CMD_BUILD = PLUGIN_ID + ".command.buildActive"; //$NON-NLS-1$
|
||||
|
@ -61,7 +64,7 @@ public class Activator extends AbstractUIPlugin {
|
|||
private static Activator plugin;
|
||||
|
||||
// The cache of the Launch Bar UI Manager Object
|
||||
private LaunchBarUIManager launchBarUIManager;
|
||||
private LaunchBarUIManager launchBarUIManager;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
|
@ -77,6 +80,9 @@ public class Activator extends AbstractUIPlugin {
|
|||
imageRegistry.put(IMG_BUTTON_BUILD, imageDescriptorFromPlugin(PLUGIN_ID, "icons/build.png")); //$NON-NLS-1$
|
||||
imageRegistry.put(IMG_BUTTON_LAUNCH, imageDescriptorFromPlugin(PLUGIN_ID, "icons/launch.png")); //$NON-NLS-1$
|
||||
imageRegistry.put(IMG_BUTTON_STOP, imageDescriptorFromPlugin(PLUGIN_ID, "icons/stop.png")); //$NON-NLS-1$
|
||||
imageRegistry.put(IMG_LOCAL_TARGET, imageDescriptorFromPlugin(PLUGIN_ID, "icons/localTarget.png")); //$NON-NLS-1$
|
||||
|
||||
context.registerService(ILaunchTargetUIManager.class, new LaunchTargetUIManager(), null);
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
|
|
|
@ -58,8 +58,9 @@ public class Messages extends NLS {
|
|||
public static String NewLaunchConfigWizard_0;
|
||||
public static String StopActiveCommandHandler_0;
|
||||
public static String StopActiveCommandHandler_1;
|
||||
public static String TargetSelector_ToolTipPrefix;
|
||||
public static String TargetSelector_CreateNewTarget;
|
||||
|
||||
|
||||
public static String DescriptorMustNotBeNull;
|
||||
public static String DescriptorMustNotBeNullDesc;
|
||||
public static String NoActiveTarget;
|
||||
|
@ -72,9 +73,7 @@ public class Messages extends NLS {
|
|||
public static String LaunchConfigurationNotFoundDesc;
|
||||
public static String NoLaunchTabsDefined;
|
||||
public static String NoLaunchTabsDefinedDesc;
|
||||
|
||||
|
||||
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
|
|
|
@ -28,10 +28,10 @@ import org.eclipse.debug.ui.ILaunchGroup;
|
|||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
|
@ -46,83 +46,97 @@ public class ConfigureActiveLaunchHandler extends AbstractHandler {
|
|||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
|
||||
public static IStatus canOpenConfigurationEditor(ILaunchDescriptor desc) {
|
||||
if (desc == null)
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.DescriptorMustNotBeNull, new Exception(Messages.DescriptorMustNotBeNullDesc));
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.DescriptorMustNotBeNull,
|
||||
new Exception(Messages.DescriptorMustNotBeNullDesc));
|
||||
LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
||||
ILaunchMode mode = manager.getActiveLaunchMode();
|
||||
IRemoteConnection target = manager.getActiveLaunchTarget();
|
||||
ILaunchTarget target = manager.getActiveLaunchTarget();
|
||||
if (target == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoActiveTarget, new Exception(Messages.NoActiveTargetDesc));
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoActiveTarget,
|
||||
new Exception(Messages.NoActiveTargetDesc));
|
||||
}
|
||||
|
||||
|
||||
ILaunchConfigurationType configType = null;
|
||||
try {
|
||||
configType = manager.getLaunchConfigurationType(desc, target);
|
||||
} catch(CoreException ce) {/* ignore */ };
|
||||
} catch (CoreException ce) {
|
||||
/* ignore */ }
|
||||
;
|
||||
if (configType == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchConfigType, new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchConfigType,
|
||||
new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
}
|
||||
|
||||
if( mode == null ) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected, new Exception(Messages.NoLaunchModeSelected));
|
||||
|
||||
if (mode == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected,
|
||||
new Exception(Messages.NoLaunchModeSelected));
|
||||
}
|
||||
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType, mode.getIdentifier());
|
||||
if( group == null ) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchGroupSelected, new Exception(Messages.NoLaunchGroupSelected));
|
||||
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType,
|
||||
mode.getIdentifier());
|
||||
if (group == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchGroupSelected,
|
||||
new Exception(Messages.NoLaunchGroupSelected));
|
||||
}
|
||||
|
||||
|
||||
String mode2 = group.getMode();
|
||||
if( mode2 == null ) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected, new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
if (mode2 == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected,
|
||||
new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
}
|
||||
|
||||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier());
|
||||
|
||||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
|
||||
.getLaunchGroup(group.getIdentifier());
|
||||
if (groupExt != null) {
|
||||
ILaunchConfiguration config = null;
|
||||
try {
|
||||
config = manager.getLaunchConfiguration(desc, target);
|
||||
} catch(CoreException ce) {
|
||||
} catch (CoreException ce) {
|
||||
// Ignore
|
||||
}
|
||||
if (config == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LaunchConfigurationNotFound, new Exception(Messages.LaunchConfigurationNotFoundDesc));
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LaunchConfigurationNotFound,
|
||||
new Exception(Messages.LaunchConfigurationNotFoundDesc));
|
||||
}
|
||||
try {
|
||||
LaunchConfigurationPresentationManager mgr = LaunchConfigurationPresentationManager.getDefault();
|
||||
ILaunchConfigurationTabGroup tabgroup = mgr.getTabGroup(config, mode.getIdentifier());
|
||||
} catch(CoreException ce) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID,Messages.NoLaunchTabsDefined, new Exception(Messages.NoLaunchTabsDefinedDesc));
|
||||
} catch (CoreException ce) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchTabsDefined,
|
||||
new Exception(Messages.NoLaunchTabsDefinedDesc));
|
||||
}
|
||||
} else {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CannotEditLaunchConfiguration, new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CannotEditLaunchConfiguration,
|
||||
new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void openConfigurationEditor(ILaunchDescriptor desc) {
|
||||
if (desc == null)
|
||||
return;
|
||||
|
||||
|
||||
// Display the error message
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||
IStatus s = canOpenConfigurationEditor(desc);
|
||||
if( !s.isOK()) {
|
||||
MessageDialog.openError(shell, s.getMessage(), s.getException() == null ? s.getMessage() : s.getException().getMessage());
|
||||
if (!s.isOK()) {
|
||||
MessageDialog.openError(shell, s.getMessage(),
|
||||
s.getException() == null ? s.getMessage() : s.getException().getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
// At this point, no error handling should be needed.
|
||||
|
||||
// At this point, no error handling should be needed.
|
||||
try {
|
||||
LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
||||
ILaunchMode mode = manager.getActiveLaunchMode();
|
||||
IRemoteConnection target = manager.getActiveLaunchTarget();
|
||||
ILaunchTarget target = manager.getActiveLaunchTarget();
|
||||
ILaunchConfigurationType configType = manager.getLaunchConfigurationType(desc, target);
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType, mode.getIdentifier());
|
||||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier());
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType,
|
||||
mode.getIdentifier());
|
||||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
|
||||
.getLaunchGroup(group.getIdentifier());
|
||||
ILaunchConfiguration config = manager.getLaunchConfiguration(desc, target);
|
||||
if (config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).isDirty()) {
|
||||
config = ((ILaunchConfigurationWorkingCopy) config).doSave();
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.launchbar.ui.IHoverProvider;
|
||||
import org.eclipse.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -32,7 +31,6 @@ import org.eclipse.swt.events.DisposeListener;
|
|||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
import org.eclipse.swt.events.MouseTrackListener;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
|
@ -57,13 +55,10 @@ import org.eclipse.ui.PlatformUI;
|
|||
public abstract class CSelector extends Composite {
|
||||
private IStructuredContentProvider contentProvider;
|
||||
private ILabelProvider labelProvider;
|
||||
private IHoverProvider hoverProvider;
|
||||
private Comparator<?> sorter;
|
||||
private Comparator<?> sorterTop;
|
||||
private Object input;
|
||||
private Composite buttonComposite;
|
||||
private String toolTipText;
|
||||
private boolean toolTipWasModified; // Used for the hover provider
|
||||
private static final int arrowMax = 2;
|
||||
private Transition arrowTransition;
|
||||
private Object selection;
|
||||
|
@ -77,51 +72,7 @@ public abstract class CSelector extends Composite {
|
|||
private Shell popup;
|
||||
private LaunchBarListViewer listViewer;
|
||||
private Job delayJob;
|
||||
private MouseTrackListener mouseTrackListener = new MouseTrackListener() {
|
||||
@Override
|
||||
public void mouseEnter(MouseEvent e) {
|
||||
if (!mouseOver) {
|
||||
mouseOver = true;
|
||||
redraw();
|
||||
if (toolTipWasModified) {
|
||||
buttonComposite.setToolTipText(toolTipText);
|
||||
if (currentLabel != null) {
|
||||
currentLabel.setToolTipText(toolTipText);
|
||||
}
|
||||
if (currentIcon != null) {
|
||||
currentIcon.setToolTipText(toolTipText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseHover(MouseEvent e) {
|
||||
if (hoverProvider != null && (popup == null || popup.isDisposed())) {
|
||||
final Object eventSource = e.getSource();
|
||||
if ((eventSource == currentLabel || eventSource == buttonComposite || eventSource == currentIcon)) {
|
||||
if (hoverProvider.displayHover(selection)) {
|
||||
buttonComposite.setToolTipText(""); //$NON-NLS-1$
|
||||
if (currentLabel != null) {
|
||||
currentLabel.setToolTipText(""); //$NON-NLS-1$
|
||||
}
|
||||
if (currentIcon != null) {
|
||||
currentIcon.setToolTipText(""); //$NON-NLS-1$
|
||||
}
|
||||
toolTipWasModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExit(MouseEvent e) {
|
||||
if (mouseOver) {
|
||||
mouseOver = false;
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
};
|
||||
private MouseListener mouseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseUp(MouseEvent event) {
|
||||
|
@ -159,8 +110,10 @@ public abstract class CSelector extends Composite {
|
|||
break;
|
||||
case SWT.FocusOut:
|
||||
if (isPopUpInFocus()) {
|
||||
// we about to loose focus from popup children, but it may go
|
||||
// to another child, lets schedule a job to wait before we close
|
||||
// we about to loose focus from popup children, but it may
|
||||
// go
|
||||
// to another child, lets schedule a job to wait before we
|
||||
// close
|
||||
if (closingJob != null)
|
||||
closingJob.cancel();
|
||||
closingJob = new Job(Messages.CSelector_0) {
|
||||
|
@ -212,7 +165,6 @@ public abstract class CSelector extends Composite {
|
|||
}
|
||||
});
|
||||
addMouseListener(mouseListener);
|
||||
addMouseTrackListener(mouseTrackListener);
|
||||
}
|
||||
|
||||
private boolean isPopUpInFocus() {
|
||||
|
@ -260,7 +212,7 @@ public abstract class CSelector extends Composite {
|
|||
this.selection = element;
|
||||
if (buttonComposite != null)
|
||||
buttonComposite.dispose();
|
||||
toolTipText = getToolTipText();
|
||||
String toolTipText = getToolTipText();
|
||||
boolean editable = false;
|
||||
int columns = 2;
|
||||
Image image = labelProvider.getImage(element);
|
||||
|
@ -276,19 +228,16 @@ public abstract class CSelector extends Composite {
|
|||
buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
buttonComposite.setBackground(backgroundColor);
|
||||
buttonComposite.addMouseListener(mouseListener);
|
||||
buttonComposite.addMouseTrackListener(mouseTrackListener);
|
||||
buttonComposite.setToolTipText(toolTipText);
|
||||
if (element != null) {
|
||||
if (image != null) {
|
||||
Label icon = createImage(buttonComposite, image);
|
||||
icon.addMouseListener(mouseListener);
|
||||
icon.addMouseTrackListener(mouseTrackListener);
|
||||
currentIcon = icon;
|
||||
currentIcon.setToolTipText(toolTipText);
|
||||
}
|
||||
Label label = createLabel(buttonComposite, element);
|
||||
label.addMouseListener(mouseListener);
|
||||
label.addMouseTrackListener(mouseTrackListener);
|
||||
currentLabel = label;
|
||||
currentLabel.setToolTipText(toolTipText);
|
||||
} else {
|
||||
|
@ -318,15 +267,11 @@ public abstract class CSelector extends Composite {
|
|||
Rectangle bounds = arrow.getBounds();
|
||||
int arrowWidth = bounds.width - hPadding * 2;
|
||||
int current = arrowTransition.getCurrent();
|
||||
gc.drawPolyline(new int[] { hPadding,
|
||||
bounds.height / 2 - current,
|
||||
hPadding + (arrowWidth / 2),
|
||||
bounds.height / 2 + current, hPadding + arrowWidth,
|
||||
bounds.height / 2 - current });
|
||||
gc.drawPolyline(new int[] { hPadding, bounds.height / 2 - current, hPadding + (arrowWidth / 2),
|
||||
bounds.height / 2 + current, hPadding + arrowWidth, bounds.height / 2 - current });
|
||||
}
|
||||
});
|
||||
arrow.addMouseListener(mouseListener);
|
||||
arrow.addMouseTrackListener(mouseTrackListener);
|
||||
if (editable) {
|
||||
final EditButton editButton = new EditButton(buttonComposite, SWT.NONE);
|
||||
editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
||||
|
@ -359,10 +304,6 @@ public abstract class CSelector extends Composite {
|
|||
return mouseListener;
|
||||
}
|
||||
|
||||
public MouseTrackListener getMouseTrackListener() {
|
||||
return mouseTrackListener;
|
||||
}
|
||||
|
||||
protected void openPopup() {
|
||||
Object[] elements = contentProvider.getElements(input);
|
||||
if (elements.length == 0 && !hasActionArea())
|
||||
|
@ -374,7 +315,6 @@ public abstract class CSelector extends Composite {
|
|||
popup = new Shell(getShell(), SWT.TOOL | SWT.ON_TOP | SWT.RESIZE);
|
||||
popup.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create());
|
||||
|
||||
|
||||
listViewer = new LaunchBarListViewer(popup);
|
||||
initializeListViewer(listViewer);
|
||||
listViewer.setFilterVisible(elements.length > 7);
|
||||
|
@ -395,8 +335,7 @@ public abstract class CSelector extends Composite {
|
|||
if (hasActionArea())
|
||||
createActionArea(popup);
|
||||
Rectangle buttonBounds = getBounds();
|
||||
Point popupLocation = popup.getDisplay().map(this, null, 0,
|
||||
buttonBounds.height);
|
||||
Point popupLocation = popup.getDisplay().map(this, null, 0, buttonBounds.height);
|
||||
popup.setLocation(popupLocation.x, popupLocation.y + 5);
|
||||
|
||||
restoreShellSize();
|
||||
|
@ -415,9 +354,6 @@ public abstract class CSelector extends Composite {
|
|||
}
|
||||
|
||||
});
|
||||
if (hoverProvider != null) {
|
||||
hoverProvider.dismissHover(selection != null ? selection : null, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getDialogPreferencePrefix() {
|
||||
|
@ -432,8 +368,8 @@ public abstract class CSelector extends Composite {
|
|||
try {
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
String prefName = getDialogPreferencePrefix();
|
||||
int w = store.getInt(prefName + ".shell.w");
|
||||
int h = store.getInt(prefName + ".shell.h");
|
||||
int w = store.getInt(prefName + ".shell.w"); //$NON-NLS-1$
|
||||
int h = store.getInt(prefName + ".shell.h"); //$NON-NLS-1$
|
||||
size.x = Math.max(size.x, w);
|
||||
size.y = Math.max(size.y, h);
|
||||
} catch (Exception e) {
|
||||
|
@ -446,8 +382,8 @@ public abstract class CSelector extends Composite {
|
|||
Point size = popup.getSize();
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
String prefName = getDialogPreferencePrefix();
|
||||
store.setValue(prefName + ".shell.w", size.x);
|
||||
store.setValue(prefName + ".shell.h", size.y);
|
||||
store.setValue(prefName + ".shell.w", size.x); //$NON-NLS-1$
|
||||
store.setValue(prefName + ".shell.h", size.y); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected void initializeListViewer(LaunchBarListViewer listViewer) {
|
||||
|
@ -478,8 +414,7 @@ public abstract class CSelector extends Composite {
|
|||
GC gc = new GC(buttonImage);
|
||||
gc.setAntialias(SWT.ON);
|
||||
gc.setInterpolation(SWT.HIGH);
|
||||
gc.drawImage(image, 0, 0, image.getBounds().width,
|
||||
image.getBounds().height, 0, 0, 16, 16);
|
||||
gc.drawImage(image, 0, 0, image.getBounds().width, image.getBounds().height, 0, 0, 16, 16);
|
||||
gc.dispose();
|
||||
image = buttonImage;
|
||||
disposeImage = true;
|
||||
|
@ -523,12 +458,18 @@ public abstract class CSelector extends Composite {
|
|||
return labelProvider;
|
||||
}
|
||||
|
||||
public void setHoverProvider(IHoverProvider hoverProvider) {
|
||||
this.hoverProvider = hoverProvider;
|
||||
}
|
||||
|
||||
public IHoverProvider getHoverProvider() {
|
||||
return hoverProvider;
|
||||
@Override
|
||||
public void setToolTipText(String toolTipText) {
|
||||
super.setToolTipText(toolTipText);
|
||||
if (buttonComposite != null) {
|
||||
buttonComposite.setToolTipText(toolTipText);
|
||||
}
|
||||
if (currentLabel != null) {
|
||||
currentLabel.setToolTipText(toolTipText);
|
||||
}
|
||||
if (currentIcon != null) {
|
||||
currentIcon.setToolTipText(toolTipText);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -561,7 +502,8 @@ public abstract class CSelector extends Composite {
|
|||
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
update(selection); // update current selection - name or icon may have changed
|
||||
update(selection); // update current selection - name or icon
|
||||
// may have changed
|
||||
if (popup != null && !popup.isDisposed()) {
|
||||
listViewer.refresh(true); // update all labels in the popup
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
|||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager.Listener;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
|
@ -36,7 +36,8 @@ import org.eclipse.swt.widgets.ToolItem;
|
|||
|
||||
public class LaunchBarControl implements Listener {
|
||||
public static final String ID = "org.eclipse.launchbar"; //$NON-NLS-1$
|
||||
public static final String CLASS_URI = "bundleclass://" + Activator.PLUGIN_ID + "/" + LaunchBarControl.class.getName(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
public static final String CLASS_URI = "bundleclass://" + Activator.PLUGIN_ID + "/" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ LaunchBarControl.class.getName();
|
||||
|
||||
private LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
||||
|
||||
|
@ -82,7 +83,7 @@ public class LaunchBarControl implements Listener {
|
|||
Label label = new Label(container, SWT.NONE);
|
||||
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
label.setText(Messages.LaunchBarControl_0 + ":"); //$NON-NLS-1$
|
||||
|
||||
|
||||
targetSelector = new TargetSelector(container, SWT.NONE);
|
||||
targetSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
targetSelector.setInput(manager);
|
||||
|
@ -107,9 +108,10 @@ public class LaunchBarControl implements Listener {
|
|||
|
||||
private void createButton(Composite parent, String imageName, String toolTipText, final String command) {
|
||||
ToolItem button = new ToolItem((ToolBar) parent, SWT.FLAT);
|
||||
//button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
|
||||
// button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
|
||||
Image srcImage = Activator.getDefault().getImage(imageName);
|
||||
//Image image = new Image(parent.getDisplay(), srcImage, SWT.IMAGE_COPY);
|
||||
// Image image = new Image(parent.getDisplay(), srcImage,
|
||||
// SWT.IMAGE_COPY);
|
||||
button.setImage(srcImage);
|
||||
button.setToolTipText(toolTipText);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -139,7 +141,7 @@ public class LaunchBarControl implements Listener {
|
|||
@Override
|
||||
public void activeLaunchTargetChanged() {
|
||||
if (targetSelector != null) {
|
||||
final IRemoteConnection target = manager.getActiveLaunchTarget();
|
||||
final ILaunchTarget target = manager.getActiveLaunchTarget();
|
||||
targetSelector.setDelayedSelection(target, SELECTION_DELAY);
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +154,7 @@ public class LaunchBarControl implements Listener {
|
|||
|
||||
@Override
|
||||
public void launchTargetsChanged() {
|
||||
if (targetSelector!=null){
|
||||
if (targetSelector != null) {
|
||||
targetSelector.refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,9 +48,11 @@ public class ModeSelector extends CSelector {
|
|||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
try {
|
||||
|
@ -66,6 +68,7 @@ public class ModeSelector extends CSelector {
|
|||
|
||||
setLabelProvider(new LabelProvider() {
|
||||
private Map<ImageDescriptor, Image> images = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
@ -73,13 +76,14 @@ public class ModeSelector extends CSelector {
|
|||
image.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof ILaunchMode) {
|
||||
ILaunchMode mode = (ILaunchMode) element;
|
||||
try {
|
||||
ILaunchGroup group = getLaunchGroup(mode.getIdentifier());
|
||||
if( group == null ) {
|
||||
if (group == null) {
|
||||
group = getDefaultLaunchGroup(mode.getIdentifier());
|
||||
}
|
||||
if (group != null) {
|
||||
|
@ -99,13 +103,14 @@ public class ModeSelector extends CSelector {
|
|||
}
|
||||
return super.getImage(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if (element instanceof ILaunchMode) {
|
||||
ILaunchMode mode = (ILaunchMode) element;
|
||||
try {
|
||||
ILaunchGroup group = getLaunchGroup(mode.getIdentifier());
|
||||
if( group == null ) {
|
||||
if (group == null) {
|
||||
group = getDefaultLaunchGroup(mode.getIdentifier());
|
||||
}
|
||||
if (group != null) {
|
||||
|
@ -123,8 +128,8 @@ public class ModeSelector extends CSelector {
|
|||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (o1 instanceof ILaunchMode && o2 instanceof ILaunchMode) {
|
||||
String mode1 = ((ILaunchMode)o1).getIdentifier();
|
||||
String mode2 = ((ILaunchMode)o2).getIdentifier();
|
||||
String mode1 = ((ILaunchMode) o1).getIdentifier();
|
||||
String mode2 = ((ILaunchMode) o2).getIdentifier();
|
||||
// run comes first, then debug, then the rest
|
||||
if (mode1.equals("run")) { //$NON-NLS-1$
|
||||
if (mode2.equals("run")) //$NON-NLS-1$
|
||||
|
@ -152,18 +157,19 @@ public class ModeSelector extends CSelector {
|
|||
String groupId = null;
|
||||
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||
groupId = IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP;
|
||||
} else if( mode.equals(ILaunchManager.PROFILE_MODE)) {
|
||||
} else if (mode.equals(ILaunchManager.PROFILE_MODE)) {
|
||||
groupId = IDebugUIConstants.ID_PROFILE_LAUNCH_GROUP;
|
||||
} else {
|
||||
groupId = IDebugUIConstants.ID_RUN_LAUNCH_GROUP;
|
||||
}
|
||||
if( groupId != null )
|
||||
if (groupId != null)
|
||||
return DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(groupId);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected ILaunchGroup getLaunchGroup(String mode) throws CoreException {
|
||||
ILaunchConfigurationType type = manager.getLaunchConfigurationType(manager.getActiveLaunchDescriptor(), manager.getActiveLaunchTarget());
|
||||
ILaunchConfigurationType type = manager.getLaunchConfigurationType(manager.getActiveLaunchDescriptor(),
|
||||
manager.getActiveLaunchTarget());
|
||||
if (type == null)
|
||||
return null;
|
||||
return DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(type, mode);
|
||||
|
@ -179,7 +185,8 @@ public class ModeSelector extends CSelector {
|
|||
} catch (CoreException e) {
|
||||
Activator.log(e.getStatus());
|
||||
} catch (Exception e) {
|
||||
// manager can throw illegal state exception hopefully we never get it
|
||||
// manager can throw illegal state exception hopefully we never
|
||||
// get it
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,54 +13,49 @@ package org.eclipse.launchbar.ui.internal.controls;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.Command;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.commands.NotEnabledException;
|
||||
import org.eclipse.core.commands.NotHandledException;
|
||||
import org.eclipse.core.commands.common.NotDefinedException;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.resource.CompositeImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.window.SameShellProvider;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetListener;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.eclipse.launchbar.core.target.TargetStatus;
|
||||
import org.eclipse.launchbar.core.target.TargetStatus.Code;
|
||||
import org.eclipse.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.launchbar.ui.internal.LaunchBarUIManager;
|
||||
import org.eclipse.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionService;
|
||||
import org.eclipse.remote.ui.RemoteConnectionsLabelProvider;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
||||
import org.eclipse.swt.events.MouseTrackListener;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.ui.ISharedImages;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.commands.ICommandService;
|
||||
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
||||
|
||||
public class TargetSelector extends CSelector {
|
||||
public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
||||
|
||||
private final LaunchBarUIManager uiManager = Activator.getDefault().getLaunchBarUIManager();
|
||||
private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class);
|
||||
private final ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class);
|
||||
|
||||
private static final String[] noTargets = new String[] { "---" }; //$NON-NLS-1$
|
||||
|
||||
public TargetSelector(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
|
||||
targetManager.addListener(this);
|
||||
|
||||
setContentProvider(new IStructuredContentProvider() {
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
|
@ -73,19 +68,69 @@ public class TargetSelector extends CSelector {
|
|||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
LaunchBarManager manager = uiManager.getManager();
|
||||
try {
|
||||
List<IRemoteConnection> targets = manager.getLaunchTargets(manager.getActiveLaunchDescriptor());
|
||||
if (!targets.isEmpty()) {
|
||||
return targets.toArray();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
List<ILaunchTarget> targets = manager.getLaunchTargets(manager.getActiveLaunchDescriptor());
|
||||
if (!targets.isEmpty()) {
|
||||
return targets.toArray();
|
||||
}
|
||||
return noTargets;
|
||||
}
|
||||
});
|
||||
|
||||
setLabelProvider(new RemoteConnectionsLabelProvider());
|
||||
setLabelProvider(new LabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if (element instanceof ILaunchTarget) {
|
||||
ILaunchTarget target = (ILaunchTarget) element;
|
||||
ILabelProvider provider = targetUIManager.getLabelProvider(target);
|
||||
return provider != null ? provider.getText(target) : target.getName();
|
||||
}
|
||||
return super.getText(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof ILaunchTarget) {
|
||||
// TODO apply a status overlay
|
||||
ILaunchTarget target = (ILaunchTarget) element;
|
||||
ILabelProvider provider = targetUIManager.getLabelProvider(target);
|
||||
if (provider != null) {
|
||||
final Image baseImage = provider.getImage(target);
|
||||
final TargetStatus status = targetManager.getStatus(target);
|
||||
if (status.getCode() == Code.OK) {
|
||||
return baseImage;
|
||||
} else {
|
||||
String compId = target.getTypeId()
|
||||
+ (status.getCode() == Code.ERROR ? ".error" : ".warning"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
Image image = Activator.getDefault().getImageRegistry().get(compId);
|
||||
if (image == null) {
|
||||
ImageDescriptor desc = new CompositeImageDescriptor() {
|
||||
@Override
|
||||
protected Point getSize() {
|
||||
Rectangle bounds = baseImage.getBounds();
|
||||
return new Point(bounds.width, bounds.height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawCompositeImage(int width, int height) {
|
||||
Image overlay = PlatformUI.getWorkbench().getSharedImages()
|
||||
.getImage(status.getCode() == Code.ERROR
|
||||
? ISharedImages.IMG_DEC_FIELD_ERROR
|
||||
: ISharedImages.IMG_DEC_FIELD_WARNING);
|
||||
drawImage(baseImage.getImageData(), 0, 0);
|
||||
int y = baseImage.getBounds().height - overlay.getBounds().height;
|
||||
drawImage(overlay.getImageData(), 0, y);
|
||||
}
|
||||
};
|
||||
image = desc.createImage();
|
||||
Activator.getDefault().getImageRegistry().put(compId, image);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getImage(element);
|
||||
}
|
||||
});
|
||||
|
||||
setSorter(new Comparator<Object>() {
|
||||
@Override
|
||||
|
@ -100,11 +145,10 @@ public class TargetSelector extends CSelector {
|
|||
|
||||
@Override
|
||||
public boolean isEditable(Object element) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private ISelectionProvider getSelectionProvider(){
|
||||
private ISelectionProvider getSelectionProvider() {
|
||||
return new ISelectionProvider() {
|
||||
@Override
|
||||
public void setSelection(ISelection selection) {
|
||||
|
@ -127,83 +171,18 @@ public class TargetSelector extends CSelector {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEdit(Object element) {
|
||||
// opens property dialog on a selected target
|
||||
new PropertyDialogAction(new SameShellProvider(getShell()), getSelectionProvider()).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasActionArea() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createActionArea(final Composite parent) {
|
||||
Composite actionArea = new Composite(parent, SWT.NONE);
|
||||
GridLayout actionLayout = new GridLayout();
|
||||
actionLayout.marginWidth = actionLayout.marginHeight = 0;
|
||||
actionArea.setLayout(actionLayout);
|
||||
actionArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
|
||||
final Composite createButton = new Composite(actionArea, SWT.NONE);
|
||||
createButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
GridLayout buttonLayout = new GridLayout();
|
||||
buttonLayout.marginWidth = buttonLayout.marginHeight = 7;
|
||||
createButton.setLayout(buttonLayout);
|
||||
createButton.setBackground(backgroundColor);
|
||||
createButton.addPaintListener(new PaintListener() {
|
||||
@Override
|
||||
public void paintControl(PaintEvent e) {
|
||||
Point size = createButton.getSize();
|
||||
GC gc = e.gc;
|
||||
gc.setForeground(outlineColor);
|
||||
gc.drawLine(0, 0, size.x, 0);
|
||||
}
|
||||
});
|
||||
|
||||
final Label createLabel = new Label(createButton, SWT.None);
|
||||
createLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
createLabel.setText(Messages.TargetSelector_CreateNewTarget);
|
||||
createLabel.setBackground(backgroundColor);
|
||||
|
||||
MouseListener mouseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseUp(org.eclipse.swt.events.MouseEvent event) {
|
||||
try {
|
||||
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
|
||||
Command newConnectionCmd = commandService.getCommand(IRemoteUIConnectionService.NEW_CONNECTION_COMMAND);
|
||||
newConnectionCmd.executeWithChecks(new ExecutionEvent());
|
||||
} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
createButton.addMouseListener(mouseListener);
|
||||
createLabel.addMouseListener(mouseListener);
|
||||
|
||||
MouseTrackListener mouseTrackListener = new MouseTrackAdapter() {
|
||||
@Override
|
||||
public void mouseEnter(MouseEvent e) {
|
||||
createButton.setBackground(highlightColor);
|
||||
createLabel.setBackground(highlightColor);
|
||||
}
|
||||
@Override
|
||||
public void mouseExit(MouseEvent e) {
|
||||
createButton.setBackground(white);
|
||||
createLabel.setBackground(white);
|
||||
}
|
||||
};
|
||||
createButton.addMouseTrackListener(mouseTrackListener);
|
||||
createLabel.addMouseTrackListener(mouseTrackListener);
|
||||
new PropertyDialogAction(new SameShellProvider(getShell()), getSelectionProvider()).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireSelectionChanged() {
|
||||
Object selection = getSelection();
|
||||
if (selection instanceof IRemoteConnection) {
|
||||
IRemoteConnection target = (IRemoteConnection) selection;
|
||||
if (selection instanceof ILaunchTarget) {
|
||||
ILaunchTarget target = (ILaunchTarget) selection;
|
||||
try {
|
||||
uiManager.getManager().setActiveLaunchTarget(target);
|
||||
} catch (CoreException e) {
|
||||
|
@ -212,6 +191,11 @@ public class TargetSelector extends CSelector {
|
|||
}
|
||||
}
|
||||
|
||||
public void setToolTipText(ILaunchTarget target) {
|
||||
String text = Messages.TargetSelector_ToolTipPrefix + ": " + targetManager.getStatus(target).getMessage(); //$NON-NLS-1$
|
||||
setToolTipText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
||||
return super.computeSize(200, hHint, changed);
|
||||
|
@ -219,9 +203,35 @@ public class TargetSelector extends CSelector {
|
|||
|
||||
@Override
|
||||
public void setSelection(Object element) {
|
||||
if (element == null)
|
||||
if (element == null) {
|
||||
element = noTargets[0];
|
||||
} else if (element instanceof ILaunchTarget) {
|
||||
setToolTipText((ILaunchTarget) element);
|
||||
}
|
||||
super.setSelection(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
targetManager.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Object element) {
|
||||
super.update(element);
|
||||
if (element != null && element instanceof ILaunchTarget) {
|
||||
setToolTipText((ILaunchTarget) element);
|
||||
} else {
|
||||
setToolTipText(Messages.TargetSelector_ToolTipPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchTargetStatusChanged(ILaunchTarget target) {
|
||||
if (target.equals(uiManager.getManager().getActiveLaunchTarget())) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ NewLaunchConfigTypePage_2=Select the type of launch configuration to create.
|
|||
NewLaunchConfigWizard_0=Create Launch Configuration
|
||||
StopActiveCommandHandler_0=Stopping launches
|
||||
StopActiveCommandHandler_1=Stopping build
|
||||
TargetSelector_ToolTipPrefix=Launch Target
|
||||
TargetSelector_CreateNewTarget=Create New Connection...
|
||||
|
||||
DescriptorMustNotBeNull=Descriptor must not be null
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.ui.internal.target;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
public class LaunchTargetUIManager implements ILaunchTargetUIManager {
|
||||
|
||||
private Map<String, IConfigurationElement> typeElements;
|
||||
private Map<String, ILabelProvider> labelProviders = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public ILabelProvider getLabelProvider(ILaunchTarget target) {
|
||||
if (typeElements == null) {
|
||||
// Load them up
|
||||
typeElements = new HashMap<>();
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint point = registry
|
||||
.getExtensionPoint(Activator.getDefault().getBundle().getSymbolicName() + ".launchTargetTypeUI"); //$NON-NLS-1$
|
||||
for (IExtension extension : point.getExtensions()) {
|
||||
for (IConfigurationElement element : extension.getConfigurationElements()) {
|
||||
String id = element.getAttribute("id"); //$NON-NLS-1$
|
||||
if (id != null) {
|
||||
typeElements.put(id, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String typeId = target.getTypeId();
|
||||
ILabelProvider labelProvider = labelProviders.get(typeId);
|
||||
if (labelProvider == null) {
|
||||
IConfigurationElement element = typeElements.get(typeId);
|
||||
if (element != null) {
|
||||
try {
|
||||
labelProvider = (ILabelProvider) element.createExecutableExtension("labelProvider"); //$NON-NLS-1$
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (labelProvider == null) {
|
||||
labelProvider = new LabelProvider() {
|
||||
public String getText(Object element) {
|
||||
if (element instanceof ILaunchTarget) {
|
||||
return ((ILaunchTarget) element).getName();
|
||||
}
|
||||
return super.getText(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof ILaunchTarget) {
|
||||
return Activator.getDefault().getImage(Activator.IMG_LOCAL_TARGET);
|
||||
}
|
||||
return super.getImage(element);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
return labelProvider;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.ui.target;
|
||||
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
|
||||
/**
|
||||
* A manager for the launch target UI.
|
||||
*/
|
||||
public interface ILaunchTargetUIManager {
|
||||
|
||||
/**
|
||||
* Return a label provider that gives the test and image for the target.
|
||||
*
|
||||
* @param target
|
||||
* the launch target
|
||||
* @return the label provider for the launch target
|
||||
*/
|
||||
ILabelProvider getLabelProvider(ILaunchTarget target);
|
||||
|
||||
}
|
|
@ -18,7 +18,6 @@ import static org.junit.Assert.assertSame;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -29,9 +28,8 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.launchbar.core.internal.Activator;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager2Test;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.FixMethodOrder;
|
||||
|
@ -41,10 +39,9 @@ import org.junit.runners.MethodSorters;
|
|||
@SuppressWarnings("nls")
|
||||
@FixMethodOrder(MethodSorters.JVM)
|
||||
public class PerTargetLaunchConfigProviderTest {
|
||||
private IRemoteServicesManager remoteServiceManager;
|
||||
private IRemoteConnection localTarget;
|
||||
private ILaunchTarget localTarget;
|
||||
private String launchName;
|
||||
private IRemoteConnection otherTarget;
|
||||
private ILaunchTarget otherTarget;
|
||||
private ILaunchConfigurationType launchConfigType;
|
||||
private ILaunchDescriptorType descriptorType;
|
||||
private ILaunchDescriptor descriptor;
|
||||
|
@ -52,14 +49,24 @@ public class PerTargetLaunchConfigProviderTest {
|
|||
|
||||
@Before
|
||||
public void basicSetupOnly() throws CoreException {
|
||||
remoteServiceManager = spy(Activator.getService(IRemoteServicesManager.class));
|
||||
localTarget = remoteServiceManager.getLocalConnectionType().getConnections().get(0);
|
||||
ILaunchTargetManager targetManager = mock(ILaunchTargetManager.class);
|
||||
Activator.getDefault().getBundle().getBundleContext().registerService(ILaunchTargetManager.class, targetManager,
|
||||
null);
|
||||
|
||||
localTarget = mock(ILaunchTarget.class);
|
||||
doReturn("Local").when(localTarget).getName();
|
||||
doReturn(ILaunchTargetManager.localLaunchTargetTypeId).when(localTarget).getTypeId();
|
||||
doReturn(localTarget).when(targetManager).getLaunchTarget(ILaunchTargetManager.localLaunchTargetTypeId,
|
||||
"Local");
|
||||
|
||||
// other mocked remote connections
|
||||
otherTarget = mock(IRemoteConnection.class);
|
||||
IRemoteConnectionType rtype = mock(IRemoteConnectionType.class);
|
||||
doReturn(rtype).when(otherTarget).getConnectionType();
|
||||
doReturn("otherTargetType").when(rtype).getId();
|
||||
otherTarget = mock(ILaunchTarget.class);
|
||||
doReturn("otherTargetType").when(otherTarget).getTypeId();
|
||||
doReturn("otherTarget").when(otherTarget).getName();
|
||||
doReturn(otherTarget).when(targetManager).getLaunchTarget("otherTargetType", "otherTarget");
|
||||
|
||||
doReturn(new ILaunchTarget[] { localTarget, otherTarget }).when(targetManager).getLaunchTargets();
|
||||
|
||||
// launch stuff
|
||||
launchName = "test";
|
||||
// launch config type
|
||||
|
@ -90,18 +97,18 @@ public class PerTargetLaunchConfigProviderTest {
|
|||
private ILaunchBarManager manager;
|
||||
|
||||
@Override
|
||||
public boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
|
||||
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor,
|
||||
IRemoteConnection target) throws CoreException {
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
return launchConfigType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target,
|
||||
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
|
||||
ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
|
||||
super.populateLaunchConfiguration(descriptor, target, workingCopy);
|
||||
workingCopy.setAttribute(CONNECTION_NAME_ATTR, target.getName());
|
||||
|
@ -113,7 +120,7 @@ public class PerTargetLaunchConfigProviderTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IRemoteConnection getLaunchTarget(ILaunchConfiguration configuration) throws CoreException {
|
||||
protected ILaunchTarget getLaunchTarget(ILaunchConfiguration configuration) throws CoreException {
|
||||
String name = configuration.getAttribute(CONNECTION_NAME_ATTR, "");
|
||||
if (localTarget.getName().equals(name)) {
|
||||
return localTarget;
|
||||
|
@ -133,7 +140,7 @@ public class PerTargetLaunchConfigProviderTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
ILaunchConfiguration config = super.getLaunchConfiguration(descriptor, target);
|
||||
// Since this provider isn't hooked in properly, need to manually
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.mockito.Mockito.doReturn;
|
|||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
@ -57,9 +56,8 @@ import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
|||
import org.eclipse.launchbar.core.ProjectLaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.ProjectPerTargetLaunchConfigProvider;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager.Listener;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.junit.Before;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
|
@ -81,13 +79,12 @@ public class LaunchBarManager2Test {
|
|||
IEclipsePreferences store = new EclipsePreferences();
|
||||
private ArrayList<IConfigurationElement> elements;
|
||||
private IExtension extension;
|
||||
private static final String localTargetTypeId = "org.eclipse.remote.LocalServices";
|
||||
private String descriptorTypeId;
|
||||
private IRemoteConnection localTarget;
|
||||
private ILaunchTargetManager targetManager;
|
||||
private ILaunchTarget localTarget;
|
||||
private String launchObject;
|
||||
private IRemoteServicesManager remoteServiceManager;
|
||||
private IRemoteConnection otherTarget;
|
||||
private List<IRemoteConnection> targets;
|
||||
private ILaunchTarget otherTarget;
|
||||
private ILaunchTarget[] targets;
|
||||
|
||||
public class FixedLaunchBarManager extends LaunchBarManager {
|
||||
public FixedLaunchBarManager() throws CoreException {
|
||||
|
@ -110,8 +107,8 @@ public class LaunchBarManager2Test {
|
|||
}
|
||||
|
||||
@Override
|
||||
IRemoteServicesManager getRemoteServicesManager() {
|
||||
return remoteServiceManager;
|
||||
ILaunchTargetManager getLaunchTargetManager() {
|
||||
return targetManager;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -129,7 +126,7 @@ public class LaunchBarManager2Test {
|
|||
}
|
||||
|
||||
protected ILaunchConfigurationProvider mockConfigProviderElement(String descriptorTypeId, int priority,
|
||||
ILaunchDescriptor descriptor, IRemoteConnection target, ILaunchConfiguration config, Object launchObj)
|
||||
ILaunchDescriptor descriptor, ILaunchTarget target, ILaunchConfiguration config, Object launchObj)
|
||||
throws CoreException {
|
||||
ILaunchConfigurationProvider provider = mock(ILaunchConfigurationProvider.class);
|
||||
mockProviderElement(descriptorTypeId, priority, provider);
|
||||
|
@ -166,7 +163,7 @@ public class LaunchBarManager2Test {
|
|||
|
||||
protected void init() throws CoreException {
|
||||
doReturn(elements.toArray(new IConfigurationElement[0])).when(extension).getConfigurationElements();
|
||||
doReturn(targets).when(remoteServiceManager).getAllRemoteConnections();
|
||||
doReturn(targets).when(targetManager).getLaunchTargets();
|
||||
manager.init();
|
||||
}
|
||||
|
||||
|
@ -219,13 +216,10 @@ public class LaunchBarManager2Test {
|
|||
* @param t2
|
||||
* @return
|
||||
*/
|
||||
private IRemoteConnection mockRemoteConnection(String t2) {
|
||||
IRemoteConnection target = mock(IRemoteConnection.class);
|
||||
IRemoteConnectionType type = mock(IRemoteConnectionType.class);
|
||||
doReturn(t2).when(type).getName();
|
||||
doReturn(t2).when(type).getId();
|
||||
private ILaunchTarget mockRemoteConnection(String t2) {
|
||||
ILaunchTarget target = mock(ILaunchTarget.class);
|
||||
doReturn(t2).when(target).getTypeId();
|
||||
doReturn(t2 + ".target").when(target).getName();
|
||||
doReturn(type).when(target).getConnectionType();
|
||||
return target;
|
||||
}
|
||||
|
||||
|
@ -270,17 +264,18 @@ public class LaunchBarManager2Test {
|
|||
lman = mock(ILaunchManager.class);
|
||||
doReturn(globalmodes.toArray(new ILaunchMode[globalmodes.size()])).when(lman).getLaunchModes();
|
||||
doReturn(new ILaunchConfiguration[] {}).when(lman).getLaunchConfigurations();
|
||||
remoteServiceManager = spy(Activator.getService(IRemoteServicesManager.class));
|
||||
targetManager = mock(ILaunchTargetManager.class);
|
||||
manager = new FixedLaunchBarManager();
|
||||
localTarget = manager.getRemoteServicesManager().getLocalConnectionType().getConnections().get(0);
|
||||
localTarget = mock(ILaunchTarget.class);
|
||||
doReturn(ILaunchTargetManager.localLaunchTargetTypeId).when(localTarget).getTypeId();
|
||||
doReturn("Local").when(localTarget).getName();
|
||||
// mock
|
||||
launchObject = "test";
|
||||
// remote connections
|
||||
otherTarget = mock(IRemoteConnection.class);
|
||||
IRemoteConnectionType rtype = mock(IRemoteConnectionType.class);
|
||||
doReturn(rtype).when(otherTarget).getConnectionType();
|
||||
doReturn("otherTargetType").when(rtype).getId();
|
||||
targets = Arrays.asList(new IRemoteConnection[] { otherTarget, localTarget });
|
||||
otherTarget = mock(ILaunchTarget.class);
|
||||
doReturn("otherTargetType").when(otherTarget).getTypeId();
|
||||
doReturn("otherTarget").when(otherTarget).getName();
|
||||
targets = new ILaunchTarget[] { otherTarget, localTarget };
|
||||
// lc
|
||||
String launchConfigTypeId = "lctype1";
|
||||
launchConfigType = mockLCType(launchConfigTypeId);
|
||||
|
@ -329,7 +324,7 @@ public class LaunchBarManager2Test {
|
|||
@Test
|
||||
public void testAddConfigMappingTwo() throws CoreException {
|
||||
basicSetupOnly();
|
||||
IRemoteConnection target = mockRemoteConnection("t2");
|
||||
ILaunchTarget target = mockRemoteConnection("t2");
|
||||
mockConfigProviderElement(descriptorTypeId, 10, descriptor, target, launchConfig, launchObject);
|
||||
// now create another lc type, which is not registered in config type
|
||||
ILaunchConfigurationType lctype2 = mockLCType("lctypeid2");
|
||||
|
@ -346,7 +341,7 @@ public class LaunchBarManager2Test {
|
|||
@Test
|
||||
public void testAddConfigProviderTwo2() throws CoreException {
|
||||
basicSetupOnly();
|
||||
IRemoteConnection target = mockRemoteConnection("t2");
|
||||
ILaunchTarget target = mockRemoteConnection("t2");
|
||||
mockConfigProviderElement(descriptorTypeId, 15, descriptor, target, launchConfig, launchObject);
|
||||
ILaunchConfigurationType lctype2 = mockLCType("lctypeid2");
|
||||
ILaunchConfiguration lc2 = mockLC("lc2", lctype2);
|
||||
|
@ -360,7 +355,7 @@ public class LaunchBarManager2Test {
|
|||
public void testGetLaunchTargets() throws CoreException {
|
||||
manager.launchObjectAdded(launchObject);
|
||||
manager.setActiveLaunchDescriptor(descriptor);
|
||||
List<IRemoteConnection> launchTargets = manager.getLaunchTargets(descriptor);
|
||||
List<ILaunchTarget> launchTargets = manager.getLaunchTargets(descriptor);
|
||||
assertEquals(1, launchTargets.size());
|
||||
assertEquals(otherTarget, launchTargets.get(0));
|
||||
}
|
||||
|
@ -374,7 +369,7 @@ public class LaunchBarManager2Test {
|
|||
init();
|
||||
manager.launchObjectAdded(launchObject);
|
||||
ILaunchDescriptor desc = manager.getActiveLaunchDescriptor();
|
||||
List<IRemoteConnection> launchTargets = manager.getLaunchTargets(desc);
|
||||
List<ILaunchTarget> launchTargets = manager.getLaunchTargets(desc);
|
||||
assertEquals(1, launchTargets.size());
|
||||
}
|
||||
|
||||
|
@ -387,7 +382,7 @@ public class LaunchBarManager2Test {
|
|||
init();
|
||||
manager.launchObjectAdded(launchObject);
|
||||
ILaunchDescriptor desc = manager.getActiveLaunchDescriptor();
|
||||
List<IRemoteConnection> launchTargets = manager.getLaunchTargets(desc);
|
||||
List<ILaunchTarget> launchTargets = manager.getLaunchTargets(desc);
|
||||
assertEquals(1, launchTargets.size());
|
||||
}
|
||||
|
||||
|
@ -577,7 +572,7 @@ public class LaunchBarManager2Test {
|
|||
provider = new ProjectPerTargetLaunchConfigProvider() {
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor,
|
||||
IRemoteConnection target) throws CoreException {
|
||||
ILaunchTarget target) throws CoreException {
|
||||
return launchConfigType;
|
||||
}
|
||||
|
||||
|
@ -592,7 +587,7 @@ public class LaunchBarManager2Test {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IRemoteConnection getLaunchTarget(ILaunchConfiguration configuration) throws CoreException {
|
||||
protected ILaunchTarget getLaunchTarget(ILaunchConfiguration configuration) throws CoreException {
|
||||
return localTarget;
|
||||
}
|
||||
};
|
||||
|
@ -835,14 +830,6 @@ public class LaunchBarManager2Test {
|
|||
assertEquals(localTarget, manager.getActiveLaunchTarget());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLaunchTarget() throws CoreException {
|
||||
IRemoteConnectionType targetType = remoteServiceManager.getConnectionType(localTargetTypeId);
|
||||
final List<IRemoteConnection> list = targetType.getConnections();
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(localTarget, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLaunchConfigurationType() throws CoreException {
|
||||
manager.launchObjectAdded(launchObject);
|
||||
|
|
|
@ -34,9 +34,8 @@ import org.eclipse.debug.core.ILaunchMode;
|
|||
import org.eclipse.launchbar.core.ILaunchConfigurationProvider;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
@ -73,8 +72,18 @@ public class LaunchBarManagerTest {
|
|||
doReturn(true).when(launchConfigType).supportsMode("run");
|
||||
doReturn(true).when(launchConfigType).supportsMode("debug");
|
||||
|
||||
final ILaunchTargetManager targetManager = mock(ILaunchTargetManager.class);
|
||||
ILaunchTarget localTarget = mock(ILaunchTarget.class);
|
||||
doReturn(ILaunchTargetManager.localLaunchTargetTypeId).when(localTarget).getTypeId();
|
||||
doReturn("Local").when(localTarget).getName();
|
||||
doReturn(new ILaunchTarget[] { localTarget }).when(targetManager).getLaunchTargets();
|
||||
|
||||
// Inject the launch config
|
||||
LaunchBarManager manager = new LaunchBarManager(false) {
|
||||
@Override
|
||||
ILaunchTargetManager getLaunchTargetManager() {
|
||||
return targetManager;
|
||||
}
|
||||
};
|
||||
manager.init();
|
||||
manager.launchConfigurationAdded(launchConfig);
|
||||
|
@ -83,11 +92,9 @@ public class LaunchBarManagerTest {
|
|||
assertNotNull(manager.getActiveLaunchDescriptor());
|
||||
assertEquals(launchConfig, manager.getActiveLaunchDescriptor().getAdapter(ILaunchConfiguration.class));
|
||||
|
||||
IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType localServices = remoteManager.getLocalConnectionType();
|
||||
IRemoteConnection localConnection = localServices.getConnections().get(0);
|
||||
assertNotNull(manager.getActiveLaunchTarget());
|
||||
assertEquals(localConnection, manager.getActiveLaunchTarget());
|
||||
assertEquals(ILaunchTargetManager.localLaunchTargetTypeId, manager.getActiveLaunchTarget().getTypeId());
|
||||
assertEquals("Local", manager.getActiveLaunchTarget().getName());
|
||||
|
||||
assertNotNull(manager.getActiveLaunchMode());
|
||||
assertEquals("run", manager.getActiveLaunchMode().getIdentifier());
|
||||
|
@ -156,18 +163,23 @@ public class LaunchBarManagerTest {
|
|||
ILaunchConfigurationProvider configProvider = mock(ILaunchConfigurationProvider.class);
|
||||
doReturn(configProvider).when(element).createExecutableExtension("class");
|
||||
|
||||
final ILaunchTargetManager targetManager = mock(ILaunchTargetManager.class);
|
||||
ILaunchTarget localTarget = mock(ILaunchTarget.class);
|
||||
doReturn(ILaunchTargetManager.localLaunchTargetTypeId).when(localTarget).getTypeId();
|
||||
doReturn("Local").when(localTarget).getName();
|
||||
doReturn(new ILaunchTarget[] { localTarget }).when(targetManager).getLaunchTargets();
|
||||
|
||||
ILaunchConfiguration launchConfig = mock(ILaunchConfiguration.class);
|
||||
doReturn(launchConfig).when(configProvider).getLaunchConfiguration(eq(descriptor),
|
||||
any(IRemoteConnection.class));
|
||||
doReturn(launchConfig).when(configProvider).getLaunchConfiguration(eq(descriptor), any(ILaunchTarget.class));
|
||||
doReturn(launchConfigType).when(configProvider).getLaunchConfigurationType(any(ILaunchDescriptor.class),
|
||||
any(IRemoteConnection.class));
|
||||
any(ILaunchTarget.class));
|
||||
doAnswer(new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock invocation) throws Throwable {
|
||||
IRemoteConnection target = (IRemoteConnection) invocation.getArguments()[1];
|
||||
return target.getConnectionType().getId().equals("org.eclipse.remote.LocalServices");
|
||||
ILaunchTarget target = (ILaunchTarget) invocation.getArguments()[1];
|
||||
return target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId);
|
||||
}
|
||||
}).when(configProvider).supports(eq(descriptor), any(IRemoteConnection.class));
|
||||
}).when(configProvider).supports(eq(descriptor), any(ILaunchTarget.class));
|
||||
|
||||
doReturn(elements.toArray(new IConfigurationElement[0])).when(extension).getConfigurationElements();
|
||||
|
||||
|
@ -182,17 +194,20 @@ public class LaunchBarManagerTest {
|
|||
ILaunchManager getLaunchManager() {
|
||||
return launchManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
ILaunchTargetManager getLaunchTargetManager() {
|
||||
return targetManager;
|
||||
}
|
||||
|
||||
};
|
||||
manager.init();
|
||||
manager.launchObjectAdded(launchObject);
|
||||
|
||||
assertEquals(descriptor, manager.getActiveLaunchDescriptor());
|
||||
assertEquals(runMode, manager.getActiveLaunchMode());
|
||||
IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType localServices = remoteManager.getLocalConnectionType();
|
||||
IRemoteConnection localConnection = localServices.getConnections().get(0);
|
||||
assertNotNull(localConnection);
|
||||
assertEquals(localConnection, manager.getActiveLaunchTarget());
|
||||
assertEquals(ILaunchTargetManager.localLaunchTargetTypeId, manager.getActiveLaunchTarget().getTypeId());
|
||||
assertEquals("Local", manager.getActiveLaunchTarget().getName());
|
||||
assertEquals(launchConfig, manager.getActiveLaunchConfiguration());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue