mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Bug 437392 - Remove LaunchBar from CDT repo.
It is now located in the cdt/org.eclipse.launchbar repo. The intention is to move it to a project lower down the stack so it can be reused accross Eclipse. Change-Id: I9d623fa372fcf6e345ba68a8830db190a75e0d28 Reviewed-on: https://git.eclipse.org/r/38266 Tested-by: Hudson CI Reviewed-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
parent
c8ba1b6c3a
commit
3c14369a9a
105 changed files with 1 additions and 8343 deletions
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>org.eclipse.cdt.launchbar-feature</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,12 +0,0 @@
|
||||||
###############################################################################
|
|
||||||
# Copyright (c) 2014 QNX 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:
|
|
||||||
# QNX - initial API and implementation
|
|
||||||
###############################################################################
|
|
||||||
bin.includes = feature.xml,\
|
|
||||||
feature.properties
|
|
|
@ -1,33 +0,0 @@
|
||||||
###############################################################################
|
|
||||||
# Copyright (c) 2005, 2010 IBM Corporation 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:
|
|
||||||
# IBM Corporation - initial API and implementation
|
|
||||||
###############################################################################
|
|
||||||
# features.properties
|
|
||||||
# contains externalized strings for feature.xml
|
|
||||||
# "%foo" in feature.xml corresponds to the key "foo" in this file
|
|
||||||
# java.io.Properties file (ISO 8859-1 with "\" escapes)
|
|
||||||
# This file should be translated.
|
|
||||||
|
|
||||||
# "featureName" property - name of the feature
|
|
||||||
featureName=LaunchBar
|
|
||||||
|
|
||||||
# "providerName" property - name of the company that provides the feature
|
|
||||||
providerName=Eclipse CDT
|
|
||||||
|
|
||||||
# "description" property - description of the feature
|
|
||||||
description=A Tool Control that sits in the TOP trim bar that controls build and launch.
|
|
||||||
|
|
||||||
# copyright
|
|
||||||
copyright=\
|
|
||||||
Copyright (c) 2014 QNX Software Systems and others\n\
|
|
||||||
All rights reserved. This program and the accompanying materials\n\
|
|
||||||
are made available under the terms of the Eclipse Public License v1.0\n\
|
|
||||||
which accompanies this distribution, and is available at\n\
|
|
||||||
http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<feature
|
|
||||||
id="org.eclipse.cdt.launchbar"
|
|
||||||
label="%featureName"
|
|
||||||
version="8.5.0.qualifier"
|
|
||||||
provider-name="%providerName"
|
|
||||||
license-feature="org.eclipse.license"
|
|
||||||
license-feature-version="0.0.0">
|
|
||||||
|
|
||||||
<description>
|
|
||||||
%description
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<copyright>
|
|
||||||
%copyright
|
|
||||||
</copyright>
|
|
||||||
|
|
||||||
<license url="%licenseURL">
|
|
||||||
%license
|
|
||||||
</license>
|
|
||||||
|
|
||||||
<plugin
|
|
||||||
id="org.eclipse.cdt.launchbar.cdt.core"
|
|
||||||
download-size="0"
|
|
||||||
install-size="0"
|
|
||||||
version="0.0.0"
|
|
||||||
unpack="false"/>
|
|
||||||
|
|
||||||
<plugin
|
|
||||||
id="org.eclipse.cdt.launchbar.core"
|
|
||||||
download-size="0"
|
|
||||||
install-size="0"
|
|
||||||
version="0.0.0"
|
|
||||||
unpack="false"/>
|
|
||||||
|
|
||||||
<plugin
|
|
||||||
id="org.eclipse.cdt.launchbar.ui"
|
|
||||||
download-size="0"
|
|
||||||
install-size="0"
|
|
||||||
version="0.0.0"
|
|
||||||
unpack="false"/>
|
|
||||||
|
|
||||||
</feature>
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.eclipse.cdt</groupId>
|
|
||||||
<artifactId>cdt-parent</artifactId>
|
|
||||||
<version>8.5.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<version>8.5.0-SNAPSHOT</version>
|
|
||||||
<groupId>org.eclipse.cdt.features</groupId>
|
|
||||||
<artifactId>org.eclipse.cdt.launchbar</artifactId>
|
|
||||||
<packaging>eclipse-feature</packaging>
|
|
||||||
</project>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?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.pde.core.requiredPlugins"/>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>org.eclipse.cdt.launchbar.cdt.core</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.pde.PluginNature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,7 +0,0 @@
|
||||||
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.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
|
|
@ -1,14 +0,0 @@
|
||||||
Manifest-Version: 1.0
|
|
||||||
Bundle-ManifestVersion: 2
|
|
||||||
Bundle-Name: LaunchBar for CDT Core
|
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.launchbar.cdt.core;singleton:=true
|
|
||||||
Bundle-Version: 1.0.0.qualifier
|
|
||||||
Bundle-Activator: org.eclipse.cdt.launchbar.cdt.core.internal.Activator
|
|
||||||
Bundle-Vendor: Eclipse CDT
|
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
|
||||||
org.eclipse.cdt.launchbar.core,
|
|
||||||
org.eclipse.debug.core,
|
|
||||||
org.eclipse.cdt.debug.core
|
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
|
||||||
Bundle-ActivationPolicy: lazy
|
|
||||||
Export-Package: org.eclipse.cdt.launchbar.cdt.core.internal;x-internal:=true
|
|
|
@ -1,5 +0,0 @@
|
||||||
source.. = src/
|
|
||||||
output.. = bin/
|
|
||||||
bin.includes = META-INF/,\
|
|
||||||
.,\
|
|
||||||
plugin.xml
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<?eclipse version="3.4"?>
|
|
||||||
<plugin>
|
|
||||||
|
|
||||||
</plugin>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.eclipse.cdt</groupId>
|
|
||||||
<artifactId>cdt-parent</artifactId>
|
|
||||||
<version>8.5.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
<artifactId>org.eclipse.cdt.launchbar.cdt.core</artifactId>
|
|
||||||
<packaging>eclipse-plugin</packaging>
|
|
||||||
</project>
|
|
|
@ -1,42 +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.cdt.launchbar.cdt.core.internal;
|
|
||||||
|
|
||||||
import org.osgi.framework.BundleActivator;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
|
|
||||||
public class Activator implements BundleActivator {
|
|
||||||
|
|
||||||
public static final String ID = "org.eclipse.cdt.launchbar.cdt.core";
|
|
||||||
|
|
||||||
private static BundleContext context;
|
|
||||||
|
|
||||||
static BundleContext getContext() {
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
|
||||||
*/
|
|
||||||
public void start(BundleContext bundleContext) throws Exception {
|
|
||||||
Activator.context = bundleContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
|
||||||
*/
|
|
||||||
public void stop(BundleContext bundleContext) throws Exception {
|
|
||||||
Activator.context = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?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.pde.core.requiredPlugins"/>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>org.eclipse.cdt.launchbar.core.tests</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.pde.PluginNature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,7 +0,0 @@
|
||||||
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.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
|
|
@ -1,17 +0,0 @@
|
||||||
Manifest-Version: 1.0
|
|
||||||
Bundle-ManifestVersion: 2
|
|
||||||
Bundle-Name: Launch Bar Core Tests
|
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.launchbar.core.tests
|
|
||||||
Bundle-Version: 1.0.0.qualifier
|
|
||||||
Bundle-Activator: org.eclipse.cdt.launchbar.core.tests.Activator
|
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
|
||||||
org.junit;bundle-version="4.11.0",
|
|
||||||
org.mockito,
|
|
||||||
org.eclipse.cdt.launchbar.core;bundle-version="1.0.0",
|
|
||||||
org.eclipse.debug.core,
|
|
||||||
org.eclipse.cdt.debug.core,
|
|
||||||
org.eclipse.core.filesystem,
|
|
||||||
org.hamcrest.core
|
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
|
||||||
Bundle-ActivationPolicy: lazy
|
|
||||||
Export-Package: org.eclipse.cdt.launchbar.core.tests
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
|
|
||||||
|
|
||||||
<body lang="EN-US">
|
|
||||||
<h2>About This Content</h2>
|
|
||||||
|
|
||||||
<p>June 22, 2007</p>
|
|
||||||
<h3>License</h3>
|
|
||||||
|
|
||||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
|
||||||
indicated below, the Content is provided to you under the terms and conditions of the
|
|
||||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
|
|
||||||
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
|
||||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
|
||||||
|
|
||||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
|
|
||||||
being redistributed by another party ("Redistributor") and different terms and conditions may
|
|
||||||
apply to your use of any object code in the Content. Check the Redistributor's license that was
|
|
||||||
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
|
||||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
|
|
||||||
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
|
|
||||||
|
|
||||||
</body></html>
|
|
|
@ -1,4 +0,0 @@
|
||||||
source.. = src/
|
|
||||||
output.. = bin/
|
|
||||||
bin.includes = META-INF/,\
|
|
||||||
.
|
|
|
@ -1,42 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.eclipse.cdt</groupId>
|
|
||||||
<artifactId>cdt-parent</artifactId>
|
|
||||||
<version>8.5.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
<artifactId>org.eclipse.cdt.launchbar.core.tests</artifactId>
|
|
||||||
<packaging>eclipse-test-plugin</packaging>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.eclipse.tycho</groupId>
|
|
||||||
<artifactId>tycho-surefire-plugin</artifactId>
|
|
||||||
<version>${tycho-version}</version>
|
|
||||||
<configuration>
|
|
||||||
<!-- It does not need ui, but it does not work headless for some reason -->
|
|
||||||
<useUIHarness>true</useUIHarness>
|
|
||||||
<argLine>${tycho.testArgLine} ${base.ui.test.vmargs} -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
|
||||||
<includes>
|
|
||||||
<include>**/AutomatedIntegrationSuite.*</include>
|
|
||||||
</includes>
|
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>org.eclipse.platform.feature.group</artifactId>
|
|
||||||
<type>p2-installable-unit</type>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -1,829 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
> * Copyright (c) 2014 QNX Software Systems. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* You must obtain a written license from and pay applicable license fees to QNX
|
|
||||||
* Software Systems before you may reproduce, modify or distribute this software,
|
|
||||||
* or any work that includes all or part of this software. Free development
|
|
||||||
* licenses are available for evaluation and non-commercial purposes. For more
|
|
||||||
* information visit [http://licensing.qnx.com] or email licensing@qnx.com.
|
|
||||||
*
|
|
||||||
* This file may contain contributions from others. Please review this entire
|
|
||||||
* file for other proprietary rights or license notices, as well as the QNX
|
|
||||||
* Development Suite License Guide at [http://licensing.qnx.com/license-guide/]
|
|
||||||
* for other information.
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptorType;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchObjectProvider;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
|
||||||
import org.eclipse.cdt.launchbar.core.LaunchConfigurationProvider;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager.Listener;
|
|
||||||
import org.eclipse.core.internal.preferences.EclipsePreferences;
|
|
||||||
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.PlatformObject;
|
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author elaskavaia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LaunchBarManagerTest extends TestCase {
|
|
||||||
|
|
||||||
// default type ids
|
|
||||||
private static final String DEFAULT_CONFIG_TYPE_ID = "configType.test";
|
|
||||||
private static final String DEFAULT_TARGET_TYPE_ID = "targetType.test";
|
|
||||||
private static final String DEFAULT_DESCRIPTOR_TYPE_ID = "descriptorType.test";
|
|
||||||
|
|
||||||
private IEclipsePreferences prefs;
|
|
||||||
private ILaunchManager launchManager;
|
|
||||||
|
|
||||||
public class TestLaunchBarManager extends LaunchBarManager {
|
|
||||||
private ILaunchMode[] defaultLaunchModes;
|
|
||||||
boolean done;
|
|
||||||
|
|
||||||
public TestLaunchBarManager() throws CoreException {
|
|
||||||
super();
|
|
||||||
// For the tests, need to wait until the init is done
|
|
||||||
synchronized (this) {
|
|
||||||
while (!done) {
|
|
||||||
try {
|
|
||||||
wait();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() throws CoreException {
|
|
||||||
super.init();
|
|
||||||
synchronized (this) {
|
|
||||||
done = true;
|
|
||||||
notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IExtensionPoint getExtensionPoint() throws CoreException {
|
|
||||||
// default things
|
|
||||||
IExtensionPoint point = mock(IExtensionPoint.class);
|
|
||||||
|
|
||||||
IExtension extension = mock(IExtension.class);
|
|
||||||
doReturn(new IExtension[] { extension }).when(point).getExtensions();
|
|
||||||
|
|
||||||
List<IConfigurationElement> elements = new ArrayList<>();
|
|
||||||
|
|
||||||
IConfigurationElement element;
|
|
||||||
|
|
||||||
// The local target
|
|
||||||
element = mock(IConfigurationElement.class);
|
|
||||||
elements.add(element);
|
|
||||||
doReturn("targetType").when(element).getName();
|
|
||||||
doReturn(LocalTargetType.ID).when(element).getAttribute("id");
|
|
||||||
doReturn(new LocalTargetType()).when(element).createExecutableExtension("class");
|
|
||||||
|
|
||||||
// Test targets
|
|
||||||
for (TestLaunchTargetType targetType : getTestTargetTypes()) {
|
|
||||||
element = mock(IConfigurationElement.class);
|
|
||||||
elements.add(element);
|
|
||||||
doReturn("targetType").when(element).getName();
|
|
||||||
doReturn(targetType.id).when(element).getAttribute("id");
|
|
||||||
doReturn(targetType).when(element).createExecutableExtension("class");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test descriptors
|
|
||||||
for (TestLaunchDescriptorType descType : getTestDescriptorTypes()) {
|
|
||||||
element = mock(IConfigurationElement.class);
|
|
||||||
elements.add(element);
|
|
||||||
doReturn("descriptorType").when(element).getName();
|
|
||||||
doReturn(descType.id).when(element).getAttribute("id");
|
|
||||||
doReturn(Integer.toString(descType.priority)).when(element).getAttribute("priority");
|
|
||||||
doReturn(descType).when(element).createExecutableExtension("class");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test config types
|
|
||||||
for (TestLaunchConfigurationProvider provider : getTestConfigProviders()) {
|
|
||||||
element = mock(IConfigurationElement.class);
|
|
||||||
elements.add(element);
|
|
||||||
doReturn("configType").when(element).getName();
|
|
||||||
doReturn(provider.descTypeId).when(element).getAttribute("descriptorType");
|
|
||||||
doReturn(provider.targetTypeId).when(element).getAttribute("targetType");
|
|
||||||
doReturn(provider.configType.getIdentifier()).when(element).getAttribute("launchConfigurationType");
|
|
||||||
doReturn(Boolean.toString(provider.isDefault)).when(element).getAttribute("isDefault");
|
|
||||||
|
|
||||||
element = mock(IConfigurationElement.class);
|
|
||||||
elements.add(element);
|
|
||||||
doReturn("configProvider").when(element).getName();
|
|
||||||
doReturn(provider.configType.getIdentifier()).when(element).getAttribute("launchConfigurationType");
|
|
||||||
doReturn(provider).when(element).createExecutableExtension("class");
|
|
||||||
}
|
|
||||||
|
|
||||||
// test object providers
|
|
||||||
for (TestLaunchObjectProvider objectProvider : getTestObjectProviders()) {
|
|
||||||
element = mock(IConfigurationElement.class);
|
|
||||||
elements.add(element);
|
|
||||||
doReturn("objectProvider").when(element).getName();
|
|
||||||
doReturn(objectProvider).when(element).createExecutableExtension("class");
|
|
||||||
}
|
|
||||||
|
|
||||||
doReturn(elements.toArray(new IConfigurationElement[0])).when(extension).getConfigurationElements();
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TestLaunchTargetType[] getTestTargetTypes() {
|
|
||||||
return new TestLaunchTargetType[] {
|
|
||||||
new TestLaunchTargetType(DEFAULT_TARGET_TYPE_ID)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TestLaunchDescriptorType[] getTestDescriptorTypes() {
|
|
||||||
return new TestLaunchDescriptorType[] {
|
|
||||||
new TestLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID, 5)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TestLaunchConfigurationProvider[] getTestConfigProviders() {
|
|
||||||
ILaunchConfigurationType configType = mockLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID);
|
|
||||||
return new TestLaunchConfigurationProvider[] {
|
|
||||||
new TestLaunchConfigurationProvider(DEFAULT_DESCRIPTOR_TYPE_ID, DEFAULT_TARGET_TYPE_ID, configType, true, this)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TestLaunchObjectProvider[] getTestObjectProviders() {
|
|
||||||
return new TestLaunchObjectProvider[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ILaunchManager getLaunchManager() {
|
|
||||||
return launchManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IEclipsePreferences getPreferenceStore() {
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static class TestLaunchTargetType implements ILaunchTargetType {
|
|
||||||
final String id;
|
|
||||||
|
|
||||||
public TestLaunchTargetType(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(ILaunchBarManager manager) throws CoreException {
|
|
||||||
// override if you want to add targets
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestLaunchTarget extends PlatformObject implements ILaunchTarget {
|
|
||||||
private ILaunchTargetType type;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public TestLaunchTarget(String name, ILaunchTargetType type) {
|
|
||||||
this.name = name;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILaunchTargetType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive(boolean active) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestLaunchObject {
|
|
||||||
final String name;
|
|
||||||
final ILaunchDescriptorType descType;
|
|
||||||
|
|
||||||
public TestLaunchObject(String name, ILaunchDescriptorType descType) {
|
|
||||||
this.name = name;
|
|
||||||
this.descType = descType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj instanceof TestLaunchObject) {
|
|
||||||
return name.equals(((TestLaunchObject) obj).name);
|
|
||||||
}
|
|
||||||
return super.equals(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return name.hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
|
|
||||||
private final TestLaunchObject object;
|
|
||||||
private final TestLaunchDescriptorType type;
|
|
||||||
|
|
||||||
public TestLaunchDescriptor(TestLaunchDescriptorType type, TestLaunchObject object) {
|
|
||||||
this.object = object;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
|
||||||
if (TestLaunchObject.class.equals(adapter)) {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
return super.getAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return object.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchDescriptorType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestLaunchDescriptorType implements ILaunchDescriptorType {
|
|
||||||
final String id;
|
|
||||||
final int priority;
|
|
||||||
|
|
||||||
public TestLaunchDescriptorType(String id, int priority) {
|
|
||||||
this.id = id;
|
|
||||||
this.priority = priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean ownsLaunchObject(Object launchObject) throws CoreException {
|
|
||||||
if (!(launchObject instanceof TestLaunchObject)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return ((TestLaunchObject) launchObject).descType.equals(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException {
|
|
||||||
return new TestLaunchDescriptor(this, (TestLaunchObject) launchObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestLaunchConfigurationProvider extends LaunchConfigurationProvider {
|
|
||||||
final String descTypeId;
|
|
||||||
final String targetTypeId;
|
|
||||||
final ILaunchConfigurationType configType;
|
|
||||||
final boolean isDefault;
|
|
||||||
final LaunchBarManager manager;
|
|
||||||
|
|
||||||
private static final String OBJECT_NAME = "testObject.objectName";
|
|
||||||
private static final String DESC_TYPE = "testObject.descType";
|
|
||||||
|
|
||||||
public TestLaunchConfigurationProvider(String descTypeId, String targetTypeId, ILaunchConfigurationType configType, boolean isDefault, LaunchBarManager manager) {
|
|
||||||
this.descTypeId = descTypeId;
|
|
||||||
this.targetTypeId = targetTypeId;
|
|
||||||
this.configType = configType;
|
|
||||||
this.isDefault = isDefault;
|
|
||||||
this.manager = manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchConfigurationType getLaunchConfigurationType() throws CoreException {
|
|
||||||
return configType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchConfiguration createLaunchConfiguration(ILaunchManager launchManager, ILaunchDescriptor descriptor) throws CoreException {
|
|
||||||
String name = launchManager.generateLaunchConfigurationName(getConfigurationName(descriptor));
|
|
||||||
ILaunchConfigurationWorkingCopy workingCopy = getLaunchConfigurationType().newInstance(null, name);
|
|
||||||
doReturn(name).when(workingCopy).getAttribute(ORIGINAL_NAME, "");
|
|
||||||
|
|
||||||
TestLaunchObject launchObject = (TestLaunchObject) descriptor.getAdapter(TestLaunchObject.class);
|
|
||||||
doReturn(launchObject.name).when(workingCopy).getAttribute(OBJECT_NAME, "");
|
|
||||||
doReturn(manager.getDescriptorTypeId(launchObject.descType)).when(workingCopy).getAttribute(DESC_TYPE, "");
|
|
||||||
return workingCopy.doSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateConfiguration(ILaunchConfigurationWorkingCopy workingCopy, ILaunchDescriptor descriptor) throws CoreException {
|
|
||||||
super.populateConfiguration(workingCopy, descriptor);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
|
|
||||||
if (ownsConfiguration(configuration)) {
|
|
||||||
String objectName = configuration.getAttribute(OBJECT_NAME, "");
|
|
||||||
String descTypeId = configuration.getAttribute(DESC_TYPE, "");
|
|
||||||
if (!objectName.isEmpty() && !descTypeId.isEmpty()) {
|
|
||||||
return new TestLaunchObject(objectName, manager.getLaunchDescriptorType(descTypeId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
|
|
||||||
if (ownsConfiguration(configuration)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract class TestLaunchObjectProvider implements ILaunchObjectProvider {
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
// nothing by default
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ILaunchConfigurationType mockLaunchConfigurationType(String id) {
|
|
||||||
return mockLaunchConfigurationType(id, launchManager.getLaunchModes());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ILaunchConfigurationType mockLaunchConfigurationType(String id, ILaunchMode[] modes) {
|
|
||||||
ILaunchConfigurationType type = mock(ILaunchConfigurationType.class);
|
|
||||||
doReturn(id).when(type).getIdentifier();
|
|
||||||
doReturn(type).when(launchManager).getLaunchConfigurationType(id);
|
|
||||||
|
|
||||||
// mock for supportsMode
|
|
||||||
for (ILaunchMode mode : modes) {
|
|
||||||
String modeid = mode.getIdentifier();
|
|
||||||
doReturn(true).when(type).supportsMode(modeid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ILaunchConfigurationWorkingCopy mockLaunchConfiguration(String name, ILaunchConfigurationType type) throws CoreException {
|
|
||||||
ILaunchConfigurationWorkingCopy wc = mock(ILaunchConfigurationWorkingCopy.class);
|
|
||||||
doReturn(name).when(wc).getName();
|
|
||||||
doReturn(type).when(wc).getType();
|
|
||||||
doReturn(wc).when(wc).doSave();
|
|
||||||
doReturn(name).when(launchManager).generateLaunchConfigurationName(name);
|
|
||||||
doReturn(wc).when(type).newInstance(null, name);
|
|
||||||
return wc;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now that we have all the setup,
|
|
||||||
// Actual tests :)
|
|
||||||
//
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
// Prefs are shared across an entire test
|
|
||||||
prefs = new EclipsePreferences();
|
|
||||||
|
|
||||||
// launch manager and default modes
|
|
||||||
launchManager = mock(ILaunchManager.class);
|
|
||||||
try {
|
|
||||||
doReturn(new ILaunchConfiguration[] {}).when(launchManager).getLaunchConfigurations();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
ILaunchMode runMode = mock(ILaunchMode.class);
|
|
||||||
doReturn("run").when(runMode).getIdentifier();
|
|
||||||
doReturn("Run").when(runMode).getLabel();
|
|
||||||
doReturn("Run As...").when(runMode).getLaunchAsLabel();
|
|
||||||
doReturn(runMode).when(launchManager).getLaunchMode("run");
|
|
||||||
|
|
||||||
ILaunchMode debugMode = mock(ILaunchMode.class);
|
|
||||||
doReturn("debug").when(debugMode).getIdentifier();
|
|
||||||
doReturn("Debug").when(debugMode).getLabel();
|
|
||||||
doReturn("Debug As...").when(debugMode).getLaunchAsLabel();
|
|
||||||
doReturn(debugMode).when(launchManager).getLaunchMode("debug");
|
|
||||||
|
|
||||||
doReturn(new ILaunchMode[] { runMode, debugMode }).when(launchManager).getLaunchModes();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLaunchBarManager() throws Exception {
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager();
|
|
||||||
assertNull(manager.getActiveLaunchDescriptor());
|
|
||||||
assertNull(manager.getActiveLaunchTarget());
|
|
||||||
assertNull(manager.getActiveLaunchMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccessPath() throws Exception {
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager();
|
|
||||||
|
|
||||||
// mock out the launch config that will be created
|
|
||||||
String name = "testConfig";
|
|
||||||
ILaunchConfigurationType configType = manager.getLaunchManager().getLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID);
|
|
||||||
assertNotNull(configType);
|
|
||||||
ILaunchConfigurationWorkingCopy wc = mockLaunchConfiguration(name, configType);
|
|
||||||
|
|
||||||
// fire in launch object and target
|
|
||||||
ILaunchDescriptorType descType = manager.getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID);
|
|
||||||
assertNotNull(descType);
|
|
||||||
TestLaunchObject launchObject = new TestLaunchObject(name, descType);
|
|
||||||
manager.launchObjectAdded(launchObject);
|
|
||||||
|
|
||||||
// check our state
|
|
||||||
assertEquals(manager.getLaunchDescriptor(launchObject), manager.getActiveLaunchDescriptor());
|
|
||||||
assertNull(manager.getActiveLaunchTarget());
|
|
||||||
assertNotNull(manager.getActiveLaunchMode());
|
|
||||||
|
|
||||||
ILaunchTargetType targetType = manager.getLaunchTargetType(DEFAULT_TARGET_TYPE_ID);
|
|
||||||
assertNotNull(targetType);
|
|
||||||
ILaunchTarget testTarget = new TestLaunchTarget("testTarget", targetType);
|
|
||||||
manager.launchTargetAdded(testTarget);
|
|
||||||
|
|
||||||
// verify that our launch config got created and saved
|
|
||||||
assertNotNull(manager.getActiveLaunchMode());
|
|
||||||
assertEquals(wc, manager.getActiveLaunchConfiguration());
|
|
||||||
verify(wc).doSave();
|
|
||||||
|
|
||||||
// now remove the launch object and make sure everything resets
|
|
||||||
manager.launchObjectRemoved(launchObject);
|
|
||||||
assertNull(manager.getActiveLaunchDescriptor());
|
|
||||||
assertNull(manager.getActiveLaunchTarget());
|
|
||||||
assertNull(manager.getActiveLaunchMode());
|
|
||||||
verify(wc).delete();
|
|
||||||
|
|
||||||
// remove the target and make sure it's gone.
|
|
||||||
manager.launchTargetRemoved(testTarget);
|
|
||||||
ILaunchTarget[] allTargets = manager.getAllLaunchTargets();
|
|
||||||
assertEquals(1, allTargets.length);
|
|
||||||
assertNotEquals(testTarget, allTargets[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWrongObject() throws Exception {
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager();
|
|
||||||
|
|
||||||
// mock out the launch config that will be created
|
|
||||||
String name = "testConfig";
|
|
||||||
ILaunchConfigurationType configType = manager.getLaunchManager().getLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID);
|
|
||||||
mockLaunchConfiguration(name, configType);
|
|
||||||
|
|
||||||
// fire in launch target but object with no descriptor
|
|
||||||
manager.launchObjectAdded(new Object());
|
|
||||||
manager.launchTargetAdded(new TestLaunchTarget("testTarget", manager.getLaunchTargetType(DEFAULT_TARGET_TYPE_ID)));
|
|
||||||
|
|
||||||
// verify that there are no launch configs
|
|
||||||
assertNull(manager.getActiveLaunchConfiguration());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNoTarget() throws Exception {
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager();
|
|
||||||
|
|
||||||
// mock out the launch config that will be created
|
|
||||||
String name = "testConfig";
|
|
||||||
ILaunchConfigurationType configType = manager.getLaunchManager().getLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID);
|
|
||||||
ILaunchConfigurationWorkingCopy wc = mockLaunchConfiguration(name, configType);
|
|
||||||
|
|
||||||
// create descriptor and target
|
|
||||||
manager.launchObjectAdded(new TestLaunchObject(name, manager.getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID)));
|
|
||||||
|
|
||||||
// verify that our launch config got created and saved even though the default config type
|
|
||||||
assertEquals(wc, manager.getActiveLaunchConfiguration());
|
|
||||||
verify(wc).doSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultDescriptor() throws Exception {
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager();
|
|
||||||
|
|
||||||
ILaunchConfigurationType configType = mockLaunchConfigurationType("configType.default");
|
|
||||||
ILaunchConfiguration config = mockLaunchConfiguration("defaultConfig", configType);
|
|
||||||
manager.launchConfigurationAdded(config);
|
|
||||||
assertEquals(config, manager.getActiveLaunchConfiguration());
|
|
||||||
|
|
||||||
manager.launchConfigurationRemoved(config);
|
|
||||||
assertNull(manager.getActiveLaunchConfiguration());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetActiveDescriptor() throws Exception {
|
|
||||||
final TestLaunchBarManager manager = new TestLaunchBarManager();
|
|
||||||
ILaunchMode runMode = launchManager.getLaunchMode("run");
|
|
||||||
ILaunchMode debugMode = launchManager.getLaunchMode("debug");
|
|
||||||
|
|
||||||
// descriptor for the test descriptor
|
|
||||||
String name = "test1";
|
|
||||||
ILaunchConfigurationType configType = manager.getLaunchManager().getLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID);
|
|
||||||
ILaunchConfigurationWorkingCopy wc = mockLaunchConfiguration(name, configType);
|
|
||||||
|
|
||||||
ILaunchDescriptorType descType = manager.getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID);
|
|
||||||
TestLaunchObject testObject1 = new TestLaunchObject(name, descType);
|
|
||||||
manager.launchObjectAdded(testObject1);
|
|
||||||
ILaunchDescriptor test1 = manager.getLaunchDescriptor(testObject1);
|
|
||||||
assertNotNull(test1);
|
|
||||||
|
|
||||||
final ILaunchMode[] testActiveMode = new ILaunchMode[1];
|
|
||||||
final ILaunchDescriptor[] testActiveDesc = new ILaunchDescriptor[1];
|
|
||||||
Listener listener = new Listener() {
|
|
||||||
@Override
|
|
||||||
public void launchTargetsChanged() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activeLaunchTargetChanged() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activeLaunchModeChanged() {
|
|
||||||
testActiveMode[0] = manager.getActiveLaunchMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activeLaunchDescriptorChanged() {
|
|
||||||
testActiveDesc[0] = manager.getActiveLaunchDescriptor();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
manager.addListener(listener);
|
|
||||||
|
|
||||||
// descriptor for the default descriptor
|
|
||||||
ILaunchConfigurationType defaultConfigType = mockLaunchConfigurationType("configType.default");
|
|
||||||
ILaunchConfiguration config = mockLaunchConfiguration("test2", defaultConfigType);
|
|
||||||
manager.launchConfigurationAdded(config);
|
|
||||||
ILaunchDescriptor test2 = manager.getLaunchDescriptor(config);
|
|
||||||
assertNotNull(test2);
|
|
||||||
assertNotSame(test1, test2);
|
|
||||||
manager.setActiveLaunchMode(runMode);
|
|
||||||
|
|
||||||
// test2 should be active by default since it was created last
|
|
||||||
assertEquals(test2, manager.getActiveLaunchDescriptor());
|
|
||||||
assertEquals(test2, testActiveDesc[0]);
|
|
||||||
assertEquals(config, manager.getActiveLaunchConfiguration());
|
|
||||||
assertEquals(runMode, manager.getActiveLaunchMode());
|
|
||||||
assertEquals(runMode, testActiveMode[0]);
|
|
||||||
|
|
||||||
// flip to test1
|
|
||||||
testActiveMode[0] = null;
|
|
||||||
testActiveDesc[0] = null;
|
|
||||||
manager.setActiveLaunchDescriptor(test1);
|
|
||||||
manager.setActiveLaunchMode(debugMode);
|
|
||||||
assertEquals(test1, manager.getActiveLaunchDescriptor());
|
|
||||||
assertEquals(test1, testActiveDesc[0]);
|
|
||||||
assertEquals(wc, manager.getActiveLaunchConfiguration());
|
|
||||||
assertEquals(debugMode, manager.getActiveLaunchMode());
|
|
||||||
assertEquals(debugMode, testActiveMode[0]);
|
|
||||||
|
|
||||||
// and back to test2
|
|
||||||
testActiveMode[0] = null;
|
|
||||||
testActiveDesc[0] = null;
|
|
||||||
manager.setActiveLaunchDescriptor(test2);
|
|
||||||
assertEquals(test2, manager.getActiveLaunchDescriptor());
|
|
||||||
assertEquals(test2, testActiveDesc[0]);
|
|
||||||
assertEquals(config, manager.getActiveLaunchConfiguration());
|
|
||||||
assertEquals(runMode, manager.getActiveLaunchMode());
|
|
||||||
assertEquals(runMode, testActiveMode[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetActiveMode() throws Exception {
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager();
|
|
||||||
ILaunchMode runMode = launchManager.getLaunchMode("run");
|
|
||||||
ILaunchMode debugMode = launchManager.getLaunchMode("debug");
|
|
||||||
|
|
||||||
String name = "test";
|
|
||||||
ILaunchConfigurationType testConfigType = manager.getLaunchManager().getLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID);
|
|
||||||
mockLaunchConfiguration(name, testConfigType);
|
|
||||||
|
|
||||||
ILaunchDescriptorType descType = manager.getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID);
|
|
||||||
TestLaunchObject testObject = new TestLaunchObject(name, descType);
|
|
||||||
manager.launchObjectAdded(testObject);
|
|
||||||
assertNotNull(manager.getActiveLaunchConfiguration());
|
|
||||||
|
|
||||||
// The default launch mode is debug (that may change)
|
|
||||||
assertEquals(debugMode, manager.getActiveLaunchMode());
|
|
||||||
|
|
||||||
// Set to run
|
|
||||||
manager.setActiveLaunchMode(runMode);
|
|
||||||
assertEquals(runMode, manager.getActiveLaunchMode());
|
|
||||||
|
|
||||||
// and back to debug
|
|
||||||
manager.setActiveLaunchMode(debugMode);
|
|
||||||
assertEquals(debugMode, manager.getActiveLaunchMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetActiveTarget() throws Exception {
|
|
||||||
// create separate target types and provider types for each one
|
|
||||||
final ILaunchConfigurationType configType1 = mockLaunchConfigurationType("configType.test1");
|
|
||||||
final ILaunchConfigurationType configType2 = mockLaunchConfigurationType("configType.test2");
|
|
||||||
final TestLaunchTargetType targetType1 = new TestLaunchTargetType("targetType.test1");
|
|
||||||
final TestLaunchTargetType targetType2 = new TestLaunchTargetType("targetType.test2");
|
|
||||||
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager() {
|
|
||||||
@Override
|
|
||||||
protected TestLaunchTargetType[] getTestTargetTypes() {
|
|
||||||
return new TestLaunchTargetType[] { targetType1, targetType2 };
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected TestLaunchConfigurationProvider[] getTestConfigProviders() {
|
|
||||||
TestLaunchConfigurationProvider provider1 = new TestLaunchConfigurationProvider(
|
|
||||||
DEFAULT_DESCRIPTOR_TYPE_ID, targetType1.id, configType1, true, this);
|
|
||||||
TestLaunchConfigurationProvider provider2 = new TestLaunchConfigurationProvider(
|
|
||||||
DEFAULT_DESCRIPTOR_TYPE_ID, targetType2.id, configType2, true, this);
|
|
||||||
return new TestLaunchConfigurationProvider[] { provider1, provider2 };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Target 1
|
|
||||||
ILaunchConfiguration config1 = mockLaunchConfiguration("test1", configType1);
|
|
||||||
TestLaunchTarget target1 = new TestLaunchTarget("testTarget1", targetType1);
|
|
||||||
manager.launchTargetAdded(target1);
|
|
||||||
|
|
||||||
// add in our object
|
|
||||||
manager.launchObjectAdded(new TestLaunchObject("test1", manager.getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID)));
|
|
||||||
|
|
||||||
// launch config and target should be the default one
|
|
||||||
assertEquals(target1, manager.getActiveLaunchTarget());
|
|
||||||
assertEquals(config1, manager.getActiveLaunchConfiguration());
|
|
||||||
|
|
||||||
// switching to second target type should create a new config, but it needs a new name
|
|
||||||
ILaunchManager launchManager = manager.getLaunchManager();
|
|
||||||
doReturn("test2").when(launchManager).generateLaunchConfigurationName("test1");
|
|
||||||
ILaunchConfiguration config2 = mockLaunchConfiguration("test2", configType2);
|
|
||||||
TestLaunchTarget target2 = new TestLaunchTarget("testTarget2", targetType2);
|
|
||||||
manager.setActiveLaunchTarget(target2);
|
|
||||||
|
|
||||||
assertEquals(target2, manager.getActiveLaunchTarget());
|
|
||||||
assertEquals(config2, manager.getActiveLaunchConfiguration());
|
|
||||||
assertEquals("test2", manager.getActiveLaunchConfiguration().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TestRestartLaunchBarManager extends TestLaunchBarManager {
|
|
||||||
public TestRestartLaunchBarManager() throws CoreException {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TestLaunchTargetType[] getTestTargetTypes() {
|
|
||||||
TestLaunchTargetType targetType = new TestLaunchTargetType(DEFAULT_TARGET_TYPE_ID) {
|
|
||||||
public void init(ILaunchBarManager manager) throws CoreException {
|
|
||||||
manager.launchTargetAdded(new TestLaunchTarget("testTarget1", this));
|
|
||||||
manager.launchTargetAdded(new TestLaunchTarget("testTarget2", this));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return new TestLaunchTargetType[] { targetType };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TestLaunchObjectProvider[] getTestObjectProviders() {
|
|
||||||
TestLaunchObjectProvider provider = new TestLaunchObjectProvider() {
|
|
||||||
@Override
|
|
||||||
public void init(ILaunchBarManager manager) throws CoreException {
|
|
||||||
mockLaunchConfiguration("test1", launchManager.getLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID));
|
|
||||||
manager.launchObjectAdded(new TestLaunchObject("test1", getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID)));
|
|
||||||
mockLaunchConfiguration("test2", launchManager.getLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID));
|
|
||||||
manager.launchObjectAdded(new TestLaunchObject("test2", getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return new TestLaunchObjectProvider[] { provider };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRestart() throws Exception {
|
|
||||||
// create two over everything, set second active, and make sure it's remembered in a second manager
|
|
||||||
TestLaunchBarManager manager = new TestRestartLaunchBarManager();
|
|
||||||
ILaunchMode runMode = launchManager.getLaunchMode("run");
|
|
||||||
ILaunchMode debugMode = launchManager.getLaunchMode("debug");
|
|
||||||
assertNotNull(runMode);
|
|
||||||
|
|
||||||
// get our targets
|
|
||||||
ILaunchTarget target1 = manager.getLaunchTarget(new Pair<String, String>(DEFAULT_TARGET_TYPE_ID, "testTarget1"));
|
|
||||||
assertNotNull(target1);
|
|
||||||
ILaunchTarget target2 = manager.getLaunchTarget(new Pair<String, String>(DEFAULT_TARGET_TYPE_ID, "testTarget2"));
|
|
||||||
assertNotNull(target2);
|
|
||||||
|
|
||||||
// get our descriptors
|
|
||||||
ILaunchDescriptor desc1 = manager.getLaunchDescriptor(new Pair<String, String>(DEFAULT_DESCRIPTOR_TYPE_ID, "test1"));
|
|
||||||
assertNotNull(desc1);
|
|
||||||
ILaunchDescriptor desc2 = manager.getLaunchDescriptor(new Pair<String, String>(DEFAULT_DESCRIPTOR_TYPE_ID, "test2"));
|
|
||||||
assertNotNull(desc2);
|
|
||||||
|
|
||||||
// Set the actives one way
|
|
||||||
manager.setActiveLaunchDescriptor(desc1);
|
|
||||||
manager.setActiveLaunchTarget(target1);
|
|
||||||
manager.setActiveLaunchMode(runMode);
|
|
||||||
|
|
||||||
// Create a new manager and check they are the same
|
|
||||||
manager = new TestRestartLaunchBarManager();
|
|
||||||
desc1 = manager.getLaunchDescriptor(new Pair<String, String>(DEFAULT_DESCRIPTOR_TYPE_ID, "test1"));
|
|
||||||
assertNotNull(desc1);
|
|
||||||
desc2 = manager.getLaunchDescriptor(new Pair<String, String>(DEFAULT_DESCRIPTOR_TYPE_ID, "test2"));
|
|
||||||
assertNotNull(desc2);
|
|
||||||
assertEquals(desc1, manager.getActiveLaunchDescriptor());
|
|
||||||
|
|
||||||
target1 = manager.getLaunchTarget(new Pair<String, String>(DEFAULT_TARGET_TYPE_ID, "testTarget1"));
|
|
||||||
assertNotNull(target1);
|
|
||||||
target2 = manager.getLaunchTarget(new Pair<String, String>(DEFAULT_TARGET_TYPE_ID, "testTarget2"));
|
|
||||||
assertNotNull(target2);
|
|
||||||
assertEquals(target1, manager.getActiveLaunchTarget());
|
|
||||||
assertEquals(runMode, manager.getActiveLaunchMode());
|
|
||||||
|
|
||||||
// Set them the other way
|
|
||||||
manager.setActiveLaunchDescriptor(desc2);
|
|
||||||
manager.setActiveLaunchTarget(target2);
|
|
||||||
manager.setActiveLaunchMode(debugMode);
|
|
||||||
|
|
||||||
// Create a new manager and check they stuck
|
|
||||||
manager = new TestRestartLaunchBarManager();
|
|
||||||
desc2 = manager.getLaunchDescriptor(new Pair<String, String>(DEFAULT_DESCRIPTOR_TYPE_ID, "test2"));
|
|
||||||
assertNotNull(desc2);
|
|
||||||
assertEquals(desc2, manager.getActiveLaunchDescriptor());
|
|
||||||
target2 = manager.getLaunchTarget(new Pair<String, String>(DEFAULT_TARGET_TYPE_ID, "testTarget2"));
|
|
||||||
assertNotNull(target2);
|
|
||||||
assertEquals(target2, manager.getActiveLaunchTarget());
|
|
||||||
assertEquals(debugMode, manager.getActiveLaunchMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLaunchConfigCapture() throws Exception {
|
|
||||||
final ILaunchConfigurationType configType = mockLaunchConfigurationType(DEFAULT_CONFIG_TYPE_ID);
|
|
||||||
TestLaunchBarManager manager = new TestLaunchBarManager() {
|
|
||||||
protected TestLaunchConfigurationProvider[] getTestConfigProviders() {
|
|
||||||
return new TestLaunchConfigurationProvider[] {
|
|
||||||
new TestLaunchConfigurationProvider(DEFAULT_DESCRIPTOR_TYPE_ID, DEFAULT_TARGET_TYPE_ID, configType, true, this)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ILaunchConfiguration config = mockLaunchConfiguration("test", configType);
|
|
||||||
manager.launchObjectAdded(new TestLaunchObject("test", manager.getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID)));
|
|
||||||
String activeDescId = manager.toString(manager.getDescriptorId(manager.getActiveLaunchDescriptor()));
|
|
||||||
assertEquals(manager.getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID), manager.getActiveLaunchDescriptor().getType());
|
|
||||||
assertEquals(config, manager.getActiveLaunchConfiguration());
|
|
||||||
|
|
||||||
// restart and make sure the same descriptor is selected and new one new ones created
|
|
||||||
doReturn(new ILaunchConfiguration[] { config }).when(launchManager).getLaunchConfigurations();
|
|
||||||
manager = new TestLaunchBarManager() {
|
|
||||||
protected TestLaunchConfigurationProvider[] getTestConfigProviders() {
|
|
||||||
return new TestLaunchConfigurationProvider[] {
|
|
||||||
new TestLaunchConfigurationProvider(DEFAULT_DESCRIPTOR_TYPE_ID, DEFAULT_TARGET_TYPE_ID, configType, true, this)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected TestLaunchObjectProvider[] getTestObjectProviders() {
|
|
||||||
return new TestLaunchObjectProvider[] {
|
|
||||||
new TestLaunchObjectProvider() {
|
|
||||||
@Override
|
|
||||||
public void init(ILaunchBarManager manager) throws CoreException {
|
|
||||||
manager.launchObjectAdded(
|
|
||||||
new TestLaunchObject("test",
|
|
||||||
getLaunchDescriptorType(DEFAULT_DESCRIPTOR_TYPE_ID)));;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
String newActiveDescId = manager.toString(manager.getDescriptorId(manager.getActiveLaunchDescriptor()));
|
|
||||||
assertEquals(activeDescId, newActiveDescId);
|
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO - test that two target types that map to the same desc type and config type share configs
|
|
||||||
// TODO - test duplicating a config. make sure it's default desc and same targets
|
|
||||||
// TODO - test project descriptors and stuff
|
|
||||||
// TODO - test descriptor takeovers (new descriptors on launchObjectChange
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.core.tests;
|
|
||||||
|
|
||||||
import org.osgi.framework.BundleActivator;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
|
|
||||||
public class Activator implements BundleActivator {
|
|
||||||
|
|
||||||
private static BundleContext context;
|
|
||||||
|
|
||||||
static BundleContext getContext() {
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
|
||||||
*/
|
|
||||||
public void start(BundleContext bundleContext) throws Exception {
|
|
||||||
Activator.context = bundleContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
|
||||||
*/
|
|
||||||
public void stop(BundleContext bundleContext) throws Exception {
|
|
||||||
Activator.context = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2004, 2011 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:
|
|
||||||
* QNX Software Systems - initial API and implementation
|
|
||||||
* Markus Schorn (Wind River Systems)
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.launchbar.core.tests;
|
|
||||||
|
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManagerTest;
|
|
||||||
|
|
||||||
public class AutomatedIntegrationSuite extends TestSuite {
|
|
||||||
public AutomatedIntegrationSuite() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public AutomatedIntegrationSuite(Class<? extends TestCase> theClass, String name) {
|
|
||||||
super(theClass, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AutomatedIntegrationSuite(Class<? extends TestCase> theClass) {
|
|
||||||
super(theClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AutomatedIntegrationSuite(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Test suite() {
|
|
||||||
final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite();
|
|
||||||
// tests
|
|
||||||
suite.addTestSuite(LaunchBarManagerTest.class);
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?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.pde.core.requiredPlugins"/>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
|
@ -1,2 +0,0 @@
|
||||||
org.eclipse.cdt.launchbar.core/debug=true
|
|
||||||
org.eclipse.cdt.launchbar.core/debug/launchbar=true
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>org.eclipse.cdt.launchbar.core</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.pde.PluginNature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,7 +0,0 @@
|
||||||
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.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
|
|
@ -1,13 +0,0 @@
|
||||||
Manifest-Version: 1.0
|
|
||||||
Bundle-ManifestVersion: 2
|
|
||||||
Bundle-Name: LaunchBar Core
|
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.launchbar.core;singleton:=true
|
|
||||||
Bundle-Version: 1.0.0.qualifier
|
|
||||||
Bundle-Activator: org.eclipse.cdt.launchbar.core.internal.Activator
|
|
||||||
Bundle-Vendor: Eclipse CDT
|
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
|
||||||
org.eclipse.debug.core
|
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
|
||||||
Bundle-ActivationPolicy: lazy
|
|
||||||
Export-Package: org.eclipse.cdt.launchbar.core,
|
|
||||||
org.eclipse.cdt.launchbar.core.internal;x-friends:="org.eclipse.cdt.launchbar.ui,org.eclipse.cdt.launchbar.core.tests"
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
|
|
||||||
|
|
||||||
<body lang="EN-US">
|
|
||||||
<h2>About This Content</h2>
|
|
||||||
|
|
||||||
<p>June 22, 2007</p>
|
|
||||||
<h3>License</h3>
|
|
||||||
|
|
||||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
|
||||||
indicated below, the Content is provided to you under the terms and conditions of the
|
|
||||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
|
|
||||||
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
|
||||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
|
||||||
|
|
||||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
|
|
||||||
being redistributed by another party ("Redistributor") and different terms and conditions may
|
|
||||||
apply to your use of any object code in the Content. Check the Redistributor's license that was
|
|
||||||
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
|
||||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
|
|
||||||
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
|
|
||||||
|
|
||||||
</body></html>
|
|
|
@ -1,5 +0,0 @@
|
||||||
source.. = src/
|
|
||||||
output.. = bin/
|
|
||||||
bin.includes = META-INF/,\
|
|
||||||
.,\
|
|
||||||
plugin.xml
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<?eclipse version="3.4"?>
|
|
||||||
<plugin>
|
|
||||||
<extension-point id="launchBarContributions" name="Launch Bar Contributions" schema="schema/launchBarContributions.exsd"/>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.cdt.launchbar.core.launchBarContributions">
|
|
||||||
<targetType
|
|
||||||
class="org.eclipse.cdt.launchbar.core.internal.LocalTargetType"
|
|
||||||
id="org.eclipse.cdt.launchbar.core.targetType.local">
|
|
||||||
</targetType>
|
|
||||||
<objectProvider
|
|
||||||
class="org.eclipse.cdt.launchbar.core.internal.ProjectLaunchObjectProvider"
|
|
||||||
id="org.eclipse.cdt.launchbar.core.objectProvider.project">
|
|
||||||
</objectProvider>
|
|
||||||
</extension>
|
|
||||||
|
|
||||||
</plugin>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.eclipse.cdt</groupId>
|
|
||||||
<artifactId>cdt-parent</artifactId>
|
|
||||||
<version>8.5.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
<artifactId>org.eclipse.cdt.launchbar.core</artifactId>
|
|
||||||
<packaging>eclipse-plugin</packaging>
|
|
||||||
</project>
|
|
|
@ -1,294 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<!-- Schema file written by PDE -->
|
|
||||||
<schema targetNamespace="org.eclipse.cdt.launchbar.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.schema plugin="org.eclipse.cdt.launchbar.core" id="launchBarContributions" name="Launch Bar Contributions"/>
|
|
||||||
</appinfo>
|
|
||||||
<documentation>
|
|
||||||
[Enter description of this extension point.]
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<element name="extension">
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.element />
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
|
||||||
<element ref="descriptorType"/>
|
|
||||||
<element ref="targetType"/>
|
|
||||||
<element ref="configType"/>
|
|
||||||
<element ref="configProvider"/>
|
|
||||||
<element ref="objectProvider"/>
|
|
||||||
<element ref="defaultConfigTarget"/>
|
|
||||||
</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="descriptorType">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
A descriptor represents an object that can be converted into a launch configuration. The typical example is IProject. Launch configurations can be created that launch the build output of the project.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="id" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="priority" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="class" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.launchbar.core.ILaunchDescriptorType"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="targetType">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
A target is the machine you launch on. Typical examples include the local machine we are running on, or remote embedded or server targets.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="id" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="class" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.launchbar.core.ILaunchTargetType"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="configType">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Descriptor types and target types map to a launch configuration type. Configurations of that type knows how to launch for the desciptor on targets of that type.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="descriptorType" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.launchbar.core.launchBarContributions/descriptorType/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="targetType" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.launchbar.core.launchBarContributions/targetType/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="launchConfigurationType" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.debug.core.launchConfigurationTypes/launchConfigurationType/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="isDefault" type="boolean">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Is this the default target type for this descriptor type.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="configProvider">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
The config provider knows how to create launch configurations from descriptors. It tracks which configs it has created so that they don't show up as descriptors on their own.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="launchConfigurationType" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.debug.core.launchConfigurationTypes/launchConfigurationType/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="class" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.launchbar.core.ILaunchConfigurationProvider"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="defaultConfigTarget">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
The default config provider is brought in when no other config providers claim a given launch configuration. This entry associates a target type with the launch configuration so that it can be launched on targets of that type.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="launchConfigurationType" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.debug.core.launchConfigurationTypes/launchConfigurationType/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="targetType" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.launchbar.core.launchBarContributions/targetType/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="isDefault" type="boolean">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Is this the default target type for this descriptor type.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="objectProvider">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Object providers pump launch objects into the model as they are created and removed. These are used to create descriptors for these objects.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="id" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="class" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.launchbar.core.ILaunchObjectProvider"/>
|
|
||||||
</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,68 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
public interface ILaunchBarManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A launch object has been added. Create a matching launch descriptor if available.
|
|
||||||
*
|
|
||||||
* @param element launch object
|
|
||||||
* @return the launch descriptor that got created, null of none was
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
ILaunchDescriptor launchObjectAdded(Object launchObject) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A launch object has been removed. Remove the associated launch descriptor if there is one.
|
|
||||||
*
|
|
||||||
* @param element launch object
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
void launchObjectRemoved(Object launchObject) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A launch object has changed in some way that affects the launch bar.
|
|
||||||
*
|
|
||||||
* @param launchObject
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
void launchObjectChanged(Object launchObject) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A new launch target has been added.
|
|
||||||
*
|
|
||||||
* @param target launch target
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
void launchTargetAdded(ILaunchTarget target) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A launch target has been removed.
|
|
||||||
*
|
|
||||||
* @param target launch target
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
void launchTargetRemoved(ILaunchTarget target) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The launch target has changed in some way that affects the
|
|
||||||
* launch bar.
|
|
||||||
*
|
|
||||||
* @param target launch target
|
|
||||||
*/
|
|
||||||
void launchTargetChanged(ILaunchTarget target);
|
|
||||||
|
|
||||||
// TODO API for adding and removing types.
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,62 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The provider of launch configurations of a given type for a given descriptor type
|
|
||||||
* and a given target type.
|
|
||||||
*/
|
|
||||||
public interface ILaunchConfigurationProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does this provider own this launch configuration. If so, make sure the launch descriptor
|
|
||||||
* is properly constructed by sending in a launch object to the launch manager.
|
|
||||||
* And return that object.
|
|
||||||
*
|
|
||||||
* @param configuration
|
|
||||||
* @return launch object that relates to this config
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
Object launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A launch configuration has been removed.
|
|
||||||
*
|
|
||||||
* @param configuration
|
|
||||||
* @return was the launch configuration removed by this provider?
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the launch configuration type for configurations created by this provider.
|
|
||||||
*
|
|
||||||
* @return launch configuration type
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
ILaunchConfigurationType getLaunchConfigurationType() throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a launch configuration for the descriptor to launch on the target.
|
|
||||||
*
|
|
||||||
* @param descriptor
|
|
||||||
* @param target
|
|
||||||
* @return launch configuration
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
ILaunchConfiguration createLaunchConfiguration(ILaunchManager launchManager, ILaunchDescriptor descriptor) throws CoreException;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,38 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a thing that can be launched.
|
|
||||||
* It is good practice that the descriptor is adaptable to the launch object
|
|
||||||
* it is representing.
|
|
||||||
*/
|
|
||||||
public interface ILaunchDescriptor extends IAdaptable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Name to show in the launch descriptor selector.
|
|
||||||
* Names must be unique for all descriptors of a given type.
|
|
||||||
*
|
|
||||||
* @return name of the launch descriptor
|
|
||||||
*/
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of launch descriptor.
|
|
||||||
*
|
|
||||||
* @return provider
|
|
||||||
*/
|
|
||||||
ILaunchDescriptorType getType();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,45 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides mapping between launch objects and launch descriptors.
|
|
||||||
*
|
|
||||||
* It is strongly recommended to extend AbstarctLaunchDescriptorType instead of implementing this directly
|
|
||||||
*/
|
|
||||||
public interface ILaunchDescriptorType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does this type own this launch object?
|
|
||||||
*
|
|
||||||
* @deprecated this needs to be replaced by enablement to avoid plug-in loading.
|
|
||||||
*
|
|
||||||
* @param element
|
|
||||||
* @return owns element
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
boolean ownsLaunchObject(Object launchObject) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a descriptor for the given launch object.
|
|
||||||
*
|
|
||||||
* May return null to essentially eat the element so no other types
|
|
||||||
* create a descriptor for it.
|
|
||||||
*
|
|
||||||
* @param descriptor launch object for descriptor
|
|
||||||
* @return the best descriptor
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An extension that serves up objects to feed launch descriptors.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface ILaunchObjectProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add initial launch descriptors and set up for new ones.
|
|
||||||
*
|
|
||||||
* @param launchbar manager
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
void init(ILaunchBarManager manager) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shutting down, remove any listeners.
|
|
||||||
*/
|
|
||||||
void dispose();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,39 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
|
|
||||||
public interface ILaunchTarget extends IAdaptable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of this target.
|
|
||||||
* Names must be unique across all targets of a given type.
|
|
||||||
*
|
|
||||||
* @return name of the target
|
|
||||||
*/
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the type for this target.
|
|
||||||
*
|
|
||||||
* @return type of the target
|
|
||||||
*/
|
|
||||||
ILaunchTargetType getType();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The active state of this target has changed.
|
|
||||||
*
|
|
||||||
* @param active active state of the target
|
|
||||||
*/
|
|
||||||
void setActive(boolean active);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,30 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
public interface ILaunchTargetType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add initial targets and set up any listeners.
|
|
||||||
*
|
|
||||||
* @param manager
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
void init(ILaunchBarManager manager) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shutting down, remove any listeners
|
|
||||||
*/
|
|
||||||
void dispose();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,77 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.Activator;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A root class for launch configuration providers. Provides the ability to detect launch
|
|
||||||
* configurations that it has created.
|
|
||||||
*/
|
|
||||||
public abstract class LaunchConfigurationProvider implements ILaunchConfigurationProvider {
|
|
||||||
|
|
||||||
// Used to make sure this is the config we've created
|
|
||||||
protected static final String ORIGINAL_NAME = Activator.PLUGIN_ID + ".originalName";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchConfiguration createLaunchConfiguration(ILaunchManager launchManager, ILaunchDescriptor descriptor) throws CoreException {
|
|
||||||
String name = launchManager.generateLaunchConfigurationName(getConfigurationName(descriptor));
|
|
||||||
ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationType().newInstance(null, name);
|
|
||||||
wc.setAttribute(ORIGINAL_NAME, name);
|
|
||||||
populateConfiguration(wc, descriptor);
|
|
||||||
return wc.doSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Potential name for new configurations. Names are still put through the launch manager
|
|
||||||
* to ensure they are unique.
|
|
||||||
*
|
|
||||||
* @param descriptor the launch descriptor triggering the configuration creation
|
|
||||||
* @return candidate configuration name
|
|
||||||
*/
|
|
||||||
protected String getConfigurationName(ILaunchDescriptor descriptor) {
|
|
||||||
// by default, use the descriptor name
|
|
||||||
return descriptor.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populate the new configuration with attributes and resources.
|
|
||||||
*
|
|
||||||
* @param workingCopy working copy for the new configuration
|
|
||||||
* @param descriptor the launch descriptor that triggered the new configuration
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
protected void populateConfiguration(ILaunchConfigurationWorkingCopy workingCopy, ILaunchDescriptor descriptor) throws CoreException {
|
|
||||||
// by default, nothing to add
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if we created this launch configuration. Generally used by the launch configuration
|
|
||||||
* add handler to determine if the incoming launch configuration is ours.
|
|
||||||
*
|
|
||||||
* @param configuration
|
|
||||||
* @return do we own this launch configuration
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
protected boolean ownsConfiguration(ILaunchConfiguration configuration) throws CoreException {
|
|
||||||
// must be the same config type
|
|
||||||
if (!configuration.getType().equals(getLaunchConfigurationType()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// we created it if it has the same name we created it with
|
|
||||||
return configuration.getAttribute(ORIGINAL_NAME, "").equals(configuration.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,80 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A root launch configuration provider that can be used with project launch descriptors.
|
|
||||||
* Takes ownership of configurations we've created that map to the the project.
|
|
||||||
*/
|
|
||||||
public abstract class ProjectLaunchConfigurationProvider extends LaunchConfigurationProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateConfiguration(ILaunchConfigurationWorkingCopy workingCopy, ILaunchDescriptor descriptor) throws CoreException {
|
|
||||||
super.populateConfiguration(workingCopy, descriptor);
|
|
||||||
|
|
||||||
// Add our project to the mapped resources
|
|
||||||
IProject project = (IProject) descriptor.getAdapter(IProject.class);
|
|
||||||
IResource[] mappedResources = workingCopy.getMappedResources();
|
|
||||||
if (mappedResources == null || mappedResources.length == 0) {
|
|
||||||
workingCopy.setMappedResources(new IResource[] { project });
|
|
||||||
} else {
|
|
||||||
IResource[] newResources = new IResource[mappedResources.length + 1];
|
|
||||||
System.arraycopy(mappedResources, 0, newResources, 0, mappedResources.length);
|
|
||||||
newResources[mappedResources.length] = project;
|
|
||||||
workingCopy.setMappedResources(newResources);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract the project from the launch configuration. Used when checking if we own it.
|
|
||||||
*
|
|
||||||
* @param configuration
|
|
||||||
* @return project for launch configuration.
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
protected IProject getProject(ILaunchConfiguration configuration) throws CoreException {
|
|
||||||
// by default return the first project in the mapped resources
|
|
||||||
for (IResource resource : configuration.getMappedResources()) {
|
|
||||||
if (resource instanceof IProject) {
|
|
||||||
return (IProject) resource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
|
|
||||||
if (!ownsConfiguration(configuration)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
IProject project = getProject(configuration);
|
|
||||||
if (project == null) {
|
|
||||||
// The user must have changed project. We don't own it any more in that case.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
|
|
||||||
return ownsConfiguration(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +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.cdt.launchbar.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A reusable descriptor for wrapping projects that can be used by descriptor types
|
|
||||||
* that map to projects.
|
|
||||||
*/
|
|
||||||
public class ProjectLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
|
|
||||||
|
|
||||||
private final ILaunchDescriptorType type;
|
|
||||||
private final IProject project;
|
|
||||||
|
|
||||||
public ProjectLaunchDescriptor(ILaunchDescriptorType type, IProject project) {
|
|
||||||
this.type = type;
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
|
||||||
if (IProject.class.equals(adapter)) {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
return super.getAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return project.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchDescriptorType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,71 +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.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Plugin;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
|
|
||||||
public class Activator extends Plugin {
|
|
||||||
|
|
||||||
public static final String PLUGIN_ID = "org.eclipse.cdt.launchbar.core";
|
|
||||||
private static Activator plugin;
|
|
||||||
private LaunchBarManager launchBarManager;
|
|
||||||
|
|
||||||
public void start(BundleContext bundleContext) throws Exception {
|
|
||||||
super.start(bundleContext);
|
|
||||||
plugin = this;
|
|
||||||
launchBarManager = new LaunchBarManager();
|
|
||||||
bundleContext.registerService(ILaunchBarManager.class, launchBarManager, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop(BundleContext bundleContext) throws Exception {
|
|
||||||
super.stop(bundleContext);
|
|
||||||
plugin = null;
|
|
||||||
launchBarManager.dispose();
|
|
||||||
launchBarManager = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Activator getDefault() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaunchBarManager getLaunchBarManager() {
|
|
||||||
return launchBarManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void throwCoreException(Exception e) throws CoreException {
|
|
||||||
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void log(IStatus status) {
|
|
||||||
if (plugin != null)
|
|
||||||
plugin.getLog().log(status);
|
|
||||||
else
|
|
||||||
System.err.println(status.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void log(Exception exception) {
|
|
||||||
log(new Status(IStatus.ERROR, PLUGIN_ID, exception.getLocalizedMessage(), exception));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String DEBUG_ONE =
|
|
||||||
PLUGIN_ID + "/debug/launchbar";
|
|
||||||
|
|
||||||
public static void trace(String str) {
|
|
||||||
if (plugin == null || (plugin.isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption(DEBUG_ONE))))
|
|
||||||
System.out.println("launchbar: " + str);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +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.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptorType;
|
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A special launch descriptor that managed configurations that aren't owned by other
|
|
||||||
* descriptors.
|
|
||||||
*/
|
|
||||||
public class DefaultLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
|
|
||||||
|
|
||||||
private final DefaultLaunchDescriptorType type;
|
|
||||||
private final ILaunchConfiguration configuration;
|
|
||||||
|
|
||||||
public DefaultLaunchDescriptor(DefaultLaunchDescriptorType type, ILaunchConfiguration configuration) {
|
|
||||||
this.type = type;
|
|
||||||
this.configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
|
||||||
if (ILaunchConfiguration.class.equals(adapter)) {
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
return super.getAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return configuration.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchDescriptorType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptorType;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A special descriptor type that managed configurations that aren't owned
|
|
||||||
* by other descriptor types.
|
|
||||||
*/
|
|
||||||
public class DefaultLaunchDescriptorType implements ILaunchDescriptorType {
|
|
||||||
|
|
||||||
public static final String ID = Activator.PLUGIN_ID + ".descriptorType.default";
|
|
||||||
|
|
||||||
private Map<ILaunchConfiguration, DefaultLaunchDescriptor> descriptors = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean ownsLaunchObject(Object element) {
|
|
||||||
// This descriptor type doesn't own any launch objects
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchDescriptor getDescriptor(Object element) {
|
|
||||||
if (element instanceof ILaunchConfiguration) {
|
|
||||||
ILaunchConfiguration config = (ILaunchConfiguration) element;
|
|
||||||
DefaultLaunchDescriptor descriptor = descriptors.get(config);
|
|
||||||
if (descriptor == null) {
|
|
||||||
descriptor = new DefaultLaunchDescriptor(this, config);
|
|
||||||
descriptors.put(config, descriptor);
|
|
||||||
}
|
|
||||||
return descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,65 +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.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A wrapper class that delays instantiation of classes until they're needed
|
|
||||||
* to prevent early plug-in loading.
|
|
||||||
*
|
|
||||||
* @param <T> the type of the object created
|
|
||||||
*/
|
|
||||||
public class ExecutableExtension<T> {
|
|
||||||
|
|
||||||
private IConfigurationElement element;
|
|
||||||
private String propertyName;
|
|
||||||
private T object;
|
|
||||||
|
|
||||||
public ExecutableExtension(IConfigurationElement element, String propertyName) {
|
|
||||||
this.element = element;
|
|
||||||
this.propertyName = propertyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For testing, pre-populate the object
|
|
||||||
public ExecutableExtension(T object) {
|
|
||||||
this.object = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the object instantiating it if necessary.
|
|
||||||
* @return object
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public T get() throws CoreException {
|
|
||||||
if (element != null) {
|
|
||||||
object = (T) element.createExecutableExtension(propertyName);
|
|
||||||
element = null;
|
|
||||||
propertyName = null;
|
|
||||||
}
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new object. Can't be done if you've done a get already.
|
|
||||||
* @return a new object from the extension or null if get was called earlier
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public T create() throws CoreException {
|
|
||||||
if (element != null) {
|
|
||||||
return (T) element.createExecutableExtension(propertyName);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,43 +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.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The launch target representing the machine we're running on.
|
|
||||||
*/
|
|
||||||
public class LocalTarget extends PlatformObject implements ILaunchTarget {
|
|
||||||
|
|
||||||
private final LocalTargetType type;
|
|
||||||
|
|
||||||
public LocalTarget(LocalTargetType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return Messages.LocalTarget_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchTargetType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive(boolean active) {
|
|
||||||
// nothing to do, we have no active state
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The target type that creates the local target.
|
|
||||||
*/
|
|
||||||
public class LocalTargetType implements ILaunchTargetType {
|
|
||||||
|
|
||||||
public static final String ID = Activator.PLUGIN_ID + ".targetType.local";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(ILaunchBarManager manager) throws CoreException {
|
|
||||||
// create the local target
|
|
||||||
manager.launchTargetAdded(new LocalTarget(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,25 +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.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import org.eclipse.osgi.util.NLS;
|
|
||||||
|
|
||||||
public class Messages extends NLS {
|
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.launchbar.core.internal.messages"; //$NON-NLS-1$
|
|
||||||
public static String LocalTarget_name;
|
|
||||||
static {
|
|
||||||
// initialize resource bundle
|
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Messages() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,70 +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.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Yet another implementation for Pair. You'd figure Java would have this out of the box.
|
|
||||||
* Used in the launch bar mainly for modeling descriptor and target id's which includ both
|
|
||||||
* type id and the object name.
|
|
||||||
*
|
|
||||||
* @param <S> first element
|
|
||||||
* @param <T> second element
|
|
||||||
*/
|
|
||||||
public class Pair<S, T> {
|
|
||||||
|
|
||||||
private final S first;
|
|
||||||
private final T second;
|
|
||||||
|
|
||||||
public Pair(S first, T second) {
|
|
||||||
this.first = first;
|
|
||||||
this.second = second;
|
|
||||||
}
|
|
||||||
|
|
||||||
public S getFirst() {
|
|
||||||
return first;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getSecond() {
|
|
||||||
return second;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((first == null) ? 0 : first.hashCode());
|
|
||||||
result = prime * result + ((second == null) ? 0 : second.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;
|
|
||||||
@SuppressWarnings("unchecked") Pair<S, T> other = (Pair<S, T>) obj;
|
|
||||||
if (first == null) {
|
|
||||||
if (other.first != null)
|
|
||||||
return false;
|
|
||||||
} else if (!first.equals(other.first))
|
|
||||||
return false;
|
|
||||||
if (second == null) {
|
|
||||||
if (other.second != null)
|
|
||||||
return false;
|
|
||||||
} else if (!second.equals(other.second))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,77 +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 - Initial API and implementation
|
|
||||||
* Alena Laskavaia
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.launchbar.core.internal;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchObjectProvider;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IFolder;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
|
||||||
import org.eclipse.core.resources.IResourceChangeListener;
|
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
|
||||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Injects IProject objects from platform resources into the launch bar model for potential
|
|
||||||
* project descriptors.
|
|
||||||
*/
|
|
||||||
public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IResourceChangeListener {
|
|
||||||
private ILaunchBarManager manager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(ILaunchBarManager manager) throws CoreException {
|
|
||||||
this.manager = manager;
|
|
||||||
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
|
|
||||||
manager.launchObjectAdded(project);
|
|
||||||
}
|
|
||||||
ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resourceChanged(IResourceChangeEvent event) {
|
|
||||||
try {
|
|
||||||
event.getDelta().accept(new IResourceDeltaVisitor() {
|
|
||||||
@Override
|
|
||||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
|
||||||
IResource res = delta.getResource();
|
|
||||||
if (res instanceof IProject) {
|
|
||||||
IProject project = (IProject) res;
|
|
||||||
int kind = delta.getKind();
|
|
||||||
if ((kind & IResourceDelta.ADDED) != 0) {
|
|
||||||
manager.launchObjectAdded(project);
|
|
||||||
} else if ((kind & IResourceDelta.REMOVED) != 0) {
|
|
||||||
manager.launchObjectRemoved(project);
|
|
||||||
} else if ((kind & IResourceDelta.CHANGED) != 0) {
|
|
||||||
// TODO may need to be more concise as to what changes we're looking for
|
|
||||||
manager.launchObjectChanged(project);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else if (res instanceof IFile || res instanceof IFolder) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +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
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
LocalTarget_name=Local Machine
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?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.pde.core.requiredPlugins"/>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>org.eclipse.cdt.launchbar.ui</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.pde.PluginNature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,7 +0,0 @@
|
||||||
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.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
|
|
@ -1,29 +0,0 @@
|
||||||
Manifest-Version: 1.0
|
|
||||||
Bundle-ManifestVersion: 2
|
|
||||||
Bundle-Name: LaunchBar UI
|
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.launchbar.ui;singleton:=true
|
|
||||||
Bundle-Version: 1.0.0.qualifier
|
|
||||||
Bundle-Activator: org.eclipse.cdt.launchbar.ui.internal.Activator
|
|
||||||
Bundle-Vendor: Eclipse CDT
|
|
||||||
Require-Bundle: org.eclipse.ui,
|
|
||||||
org.eclipse.core.runtime,
|
|
||||||
org.eclipse.e4.ui.workbench,
|
|
||||||
org.eclipse.e4.ui.model.workbench,
|
|
||||||
org.eclipse.e4.core.di,
|
|
||||||
org.eclipse.e4.core.services,
|
|
||||||
org.eclipse.osgi.services,
|
|
||||||
org.eclipse.cdt.launchbar.core,
|
|
||||||
org.eclipse.debug.ui,
|
|
||||||
org.eclipse.ui.workbench,
|
|
||||||
org.eclipse.ui.ide,
|
|
||||||
org.eclipse.swt,
|
|
||||||
org.eclipse.ui.navigator
|
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
|
||||||
Bundle-ActivationPolicy: lazy
|
|
||||||
Bundle-Localization: plugin
|
|
||||||
Export-Package: org.eclipse.cdt.launchbar.ui,
|
|
||||||
org.eclipse.cdt.launchbar.ui.internal;x-internal:=true,
|
|
||||||
org.eclipse.cdt.launchbar.ui.internal.commands;x-internal:=true,
|
|
||||||
org.eclipse.cdt.launchbar.ui.internal.controls;x-internal:=true,
|
|
||||||
org.eclipse.cdt.launchbar.ui.internal.dialogs;x-internal:=true
|
|
||||||
Import-Package: javax.inject
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
|
|
||||||
|
|
||||||
<body lang="EN-US">
|
|
||||||
<h2>About This Content</h2>
|
|
||||||
|
|
||||||
<p>June 22, 2007</p>
|
|
||||||
<h3>License</h3>
|
|
||||||
|
|
||||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
|
||||||
indicated below, the Content is provided to you under the terms and conditions of the
|
|
||||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
|
|
||||||
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
|
||||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
|
||||||
|
|
||||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
|
|
||||||
being redistributed by another party ("Redistributor") and different terms and conditions may
|
|
||||||
apply to your use of any object code in the Content. Check the Redistributor's license that was
|
|
||||||
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
|
||||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
|
|
||||||
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
|
|
||||||
|
|
||||||
</body></html>
|
|
|
@ -1,7 +0,0 @@
|
||||||
source.. = src/
|
|
||||||
output.. = bin/
|
|
||||||
bin.includes = META-INF/,\
|
|
||||||
.,\
|
|
||||||
plugin.xml,\
|
|
||||||
icons/,\
|
|
||||||
plugin.properties
|
|
Binary file not shown.
Before Width: | Height: | Size: 625 B |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 466 B |
Binary file not shown.
Before Width: | Height: | Size: 358 B |
|
@ -1,3 +0,0 @@
|
||||||
launchToolBar.label = LaunchBar
|
|
||||||
targetsView.name = Launch Targets
|
|
||||||
targetsContent.name = Launch Targets
|
|
|
@ -1,155 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<?eclipse version="3.4"?>
|
|
||||||
<plugin>
|
|
||||||
<extension-point id="launchBarUIContributions" name="launchBar UI Contributions" schema="schema/launchBarUIContributions.exsd"/>
|
|
||||||
<extension
|
|
||||||
id="launchBarInjector"
|
|
||||||
point="org.eclipse.e4.workbench.model">
|
|
||||||
<processor
|
|
||||||
apply="always"
|
|
||||||
beforefragment="false"
|
|
||||||
class="org.eclipse.cdt.launchbar.ui.internal.LaunchBarInjector">
|
|
||||||
</processor>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.commands">
|
|
||||||
<category
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.category.launchBar"
|
|
||||||
name="Launch Bar">
|
|
||||||
</category>
|
|
||||||
<command
|
|
||||||
categoryId="org.eclipse.cdt.launchbar.ui.category.launchBar"
|
|
||||||
defaultHandler="org.eclipse.cdt.launchbar.ui.internal.commands.BuildActiveCommandHandler"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.command.buildActive"
|
|
||||||
name="Build for Active Launch Configuration">
|
|
||||||
</command>
|
|
||||||
<command
|
|
||||||
categoryId="org.eclipse.cdt.launchbar.ui.category.launchBar"
|
|
||||||
defaultHandler="org.eclipse.cdt.launchbar.ui.internal.commands.LaunchActiveCommandHandler"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.command.launchActive"
|
|
||||||
name="Launch Active Configuration">
|
|
||||||
</command>
|
|
||||||
<command
|
|
||||||
categoryId="org.eclipse.cdt.launchbar.ui.category.launchBar"
|
|
||||||
defaultHandler="org.eclipse.cdt.launchbar.ui.internal.commands.StopActiveCommandHandler"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.command.stop"
|
|
||||||
name="Stop">
|
|
||||||
</command>
|
|
||||||
<command
|
|
||||||
defaultHandler="org.eclipse.cdt.launchbar.ui.internal.commands.ConfigureActiveLaunchHandler"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.command.configureActiveLaunch"
|
|
||||||
name="Configure Active Launch Configuration">
|
|
||||||
</command>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.core.runtime.preferences">
|
|
||||||
<initializer
|
|
||||||
class="org.eclipse.cdt.launchbar.ui.internal.LaunchBarPreferenceInitializer">
|
|
||||||
</initializer>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.preferencePages">
|
|
||||||
<page
|
|
||||||
category="org.eclipse.debug.ui.LaunchingPreferencePage"
|
|
||||||
class="org.eclipse.cdt.launchbar.ui.internal.LaunchBarPreferencePage"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.prefPage"
|
|
||||||
name="Launch Bar">
|
|
||||||
</page>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.cdt.launchbar.ui.launchBarUIContributions">
|
|
||||||
<descriptorUI
|
|
||||||
descriptorTypeId="org.eclipse.cdt.launchbar.core.descriptor.default"
|
|
||||||
labelProvider="org.eclipse.cdt.launchbar.ui.internal.DefaultDescriptorLabelProvider">
|
|
||||||
</descriptorUI>
|
|
||||||
<targetUI
|
|
||||||
labelProvider="org.eclipse.cdt.launchbar.ui.internal.LocalTargetLabelProvider"
|
|
||||||
targetTypeId="org.eclipse.cdt.launchbar.core.target.local"
|
|
||||||
name="Local Target">
|
|
||||||
</targetUI>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.perspectiveExtensions">
|
|
||||||
<perspectiveExtension
|
|
||||||
targetID="org.eclipse.cdt.ui.CPerspective">
|
|
||||||
<view
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.targetsView"
|
|
||||||
minimized="false"
|
|
||||||
ratio="0.75"
|
|
||||||
relationship="bottom"
|
|
||||||
relative="org.eclipse.ui.navigator.ProjectExplorer">
|
|
||||||
</view>
|
|
||||||
</perspectiveExtension>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.propertyPages">
|
|
||||||
<page
|
|
||||||
class="org.eclipse.cdt.launchbar.ui.internal.targetsView.TargetPropertyPage"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.infoPropertyPage"
|
|
||||||
name="About">
|
|
||||||
<enabledWhen>
|
|
||||||
<instanceof
|
|
||||||
value="org.eclipse.cdt.launchbar.core.ILaunchTarget">
|
|
||||||
</instanceof>
|
|
||||||
</enabledWhen>
|
|
||||||
</page>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.views">
|
|
||||||
<view
|
|
||||||
category="org.eclipse.cdt.ui.views"
|
|
||||||
class="org.eclipse.cdt.launchbar.ui.internal.targetsView.LaunchTargetsNavigator"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.targetsView"
|
|
||||||
name="%targetsView.name"
|
|
||||||
restorable="true">
|
|
||||||
</view>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.navigator.navigatorContent">
|
|
||||||
<navigatorContent
|
|
||||||
activeByDefault="true"
|
|
||||||
contentProvider="org.eclipse.cdt.launchbar.ui.internal.targetsView.LaunchTargetsContentProvider"
|
|
||||||
id="org.eclipse.cdt.launchbar.ui.targetsViewContent"
|
|
||||||
labelProvider="org.eclipse.cdt.launchbar.ui.internal.targetsView.LaunchTargetsLabelProvider"
|
|
||||||
name="%targetsContent.name">
|
|
||||||
<triggerPoints>
|
|
||||||
<or>
|
|
||||||
<instanceof
|
|
||||||
value="org.eclipse.cdt.launchbar.core.ILaunchBarManager">
|
|
||||||
</instanceof>
|
|
||||||
</or>
|
|
||||||
</triggerPoints>
|
|
||||||
<possibleChildren>
|
|
||||||
<or>
|
|
||||||
<instanceof
|
|
||||||
value="org.eclipse.cdt.launchbar.core.ILaunchTarget">
|
|
||||||
</instanceof>
|
|
||||||
</or>
|
|
||||||
</possibleChildren>
|
|
||||||
<actionProvider
|
|
||||||
class="org.eclipse.cdt.launchbar.ui.internal.targetsView.LaunchTargetsActionProvider">
|
|
||||||
<enablement>
|
|
||||||
<instanceof
|
|
||||||
value="org.eclipse.cdt.launchbar.core.ILaunchTarget">
|
|
||||||
</instanceof>
|
|
||||||
</enablement>
|
|
||||||
</actionProvider>
|
|
||||||
</navigatorContent>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.ui.navigator.viewer">
|
|
||||||
<viewer
|
|
||||||
viewerId="org.eclipse.cdt.launchbar.ui.targetsView">
|
|
||||||
</viewer>
|
|
||||||
<viewerContentBinding
|
|
||||||
viewerId="org.eclipse.cdt.launchbar.ui.targetsView">
|
|
||||||
<includes>
|
|
||||||
<contentExtension
|
|
||||||
isRoot="true"
|
|
||||||
pattern="org.eclipse.cdt.launchbar.ui.targetsViewContent">
|
|
||||||
</contentExtension>
|
|
||||||
</includes>
|
|
||||||
</viewerContentBinding>
|
|
||||||
</extension>
|
|
||||||
|
|
||||||
</plugin>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.eclipse.cdt</groupId>
|
|
||||||
<artifactId>cdt-parent</artifactId>
|
|
||||||
<version>8.5.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
<artifactId>org.eclipse.cdt.launchbar.ui</artifactId>
|
|
||||||
<packaging>eclipse-plugin</packaging>
|
|
||||||
</project>
|
|
|
@ -1,188 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<!-- Schema file written by PDE -->
|
|
||||||
<schema targetNamespace="org.eclipse.cdt.launchbar.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.schema plugin="org.eclipse.cdt.launchbar.ui" id="launchBarUIContributions" name="launchBar UI Contributions"/>
|
|
||||||
</appinfo>
|
|
||||||
<documentation>
|
|
||||||
[Enter description of this extension point.]
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<element name="extension">
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.element />
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
|
||||||
<element ref="descriptorUI"/>
|
|
||||||
<element ref="targetUI"/>
|
|
||||||
</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="descriptorUI">
|
|
||||||
<complexType>
|
|
||||||
<attribute name="descriptorTypeId" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.launchbar.core.launchBarContributions/descriptorType/@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>
|
|
||||||
|
|
||||||
<element name="targetUI">
|
|
||||||
<complexType>
|
|
||||||
<attribute name="targetTypeId" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.launchbar.core.launchBarContributions/targetType/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="name" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Used for identifying this launch target type in various UI elements.
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute translatable="true"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="icon" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Used for identifying this launch target type in various UI elements.
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="resource"/>
|
|
||||||
</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>
|
|
||||||
<attribute name="hoverProvider" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.launchbar.ui.IHoverProvider"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="editCommandId" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.ui.commands/command/@id"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="newWizard" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
An INewWizard that creates a target of this type.
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="java" basedOn=":org.eclipse.ui.INewWizard"/>
|
|
||||||
</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.cdt.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);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +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.cdt.launchbar.ui;
|
|
||||||
|
|
||||||
public interface ILaunchBarUIConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parameter name for the edit target command.
|
|
||||||
*/
|
|
||||||
public static final String TARGET_NAME = "targetName";
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,155 +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.cdt.launchbar.ui.internal;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.core.commands.Command;
|
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
|
||||||
import org.eclipse.core.commands.IParameter;
|
|
||||||
import org.eclipse.core.commands.Parameterization;
|
|
||||||
import org.eclipse.core.commands.ParameterizedCommand;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.resource.ImageRegistry;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.commands.ICommandService;
|
|
||||||
import org.eclipse.ui.handlers.IHandlerService;
|
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
import org.osgi.framework.ServiceReference;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The activator class controls the plug-in life cycle
|
|
||||||
*/
|
|
||||||
public class Activator extends AbstractUIPlugin {
|
|
||||||
|
|
||||||
// The plug-in ID
|
|
||||||
public static final String PLUGIN_ID = "org.eclipse.cdt.launchbar.ui"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
// Images
|
|
||||||
public static final String IMG_BUTTON_BUILD = "build";
|
|
||||||
public static final String IMG_BUTTON_LAUNCH = "launch";
|
|
||||||
public static final String IMG_BUTTON_STOP = "stop";
|
|
||||||
|
|
||||||
// Command ids
|
|
||||||
public static final String CMD_BUILD = "org.eclipse.cdt.launchbar.ui.command.buildActive";
|
|
||||||
public static final String CMD_LAUNCH = "org.eclipse.cdt.launchbar.ui.command.launchActive";
|
|
||||||
public static final String CMD_STOP = "org.eclipse.cdt.launchbar.ui.command.stop";
|
|
||||||
public static final String CMD_CONFIG = "org.eclipse.cdt.launchbar.ui.command.configureActiveLaunch";
|
|
||||||
|
|
||||||
// Preference ids
|
|
||||||
public static final String PREF_ENABLE_LAUNCHBAR = "enableLaunchBar";
|
|
||||||
|
|
||||||
// The shared instance
|
|
||||||
private static Activator plugin;
|
|
||||||
|
|
||||||
// The cache of the Launch Bar UI Manager Object
|
|
||||||
private LaunchBarUIManager launchBarUIManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The constructor
|
|
||||||
*/
|
|
||||||
public Activator() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start(BundleContext context) throws Exception {
|
|
||||||
super.start(context);
|
|
||||||
plugin = this;
|
|
||||||
|
|
||||||
ImageRegistry imageRegistry = getImageRegistry();
|
|
||||||
imageRegistry.put(IMG_BUTTON_BUILD, imageDescriptorFromPlugin(PLUGIN_ID, "icons/build.png"));
|
|
||||||
imageRegistry.put(IMG_BUTTON_LAUNCH, imageDescriptorFromPlugin(PLUGIN_ID, "icons/launch.png"));
|
|
||||||
imageRegistry.put(IMG_BUTTON_STOP, imageDescriptorFromPlugin(PLUGIN_ID, "icons/stop.png"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop(BundleContext context) throws Exception {
|
|
||||||
plugin = null;
|
|
||||||
super.stop(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the shared instance
|
|
||||||
*
|
|
||||||
* @return the shared instance
|
|
||||||
*/
|
|
||||||
public static Activator getDefault() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaunchBarUIManager getLaunchBarUIManager() {
|
|
||||||
if (launchBarUIManager == null) {
|
|
||||||
LaunchBarManager manager = org.eclipse.cdt.launchbar.core.internal.Activator.getDefault().getLaunchBarManager();
|
|
||||||
launchBarUIManager = new LaunchBarUIManager(manager);
|
|
||||||
}
|
|
||||||
return launchBarUIManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image getImage(String id) {
|
|
||||||
return getImageRegistry().get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ImageDescriptor getImageDescriptor(String path) {
|
|
||||||
return imageDescriptorFromPlugin(PLUGIN_ID, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void runCommand(String commandId, String... params) {
|
|
||||||
final ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
|
|
||||||
.getService(ICommandService.class);
|
|
||||||
Command command = commandService.getCommand(commandId);
|
|
||||||
final Event trigger = new Event();
|
|
||||||
final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
|
|
||||||
.getService(IHandlerService.class);
|
|
||||||
ExecutionEvent executionEvent = handlerService.createExecutionEvent(command, trigger);
|
|
||||||
if (params.length == 0) {
|
|
||||||
try {
|
|
||||||
command.executeWithChecks(executionEvent);
|
|
||||||
} catch (OperationCanceledException e) {
|
|
||||||
// abort
|
|
||||||
} catch (Exception e) {
|
|
||||||
log(e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
final Parameterization[] parameterizations = new Parameterization[params.length / 2];
|
|
||||||
for (int i = 0; i < params.length; i += 2) {
|
|
||||||
IParameter param = command.getParameter(params[i]);
|
|
||||||
Parameterization parm = new Parameterization(param, params[i + 1]);
|
|
||||||
parameterizations[i / 2] = parm;
|
|
||||||
}
|
|
||||||
ParameterizedCommand parmCommand = new ParameterizedCommand(command, parameterizations);
|
|
||||||
handlerService.executeCommand(parmCommand, null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void log(IStatus status) {
|
|
||||||
plugin.getLog().log(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void log(Exception e) {
|
|
||||||
if (e instanceof CoreException)
|
|
||||||
log(((CoreException) e).getStatus());
|
|
||||||
plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getService(Class<T> cls) {
|
|
||||||
BundleContext context = getDefault().getBundle().getBundleContext();
|
|
||||||
ServiceReference<T> ref = context.getServiceReference(cls);
|
|
||||||
return ref != null ? context.getService(ref) : null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.ui.internal;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.Activator;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.DefaultLaunchDescriptor;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
|
|
||||||
public class DefaultDescriptorLabelProvider extends LabelProvider {
|
|
||||||
|
|
||||||
private Map<ImageDescriptor, Image> images = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
for (Image image : images.values()) {
|
|
||||||
image.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
if (element instanceof ILaunchDescriptor) {
|
|
||||||
ILaunchConfiguration config = (ILaunchConfiguration) ((ILaunchDescriptor) element).getAdapter(ILaunchConfiguration.class);
|
|
||||||
if (config != null) {
|
|
||||||
try {
|
|
||||||
ILaunchConfigurationType type = config.getType();
|
|
||||||
ImageDescriptor imageDescriptor = DebugUITools.getDefaultImageDescriptor(type);
|
|
||||||
if (imageDescriptor != null) {
|
|
||||||
Image image = images.get(imageDescriptor);
|
|
||||||
if (image == null) {
|
|
||||||
image = imageDescriptor.createImage();
|
|
||||||
images.put(imageDescriptor, image);
|
|
||||||
}
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.getImage(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getText(Object element) {
|
|
||||||
if (element instanceof ILaunchDescriptor) {
|
|
||||||
return ((ILaunchDescriptor) element).getName();
|
|
||||||
}
|
|
||||||
return super.getText(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,124 +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.cdt.launchbar.ui.internal;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.controls.LaunchBarControl;
|
|
||||||
import org.eclipse.e4.core.di.annotations.Execute;
|
|
||||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
|
||||||
import org.eclipse.e4.ui.model.application.MApplication;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.SideValue;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MTrimElement;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
|
|
||||||
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
|
|
||||||
import org.eclipse.e4.ui.workbench.UIEvents;
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
|
||||||
import org.eclipse.swt.widgets.Widget;
|
|
||||||
import org.osgi.service.event.Event;
|
|
||||||
import org.osgi.service.event.EventHandler;
|
|
||||||
|
|
||||||
public class LaunchBarInjector {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
MApplication application;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
IEventBroker eventBroker;
|
|
||||||
|
|
||||||
@Execute
|
|
||||||
void execute() {
|
|
||||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
|
||||||
boolean enabled = store.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
|
|
||||||
injectIntoAll(enabled);
|
|
||||||
|
|
||||||
// Watch for new trimmed windows and inject there too.
|
|
||||||
eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, new EventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(Event event) {
|
|
||||||
if (!UIEvents.isADD(event))
|
|
||||||
return;
|
|
||||||
Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
|
|
||||||
if (newValue instanceof MTrimBar) {
|
|
||||||
MTrimBar trimBar = (MTrimBar) newValue;
|
|
||||||
if (trimBar.getSide() == SideValue.TOP) {
|
|
||||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
|
||||||
boolean enabled = store.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
|
|
||||||
injectLaunchBar(trimBar, enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Watch for preference changes
|
|
||||||
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
|
||||||
if (event.getProperty().equals(Activator.PREF_ENABLE_LAUNCHBAR)) {
|
|
||||||
boolean enabled = Boolean.parseBoolean(event.getNewValue().toString());
|
|
||||||
injectIntoAll(enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void injectIntoAll(boolean enabled) {
|
|
||||||
// Inject the toolbar into all top trims
|
|
||||||
for (MWindow window : application.getChildren()) {
|
|
||||||
if (window instanceof MTrimmedWindow) {
|
|
||||||
for (MTrimBar trimBar : ((MTrimmedWindow) window).getTrimBars()) {
|
|
||||||
if (trimBar.getSide() == SideValue.TOP) {
|
|
||||||
injectLaunchBar(trimBar, enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void injectLaunchBar(MTrimBar trimBar, boolean enabled) {
|
|
||||||
// are we enabled or not
|
|
||||||
|
|
||||||
// Search for control in trimbar
|
|
||||||
MTrimElement launchBarElement = null;
|
|
||||||
for (MTrimElement trimElement : trimBar.getChildren()) {
|
|
||||||
if (LaunchBarControl.ID.equals(trimElement.getElementId())) {
|
|
||||||
launchBarElement = trimElement;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (launchBarElement != null) {
|
|
||||||
if (!enabled) {
|
|
||||||
// remove it if we're disabled
|
|
||||||
trimBar.getChildren().remove(launchBarElement);
|
|
||||||
// This seems to be a bug in the platform but for now, dispose of the widget
|
|
||||||
Widget widget = (Widget)launchBarElement.getWidget();
|
|
||||||
widget.dispose();
|
|
||||||
}
|
|
||||||
// either way, we're done
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enabled) {
|
|
||||||
// Add it
|
|
||||||
MToolControl launchBar = MMenuFactory.INSTANCE.createToolControl();
|
|
||||||
launchBar.setElementId(LaunchBarControl.ID);
|
|
||||||
launchBar.setContributionURI(LaunchBarControl.CLASS_URI);
|
|
||||||
trimBar.getChildren().add(0, launchBar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.ui.internal;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
|
||||||
|
|
||||||
public class LaunchBarPreferenceInitializer extends AbstractPreferenceInitializer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initializeDefaultPreferences() {
|
|
||||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
|
||||||
store.setDefault(Activator.PREF_ENABLE_LAUNCHBAR, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.ui.internal;
|
|
||||||
|
|
||||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
|
||||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
|
||||||
import org.eclipse.ui.IWorkbench;
|
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
|
||||||
|
|
||||||
public class LaunchBarPreferencePage extends FieldEditorPreferencePage implements
|
|
||||||
IWorkbenchPreferencePage {
|
|
||||||
|
|
||||||
public LaunchBarPreferencePage() {
|
|
||||||
super(GRID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(IWorkbench workbench) {
|
|
||||||
setPreferenceStore(Activator.getDefault().getPreferenceStore());
|
|
||||||
setDescription("Preferences for the Launch Bar.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createFieldEditors() {
|
|
||||||
addField(new BooleanFieldEditor(Activator.PREF_ENABLE_LAUNCHBAR, "Enable the Launch Bar.", getFieldEditorParent()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,188 +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.cdt.launchbar.ui.internal;
|
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.ExecutableExtension;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.IHoverProvider;
|
|
||||||
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.Platform;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.ui.INewWizard;
|
|
||||||
|
|
||||||
public class LaunchBarUIManager {
|
|
||||||
|
|
||||||
LaunchBarManager manager;
|
|
||||||
Map<String, ExecutableExtension<ILabelProvider>> descriptorLabelProviders = new HashMap<>();
|
|
||||||
Map<String, LaunchBarTargetContribution> targetContributions = new HashMap<>();
|
|
||||||
|
|
||||||
private final LaunchBarTargetContribution DEFAULT_CONTRIBUTION = new LaunchBarTargetContribution(null, null, null, null,
|
|
||||||
null, null);
|
|
||||||
|
|
||||||
public LaunchBarUIManager(LaunchBarManager manager) {
|
|
||||||
this.manager = manager;
|
|
||||||
|
|
||||||
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launchBarUIContributions");
|
|
||||||
IExtension[] extensions = point.getExtensions();
|
|
||||||
for (IExtension extension : extensions) {
|
|
||||||
for (IConfigurationElement element : extension.getConfigurationElements()) {
|
|
||||||
String elementName = element.getName();
|
|
||||||
if (elementName.equals("descriptorUI")) {
|
|
||||||
String descriptorTypeId = element.getAttribute("descriptorTypeId");
|
|
||||||
ExecutableExtension<ILabelProvider> labelProvider = new ExecutableExtension<>(element, "labelProvider");
|
|
||||||
descriptorLabelProviders.put(descriptorTypeId, labelProvider);
|
|
||||||
} else if (elementName.equals("targetUI")) {
|
|
||||||
String targetTypeId = element.getAttribute("targetTypeId");
|
|
||||||
String targetName = element.getAttribute("name");
|
|
||||||
String iconStr = element.getAttribute("icon");
|
|
||||||
ExecutableExtension<ILabelProvider> labelProvider = new ExecutableExtension<ILabelProvider>(element, "labelProvider");
|
|
||||||
|
|
||||||
ExecutableExtension<IHoverProvider> hoverProvider = null;
|
|
||||||
if (element.getAttribute("hoverProvider") != null) {
|
|
||||||
hoverProvider = new ExecutableExtension<IHoverProvider>(element, "hoverProvider");
|
|
||||||
}
|
|
||||||
|
|
||||||
String editCommandId = element.getAttribute("editCommandId");
|
|
||||||
|
|
||||||
ExecutableExtension<INewWizard> newWizard = null;
|
|
||||||
if (element.getAttribute("newWizard") != null) {
|
|
||||||
newWizard = new ExecutableExtension<INewWizard>(element, "newWizard");
|
|
||||||
}
|
|
||||||
|
|
||||||
targetContributions.put(targetTypeId, new LaunchBarTargetContribution(targetName, iconStr,
|
|
||||||
labelProvider, hoverProvider, editCommandId, newWizard));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaunchBarManager getManager() {
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILabelProvider getLabelProvider(ILaunchDescriptor descriptor) throws CoreException {
|
|
||||||
ExecutableExtension<ILabelProvider> provider = descriptorLabelProviders.get(manager.getDescriptorTypeId(descriptor.getType()));
|
|
||||||
return provider != null ? provider.get() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTargetTypeName(ILaunchTarget target) {
|
|
||||||
return getTargetTypeName(target.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTargetTypeName(ILaunchTargetType targetType) {
|
|
||||||
String typeId = manager.getTargetTypeId(targetType);
|
|
||||||
String name = targetContributions.get(typeId).name;
|
|
||||||
return name != null ? name : typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image getTargetTypeIcon(ILaunchTargetType targetType) {
|
|
||||||
String typeId = manager.getTargetTypeId(targetType);
|
|
||||||
return targetContributions.get(typeId).getIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILabelProvider getLabelProvider(ILaunchTarget target) throws CoreException {
|
|
||||||
ExecutableExtension<ILabelProvider> provider = getContribution(target).labelProvider;
|
|
||||||
return provider != null ? provider.get() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IHoverProvider getHoverProvider(ILaunchTarget target) throws CoreException {
|
|
||||||
ExecutableExtension<IHoverProvider> hoverProvider = getContribution(target).hoverProvider;
|
|
||||||
return hoverProvider != null ? hoverProvider.get() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEditCommand(ILaunchTarget target) {
|
|
||||||
return getContribution(target).editCommandId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<ILaunchTargetType, ExecutableExtension<INewWizard>> getNewTargetWizards() {
|
|
||||||
Map<ILaunchTargetType, ExecutableExtension<INewWizard>> wizards = new HashMap<>();
|
|
||||||
for (Entry<String, LaunchBarTargetContribution> contrib : targetContributions.entrySet()) {
|
|
||||||
if (contrib.getValue().newWizard != null) {
|
|
||||||
ILaunchTargetType type = manager.getLaunchTargetType(contrib.getKey());
|
|
||||||
if (type != null) {
|
|
||||||
wizards.put(type, contrib.getValue().newWizard);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wizards;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Image> getTargetIcons() {
|
|
||||||
Map<String, Image> icons = new HashMap<>();
|
|
||||||
for (LaunchBarTargetContribution contribution : targetContributions.values()) {
|
|
||||||
Image icon = contribution.getIcon();
|
|
||||||
if (icon != null) {
|
|
||||||
icons.put(contribution.name, icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return icons;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LaunchBarTargetContribution getContribution(ILaunchTarget target) {
|
|
||||||
LaunchBarTargetContribution c = targetContributions.get(manager.getTargetTypeId(target.getType()));
|
|
||||||
if (c == null) {
|
|
||||||
return DEFAULT_CONTRIBUTION;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LaunchBarTargetContribution {
|
|
||||||
String name;
|
|
||||||
String iconStr;
|
|
||||||
Image icon;
|
|
||||||
ExecutableExtension<ILabelProvider> labelProvider;
|
|
||||||
ExecutableExtension<IHoverProvider> hoverProvider;
|
|
||||||
String editCommandId;
|
|
||||||
ExecutableExtension<INewWizard> newWizard;
|
|
||||||
|
|
||||||
LaunchBarTargetContribution(String name, String iconStr,
|
|
||||||
ExecutableExtension<ILabelProvider> labelProvider,
|
|
||||||
ExecutableExtension<IHoverProvider> hoverProvider,
|
|
||||||
String editCommand,
|
|
||||||
ExecutableExtension<INewWizard> newWizard) {
|
|
||||||
this.name = name;
|
|
||||||
this.iconStr = iconStr;
|
|
||||||
this.icon = null;
|
|
||||||
this.labelProvider = labelProvider;
|
|
||||||
this.hoverProvider = hoverProvider;
|
|
||||||
this.editCommandId = editCommand;
|
|
||||||
this.newWizard = newWizard;
|
|
||||||
}
|
|
||||||
|
|
||||||
Image getIcon() {
|
|
||||||
if (icon == null) {
|
|
||||||
if (iconStr != null && !iconStr.isEmpty()) {
|
|
||||||
try {
|
|
||||||
icon = ImageDescriptor.createFromURL(new URL(iconStr)).createImage();
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
Activator.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.ui.internal;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
|
|
||||||
|
|
||||||
public class LocalTargetLabelProvider extends LabelProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getText(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
return ((ILaunchTarget) element).getName();
|
|
||||||
}
|
|
||||||
return super.getText(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,27 +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.cdt.launchbar.ui.internal;
|
|
||||||
|
|
||||||
import org.eclipse.osgi.util.NLS;
|
|
||||||
|
|
||||||
public class Messages extends NLS {
|
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.launchbar.ui.internal.messages"; //$NON-NLS-1$
|
|
||||||
public static String LaunchBarControl_Build;
|
|
||||||
public static String LaunchBarControl_Launch;
|
|
||||||
public static String LaunchBarControl_Stop;
|
|
||||||
static {
|
|
||||||
// initialize resource bundle
|
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Messages() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,194 +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.cdt.launchbar.ui.internal.commands;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
|
||||||
import org.eclipse.core.resources.IBuildConfiguration;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchDelegate;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
|
||||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.actions.BuildAction;
|
|
||||||
import org.eclipse.ui.ide.ResourceUtil;
|
|
||||||
import org.eclipse.ui.progress.UIJob;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build active project
|
|
||||||
*/
|
|
||||||
public class BuildActiveCommandHandler extends AbstractHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
||||||
new UIJob(Display.getDefault(), "Building Active Configuration") {
|
|
||||||
@Override
|
|
||||||
public boolean belongsTo(Object family) {
|
|
||||||
return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
final LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
|
||||||
final ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration();
|
|
||||||
|
|
||||||
final Collection<IProject> projects = getProjects(config);
|
|
||||||
if (BuildAction.isSaveAllSet()) {
|
|
||||||
saveEditors(projects);
|
|
||||||
}
|
|
||||||
|
|
||||||
new Job("Building Active Configuration") {
|
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
if (config == null) {
|
|
||||||
// Default, build the workspace
|
|
||||||
ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
|
|
||||||
String mode = launchMode.getIdentifier();
|
|
||||||
Set<String> modes = new HashSet<>();
|
|
||||||
modes.add(mode);
|
|
||||||
ILaunchDelegate delegate = config.getType().getPreferredDelegate(modes);
|
|
||||||
if (delegate == null)
|
|
||||||
delegate = config.getType().getDelegates(modes)[0];
|
|
||||||
ILaunchConfigurationDelegate configDel = delegate.getDelegate();
|
|
||||||
if (configDel instanceof ILaunchConfigurationDelegate2) {
|
|
||||||
ILaunchConfigurationDelegate2 configDel2 = (ILaunchConfigurationDelegate2)configDel;
|
|
||||||
boolean ret;
|
|
||||||
ret = configDel2.preLaunchCheck(config, mode, monitor);
|
|
||||||
if (!ret)
|
|
||||||
return Status.CANCEL_STATUS;
|
|
||||||
if (!configDel2.buildForLaunch(config, mode, monitor))
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fall through, do a normal build
|
|
||||||
if (projects.isEmpty()) {
|
|
||||||
ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
|
|
||||||
} else {
|
|
||||||
Collection<IBuildConfiguration> buildConfigs = getBuildConfigs(projects);
|
|
||||||
ResourcesPlugin.getWorkspace().build(buildConfigs.toArray(new IBuildConfiguration[buildConfigs.size()]),
|
|
||||||
IncrementalProjectBuilder.INCREMENTAL_BUILD, true, monitor);
|
|
||||||
// TODO, may need to get the buildReferences argument from the descriptor
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.schedule();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
};
|
|
||||||
}.schedule();
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Collection<IProject> getProjects(ILaunchConfiguration config) {
|
|
||||||
Set<IProject> projects = new HashSet<>();
|
|
||||||
|
|
||||||
if (config != null) {
|
|
||||||
IResource[] mappedResources;
|
|
||||||
try {
|
|
||||||
mappedResources = config.getMappedResources();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return projects;
|
|
||||||
}
|
|
||||||
if (mappedResources != null) {
|
|
||||||
for (IResource resource : mappedResources) {
|
|
||||||
IProject project = resource.getProject();
|
|
||||||
if (projects.contains(project))
|
|
||||||
continue;
|
|
||||||
projects.add(project);
|
|
||||||
try {
|
|
||||||
projects.addAll(Arrays.asList(project.getReferencedProjects()));
|
|
||||||
} catch (CoreException e) {
|
|
||||||
// skip
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return projects;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Collection<IBuildConfiguration> getBuildConfigs(Collection<IProject> projects) {
|
|
||||||
Set<IBuildConfiguration> configs = new HashSet<>();
|
|
||||||
|
|
||||||
for (IProject project : projects) {
|
|
||||||
try {
|
|
||||||
configs.add(project.getActiveBuildConfig());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
// skip
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return configs;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void saveEditors(final Collection<IProject> projects) {
|
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
|
|
||||||
for (IWorkbenchWindow window : windows) {
|
|
||||||
IWorkbenchPage[] pages = window.getPages();
|
|
||||||
for (IWorkbenchPage page : pages) {
|
|
||||||
if (projects.isEmpty()) {
|
|
||||||
page.saveAllEditors(false);
|
|
||||||
} else {
|
|
||||||
IEditorPart[] editors = page.getDirtyEditors();
|
|
||||||
for (IEditorPart editor : editors) {
|
|
||||||
IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
|
|
||||||
if (inputFile != null) {
|
|
||||||
if (projects.contains(inputFile.getProject())) {
|
|
||||||
page.saveEditor(editor, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +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.cdt.launchbar.ui.internal.commands;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.debug.ui.ILaunchGroup;
|
|
||||||
import org.eclipse.jface.window.Window;
|
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
|
||||||
|
|
||||||
public class ConfigureActiveLaunchHandler extends AbstractHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
||||||
try {
|
|
||||||
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
|
||||||
ILaunchDescriptor desc = launchBarManager.getActiveLaunchDescriptor();
|
|
||||||
ILaunchTarget target = launchBarManager.getActiveLaunchTarget();
|
|
||||||
ILaunchConfiguration launchConfiguration = launchBarManager.getLaunchConfiguration(desc, target);
|
|
||||||
if (launchConfiguration == null)
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
ILaunchConfigurationWorkingCopy wc = launchConfiguration.getWorkingCopy();
|
|
||||||
|
|
||||||
ILaunchMode activeLaunchMode = launchBarManager.getActiveLaunchMode();
|
|
||||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(launchConfiguration.getType(), activeLaunchMode.getIdentifier());
|
|
||||||
|
|
||||||
if (DebugUITools.openLaunchConfigurationPropertiesDialog(HandlerUtil.getActiveShell(event), wc, group.getIdentifier()) == Window.OK)
|
|
||||||
wc.doSave();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +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.cdt.launchbar.ui.internal.commands;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.ui.progress.UIJob;
|
|
||||||
|
|
||||||
public class LaunchActiveCommandHandler extends AbstractHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
||||||
new UIJob(Display.getDefault(), "Launching Active Configuration") {
|
|
||||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
|
||||||
ILaunchDescriptor desc = launchBarManager.getActiveLaunchDescriptor();
|
|
||||||
ILaunchTarget target = launchBarManager.getActiveLaunchTarget();
|
|
||||||
ILaunchConfiguration config = launchBarManager.getLaunchConfiguration(desc, target);
|
|
||||||
if (config == null)
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
|
|
||||||
DebugUITools.launch(config, launchMode.getIdentifier());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
};
|
|
||||||
}.schedule();
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getMode(ILaunchMode launchMode) {
|
|
||||||
return launchMode.getIdentifier(); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,88 +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.cdt.launchbar.ui.internal.commands;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.IJobManager;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.ILaunch;
|
|
||||||
|
|
||||||
public class StopActiveCommandHandler extends AbstractHandler {
|
|
||||||
private ILaunchBarManager launchBarManager;
|
|
||||||
|
|
||||||
public StopActiveCommandHandler() {
|
|
||||||
launchBarManager = Activator.getService(ILaunchBarManager.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
||||||
stop();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop() {
|
|
||||||
stopBuild();
|
|
||||||
stopActiveLaunches();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void stopActiveLaunches() {
|
|
||||||
final ILaunch[] activeLaunches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
|
|
||||||
if (activeLaunches != null && activeLaunches.length > 0) {
|
|
||||||
new Job("Stopping launches") {
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
// TODO only stop the launches for the active launch descriptor
|
|
||||||
// Not sure we have the API to map that out yet.
|
|
||||||
for (ILaunch launch : activeLaunches) {
|
|
||||||
try {
|
|
||||||
launch.terminate();
|
|
||||||
} catch (DebugException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
};
|
|
||||||
}.schedule();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void stopBuild() {
|
|
||||||
Job job = new Job("Stopping build") {
|
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor progress) {
|
|
||||||
// stops all builds
|
|
||||||
final IJobManager jobManager = Job.getJobManager();
|
|
||||||
Job[] jobs = jobManager.find(ResourcesPlugin.FAMILY_MANUAL_BUILD);
|
|
||||||
for (int i = 0; i < jobs.length; i++) {
|
|
||||||
Job job = jobs[i];
|
|
||||||
job.cancel();
|
|
||||||
}
|
|
||||||
jobs = jobManager.find(ResourcesPlugin.FAMILY_AUTO_BUILD);
|
|
||||||
for (int i = 0; i < jobs.length; i++) {
|
|
||||||
Job job = jobs[i];
|
|
||||||
job.cancel();
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
job.schedule();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,103 +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.cdt.launchbar.ui.internal.controls;
|
|
||||||
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
|
||||||
import org.eclipse.swt.events.PaintListener;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
|
|
||||||
public class CButton extends Canvas {
|
|
||||||
|
|
||||||
private boolean inButton;
|
|
||||||
private Image hotImage;
|
|
||||||
private Image coldImage;
|
|
||||||
|
|
||||||
public CButton(Composite parent, int style) {
|
|
||||||
super(parent, style);
|
|
||||||
|
|
||||||
addPaintListener(new PaintListener() {
|
|
||||||
@Override
|
|
||||||
public void paintControl(PaintEvent e) {
|
|
||||||
if (inButton) {
|
|
||||||
if (hotImage != null) {
|
|
||||||
e.gc.drawImage(hotImage, 0, 0);
|
|
||||||
} else if (coldImage != null) {
|
|
||||||
e.gc.drawImage(coldImage, 0, 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (coldImage != null) {
|
|
||||||
e.gc.drawImage(coldImage, 0, 0);
|
|
||||||
} else if (hotImage != null) {
|
|
||||||
e.gc.drawImage(hotImage, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addMouseTrackListener(new MouseTrackAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseEnter(MouseEvent e) {
|
|
||||||
inButton = true;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void mouseExit(MouseEvent e) {
|
|
||||||
inButton = false;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
|
|
||||||
if (hotImage != null)
|
|
||||||
hotImage.dispose();
|
|
||||||
|
|
||||||
if (coldImage != null)
|
|
||||||
coldImage.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
|
||||||
int width = 0;
|
|
||||||
int height = 0;
|
|
||||||
if (hotImage != null) {
|
|
||||||
Rectangle bounds = hotImage.getBounds();
|
|
||||||
width = bounds.width;
|
|
||||||
height = bounds.height;
|
|
||||||
}
|
|
||||||
if (coldImage != null) {
|
|
||||||
Rectangle bounds = coldImage.getBounds();
|
|
||||||
if (bounds.width > width)
|
|
||||||
width = bounds.width;
|
|
||||||
if (bounds.height > height)
|
|
||||||
height = bounds.height;
|
|
||||||
}
|
|
||||||
return new Point(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHotImage(Image image) {
|
|
||||||
this.hotImage = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColdImage(Image image) {
|
|
||||||
this.coldImage = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,834 +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.cdt.launchbar.ui.internal.controls;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.ui.IHoverProvider;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.custom.ScrolledComposite;
|
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
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.MouseTrackAdapter;
|
|
||||||
import org.eclipse.swt.events.MouseTrackListener;
|
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
|
||||||
import org.eclipse.swt.events.PaintListener;
|
|
||||||
import org.eclipse.swt.events.TraverseEvent;
|
|
||||||
import org.eclipse.swt.events.TraverseListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.LineAttributes;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
|
|
||||||
public abstract class CSelector extends Composite {
|
|
||||||
|
|
||||||
private IStructuredContentProvider contentProvider;
|
|
||||||
private ILabelProvider labelProvider;
|
|
||||||
private IHoverProvider hoverProvider;
|
|
||||||
private Comparator<Object> sorter;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
protected final Color backgroundColor;
|
|
||||||
protected final Color outlineColor;
|
|
||||||
protected final Color highlightColor;
|
|
||||||
protected final Color white;
|
|
||||||
|
|
||||||
private boolean mouseOver;
|
|
||||||
|
|
||||||
private Image editImage;
|
|
||||||
private boolean inEditButton;
|
|
||||||
private Image buttonImage;
|
|
||||||
private Label currentIcon;
|
|
||||||
private Label currentLabel;
|
|
||||||
|
|
||||||
private Shell popup;
|
|
||||||
private ListItem listItems[];
|
|
||||||
private int selIndex;
|
|
||||||
private ScrolledComposite listScrolled;
|
|
||||||
private final int itemH = 30;
|
|
||||||
private int scrollBucket;
|
|
||||||
private final int maxScrollBucket = 7;
|
|
||||||
private int separatorIndex = -1;
|
|
||||||
|
|
||||||
|
|
||||||
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("");
|
|
||||||
if (currentLabel != null) {
|
|
||||||
currentLabel.setToolTipText("");
|
|
||||||
}
|
|
||||||
if (currentIcon != null) {
|
|
||||||
currentIcon.setToolTipText("");
|
|
||||||
}
|
|
||||||
toolTipWasModified = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExit(MouseEvent e) {
|
|
||||||
if (mouseOver) {
|
|
||||||
mouseOver = false;
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private MouseListener mouseListener = new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseUp(MouseEvent event) {
|
|
||||||
if (popup == null || popup.isDisposed()) {
|
|
||||||
openPopup();
|
|
||||||
} else {
|
|
||||||
closePopup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private Listener focusOutListener = new Listener() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(Event event) {
|
|
||||||
switch (event.type) {
|
|
||||||
case SWT.FocusOut:
|
|
||||||
Control focusControl = getDisplay().getFocusControl();
|
|
||||||
if (focusControl != null && focusControl.getShell() == popup) {
|
|
||||||
Point loc = getDisplay().getCursorLocation();
|
|
||||||
if (!getBounds().contains(toControl(loc))) {
|
|
||||||
// Don't do it if we're in the selector, we'll deal with that later
|
|
||||||
closePopup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SWT.MouseUp:
|
|
||||||
if (popup != null && !popup.isDisposed()) {
|
|
||||||
Point loc = getDisplay().getCursorLocation();
|
|
||||||
if (!popup.getBounds().contains(loc) && !getBounds().contains(toControl(loc))) {
|
|
||||||
closePopup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
public CSelector(Composite parent, int style) {
|
|
||||||
super(parent, style);
|
|
||||||
|
|
||||||
backgroundColor = new Color(getDisplay(), new RGB(249, 249, 249));
|
|
||||||
outlineColor = new Color(getDisplay(), new RGB(189, 195, 200));
|
|
||||||
highlightColor = new Color(getDisplay(), new RGB(223, 239, 241));
|
|
||||||
white = getDisplay().getSystemColor(SWT.COLOR_WHITE);
|
|
||||||
|
|
||||||
GridLayout mainButtonLayout = new GridLayout();
|
|
||||||
setLayout(mainButtonLayout);
|
|
||||||
|
|
||||||
addPaintListener(new PaintListener() {
|
|
||||||
@Override
|
|
||||||
public void paintControl(PaintEvent e) {
|
|
||||||
GC gc = e.gc;
|
|
||||||
gc.setBackground(backgroundColor);
|
|
||||||
gc.setForeground(outlineColor);
|
|
||||||
Point size = getSize();
|
|
||||||
final int arc = 3;
|
|
||||||
gc.fillRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
|
|
||||||
gc.drawRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addMouseListener(mouseListener);
|
|
||||||
addMouseTrackListener(mouseTrackListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
backgroundColor.dispose();
|
|
||||||
outlineColor.dispose();
|
|
||||||
highlightColor.dispose();
|
|
||||||
if (editImage != null)
|
|
||||||
editImage.dispose();
|
|
||||||
if (buttonImage != null)
|
|
||||||
buttonImage.dispose();
|
|
||||||
if (popup != null)
|
|
||||||
popup.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelection(Object element) {
|
|
||||||
this.selection = element;
|
|
||||||
|
|
||||||
if (buttonComposite != null)
|
|
||||||
buttonComposite.dispose();
|
|
||||||
|
|
||||||
toolTipText = getToolTipText();
|
|
||||||
|
|
||||||
boolean editable = false;
|
|
||||||
int columns = 2;
|
|
||||||
|
|
||||||
Image image = labelProvider.getImage(element);
|
|
||||||
if (image != null)
|
|
||||||
columns++;
|
|
||||||
|
|
||||||
editable = isEditable(element);
|
|
||||||
if (editable)
|
|
||||||
columns++;
|
|
||||||
|
|
||||||
buttonComposite = new Composite(this, SWT.NONE);
|
|
||||||
GridLayout buttonLayout = new GridLayout(columns, false);
|
|
||||||
buttonLayout.marginHeight = buttonLayout.marginWidth = 0;
|
|
||||||
buttonComposite.setLayout(buttonLayout);
|
|
||||||
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 {
|
|
||||||
Composite blank = new Composite(buttonComposite, SWT.NONE);
|
|
||||||
blank.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
currentIcon = null;
|
|
||||||
currentLabel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Canvas arrow = new Canvas(buttonComposite, SWT.NONE) {
|
|
||||||
@Override
|
|
||||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
|
||||||
return new Point(12, 16);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
arrow.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
|
|
||||||
arrow.setBackground(backgroundColor);
|
|
||||||
arrowTransition = new Transition(arrow, arrowMax, 80);
|
|
||||||
|
|
||||||
arrow.addPaintListener(new PaintListener() {
|
|
||||||
@Override
|
|
||||||
public void paintControl(PaintEvent e) {
|
|
||||||
final int hPadding = 2;
|
|
||||||
|
|
||||||
GC gc = e.gc;
|
|
||||||
LineAttributes attributes = new LineAttributes(2);
|
|
||||||
attributes.cap = SWT.CAP_ROUND;
|
|
||||||
gc.setLineAttributes(attributes);
|
|
||||||
|
|
||||||
gc.setAlpha(mouseOver ? 255 : 100);
|
|
||||||
|
|
||||||
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 });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
arrow.addMouseListener(mouseListener);
|
|
||||||
arrow.addMouseTrackListener(mouseTrackListener);
|
|
||||||
|
|
||||||
if (editable) {
|
|
||||||
Control editButton = createEditButton(buttonComposite, element);
|
|
||||||
editButton.setBackground(backgroundColor);
|
|
||||||
|
|
||||||
editButton.addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
// Need to run this after the current event storm
|
|
||||||
// Or we get a disposed error.
|
|
||||||
getDisplay().asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (CSelector.this.selection != null)
|
|
||||||
handleEdit(selection);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void fireSelectionChanged();
|
|
||||||
|
|
||||||
public Object getSelection() {
|
|
||||||
return selection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MouseListener getMouseListener() {
|
|
||||||
return mouseListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MouseTrackListener getMouseTrackListener() {
|
|
||||||
return mouseTrackListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void openPopup() {
|
|
||||||
Object[] elements = contentProvider.getElements(input);
|
|
||||||
if (elements.length == 0 && !hasActionArea())
|
|
||||||
return;
|
|
||||||
|
|
||||||
arrowTransition.to(-arrowMax);
|
|
||||||
|
|
||||||
if (popup != null && !popup.isDisposed()) {
|
|
||||||
popup.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
popup = new Shell(getShell(), SWT.TOOL | SWT.ON_TOP);
|
|
||||||
GridLayout layout = new GridLayout();
|
|
||||||
layout.marginHeight = layout.marginWidth = 0;
|
|
||||||
layout.verticalSpacing = 0;
|
|
||||||
popup.setLayout(layout);
|
|
||||||
|
|
||||||
listScrolled = new ScrolledComposite(popup, SWT.V_SCROLL | SWT.NO_BACKGROUND);
|
|
||||||
listScrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
listScrolled.setExpandHorizontal(true);
|
|
||||||
Composite listComp = new Composite(listScrolled, SWT.NONE);
|
|
||||||
listScrolled.setContent(listComp);
|
|
||||||
layout = new GridLayout();
|
|
||||||
layout.marginHeight = layout.marginWidth = 0;
|
|
||||||
layout.verticalSpacing = 0;
|
|
||||||
listComp.setLayout(layout);
|
|
||||||
|
|
||||||
for (Control child : listComp.getChildren())
|
|
||||||
child.dispose();
|
|
||||||
|
|
||||||
if (sorter != null)
|
|
||||||
Arrays.sort(elements, sorter);
|
|
||||||
|
|
||||||
listItems = new ListItem[elements.length];
|
|
||||||
|
|
||||||
int heightHint = 0;
|
|
||||||
for (int i = 0; i < elements.length; ++i) {
|
|
||||||
if (i == separatorIndex) {
|
|
||||||
Label label = new Label(listComp, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.BORDER);
|
|
||||||
label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
|
||||||
}
|
|
||||||
listItems[i] = new ListItem(listComp, SWT.NONE, elements[i], i);
|
|
||||||
if (i < maxScrollBucket) { // this is how many visible by default
|
|
||||||
listItems[i].lazyInit();
|
|
||||||
if (i == 0) {
|
|
||||||
heightHint = listItems[0].computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
GridData gd = (GridData) listItems[i].getLayoutData();
|
|
||||||
gd.heightHint = heightHint;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Point listCompSize = listComp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
|
||||||
listComp.setSize(listCompSize);
|
|
||||||
|
|
||||||
if (hasActionArea())
|
|
||||||
createActionArea(popup);
|
|
||||||
|
|
||||||
Rectangle buttonBounds = getBounds();
|
|
||||||
Point popupLocation = popup.getDisplay().map(this, null, 0,
|
|
||||||
buttonBounds.height);
|
|
||||||
popup.setLocation(popupLocation.x, popupLocation.y + 5);
|
|
||||||
|
|
||||||
Point size = popup.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
|
||||||
Point buttonSize = getSize();
|
|
||||||
size.x = Math.min(size.x + 16, buttonSize.x * 4 / 3);
|
|
||||||
size.y = Math.min(size.y, 250);
|
|
||||||
popup.setSize(size);
|
|
||||||
|
|
||||||
popup.setVisible(true);
|
|
||||||
popup.setFocus();
|
|
||||||
getDisplay().addFilter(SWT.FocusOut, focusOutListener);
|
|
||||||
getDisplay().addFilter(SWT.MouseUp, focusOutListener);
|
|
||||||
|
|
||||||
popup.addDisposeListener(new DisposeListener() {
|
|
||||||
@Override
|
|
||||||
public void widgetDisposed(DisposeEvent e) {
|
|
||||||
getDisplay().removeFilter(SWT.FocusOut, focusOutListener);
|
|
||||||
getDisplay().removeFilter(SWT.MouseUp, focusOutListener);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
selIndex = -1;
|
|
||||||
scrollBucket = 0;
|
|
||||||
if (hoverProvider != null) {
|
|
||||||
hoverProvider.dismissHover(selection != null ? selection : null, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void closePopup() {
|
|
||||||
arrowTransition.to(arrowMax);
|
|
||||||
popup.setVisible(false);
|
|
||||||
getDisplay().asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
popup.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
TraverseListener listItemTraverseListener = new TraverseListener() {
|
|
||||||
@Override
|
|
||||||
public void keyTraversed(TraverseEvent e) {
|
|
||||||
final ListItem currItem = selIndex >=0 ? listItems[selIndex] : null;
|
|
||||||
if (currItem == null && e.keyCode != SWT.ARROW_DOWN) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.detail == SWT.TRAVERSE_ARROW_NEXT || e.detail == SWT.TRAVERSE_TAB_NEXT) {
|
|
||||||
if (inEditButton || e.keyCode == SWT.ARROW_DOWN) {
|
|
||||||
int maxIdx = listItems.length -1;
|
|
||||||
if (selIndex < maxIdx) {
|
|
||||||
inEditButton = false;
|
|
||||||
if (currItem != null)
|
|
||||||
currItem.setBackground(white);
|
|
||||||
// move to next item
|
|
||||||
selIndex++;
|
|
||||||
if (scrollBucket < maxScrollBucket) {
|
|
||||||
scrollBucket++;
|
|
||||||
} else {
|
|
||||||
// need to scroll the list up 1 item
|
|
||||||
int sY = listScrolled.getOrigin().y;
|
|
||||||
listScrolled.setOrigin(0, sY + itemH);
|
|
||||||
}
|
|
||||||
listItems[selIndex].setBackground(highlightColor);
|
|
||||||
} else if (selIndex == maxIdx && maxIdx > maxScrollBucket) {
|
|
||||||
// level the scroll for any offset at the bottom of the list
|
|
||||||
listScrolled.setOrigin(0, itemH * (maxIdx - maxScrollBucket +1));
|
|
||||||
}
|
|
||||||
} else if (currItem.editButton != null) {
|
|
||||||
// move focus on edit button
|
|
||||||
inEditButton = true;
|
|
||||||
currItem.editButton.redraw();
|
|
||||||
}
|
|
||||||
} else if (e.detail == SWT.TRAVERSE_ARROW_PREVIOUS || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
|
|
||||||
if (!inEditButton || e.keyCode == SWT.ARROW_UP) {
|
|
||||||
if (selIndex > 0) {
|
|
||||||
inEditButton = false;
|
|
||||||
currItem.setBackground(white);
|
|
||||||
// move to previous item
|
|
||||||
selIndex--;
|
|
||||||
if (scrollBucket > 0) {
|
|
||||||
scrollBucket--;
|
|
||||||
} else {
|
|
||||||
// need to scroll the list down 1 item
|
|
||||||
int sY = listScrolled.getOrigin().y;
|
|
||||||
listScrolled.setOrigin(0, sY - itemH);
|
|
||||||
}
|
|
||||||
listItems[selIndex].setBackground(highlightColor);
|
|
||||||
} else if (selIndex == 0) {
|
|
||||||
// level any offset @ beginning
|
|
||||||
listScrolled.setOrigin(0, 0);
|
|
||||||
}
|
|
||||||
} else if (currItem.editButton != null) {
|
|
||||||
// remove focus from edit button
|
|
||||||
inEditButton = false;
|
|
||||||
currItem.editButton.redraw();
|
|
||||||
}
|
|
||||||
} else if (e.detail == SWT.TRAVERSE_RETURN) {
|
|
||||||
if (inEditButton) {
|
|
||||||
inEditButton = false;
|
|
||||||
// edit button in list item was pressed
|
|
||||||
getDisplay().asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (CSelector.this.selection != null)
|
|
||||||
handleEdit(currItem.element);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// list item was pressed
|
|
||||||
popup.dispose();
|
|
||||||
setSelection(currItem.element);
|
|
||||||
fireSelectionChanged();
|
|
||||||
}
|
|
||||||
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
|
|
||||||
popup.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private class ListItem extends Composite {
|
|
||||||
protected final Object element;
|
|
||||||
private Label icon;
|
|
||||||
private Label label;
|
|
||||||
protected Control editButton;
|
|
||||||
private int index;
|
|
||||||
|
|
||||||
public ListItem(Composite parent, int style, Object _element, int index) {
|
|
||||||
super(parent, style);
|
|
||||||
this.element = _element;
|
|
||||||
this.index = index;
|
|
||||||
|
|
||||||
setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
|
||||||
addPaintListener(new PaintListener() {
|
|
||||||
@Override
|
|
||||||
public void paintControl(PaintEvent e) {
|
|
||||||
|
|
||||||
Point size = getSize();
|
|
||||||
GC gc = e.gc;
|
|
||||||
gc.setForeground(outlineColor);
|
|
||||||
gc.drawLine(0, size.y - 1, size.x, size.y - 1);
|
|
||||||
if (label == null)
|
|
||||||
lazyInit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// lazyInit();
|
|
||||||
} // end ListItem(..)
|
|
||||||
|
|
||||||
protected void lazyInit() {
|
|
||||||
Image image = labelProvider.getImage(element);
|
|
||||||
boolean editable = isEditable(element);
|
|
||||||
|
|
||||||
int columns = 1;
|
|
||||||
if (image != null)
|
|
||||||
columns++;
|
|
||||||
if (editable)
|
|
||||||
columns++;
|
|
||||||
|
|
||||||
GridLayout layout = new GridLayout(columns, false);
|
|
||||||
layout.marginWidth = layout.marginHeight = 7;
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
MouseListener listItemMouseListener = new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
popup.dispose();
|
|
||||||
setSelection(element);
|
|
||||||
fireSelectionChanged();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
MouseTrackListener listItemMouseTrackListener = new MouseTrackAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseEnter(MouseEvent e) {
|
|
||||||
setBackground(highlightColor);
|
|
||||||
int idx = getIndex();
|
|
||||||
if (idx != selIndex) {
|
|
||||||
if (selIndex >= 0) {
|
|
||||||
listItems[selIndex].setBackground(white);
|
|
||||||
scrollBucket = Math.max(Math.min(scrollBucket + idx - selIndex, maxScrollBucket), 0);
|
|
||||||
} else { // initially
|
|
||||||
scrollBucket = Math.min(idx, maxScrollBucket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selIndex = idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExit(MouseEvent e) {
|
|
||||||
setBackground(white);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
addMouseListener(listItemMouseListener);
|
|
||||||
addMouseTrackListener(listItemMouseTrackListener);
|
|
||||||
|
|
||||||
if (image != null) {
|
|
||||||
icon = createImage(this, image);
|
|
||||||
icon.addMouseListener(listItemMouseListener);
|
|
||||||
icon.addMouseTrackListener(listItemMouseTrackListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
label = createLabel(this, element);
|
|
||||||
label.addMouseListener(listItemMouseListener);
|
|
||||||
label.addMouseTrackListener(listItemMouseTrackListener);
|
|
||||||
|
|
||||||
if (editable) {
|
|
||||||
editButton = createEditButton(this, element);
|
|
||||||
editButton.setBackground(white);
|
|
||||||
editButton.addMouseTrackListener(listItemMouseTrackListener);
|
|
||||||
|
|
||||||
editButton.addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
// Need to run this after the current event storm
|
|
||||||
// Or we get a disposed error.
|
|
||||||
getDisplay().asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (CSelector.this.selection != null)
|
|
||||||
handleEdit(element);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
editButton.addTraverseListener(listItemTraverseListener);
|
|
||||||
} else {
|
|
||||||
addTraverseListener(listItemTraverseListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
setBackground(white);
|
|
||||||
|
|
||||||
layout(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBackground(Color color) {
|
|
||||||
super.setBackground(color);
|
|
||||||
|
|
||||||
if (icon != null && !icon.isDisposed())
|
|
||||||
icon.setBackground(color);
|
|
||||||
|
|
||||||
if (!label.isDisposed())
|
|
||||||
label.setBackground(color);
|
|
||||||
|
|
||||||
if (editButton != null && !editButton.isDisposed())
|
|
||||||
editButton.setBackground(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImage(Image image) {
|
|
||||||
if (icon != null && !icon.isDisposed())
|
|
||||||
icon.setImage(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String text) {
|
|
||||||
if (!label.isDisposed())
|
|
||||||
label.setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getIndex() {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
} // end ListItem class
|
|
||||||
|
|
||||||
private Label createImage(Composite parent, Image image) {
|
|
||||||
Rectangle bounds = image.getBounds();
|
|
||||||
boolean disposeImage = false;
|
|
||||||
if (bounds.height > 16 || bounds.width > 16) {
|
|
||||||
buttonImage = new Image(getDisplay(), 16, 16);
|
|
||||||
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.dispose();
|
|
||||||
image = buttonImage;
|
|
||||||
}
|
|
||||||
Label icon = new Label(parent, SWT.NONE);
|
|
||||||
icon.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
|
||||||
icon.setImage(image);
|
|
||||||
if (disposeImage) {
|
|
||||||
final Image disposableImage = image;
|
|
||||||
icon.addDisposeListener(new DisposeListener() {
|
|
||||||
@Override
|
|
||||||
public void widgetDisposed(DisposeEvent e) {
|
|
||||||
disposableImage.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Label createLabel(Composite parent, Object element) {
|
|
||||||
Label label = new Label(parent, SWT.NONE);
|
|
||||||
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
|
|
||||||
label.setText(labelProvider.getText(element));
|
|
||||||
label.setFont(getDisplay().getSystemFont());
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Control createEditButton(Composite parent, Object element) {
|
|
||||||
if (editImage == null) {
|
|
||||||
editImage = Activator.getImageDescriptor("icons/config_config.png").createImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
final Canvas editButton = new Canvas(parent, SWT.NONE) {
|
|
||||||
@Override
|
|
||||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
|
||||||
Rectangle bounds = editImage.getBounds();
|
|
||||||
return new Point(bounds.width, bounds.height);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
|
||||||
editButton.setToolTipText("Edit");
|
|
||||||
|
|
||||||
editButton.addPaintListener(new PaintListener() {
|
|
||||||
@Override
|
|
||||||
public void paintControl(PaintEvent e) {
|
|
||||||
GC gc = e.gc;
|
|
||||||
gc.setAlpha(inEditButton ? 255 : 64);
|
|
||||||
gc.drawImage(editImage, 0, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
editButton.addMouseTrackListener(new MouseTrackAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseEnter(MouseEvent e) {
|
|
||||||
inEditButton = true;
|
|
||||||
editButton.redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExit(MouseEvent e) {
|
|
||||||
inEditButton = false;
|
|
||||||
editButton.redraw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return editButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContentProvider(IStructuredContentProvider contentProvider) {
|
|
||||||
this.contentProvider = contentProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IStructuredContentProvider getContentProvider() {
|
|
||||||
return contentProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabelProvider(ILabelProvider labelProvider) {
|
|
||||||
this.labelProvider = labelProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILabelProvider getLabelProvider() {
|
|
||||||
return labelProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHoverProvider(IHoverProvider hoverProvider) {
|
|
||||||
this.hoverProvider = hoverProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IHoverProvider getHoverProvider() {
|
|
||||||
return hoverProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSorter(Comparator<Object> sorter) {
|
|
||||||
this.sorter = sorter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInput(Object input) {
|
|
||||||
this.input = input;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getInput() {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
// TODO add any new ones to the popup if it's open
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Object element) {
|
|
||||||
if (selection == element) {
|
|
||||||
if (currentIcon != null && !currentIcon.isDisposed()) {
|
|
||||||
currentIcon.setImage(labelProvider.getImage(element));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentLabel != null && !currentLabel.isDisposed()) {
|
|
||||||
currentLabel.setText(labelProvider.getText(element));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (popup != null && !popup.isDisposed()) {
|
|
||||||
Object[] elements = contentProvider.getElements(input);
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < elements.length; ++i)
|
|
||||||
if (element == elements[i])
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i != elements.length) {
|
|
||||||
listItems[i].setImage(labelProvider.getImage(element));
|
|
||||||
listItems[i].setText(labelProvider.getText(element));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean hasActionArea() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createActionArea(Composite parent) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isEditable(Object element) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleEdit(Object element) {
|
|
||||||
// nothing to do here
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSeparatorIndex() {
|
|
||||||
return separatorIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSeparatorIndex(int separatorIndex) {
|
|
||||||
this.separatorIndex = separatorIndex;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,290 +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.cdt.launchbar.ui.internal.controls;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.DefaultDescriptorLabelProvider;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.LaunchBarUIManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.dialogs.NewLaunchConfigWizard;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
|
||||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
|
|
||||||
import org.eclipse.debug.ui.ILaunchGroup;
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
import org.eclipse.jface.window.Window;
|
|
||||||
import org.eclipse.jface.wizard.WizardDialog;
|
|
||||||
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.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.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class ConfigSelector extends CSelector {
|
|
||||||
|
|
||||||
private LaunchBarUIManager uiManager = Activator.getDefault().getLaunchBarUIManager();
|
|
||||||
private DefaultDescriptorLabelProvider defaultProvider;
|
|
||||||
|
|
||||||
private static final String[] noConfigs = new String[] { "No Launch Configurations" };
|
|
||||||
private static final int SEPARATOR_INDEX = 3;
|
|
||||||
|
|
||||||
public ConfigSelector(Composite parent, int style) {
|
|
||||||
super(parent, style);
|
|
||||||
|
|
||||||
setToolTipText("Launch configuration");
|
|
||||||
defaultProvider = new DefaultDescriptorLabelProvider();
|
|
||||||
|
|
||||||
setContentProvider(new IStructuredContentProvider() {
|
|
||||||
@Override
|
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Object[] getElements(Object inputElement) {
|
|
||||||
ILaunchDescriptor[] descs = uiManager.getManager().getLaunchDescriptors();
|
|
||||||
if (descs.length > 0) {
|
|
||||||
if (descs.length > SEPARATOR_INDEX + 1) {
|
|
||||||
ILaunchDescriptor[] descsCopy = new ILaunchDescriptor[SEPARATOR_INDEX + descs.length];
|
|
||||||
System.arraycopy(descs, 0, descsCopy, 0, SEPARATOR_INDEX); // copy first 3 elements
|
|
||||||
System.arraycopy(descs, 0, descsCopy, SEPARATOR_INDEX, descs.length); // copy all into rest
|
|
||||||
// sort rest
|
|
||||||
Arrays.sort(descsCopy, SEPARATOR_INDEX, descsCopy.length, new Comparator<ILaunchDescriptor>() {
|
|
||||||
@Override
|
|
||||||
public int compare(ILaunchDescriptor o1, ILaunchDescriptor o2) {
|
|
||||||
return o1.getName().compareTo(o2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return descsCopy;
|
|
||||||
} else
|
|
||||||
return descs;
|
|
||||||
}
|
|
||||||
return noConfigs;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setLabelProvider(new LabelProvider() {
|
|
||||||
@Override
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
if (element instanceof ILaunchDescriptor) {
|
|
||||||
try {
|
|
||||||
ILaunchDescriptor configDesc = (ILaunchDescriptor)element;
|
|
||||||
ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc);
|
|
||||||
if (labelProvider != null) {
|
|
||||||
Image img = labelProvider.getImage(element);
|
|
||||||
if (img != null)
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defaultProvider.getImage(element);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getText(Object element) {
|
|
||||||
if (element instanceof String) {
|
|
||||||
return (String)element;
|
|
||||||
} else if (element instanceof ILaunchDescriptor) {
|
|
||||||
try {
|
|
||||||
ILaunchDescriptor configDesc = (ILaunchDescriptor)element;
|
|
||||||
ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc);
|
|
||||||
if (labelProvider != null) {
|
|
||||||
String text = labelProvider.getText(element);
|
|
||||||
if (text != null)
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defaultProvider.getText(element);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// no sorter on view, data is sorted by provider
|
|
||||||
setSorter(null);
|
|
||||||
setSeparatorIndex(SEPARATOR_INDEX);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void fireSelectionChanged() {
|
|
||||||
Object selected = getSelection();
|
|
||||||
if (selected instanceof ILaunchDescriptor) {
|
|
||||||
ILaunchDescriptor configDesc = (ILaunchDescriptor) selected;
|
|
||||||
try {
|
|
||||||
uiManager.getManager().setActiveLaunchDescriptor(configDesc);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEditable(Object element) {
|
|
||||||
return element instanceof ILaunchDescriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleEdit(Object element) {
|
|
||||||
try {
|
|
||||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
|
||||||
LaunchBarManager manager = uiManager.getManager();
|
|
||||||
ILaunchDescriptor desc = (ILaunchDescriptor) element;
|
|
||||||
ILaunchMode mode = manager.getActiveLaunchMode();
|
|
||||||
ILaunchTarget target = manager.getActiveLaunchTarget();
|
|
||||||
if (target == null) {
|
|
||||||
MessageDialog.openError(shell, "No Active Target", "You must create a target to edit this launch configuration.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ILaunchConfigurationType configType = manager.getLaunchConfigurationType(desc, target);
|
|
||||||
if (configType == null) {
|
|
||||||
MessageDialog.openError(shell, "No launch configuration type", "Cannot edit this configuration");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType, mode.getIdentifier());
|
|
||||||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier());
|
|
||||||
if (groupExt != null) {
|
|
||||||
ILaunchConfiguration config = manager.getLaunchConfiguration(desc, target);
|
|
||||||
if (config == null) {
|
|
||||||
MessageDialog.openError(shell, "No launch configuration", "Cannot edit this configuration");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).isDirty()) {
|
|
||||||
config = ((ILaunchConfigurationWorkingCopy) config).doSave();
|
|
||||||
}
|
|
||||||
final LaunchConfigurationEditDialog dialog = new LaunchConfigurationEditDialog(shell, config, groupExt);
|
|
||||||
dialog.setInitialStatus(Status.OK_STATUS);
|
|
||||||
dialog.open();
|
|
||||||
}
|
|
||||||
} catch (CoreException e2) {
|
|
||||||
Activator.log(e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasActionArea() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createActionArea(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(white);
|
|
||||||
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("Create New Configuration...");
|
|
||||||
createLabel.setBackground(white);
|
|
||||||
|
|
||||||
MouseListener mouseListener = new MouseAdapter() {
|
|
||||||
public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
|
|
||||||
final NewLaunchConfigWizard wizard = new NewLaunchConfigWizard();
|
|
||||||
WizardDialog dialog = new WizardDialog(getShell(), wizard);
|
|
||||||
if (dialog.open() == Window.OK) {
|
|
||||||
new Job("Create Launch Configuration") {
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
wizard.getWorkingCopy().doSave();
|
|
||||||
ILaunchMode lm = wizard.getLaunchMode();
|
|
||||||
uiManager.getManager().setActiveLaunchMode(lm);
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}.schedule();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
|
||||||
return super.computeSize(250, hHint, changed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSelection(Object element) {
|
|
||||||
if (element == null)
|
|
||||||
element = noConfigs[0];
|
|
||||||
super.setSelection(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,166 +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.cdt.launchbar.ui.internal.controls;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.PreDestroy;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager.Listener;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Messages;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
|
||||||
import org.eclipse.swt.events.MouseAdapter;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
|
|
||||||
public class LaunchBarControl implements Listener {
|
|
||||||
|
|
||||||
public static final String ID = "org.eclipse.cdt.launchbar"; //$NON-NLS-1$
|
|
||||||
public static final String CLASS_URI = "bundleclass://" + Activator.PLUGIN_ID + "/" + LaunchBarControl.class.getName(); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
|
|
||||||
private LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
|
||||||
|
|
||||||
private ConfigSelector configSelector;
|
|
||||||
private ModeSelector modeSelector;
|
|
||||||
private TargetSelector targetSelector;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void createControl(Composite parent) {
|
|
||||||
manager.addListener(this);
|
|
||||||
|
|
||||||
Composite container = new Composite(parent, SWT.NONE);
|
|
||||||
container.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
||||||
GridLayout layout = new GridLayout(7, false);
|
|
||||||
layout.marginHeight = 8;
|
|
||||||
layout.marginWidth = 8;
|
|
||||||
container.setLayout(layout);
|
|
||||||
container.addDisposeListener(new DisposeListener() {
|
|
||||||
@Override
|
|
||||||
public void widgetDisposed(DisposeEvent e) {
|
|
||||||
LaunchBarControl.this.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
createButton(container, Activator.IMG_BUTTON_BUILD, Messages.LaunchBarControl_Build, Activator.CMD_BUILD);
|
|
||||||
createButton(container, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch, Activator.CMD_LAUNCH);
|
|
||||||
createButton(container, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop, Activator.CMD_STOP);
|
|
||||||
|
|
||||||
modeSelector = new ModeSelector(container, SWT.NONE);
|
|
||||||
modeSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
||||||
modeSelector.setInput(manager);
|
|
||||||
|
|
||||||
configSelector = new ConfigSelector(container, SWT.NONE);
|
|
||||||
configSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
||||||
configSelector.setInput(manager);
|
|
||||||
|
|
||||||
Label label = new Label(container, SWT.NONE);
|
|
||||||
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
||||||
label.setText("on" + ":");
|
|
||||||
|
|
||||||
targetSelector = new TargetSelector(container, SWT.NONE);
|
|
||||||
targetSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
||||||
targetSelector.setInput(manager);
|
|
||||||
|
|
||||||
ILaunchDescriptor configDesc = manager.getActiveLaunchDescriptor();
|
|
||||||
configSelector.setSelection(configDesc == null ? null : configDesc);
|
|
||||||
|
|
||||||
ILaunchMode mode = manager.getActiveLaunchMode();
|
|
||||||
modeSelector.setSelection(mode == null ? null : mode);
|
|
||||||
|
|
||||||
ILaunchTarget target = manager.getActiveLaunchTarget();
|
|
||||||
targetSelector.setSelection(target == null ? null : target);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreDestroy
|
|
||||||
public void dispose() {
|
|
||||||
manager.removeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createButton(Composite parent, String imageName, String toolTipText, final String command) {
|
|
||||||
CButton button = new CButton(parent, SWT.NONE);
|
|
||||||
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);
|
|
||||||
button.setHotImage(image);
|
|
||||||
button.setToolTipText(toolTipText);
|
|
||||||
button.addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
Activator.runCommand(command);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activeLaunchDescriptorChanged() {
|
|
||||||
if (configSelector != null && !configSelector.isDisposed()) {
|
|
||||||
final ILaunchDescriptor configDesc = manager.getActiveLaunchDescriptor();
|
|
||||||
configSelector.getDisplay().asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!configSelector.isDisposed())
|
|
||||||
configSelector.setSelection(configDesc == null ? null : configDesc);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activeLaunchModeChanged() {
|
|
||||||
if (modeSelector != null && !modeSelector.isDisposed()) {
|
|
||||||
final ILaunchMode mode = manager.getActiveLaunchMode();
|
|
||||||
modeSelector.getDisplay().asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!modeSelector.isDisposed())
|
|
||||||
modeSelector.setSelection(mode == null ? null : mode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activeLaunchTargetChanged() {
|
|
||||||
if (targetSelector != null && !targetSelector.isDisposed()) {
|
|
||||||
final ILaunchTarget target = manager.getActiveLaunchTarget();
|
|
||||||
targetSelector.getDisplay().asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!targetSelector.isDisposed())
|
|
||||||
targetSelector.setSelection(target == null ? null : target);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void launchTargetsChanged() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,173 +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.cdt.launchbar.ui.internal.controls;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
|
||||||
import org.eclipse.debug.ui.ILaunchGroup;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class ModeSelector extends CSelector {
|
|
||||||
|
|
||||||
private static final String[] noModes = new String[] { "---" };
|
|
||||||
|
|
||||||
private final LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
|
||||||
|
|
||||||
public ModeSelector(Composite parent, int style) {
|
|
||||||
super(parent, style);
|
|
||||||
|
|
||||||
setToolTipText("Launch configuration");
|
|
||||||
|
|
||||||
setContentProvider(new IStructuredContentProvider() {
|
|
||||||
@Override
|
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Object[] getElements(Object inputElement) {
|
|
||||||
try {
|
|
||||||
ILaunchMode[] modes = manager.getLaunchModes();
|
|
||||||
if (modes.length > 0)
|
|
||||||
return modes;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
return noModes;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setLabelProvider(new LabelProvider() {
|
|
||||||
private Map<ImageDescriptor, Image> images = new HashMap<>();
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
for (Image image : images.values()) {
|
|
||||||
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) {
|
|
||||||
ImageDescriptor imageDesc = group.getImageDescriptor();
|
|
||||||
Image image = images.get(imageDesc);
|
|
||||||
if (image == null) {
|
|
||||||
image = imageDesc.createImage();
|
|
||||||
images.put(imageDesc, image);
|
|
||||||
}
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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) {
|
|
||||||
return group.getLabel().replace("&", "");
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.getText(element);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setSorter(new Comparator<Object>() {
|
|
||||||
@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();
|
|
||||||
// run comes first, then debug, then the rest
|
|
||||||
if (mode1.equals("run")) {
|
|
||||||
if (mode2.equals("run"))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (mode2.equals("run"))
|
|
||||||
return 1;
|
|
||||||
if (mode1.equals("debug")) {
|
|
||||||
if (mode2.equals("debug"))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (mode2.equals("debug"))
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected ILaunchGroup getLaunchGroup(String mode) throws CoreException {
|
|
||||||
ILaunchConfigurationType type = manager.getLaunchConfigurationType(manager.getActiveLaunchDescriptor(), manager.getActiveLaunchTarget());
|
|
||||||
if (type == null)
|
|
||||||
return null;
|
|
||||||
return DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(type, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void fireSelectionChanged() {
|
|
||||||
Object selected = getSelection();
|
|
||||||
if (selected instanceof ILaunchMode) {
|
|
||||||
ILaunchMode mode = (ILaunchMode) selected;
|
|
||||||
try {
|
|
||||||
manager.setActiveLaunchMode(mode);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
|
||||||
return super.computeSize(150, hHint, changed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSelection(Object element) {
|
|
||||||
if (element == null)
|
|
||||||
element = noModes[0];
|
|
||||||
super.setSelection(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,255 +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.cdt.launchbar.ui.internal.controls;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.IHoverProvider;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.ILaunchBarUIConstants;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.LaunchBarUIManager;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.dialogs.NewLaunchTargetWizard;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
import org.eclipse.jface.wizard.WizardDialog;
|
|
||||||
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.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.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
|
|
||||||
public class TargetSelector extends CSelector {
|
|
||||||
|
|
||||||
private final LaunchBarUIManager uiManager = Activator.getDefault().getLaunchBarUIManager();
|
|
||||||
|
|
||||||
private static final String[] noTargets = new String[] { "---" };
|
|
||||||
|
|
||||||
public TargetSelector(Composite parent, int style) {
|
|
||||||
super(parent, style);
|
|
||||||
|
|
||||||
setContentProvider(new IStructuredContentProvider() {
|
|
||||||
@Override
|
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getElements(Object inputElement) {
|
|
||||||
try {
|
|
||||||
ILaunchTarget[] targets = uiManager.getManager().getLaunchTargets();
|
|
||||||
if (targets.length > 0)
|
|
||||||
return targets;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
return noTargets;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setLabelProvider(new LabelProvider() {
|
|
||||||
@Override
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
try {
|
|
||||||
ILaunchTarget target = (ILaunchTarget) element;
|
|
||||||
ILabelProvider labelProvider = uiManager.getLabelProvider(target);
|
|
||||||
if (labelProvider != null) {
|
|
||||||
return labelProvider.getImage(element);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.getImage(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getText(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
ILaunchTarget target = (ILaunchTarget) element;
|
|
||||||
try {
|
|
||||||
ILabelProvider labelProvider = uiManager.getLabelProvider(target);
|
|
||||||
if (labelProvider != null) {
|
|
||||||
return labelProvider.getText(element);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
return target.getName();
|
|
||||||
}
|
|
||||||
return super.getText(element);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setSorter(new Comparator<Object>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Object o1, Object o2) {
|
|
||||||
// Sort by name
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setHoverProvider(new IHoverProvider() {
|
|
||||||
@Override
|
|
||||||
public boolean displayHover(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
try {
|
|
||||||
ILaunchTarget target = (ILaunchTarget) element;
|
|
||||||
IHoverProvider hoverProvider = uiManager.getHoverProvider(target);
|
|
||||||
if (hoverProvider != null) {
|
|
||||||
return hoverProvider.displayHover(element);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dismissHover(Object element, boolean immediate) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
try {
|
|
||||||
ILaunchTarget target = (ILaunchTarget) element;
|
|
||||||
IHoverProvider hoverProvider = uiManager.getHoverProvider(target);
|
|
||||||
if (hoverProvider != null) {
|
|
||||||
hoverProvider.dismissHover(element, immediate);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEditable(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
ILaunchTarget target = (ILaunchTarget) element;
|
|
||||||
return uiManager.getEditCommand(target) != null;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleEdit(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
ILaunchTarget target = (ILaunchTarget) element;
|
|
||||||
String commandId = uiManager.getEditCommand(target);
|
|
||||||
Activator.runCommand(commandId, ILaunchBarUIConstants.TARGET_NAME, target.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasActionArea() {
|
|
||||||
return !uiManager.getNewTargetWizards().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@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(white);
|
|
||||||
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("Create New Target...");
|
|
||||||
createLabel.setBackground(white);
|
|
||||||
|
|
||||||
MouseListener mouseListener = new MouseAdapter() {
|
|
||||||
public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
|
|
||||||
NewLaunchTargetWizard wizard = new NewLaunchTargetWizard(uiManager);
|
|
||||||
WizardDialog dialog = new WizardDialog(getShell(), wizard);
|
|
||||||
dialog.open();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void fireSelectionChanged() {
|
|
||||||
Object selection = getSelection();
|
|
||||||
if (selection instanceof ILaunchTarget) {
|
|
||||||
ILaunchTarget target = (ILaunchTarget) selection;
|
|
||||||
try {
|
|
||||||
uiManager.getManager().setActiveLaunchTarget(target);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
|
||||||
return super.computeSize(200, hHint, changed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSelection(Object element) {
|
|
||||||
if (element == null)
|
|
||||||
element = noTargets[0];
|
|
||||||
super.setSelection(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +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.cdt.launchbar.ui.internal.controls;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
public class Transition implements Runnable {
|
|
||||||
|
|
||||||
private final Control control;
|
|
||||||
private final int tick;
|
|
||||||
private int current;
|
|
||||||
private int to;
|
|
||||||
private int incr;
|
|
||||||
|
|
||||||
public Transition(Control control, int current, int tick) {
|
|
||||||
this.control = control;
|
|
||||||
this.current = current;
|
|
||||||
this.tick = tick;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
current += incr;
|
|
||||||
if (!control.isDisposed())
|
|
||||||
control.redraw();
|
|
||||||
if (!done())
|
|
||||||
Display.getCurrent().timerExec(tick, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void to(int to) {
|
|
||||||
if (current == to)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this.to = to;
|
|
||||||
this.incr = current > to ? -1 : 1;
|
|
||||||
Display.getCurrent().timerExec(tick, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrent() {
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean done() {
|
|
||||||
return current == to;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,162 +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.cdt.launchbar.ui.internal.dialogs;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog;
|
|
||||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Font;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class LaunchConfigurationEditDialog extends LaunchConfigurationPropertiesDialog {
|
|
||||||
|
|
||||||
private static final int DELETE_ID = 64;
|
|
||||||
private static final int DUPLICATE_ID = 65;
|
|
||||||
private static final int LAUNCH_ID = 66;
|
|
||||||
|
|
||||||
public LaunchConfigurationEditDialog(Shell shell, ILaunchConfiguration launchConfiguration, LaunchGroupExtension group) {
|
|
||||||
super(shell, launchConfiguration, group);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
|
|
||||||
PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Control createButtonBar(Composite parent) {
|
|
||||||
// Clone super's implementation, removes the monitor since we don't run from here
|
|
||||||
// And adds in the left button bar.
|
|
||||||
Font font = parent.getFont();
|
|
||||||
Composite composite = new Composite(parent, SWT.NULL);
|
|
||||||
GridLayout layout = new GridLayout();
|
|
||||||
layout.numColumns = 2;
|
|
||||||
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
|
|
||||||
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
|
|
||||||
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
|
|
||||||
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
|
|
||||||
composite.setLayout(layout);
|
|
||||||
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
||||||
composite.setFont(font);
|
|
||||||
|
|
||||||
// create help control if needed
|
|
||||||
if (isHelpAvailable()) {
|
|
||||||
createHelpControl(composite);
|
|
||||||
}
|
|
||||||
|
|
||||||
Composite leftButtonComp = new Composite(composite, SWT.NULL);
|
|
||||||
layout = new GridLayout();
|
|
||||||
layout.marginHeight = 0;
|
|
||||||
layout.marginWidth = 0;
|
|
||||||
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
|
|
||||||
layout.numColumns = 0;
|
|
||||||
leftButtonComp.setLayout(layout);
|
|
||||||
leftButtonComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
||||||
leftButtonComp.setFont(parent.getFont());
|
|
||||||
|
|
||||||
createButton(leftButtonComp, DELETE_ID, "Delete", false);
|
|
||||||
createButton(leftButtonComp, DUPLICATE_ID, "Duplicate", false);
|
|
||||||
createButton(leftButtonComp, LAUNCH_ID, "Launch", false);
|
|
||||||
|
|
||||||
Composite mainButtonComp = new Composite(composite, SWT.NONE);
|
|
||||||
layout = new GridLayout();
|
|
||||||
layout.marginWidth = 0;
|
|
||||||
layout.marginHeight = 0;
|
|
||||||
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
|
|
||||||
layout.numColumns = 0;
|
|
||||||
mainButtonComp.setLayout(layout);
|
|
||||||
mainButtonComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
|
||||||
mainButtonComp.setFont(parent.getFont());
|
|
||||||
|
|
||||||
createButton(mainButtonComp, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
|
||||||
createButton(mainButtonComp, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
|
|
||||||
|
|
||||||
return composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createButtonsForButtonBar(Composite parent) {
|
|
||||||
// Do nothing since we now have the buttons created above.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
|
|
||||||
// update the dialog with the new config
|
|
||||||
getTabViewer().setInput(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void buttonPressed(int buttonId) {
|
|
||||||
switch (buttonId) {
|
|
||||||
case DELETE_ID:
|
|
||||||
ILaunchConfiguration c = getLaunchConfiguration();
|
|
||||||
if (c.isWorkingCopy())
|
|
||||||
c = ((ILaunchConfigurationWorkingCopy)c).getOriginal();
|
|
||||||
final ILaunchConfiguration config = c;
|
|
||||||
if (MessageDialog.openConfirm(getShell(), "Confirm Delete",
|
|
||||||
"Are you sure you want to delete " + config.getName())) {
|
|
||||||
new Job("Deleting launch configuration") {
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
config.delete();
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}.schedule();
|
|
||||||
cancelPressed();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DUPLICATE_ID:
|
|
||||||
final ILaunchConfiguration original = getLaunchConfiguration();
|
|
||||||
final String newName = DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(original.getName());
|
|
||||||
new Job("Duplicating launch configuration") {
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
ILaunchConfigurationWorkingCopy newWorkingCopy = original.copy(newName);
|
|
||||||
newWorkingCopy.doSave();
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}.schedule();
|
|
||||||
break;
|
|
||||||
case LAUNCH_ID:
|
|
||||||
okPressed();
|
|
||||||
Activator.runCommand(Activator.CMD_LAUNCH);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
super.buttonPressed(buttonId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,275 +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.cdt.launchbar.ui.internal.dialogs;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
|
||||||
import org.eclipse.debug.internal.core.LaunchManager;
|
|
||||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
|
||||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
|
|
||||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager;
|
|
||||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
|
||||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
|
||||||
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
|
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
||||||
import org.eclipse.jface.resource.ColorRegistry;
|
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
|
||||||
import org.eclipse.jface.wizard.WizardPage;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.custom.CTabFolder;
|
|
||||||
import org.eclipse.swt.custom.CTabItem;
|
|
||||||
import org.eclipse.swt.events.ModifyEvent;
|
|
||||||
import org.eclipse.swt.events.ModifyListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
|
||||||
|
|
||||||
public class NewLaunchConfigEditPage extends WizardPage {
|
|
||||||
ILaunchConfigurationWorkingCopy workingCopy;
|
|
||||||
ILaunchConfigurationTabGroup tabGroup;
|
|
||||||
private Text nameText;
|
|
||||||
private CTabFolder tabFolder;
|
|
||||||
private LaunchConfigurationDialog launchConfigurationDialog = new LaunchConfigurationDialog();
|
|
||||||
private LaunchConfigurationManager launchConfigurationMgr = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
|
|
||||||
|
|
||||||
public NewLaunchConfigEditPage() {
|
|
||||||
super("NewLaunchConfigEditPage");
|
|
||||||
setTitle("Launch Configuration Properties");
|
|
||||||
setDescription("Edit the new launch configuration properties");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createControl(Composite parent) {
|
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
|
||||||
comp.setLayout(new GridLayout(2, false));
|
|
||||||
Label label = new Label(comp, SWT.NONE);
|
|
||||||
label.setLayoutData(new GridData());
|
|
||||||
label.setText("Name:");
|
|
||||||
nameText = new Text(comp, SWT.BORDER);
|
|
||||||
nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
|
||||||
ColorRegistry reg = JFaceResources.getColorRegistry();
|
|
||||||
Color c1 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$
|
|
||||||
c2 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"); //$NON-NLS-1$
|
|
||||||
tabFolder = new CTabFolder(comp, SWT.BORDER | SWT.NO_REDRAW_RESIZE | SWT.FLAT);
|
|
||||||
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
|
||||||
gridData.horizontalSpan = 2;
|
|
||||||
tabFolder.setLayoutData(gridData);
|
|
||||||
tabFolder.setSimple(false);
|
|
||||||
tabFolder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
|
|
||||||
tabFolder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
|
|
||||||
|
|
||||||
setControl(comp);
|
|
||||||
nameText.addModifyListener(new ModifyListener() {
|
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
String name = nameText.getText().trim();
|
|
||||||
workingCopy.rename(name);
|
|
||||||
|
|
||||||
String errMessage = checkName(name);
|
|
||||||
if (errMessage == null) {
|
|
||||||
validateFields();
|
|
||||||
} else {
|
|
||||||
setErrorMessage(errMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
validateFields();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String checkName(String name) {
|
|
||||||
try {
|
|
||||||
if (name.isEmpty()) {
|
|
||||||
return "Name can not be empty";
|
|
||||||
}
|
|
||||||
|
|
||||||
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
|
|
||||||
if (manager.isExistingLaunchConfigurationName(name)) {
|
|
||||||
ILaunchConfiguration config = ((LaunchManager) manager).findLaunchConfiguration(name);
|
|
||||||
if (config != workingCopy.getOriginal()) {
|
|
||||||
return ("A configuration with this name already exists");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Activator.log(e);
|
|
||||||
return (e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void changeLaunchConfigType(ILaunchConfigurationType type) {
|
|
||||||
if (type == null)
|
|
||||||
return;
|
|
||||||
try {
|
|
||||||
String initialMode = ((NewLaunchConfigWizard) getWizard()).modePage.selectedGroup.getMode();
|
|
||||||
workingCopy = type.newInstance(null, "New Configuration");
|
|
||||||
tabGroup = LaunchConfigurationPresentationManager.getDefault().getTabGroup(workingCopy, initialMode);
|
|
||||||
for (CTabItem item : tabFolder.getItems())
|
|
||||||
item.dispose();
|
|
||||||
tabGroup.createTabs(launchConfigurationDialog, initialMode);
|
|
||||||
boolean firstTab = true;
|
|
||||||
for (ILaunchConfigurationTab tab : tabGroup.getTabs()) {
|
|
||||||
tab.setLaunchConfigurationDialog(launchConfigurationDialog);
|
|
||||||
tab.createControl(tabFolder);
|
|
||||||
tab.setDefaults(workingCopy);
|
|
||||||
if (firstTab) {
|
|
||||||
firstTab = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do this after all the tabs have their controls created
|
|
||||||
for (ILaunchConfigurationTab tab : tabGroup.getTabs()) {
|
|
||||||
tab.initializeFrom(workingCopy);
|
|
||||||
|
|
||||||
CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
|
|
||||||
tabItem.setText(tab.getName());
|
|
||||||
tabItem.setImage(!tab.isValid(workingCopy) && tab.getErrorMessage() != null ?
|
|
||||||
launchConfigurationMgr.getErrorTabImage(tab) : tab.getImage());
|
|
||||||
tabItem.setControl(tab.getControl());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up any created configs before we set the name and trigger
|
|
||||||
// any validation
|
|
||||||
((NewLaunchConfigWizard) getWizard()).cleanUpConfigs();
|
|
||||||
|
|
||||||
tabFolder.setSelection(0);
|
|
||||||
nameText.setText(workingCopy.getName());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean performFinish() {
|
|
||||||
if (workingCopy == null)
|
|
||||||
return false;
|
|
||||||
for (ILaunchConfigurationTab tab : tabGroup.getTabs())
|
|
||||||
tab.performApply(workingCopy);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void validateFields() {
|
|
||||||
if (workingCopy == null)
|
|
||||||
return;
|
|
||||||
String message = null;
|
|
||||||
String old_msg = getErrorMessage();
|
|
||||||
setErrorMessage(null);
|
|
||||||
message = checkName(workingCopy.getName());
|
|
||||||
if (message == null) {
|
|
||||||
ILaunchConfigurationTab[] tabs = tabGroup.getTabs();
|
|
||||||
int tLen = tabs.length;
|
|
||||||
int tfLen = tabFolder.getItems().length;
|
|
||||||
for (int i = 0; i < tLen; i++) {
|
|
||||||
ILaunchConfigurationTab tab = tabs[i];
|
|
||||||
try {
|
|
||||||
tab.isValid(workingCopy);
|
|
||||||
message = tab.getErrorMessage();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// if createControl hasn't been called yet can throw exception..
|
|
||||||
// like the NPE issue in CTestingTab
|
|
||||||
message = e.getMessage();
|
|
||||||
}
|
|
||||||
// this is similar to what LaunchConfigurationTabGroupViewer.refresh() does, which is not available in this case
|
|
||||||
if (tLen == tfLen &&
|
|
||||||
(old_msg == null && message != null || old_msg != null && message == null)) {
|
|
||||||
CTabItem item = tabFolder.getItem(i);
|
|
||||||
if (item != null) {
|
|
||||||
item.setImage(message != null ? launchConfigurationMgr.getErrorTabImage(tab)
|
|
||||||
: tab.getImage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (message != null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setErrorMessage(message);
|
|
||||||
if (getErrorMessage() != null) {
|
|
||||||
setPageComplete(false);
|
|
||||||
} else {
|
|
||||||
setPageComplete(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LaunchConfigurationDialog implements ILaunchConfigurationDialog {
|
|
||||||
@Override
|
|
||||||
public void run(boolean fork, boolean cancelable,
|
|
||||||
IRunnableWithProgress runnable)
|
|
||||||
throws InvocationTargetException, InterruptedException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateButtons() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateMessage() {
|
|
||||||
validateFields();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String generateName(String name) {
|
|
||||||
if (name == null)
|
|
||||||
return "";
|
|
||||||
return DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchConfigurationTab[] getTabs() {
|
|
||||||
return tabGroup.getTabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILaunchConfigurationTab getActiveTab() {
|
|
||||||
int i = tabFolder.getSelectionIndex();
|
|
||||||
return tabGroup.getTabs()[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMode() {
|
|
||||||
return ((NewLaunchConfigWizard) getWizard()).modePage.selectedGroup.getMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActiveTab(ILaunchConfigurationTab tab) {
|
|
||||||
ILaunchConfigurationTab[] tabs = tabGroup.getTabs();
|
|
||||||
int tLen = tabs.length;
|
|
||||||
for (int i = 0; i < tLen; i++) {
|
|
||||||
ILaunchConfigurationTab tabi = tabs[i];
|
|
||||||
if (tabi.equals(tab)) {
|
|
||||||
setActiveTab(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActiveTab(int index) {
|
|
||||||
tabFolder.setSelection(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,114 +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.cdt.launchbar.ui.internal.dialogs;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.debug.ui.ILaunchGroup;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.wizard.WizardPage;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Table;
|
|
||||||
import org.eclipse.swt.widgets.TableItem;
|
|
||||||
|
|
||||||
public class NewLaunchConfigModePage extends WizardPage {
|
|
||||||
|
|
||||||
private Table table;
|
|
||||||
ILaunchGroup selectedGroup;
|
|
||||||
|
|
||||||
public NewLaunchConfigModePage() {
|
|
||||||
super("Select Initial Launch Mode");
|
|
||||||
setTitle("Initial Launch Mode");
|
|
||||||
setDescription("Select initial launch mode.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createControl(Composite parent) {
|
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
|
||||||
comp.setLayout(new GridLayout(1, false));
|
|
||||||
|
|
||||||
table = new Table(comp, SWT.SINGLE | SWT.BORDER);
|
|
||||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
|
||||||
table.setLayoutData(data);
|
|
||||||
|
|
||||||
Set<ILaunchGroup> done = new HashSet<>();
|
|
||||||
|
|
||||||
for (ILaunchGroup group : DebugUITools.getLaunchGroups()) {
|
|
||||||
if (group.getMode().equals("run")) {
|
|
||||||
createModeItem(group);
|
|
||||||
done.add(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ILaunchGroup group : DebugUITools.getLaunchGroups()) {
|
|
||||||
if (group.getMode().equals("debug")) {
|
|
||||||
createModeItem(group);
|
|
||||||
done.add(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ILaunchGroup group : DebugUITools.getLaunchGroups()) {
|
|
||||||
if (!done.contains(group)) {
|
|
||||||
createModeItem(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (table.getItemCount() > 0) {
|
|
||||||
// Select debug as default
|
|
||||||
int i = 0;
|
|
||||||
boolean hasDebug = false;
|
|
||||||
for (TableItem item : table.getItems()) {
|
|
||||||
if ("debug".equals(((ILaunchGroup) item.getData()).getMode())) {
|
|
||||||
hasDebug = true;
|
|
||||||
table.select(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasDebug) {
|
|
||||||
table.select(0);
|
|
||||||
}
|
|
||||||
selectedGroup = (ILaunchGroup) table.getSelection()[0].getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
table.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
selectedGroup = (ILaunchGroup)table.getSelection()[0].getData();
|
|
||||||
((NewLaunchConfigWizard)getWizard()).typePage.populateItems();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setControl(comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createModeItem(ILaunchGroup group) {
|
|
||||||
if (group.getCategory() != null || !group.isPublic())
|
|
||||||
return;
|
|
||||||
|
|
||||||
TableItem item = new TableItem(table, SWT.NONE);
|
|
||||||
item.setText(group.getLabel().replace("&", ""));
|
|
||||||
ImageDescriptor imageDesc = group.getImageDescriptor();
|
|
||||||
if (imageDesc != null) {
|
|
||||||
item.setImage(imageDesc.createImage());
|
|
||||||
}
|
|
||||||
item.setData(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,92 +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.cdt.launchbar.ui.internal.dialogs;
|
|
||||||
|
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.debug.ui.ILaunchGroup;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.wizard.IWizardPage;
|
|
||||||
import org.eclipse.jface.wizard.WizardPage;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Table;
|
|
||||||
import org.eclipse.swt.widgets.TableItem;
|
|
||||||
|
|
||||||
public class NewLaunchConfigTypePage extends WizardPage {
|
|
||||||
|
|
||||||
private Table table;
|
|
||||||
|
|
||||||
public NewLaunchConfigTypePage() {
|
|
||||||
super("Select Launch Configuration Type");
|
|
||||||
setTitle("Launch Configuration Type");
|
|
||||||
setDescription("Select the type of launch configuration to create.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createControl(Composite parent) {
|
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
|
||||||
comp.setLayout(new GridLayout(1, false));
|
|
||||||
|
|
||||||
table = new Table(comp, SWT.SINGLE | SWT.BORDER);
|
|
||||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
|
|
||||||
data.heightHint = 500;
|
|
||||||
table.setLayoutData(data);
|
|
||||||
|
|
||||||
populateItems();
|
|
||||||
|
|
||||||
setControl(comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void populateItems() {
|
|
||||||
ILaunchGroup group = ((NewLaunchConfigWizard)getWizard()).modePage.selectedGroup;
|
|
||||||
if (group == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
table.removeAll();
|
|
||||||
|
|
||||||
boolean haveItems = false;
|
|
||||||
for (ILaunchConfigurationType type : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes()) {
|
|
||||||
if (!type.isPublic() || type.getCategory() != null || !type.supportsMode(group.getMode()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
haveItems = true;
|
|
||||||
TableItem item = new TableItem(table, SWT.NONE);
|
|
||||||
item.setText(type.getName());
|
|
||||||
ImageDescriptor imageDesc = DebugUITools.getDefaultImageDescriptor(type);
|
|
||||||
if (imageDesc != null)
|
|
||||||
item.setImage(imageDesc.createImage());
|
|
||||||
item.setData(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (haveItems) {
|
|
||||||
table.select(0);
|
|
||||||
}
|
|
||||||
setPageComplete(haveItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFlipToNextPage() {
|
|
||||||
return isPageComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IWizardPage getNextPage() {
|
|
||||||
ILaunchConfigurationType type = (ILaunchConfigurationType)table.getSelection()[0].getData();
|
|
||||||
NewLaunchConfigEditPage editPage = ((NewLaunchConfigWizard)getWizard()).editPage;
|
|
||||||
editPage.changeLaunchConfigType(type);
|
|
||||||
return editPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,102 +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.cdt.launchbar.ui.internal.dialogs;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationListener;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
|
||||||
import org.eclipse.jface.wizard.Wizard;
|
|
||||||
|
|
||||||
public class NewLaunchConfigWizard extends Wizard implements ILaunchConfigurationListener {
|
|
||||||
|
|
||||||
NewLaunchConfigModePage modePage = new NewLaunchConfigModePage();
|
|
||||||
NewLaunchConfigTypePage typePage = new NewLaunchConfigTypePage();
|
|
||||||
NewLaunchConfigEditPage editPage = new NewLaunchConfigEditPage();
|
|
||||||
|
|
||||||
private List<ILaunchConfiguration> configsToDelete = new ArrayList<>();
|
|
||||||
|
|
||||||
public NewLaunchConfigWizard() {
|
|
||||||
setWindowTitle("Create Launch Configuration");
|
|
||||||
initListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPages() {
|
|
||||||
addPage(modePage);
|
|
||||||
addPage(typePage);
|
|
||||||
addPage(editPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILaunchConfigurationWorkingCopy getWorkingCopy() {
|
|
||||||
return editPage.workingCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILaunchMode getLaunchMode() {
|
|
||||||
String initMode = modePage.selectedGroup.getMode();
|
|
||||||
return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(initMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean performFinish() {
|
|
||||||
cleanUpConfigs();
|
|
||||||
return editPage.performFinish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean performCancel() {
|
|
||||||
cleanUpConfigs();
|
|
||||||
return super.performCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initListeners() {
|
|
||||||
// while the wizard is open, some ill behaved launch config tabs save the working copy.
|
|
||||||
// We need to make sure those saves are deleted when the dialog is finished.
|
|
||||||
// We also need to turn off listening in the tool bar manager so that we don't treat these
|
|
||||||
// as real launch configs.
|
|
||||||
DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cleanUpConfigs() {
|
|
||||||
DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this);
|
|
||||||
for (ILaunchConfiguration config : configsToDelete) {
|
|
||||||
try {
|
|
||||||
config.delete();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
|
|
||||||
if (!configuration.isWorkingCopy())
|
|
||||||
configsToDelete.add(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void launchConfigurationChanged(ILaunchConfiguration configuration) {
|
|
||||||
// Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
|
|
||||||
if (!configuration.isWorkingCopy())
|
|
||||||
configsToDelete.remove(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package org.eclipse.cdt.launchbar.ui.internal.dialogs;
|
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.Activator;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.ExecutableExtension;
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.LaunchBarUIManager;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.jface.wizard.IWizardPage;
|
|
||||||
import org.eclipse.jface.wizard.WizardPage;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Table;
|
|
||||||
import org.eclipse.swt.widgets.TableItem;
|
|
||||||
import org.eclipse.ui.INewWizard;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
public class NewLaunchTargetTypePage extends WizardPage {
|
|
||||||
|
|
||||||
private final LaunchBarUIManager uiManager;
|
|
||||||
private Table table;
|
|
||||||
private ExecutableExtension<INewWizard> currentExtension;
|
|
||||||
private INewWizard nextWizard;
|
|
||||||
|
|
||||||
public NewLaunchTargetTypePage(LaunchBarUIManager uiManager) {
|
|
||||||
super("NewLaunchTargetTypePage");
|
|
||||||
setTitle("Launch Target Type");
|
|
||||||
setDescription("Select type of launch target to create.");
|
|
||||||
this.uiManager = uiManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createControl(Composite parent) {
|
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
|
||||||
comp.setLayout(new GridLayout());
|
|
||||||
|
|
||||||
table = new Table(comp, SWT.SINGLE | SWT.BORDER);
|
|
||||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
|
||||||
table.setLayoutData(data);
|
|
||||||
|
|
||||||
setPageComplete(false);
|
|
||||||
for (Entry<ILaunchTargetType, ExecutableExtension<INewWizard>> entry : uiManager.getNewTargetWizards().entrySet()) {
|
|
||||||
TableItem item = new TableItem(table, SWT.NONE);
|
|
||||||
ILaunchTargetType targetType = entry.getKey();
|
|
||||||
item.setText(uiManager.getTargetTypeName(targetType));
|
|
||||||
Image icon = uiManager.getTargetTypeIcon(targetType);
|
|
||||||
if (icon != null) {
|
|
||||||
item.setImage(icon);
|
|
||||||
}
|
|
||||||
item.setData(entry.getValue());
|
|
||||||
table.select(0);
|
|
||||||
setPageComplete(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
setControl(comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFlipToNextPage() {
|
|
||||||
return isPageComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IWizardPage getNextPage() {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
ExecutableExtension<INewWizard> extension = (ExecutableExtension<INewWizard>) table.getSelection()[0].getData();
|
|
||||||
if (extension != currentExtension) {
|
|
||||||
try {
|
|
||||||
nextWizard = extension.create();
|
|
||||||
nextWizard.init(PlatformUI.getWorkbench(), null);
|
|
||||||
nextWizard.addPages();
|
|
||||||
currentExtension = extension;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextWizard != null) {
|
|
||||||
IWizardPage [] pages = nextWizard.getPages();
|
|
||||||
if (pages.length > 0) {
|
|
||||||
return pages[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getNextPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,42 +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.cdt.launchbar.ui.internal.dialogs;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.ui.internal.LaunchBarUIManager;
|
|
||||||
import org.eclipse.jface.wizard.Wizard;
|
|
||||||
|
|
||||||
public class NewLaunchTargetWizard extends Wizard {
|
|
||||||
|
|
||||||
private final NewLaunchTargetTypePage typePage;
|
|
||||||
|
|
||||||
public NewLaunchTargetWizard(LaunchBarUIManager uiManager) {
|
|
||||||
setWindowTitle("Launch Target Type");
|
|
||||||
typePage = new NewLaunchTargetTypePage(uiManager);
|
|
||||||
setForcePreviousAndNextButtons(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPages() {
|
|
||||||
addPage(typePage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean performFinish() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFinish() {
|
|
||||||
// Need to move onto the new target wizard
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
LaunchBarControl_Build=Build
|
|
||||||
LaunchBarControl_Launch=Launch
|
|
||||||
LaunchBarControl_Stop=Stop
|
|
|
@ -1,26 +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.cdt.launchbar.ui.internal.targetsView;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
|
||||||
import org.eclipse.jface.window.SameShellProvider;
|
|
||||||
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
|
||||||
import org.eclipse.ui.navigator.CommonActionProvider;
|
|
||||||
|
|
||||||
public class LaunchTargetsActionProvider extends CommonActionProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fillContextMenu(IMenuManager menu) {
|
|
||||||
menu.add(new PropertyDialogAction(new SameShellProvider(getActionSite().getViewSite().getShell()),
|
|
||||||
getActionSite().getStructuredViewer()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,73 +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.cdt.launchbar.ui.internal.targetsView;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
|
|
||||||
public class LaunchTargetsContentProvider implements ITreeContentProvider {
|
|
||||||
|
|
||||||
private LaunchBarManager manager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getElements(Object inputElement) {
|
|
||||||
if (inputElement instanceof LaunchBarManager) {
|
|
||||||
ILaunchTarget[] targets = ((LaunchBarManager) inputElement).getAllLaunchTargets();
|
|
||||||
Arrays.sort(targets, new Comparator<ILaunchTarget>() {
|
|
||||||
@Override
|
|
||||||
public int compare(ILaunchTarget o1, ILaunchTarget o2) {
|
|
||||||
return o1.getName().compareTo(o2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return targets;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getChildren(Object parentElement) {
|
|
||||||
return new Object[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getParent(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasChildren(Object element) {
|
|
||||||
if (element instanceof LaunchBarManager)
|
|
||||||
return true;
|
|
||||||
else if (element instanceof ILaunchTarget)
|
|
||||||
return false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
|
||||||
if (newInput instanceof LaunchBarManager) {
|
|
||||||
manager = (LaunchBarManager) newInput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,32 +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.cdt.launchbar.ui.internal.targetsView;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
|
|
||||||
public class LaunchTargetsLabelProvider extends LabelProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
return super.getImage(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getText(Object element) {
|
|
||||||
if (element instanceof ILaunchTarget) {
|
|
||||||
return ((ILaunchTarget) element).getName();
|
|
||||||
}
|
|
||||||
return super.getText(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue