1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-22 16:35:25 +02:00

Refactor LaunchBar Control into it's own plug-in. Adjust APIs.

Added a whole bunch of APIs to the managers to enable this without
exposing internals to the control. Documentation will be added before
release.

Change-Id: I7a643eca3d48643e7a1202d83c7b4818722c54f0
This commit is contained in:
Doug Schaefer 2016-05-09 10:41:02 -04:00
parent 91be36a418
commit 83f6bf8deb
73 changed files with 886 additions and 561 deletions

View file

@ -11,6 +11,6 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.launchbar.core, Export-Package: org.eclipse.launchbar.core,
org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui", org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests",
org.eclipse.launchbar.core.target, org.eclipse.launchbar.core.target,
org.eclipse.launchbar.core.target.launch org.eclipse.launchbar.core.target.launch

View file

@ -11,7 +11,11 @@
package org.eclipse.launchbar.core; package org.eclipse.launchbar.core;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationListener;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.launchbar.core.target.ILaunchTarget;
/** /**
* Interface to the Launch Bar Manager. * Interface to the Launch Bar Manager.
@ -21,8 +25,7 @@ import org.eclipse.debug.core.ILaunchConfigurationListener;
public interface ILaunchBarManager extends ILaunchConfigurationListener { public interface ILaunchBarManager extends ILaunchConfigurationListener {
/** /**
* A launch object has been added. Create a matching launch descriptor if * A launch object has been added. Create a matching launch descriptor if available.
* available.
* *
* @param element * @param element
* launch object * launch object
@ -32,8 +35,7 @@ public interface ILaunchBarManager extends ILaunchConfigurationListener {
ILaunchDescriptor launchObjectAdded(Object launchObject) throws CoreException; ILaunchDescriptor launchObjectAdded(Object launchObject) throws CoreException;
/** /**
* A launch object has been removed. Remove the associated launch descriptor * A launch object has been removed. Remove the associated launch descriptor if there is one.
* if there is one.
* *
* @param element * @param element
* launch object * launch object
@ -49,16 +51,52 @@ public interface ILaunchBarManager extends ILaunchConfigurationListener {
*/ */
void launchObjectChanged(Object launchObject) throws CoreException; void launchObjectChanged(Object launchObject) throws CoreException;
/** /**
* Add a linstener that can react to launch bar changes * Add a listener that can react to launch bar changes
*
* @param listener * @param listener
*/ */
public void addListener(ILaunchBarListener listener); void addListener(ILaunchBarListener listener);
/** /**
* Remove a linstener * Remove a listener
*
* @param listener * @param listener
*/ */
public void removeListener(ILaunchBarListener listener); void removeListener(ILaunchBarListener listener);
/**
* Return the type id for the given launch descriptor type. This is defined in the extension
* point that defines the type.
*
* @param descType
* descriptor type
* @return the type id for the descriptor type
*/
String getDescriptorTypeId(ILaunchDescriptorType descType) throws CoreException;
ILaunchDescriptor getActiveLaunchDescriptor() throws CoreException;
ILaunchMode getActiveLaunchMode() throws CoreException;
ILaunchTarget getActiveLaunchTarget() throws CoreException;
ILaunchConfiguration getActiveLaunchConfiguration() throws CoreException;
ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor desc, ILaunchTarget target) throws CoreException;
ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor desc, ILaunchTarget target) throws CoreException;
ILaunchDescriptor[] getLaunchDescriptors() throws CoreException;
void setActiveLaunchDescriptor(ILaunchDescriptor desc) throws CoreException;
ILaunchMode[] getLaunchModes() throws CoreException;
void setActiveLaunchMode(ILaunchMode mode) throws CoreException;
ILaunchTarget[] getLaunchTargets(ILaunchDescriptor desc) throws CoreException;
void setActiveLaunchTarget(ILaunchTarget target) throws CoreException;
} }

View file

@ -11,7 +11,6 @@
package org.eclipse.launchbar.core.internal; package org.eclipse.launchbar.core.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
@ -290,19 +289,20 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
if (i < 0) { if (i < 0) {
return null; return null;
} }
return new Pair<String, String>(key.substring(0, i), key.substring(i + 1)); return new Pair<>(key.substring(0, i), key.substring(i + 1));
} }
@Override
public String getDescriptorTypeId(ILaunchDescriptorType type) { public String getDescriptorTypeId(ILaunchDescriptorType type) {
return descriptorTypeInfo.get(type).getId(); return descriptorTypeInfo.get(type).getId();
} }
private Pair<String, String> getDescriptorId(ILaunchDescriptor descriptor) { private Pair<String, String> getDescriptorId(ILaunchDescriptor descriptor) {
return new Pair<String, String>(getDescriptorTypeId(descriptor.getType()), descriptor.getName()); return new Pair<>(getDescriptorTypeId(descriptor.getType()), descriptor.getName());
} }
private Pair<String, String> getTargetId(ILaunchTarget target) { private Pair<String, String> getTargetId(ILaunchTarget target) {
return new Pair<String, String>(target.getTypeId(), target.getName()); return new Pair<>(target.getTypeId(), target.getId());
} }
private void addDescriptor(Object launchObject, ILaunchDescriptor descriptor) throws CoreException { private void addDescriptor(Object launchObject, ILaunchDescriptor descriptor) throws CoreException {
@ -311,6 +311,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
setActiveLaunchDescriptor(descriptor); setActiveLaunchDescriptor(descriptor);
} }
@Override
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException { throws CoreException {
if (descriptor == null) if (descriptor == null)
@ -408,6 +409,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
return descs[descs.length - 1]; return descs[descs.length - 1];
} }
@Override
public ILaunchDescriptor[] getLaunchDescriptors() { public ILaunchDescriptor[] getLaunchDescriptors() {
// return descriptor in usage order (most used first). UI can sort them // return descriptor in usage order (most used first). UI can sort them
// later as it wishes // later as it wishes
@ -416,6 +418,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
return values.toArray(new ILaunchDescriptor[values.size()]); return values.toArray(new ILaunchDescriptor[values.size()]);
} }
@Override
public ILaunchDescriptor getActiveLaunchDescriptor() { public ILaunchDescriptor getActiveLaunchDescriptor() {
return activeLaunchDesc; return activeLaunchDesc;
} }
@ -453,6 +456,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} }
} }
@Override
public void setActiveLaunchDescriptor(ILaunchDescriptor descriptor) throws CoreException { public void setActiveLaunchDescriptor(ILaunchDescriptor descriptor) throws CoreException {
Activator.trace("set active descriptor " + descriptor); //$NON-NLS-1$ Activator.trace("set active descriptor " + descriptor); //$NON-NLS-1$
if (activeLaunchDesc == descriptor) { if (activeLaunchDesc == descriptor) {
@ -614,6 +618,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} }
} }
@Override
public ILaunchMode[] getLaunchModes() throws CoreException { public ILaunchMode[] getLaunchModes() throws CoreException {
ILaunchConfigurationType configType = getLaunchConfigurationType(activeLaunchDesc, activeLaunchTarget); ILaunchConfigurationType configType = getLaunchConfigurationType(activeLaunchDesc, activeLaunchTarget);
if (configType == null) if (configType == null)
@ -628,6 +633,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
return modeList.toArray(new ILaunchMode[modeList.size()]); return modeList.toArray(new ILaunchMode[modeList.size()]);
} }
@Override
public ILaunchMode getActiveLaunchMode() { public ILaunchMode getActiveLaunchMode() {
return activeLaunchMode; return activeLaunchMode;
} }
@ -647,6 +653,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} }
} }
@Override
public void setActiveLaunchMode(ILaunchMode mode) throws CoreException { public void setActiveLaunchMode(ILaunchMode mode) throws CoreException {
if (activeLaunchMode == mode) { if (activeLaunchMode == mode) {
// we have to modify listeners here because same mode does not mean // we have to modify listeners here because same mode does not mean
@ -681,16 +688,17 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} }
} }
public List<ILaunchTarget> getLaunchTargets(ILaunchDescriptor descriptor) { @Override
public ILaunchTarget[] getLaunchTargets(ILaunchDescriptor descriptor) {
if (descriptor == null) if (descriptor == null)
return Arrays.asList(launchTargetManager.getLaunchTargets()); return launchTargetManager.getLaunchTargets();
List<ILaunchTarget> targets = new ArrayList<>(); List<ILaunchTarget> targets = new ArrayList<>();
for (ILaunchTarget target : launchTargetManager.getLaunchTargets()) { for (ILaunchTarget target : launchTargetManager.getLaunchTargets()) {
if (supportsTarget(descriptor, target)) { if (supportsTarget(descriptor, target)) {
targets.add(target); targets.add(target);
} }
} }
return targets; return targets.toArray(new ILaunchTarget[targets.size()]);
} }
boolean supportsTarget(ILaunchDescriptor descriptor, ILaunchTarget target) { boolean supportsTarget(ILaunchDescriptor descriptor, ILaunchTarget target) {
@ -709,6 +717,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
return false; return false;
} }
@Override
public ILaunchTarget getActiveLaunchTarget() { public ILaunchTarget getActiveLaunchTarget() {
return activeLaunchTarget; return activeLaunchTarget;
} }
@ -728,6 +737,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} }
} }
@Override
public void setActiveLaunchTarget(ILaunchTarget target) throws CoreException { public void setActiveLaunchTarget(ILaunchTarget target) throws CoreException {
if (target == null) if (target == null)
target = ILaunchTarget.NULL_TARGET; target = ILaunchTarget.NULL_TARGET;
@ -763,12 +773,13 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} }
private ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) { private ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) {
List<ILaunchTarget> targets = getLaunchTargets(descriptor); ILaunchTarget[] targets = getLaunchTargets(descriptor);
// chances are that better target is most recently added, rather then // chances are that better target is most recently added, rather then
// the oldest // the oldest
return targets.isEmpty() ? ILaunchTarget.NULL_TARGET : targets.get(targets.size() - 1); return targets.length == 0 ? ILaunchTarget.NULL_TARGET : targets[targets.length - 1];
} }
@Override
public ILaunchConfiguration getActiveLaunchConfiguration() throws CoreException { public ILaunchConfiguration getActiveLaunchConfiguration() throws CoreException {
ILaunchConfiguration configuration = getLaunchConfiguration(activeLaunchDesc, activeLaunchTarget); ILaunchConfiguration configuration = getLaunchConfiguration(activeLaunchDesc, activeLaunchTarget);
// This is the only concrete time we have the mapping from launch // This is the only concrete time we have the mapping from launch
@ -780,6 +791,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
return configuration; return configuration;
} }
@Override
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException { throws CoreException {
if (descriptor == null) { if (descriptor == null) {

View file

@ -0,0 +1,7 @@
<?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.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.launchbar.ui.controls</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>

View file

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View file

@ -0,0 +1,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Launch Bar UI Controls
Bundle-SymbolicName: org.eclipse.launchbar.ui.controls;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.launchbar.ui.controls.internal.Activator
Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.osgi.services;bundle-version="3.5.0",
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
org.eclipse.e4.core.contexts;bundle-version="1.5.0",
org.eclipse.e4.core.services;bundle-version="2.0.0",
org.eclipse.e4.ui.model.workbench;bundle-version="1.2.0",
org.eclipse.e4.ui.workbench;bundle-version="1.4.0",
org.eclipse.debug.ui;bundle-version="3.11.200",
org.eclipse.launchbar.core;bundle-version="2.0.0",
org.eclipse.launchbar.ui;bundle-version="2.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.launchbar.ui.controls.internal;x-internal:=true

View file

@ -0,0 +1,24 @@
<!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>

View file

@ -0,0 +1,8 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
plugin.xml,\
plugin.properties,\
icons/

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 625 B

After

Width:  |  Height:  |  Size: 625 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 266 B

View file

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 239 B

View file

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View file

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

Before

Width:  |  Height:  |  Size: 466 B

After

Width:  |  Height:  |  Size: 466 B

View file

Before

Width:  |  Height:  |  Size: 466 B

After

Width:  |  Height:  |  Size: 466 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B

View file

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 323 B

View file

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 358 B

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 330 B

View file

@ -0,0 +1,3 @@
launchToolBar.label = LaunchBar
targetsView.name = Launch Targets
targetsContent.name = Launch Targets

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="launchBarInjector"
point="org.eclipse.e4.workbench.model">
<processor
apply="always"
beforefragment="false"
class="org.eclipse.launchbar.ui.controls.internal.LaunchBarInjector">
</processor>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.eclipse.launchbar.ui.controls.internal.LaunchBarPreferenceInitializer">
</initializer>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
category="org.eclipse.debug.ui.LaunchingPreferencePage"
class="org.eclipse.launchbar.ui.controls.internal.LaunchBarPreferencePage"
id="org.eclipse.launchbar.ui.prefPage"
name="Launch Bar">
</page>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
categoryId="org.eclipse.launchbar.ui.category.launchBar"
defaultHandler="org.eclipse.launchbar.ui.controls.internal.OpenLaunchSelector"
id="org.eclipse.launchbar.ui.command.openLaunchSelector"
name="Open Launch Bar Config Selector">
</command>
</extension>
</plugin>

View file

@ -0,0 +1,18 @@
<?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.launchbar</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.launchbar.ui.controls</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (c) 2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageRegistry;
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.launchbar.ui.controls"; //$NON-NLS-1$
// images
public static final String IMG_BUTTON_BACKGROUND = "bgButton"; //$NON-NLS-1$
public static final String IMG_BUTTON_BUILD = "build"; //$NON-NLS-1$
public static final String IMG_BUTTON_LAUNCH = "launch"; //$NON-NLS-1$
public static final String IMG_BUTTON_STOP = "stop"; //$NON-NLS-1$
public static final String IMG_CONFIG_CONFIG = "config_config"; //$NON-NLS-1$
public static final String IMG_EDIT_COLD = "edit_cold"; //$NON-NLS-1$
// Preference ids
public static final String PREF_ENABLE_LAUNCHBAR = "enableLaunchBar"; //$NON-NLS-1$
public static final String PREF_ENABLE_TARGETSELECTOR = "enableTargetSelector"; //$NON-NLS-1$
public static final String PREF_ENABLE_BUILDBUTTON = "enableBuildButton"; //$NON-NLS-1$
public static final String PREF_LAUNCH_HISTORY_SIZE = "launchHistorySize"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
ImageRegistry imageRegistry = getImageRegistry();
imageRegistry.put(IMG_BUTTON_BACKGROUND, imageDescriptorFromPlugin(PLUGIN_ID, "icons/bgButton.png")); //$NON-NLS-1$
imageRegistry.put(IMG_BUTTON_BUILD, imageDescriptorFromPlugin(PLUGIN_ID, "icons/build_16.png")); //$NON-NLS-1$
imageRegistry.put(IMG_BUTTON_LAUNCH, imageDescriptorFromPlugin(PLUGIN_ID, "icons/launch_16.png")); //$NON-NLS-1$
imageRegistry.put(IMG_BUTTON_STOP, imageDescriptorFromPlugin(PLUGIN_ID, "icons/stop_16.png")); //$NON-NLS-1$
imageRegistry.put(IMG_CONFIG_CONFIG, imageDescriptorFromPlugin(PLUGIN_ID, "icons/config_config.png")); //$NON-NLS-1$
imageRegistry.put(IMG_EDIT_COLD, imageDescriptorFromPlugin(PLUGIN_ID, "icons/edit_cold.png")); //$NON-NLS-1$
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
public static Activator getDefault() {
return plugin;
}
public static <T> T getService(Class<T> service) {
BundleContext context = plugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
public static void log(Throwable e) {
IStatus status;
if (e instanceof CoreException) {
status = ((CoreException) e).getStatus();
} else {
status = new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e);
}
plugin.getLog().log(status);
}
}

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import java.util.Comparator; import java.util.Comparator;
@ -23,8 +23,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.DisposeListener;

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import java.util.Comparator; import java.util.Comparator;
@ -25,13 +25,11 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window; import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.DefaultDescriptorLabelProvider;
import org.eclipse.launchbar.ui.internal.DefaultDescriptorLabelProvider; import org.eclipse.launchbar.ui.ILaunchBarUIManager;
import org.eclipse.launchbar.ui.internal.LaunchBarUIManager; import org.eclipse.launchbar.ui.NewLaunchConfigWizard;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.launchbar.ui.internal.commands.ConfigureActiveLaunchHandler;
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigWizard;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
@ -45,7 +43,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
public class ConfigSelector extends CSelector { public class ConfigSelector extends CSelector {
private LaunchBarUIManager uiManager = Activator.getDefault().getLaunchBarUIManager(); private ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class);
private ILaunchBarUIManager uiManager = Activator.getService(ILaunchBarUIManager.class);
private DefaultDescriptorLabelProvider defaultProvider; private DefaultDescriptorLabelProvider defaultProvider;
private static final String[] noConfigs = new String[] { Messages.ConfigSelector_0 }; private static final String[] noConfigs = new String[] { Messages.ConfigSelector_0 };
@ -60,16 +59,21 @@ public class ConfigSelector extends CSelector {
@Override @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
} }
@Override @Override
public void dispose() { public void dispose() {
} }
@Override @Override
public Object[] getElements(Object inputElement) { public Object[] getElements(Object inputElement) {
ILaunchDescriptor[] descs = uiManager.getManager().getLaunchDescriptors(); try {
if (descs.length == 0) ILaunchDescriptor[] descs = manager.getLaunchDescriptors();
if (descs.length == 0)
return noConfigs;
return descs;
} catch (CoreException e) {
return noConfigs; return noConfigs;
return descs; }
} }
}); });
@ -78,7 +82,7 @@ public class ConfigSelector extends CSelector {
public Image getImage(Object element) { public Image getImage(Object element) {
if (element instanceof ILaunchDescriptor) { if (element instanceof ILaunchDescriptor) {
try { try {
ILaunchDescriptor configDesc = (ILaunchDescriptor)element; ILaunchDescriptor configDesc = (ILaunchDescriptor) element;
ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc); ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc);
if (labelProvider != null) { if (labelProvider != null) {
Image img = labelProvider.getImage(element); Image img = labelProvider.getImage(element);
@ -86,18 +90,19 @@ public class ConfigSelector extends CSelector {
return img; return img;
} }
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e.getStatus()); Activator.log(e);
} }
} }
return defaultProvider.getImage(element); return defaultProvider.getImage(element);
} }
@Override @Override
public String getText(Object element) { public String getText(Object element) {
if (element instanceof String) { if (element instanceof String) {
return (String)element; return (String) element;
} else if (element instanceof ILaunchDescriptor) { } else if (element instanceof ILaunchDescriptor) {
try { try {
ILaunchDescriptor configDesc = (ILaunchDescriptor)element; ILaunchDescriptor configDesc = (ILaunchDescriptor) element;
ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc); ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc);
if (labelProvider != null) { if (labelProvider != null) {
String text = labelProvider.getText(element); String text = labelProvider.getText(element);
@ -105,7 +110,7 @@ public class ConfigSelector extends CSelector {
return text; return text;
} }
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e.getStatus()); Activator.log(e);
} }
} }
return defaultProvider.getText(element); return defaultProvider.getText(element);
@ -136,9 +141,9 @@ public class ConfigSelector extends CSelector {
if (selected instanceof ILaunchDescriptor) { if (selected instanceof ILaunchDescriptor) {
ILaunchDescriptor configDesc = (ILaunchDescriptor) selected; ILaunchDescriptor configDesc = (ILaunchDescriptor) selected;
try { try {
uiManager.getManager().setActiveLaunchDescriptor(configDesc); manager.setActiveLaunchDescriptor(configDesc);
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e.getStatus()); Activator.log(e);
} }
} }
} }
@ -150,7 +155,7 @@ public class ConfigSelector extends CSelector {
@Override @Override
public void handleEdit(Object element) { public void handleEdit(Object element) {
ConfigureActiveLaunchHandler.openConfigurationEditor((ILaunchDescriptor) element); uiManager.openConfigurationEditor((ILaunchDescriptor) element);
} }
@Override @Override
@ -170,7 +175,6 @@ public class ConfigSelector extends CSelector {
createLabel.setBackground(getBackground()); createLabel.setBackground(getBackground());
createLabel.setText(Messages.ConfigSelector_2); createLabel.setText(Messages.ConfigSelector_2);
MouseListener mouseListener = new MouseAdapter() { MouseListener mouseListener = new MouseAdapter() {
@Override @Override
public void mouseUp(org.eclipse.swt.events.MouseEvent e) { public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
@ -202,6 +206,7 @@ public class ConfigSelector extends CSelector {
createButton.setBackground(highlightColor); createButton.setBackground(highlightColor);
createLabel.setBackground(highlightColor); createLabel.setBackground(highlightColor);
} }
@Override @Override
public void mouseExit(MouseEvent e) { public void mouseExit(MouseEvent e) {
Color backgroundColor = getBackground(); Color backgroundColor = getBackground();

View file

@ -8,17 +8,17 @@
* Contributors: * Contributors:
* Alena Laskavaia * Alena Laskavaia
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
public class EditButton extends CButton { public class EditButton extends CButton {
public EditButton(Composite parent, int style) { public EditButton(Composite parent, int style) {
super(parent, style); super(parent, style);
setHotImage(Activator.getDefault().getImage("icons/config_config.png")); //$NON-NLS-1$ setHotImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_CONFIG_CONFIG));
setColdImage(Activator.getDefault().getImage("icons/edit_cold.png")); //$NON-NLS-1$ setColdImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_EDIT_COLD));
setToolTipText(Messages.EditButton_0); setToolTipText(Messages.EditButton_0);
} }
} }

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia * Alena Laskavaia
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
@ -20,7 +20,6 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleAdapter;

View file

@ -9,7 +9,7 @@
* Doug Schaefer - initial API and implementation * Doug Schaefer - initial API and implementation
* Elena Laskavaia - moved to a separate class * Elena Laskavaia - moved to a separate class
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.jface.resource.CompositeImageDescriptor; import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;

View file

@ -10,20 +10,23 @@
* Torkild U. Resheim - add preference to control target selector * Torkild U. Resheim - add preference to control target selector
* Vincent Guignot - Ingenico - add preference to control Build button * Vincent Guignot - Ingenico - add preference to control Build button
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.launchbar.core.ILaunchBarListener; import org.eclipse.launchbar.core.ILaunchBarListener;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.internal.LaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.ILaunchBarUIConstants;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.DisposeListener;
@ -32,16 +35,20 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem; import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
public class LaunchBarControl implements ILaunchBarListener { public class LaunchBarControl implements ILaunchBarListener {
public static final String ID = "org.eclipse.launchbar"; //$NON-NLS-1$ public static final String ID = "org.eclipse.launchbar"; //$NON-NLS-1$
public static final String CLASS_URI = "bundleclass://" + Activator.PLUGIN_ID + "/" //$NON-NLS-1$ //$NON-NLS-2$ public static final String CLASS_URI = "bundleclass://" + Activator.PLUGIN_ID + "/" //$NON-NLS-1$ //$NON-NLS-2$
+ LaunchBarControl.class.getName(); + LaunchBarControl.class.getName();
private LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager(); private ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class);
private ConfigSelector configSelector; private ConfigSelector configSelector;
private ModeSelector modeSelector; private ModeSelector modeSelector;
@ -70,11 +77,14 @@ public class LaunchBarControl implements ILaunchBarListener {
IPreferenceStore store = Activator.getDefault().getPreferenceStore(); IPreferenceStore store = Activator.getDefault().getPreferenceStore();
boolean buildEnabled = store.getBoolean(Activator.PREF_ENABLE_BUILDBUTTON); boolean buildEnabled = store.getBoolean(Activator.PREF_ENABLE_BUILDBUTTON);
if (buildEnabled) { if (buildEnabled) {
createButton(toolBar, Activator.IMG_BUTTON_BUILD, Messages.LaunchBarControl_Build, Activator.CMD_BUILD); createButton(toolBar, Activator.IMG_BUTTON_BUILD, Messages.LaunchBarControl_Build,
ILaunchBarUIConstants.CMD_BUILD);
} }
createButton(toolBar, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch, Activator.CMD_LAUNCH); createButton(toolBar, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch,
createButton(toolBar, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop, Activator.CMD_STOP); ILaunchBarUIConstants.CMD_LAUNCH);
createButton(toolBar, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop,
ILaunchBarUIConstants.CMD_STOP);
modeSelector = new ModeSelector(container, SWT.NONE); modeSelector = new ModeSelector(container, SWT.NONE);
modeSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); modeSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
@ -84,7 +94,6 @@ public class LaunchBarControl implements ILaunchBarListener {
configSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); configSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
configSelector.setInput(manager); configSelector.setInput(manager);
boolean enabled = store.getBoolean(Activator.PREF_ENABLE_TARGETSELECTOR); boolean enabled = store.getBoolean(Activator.PREF_ENABLE_TARGETSELECTOR);
if (enabled) { if (enabled) {
Label label = new Label(container, SWT.NONE); Label label = new Label(container, SWT.NONE);
@ -100,12 +109,16 @@ public class LaunchBarControl implements ILaunchBarListener {
} }
protected void syncSelectors() { protected void syncSelectors() {
if (configSelector != null) try {
configSelector.setSelection(manager.getActiveLaunchDescriptor()); if (configSelector != null)
if (modeSelector != null) configSelector.setSelection(manager.getActiveLaunchDescriptor());
modeSelector.setSelection(manager.getActiveLaunchMode()); if (modeSelector != null)
if (targetSelector != null) modeSelector.setSelection(manager.getActiveLaunchMode());
targetSelector.setSelection(manager.getActiveLaunchTarget()); if (targetSelector != null)
targetSelector.setSelection(manager.getActiveLaunchTarget());
} catch (CoreException e) {
Activator.log(e);
}
} }
@PreDestroy @PreDestroy
@ -113,21 +126,32 @@ public class LaunchBarControl implements ILaunchBarListener {
manager.removeListener(this); manager.removeListener(this);
} }
private ToolItem createButton(Composite parent, String imageName, String toolTipText, final String command) { private ToolItem createButton(Composite parent, String imageName, String toolTipText, final String commandId) {
ToolItem button = new ToolItem((ToolBar) parent, SWT.FLAT); ToolItem button = new ToolItem((ToolBar) parent, SWT.FLAT);
Image bgImage = Activator.getDefault().getImage(Activator.IMG_BUTTON_BACKGROUND); Image bgImage = Activator.getDefault().getImageRegistry().get(Activator.IMG_BUTTON_BACKGROUND);
Image fgImage = Activator.getDefault().getImage(imageName); Image fgImage = Activator.getDefault().getImageRegistry().get(imageName);
ImageDescriptor imageDesc = new LaunchBarButtonImageDescriptor(fgImage, bgImage); ImageDescriptor imageDesc = new LaunchBarButtonImageDescriptor(fgImage, bgImage);
Image image = imageDesc.createImage(); Image image = imageDesc.createImage();
button.setImage(image); button.setImage(image);
button.setToolTipText(toolTipText); button.setToolTipText(toolTipText);
button.setData("command", command); //$NON-NLS-1$ button.setData("command", commandId); //$NON-NLS-1$
button.addSelectionListener(new SelectionAdapter() { button.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
Activator.runCommand(command); final ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = commandService.getCommand(commandId);
final Event trigger = new Event();
final IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
ExecutionEvent executionEvent = handlerService.createExecutionEvent(command, trigger);
try {
command.executeWithChecks(executionEvent);
} catch (OperationCanceledException ex) {
// abort
} catch (Exception ex) {
Activator.log(ex);
}
}; };
}); });
button.addDisposeListener(new DisposeListener() { button.addDisposeListener(new DisposeListener() {
@ -170,4 +194,5 @@ public class LaunchBarControl implements ILaunchBarListener {
public ConfigSelector getConfigSelector() { public ConfigSelector getConfigSelector() {
return configSelector; return configSelector;
} }
} }

View file

@ -10,7 +10,7 @@
* Torkild U. Resheim - add preference to control target selector * Torkild U. Resheim - add preference to control target selector
* Vincent Guignot - Ingenico - add preference to control Build button * Vincent Guignot - Ingenico - add preference to control Build button
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal; package org.eclipse.launchbar.ui.controls.internal;
import javax.inject.Inject; import javax.inject.Inject;
@ -28,7 +28,6 @@ import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.launchbar.ui.internal.controls.LaunchBarControl;
import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.widgets.Widget;
import org.osgi.service.event.Event; import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler; import org.osgi.service.event.EventHandler;
@ -100,19 +99,25 @@ public class LaunchBarInjector {
private void injectLaunchBar(MTrimBar trimBar, boolean enabled) { private void injectLaunchBar(MTrimBar trimBar, boolean enabled) {
// are we enabled or not // are we enabled or not
// and fix up the class URI for 2.0
// Search for control in trimbar // Search for control in trimbar
MTrimElement launchBarElement = null; MToolControl launchBarElement = null;
for (MTrimElement trimElement : trimBar.getChildren()) { for (MTrimElement trimElement : trimBar.getChildren()) {
if (LaunchBarControl.ID.equals(trimElement.getElementId())) { if (LaunchBarControl.ID.equals(trimElement.getElementId())) {
launchBarElement = trimElement; launchBarElement = (MToolControl) trimElement;
break; break;
} }
} }
if (launchBarElement != null) { if (launchBarElement != null) {
// Fix up class name
if (!LaunchBarControl.CLASS_URI.equals(launchBarElement.getContributionURI())) {
launchBarElement.setContributionURI(LaunchBarControl.CLASS_URI);
}
// remove it if we're disabled
if (!enabled) { if (!enabled) {
// remove it if we're disabled
trimBar.getChildren().remove(launchBarElement); trimBar.getChildren().remove(launchBarElement);
// This seems to be a bug in the platform but for now, dispose of the widget // This seems to be a bug in the platform but for now, dispose of the widget
Widget widget = (Widget)launchBarElement.getWidget(); Widget widget = (Widget)launchBarElement.getWidget();

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia * Alena Laskavaia
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
@ -26,8 +26,6 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeEvent;

View file

@ -10,7 +10,7 @@
* Torkild U. Resheim - add preference to control target selector * Torkild U. Resheim - add preference to control target selector
* Vincent Guignot - Ingenico - add preference to control Build button * Vincent Guignot - Ingenico - add preference to control Build button
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal; package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
@ -20,8 +20,8 @@ public class LaunchBarPreferenceInitializer extends AbstractPreferenceInitialize
@Override @Override
public void initializeDefaultPreferences() { public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore(); IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(Activator.PREF_ENABLE_BUILDBUTTON, true);
store.setDefault(Activator.PREF_ENABLE_LAUNCHBAR, true); store.setDefault(Activator.PREF_ENABLE_LAUNCHBAR, true);
store.setDefault(Activator.PREF_ENABLE_BUILDBUTTON, true);
store.setDefault(Activator.PREF_ENABLE_TARGETSELECTOR, true); store.setDefault(Activator.PREF_ENABLE_TARGETSELECTOR, true);
store.setDefault(Activator.PREF_LAUNCH_HISTORY_SIZE, 3); store.setDefault(Activator.PREF_LAUNCH_HISTORY_SIZE, 3);
} }

View file

@ -10,7 +10,7 @@
* Torkild U. Resheim - add preference to control target selector * Torkild U. Resheim - add preference to control target selector
* Vincent Guignot - Ingenico - add preference to control Build button * Vincent Guignot - Ingenico - add preference to control Build button
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal; package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FieldEditorPreferencePage;

View file

@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer
* Torkild U. Resheim - add preference to control target selector
* Vincent Guignot - Ingenico - add preference to control Build button
*******************************************************************************/
package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.launchbar.ui.controls.internal.messages"; //$NON-NLS-1$
public static String ConfigSelector_0;
public static String ConfigSelector_1;
public static String ConfigSelector_2;
public static String ConfigSelector_3;
public static String CSelector_0;
public static String CSelector_1;
public static String EditButton_0;
public static String FilterControl_0;
public static String FilterControl_1;
public static String LaunchBarControl_0;
public static String LaunchBarControl_Build;
public static String LaunchBarControl_Launch;
public static String LaunchBarControl_Stop;
public static String LaunchBarListViewer_0;
public static String LaunchBarPreferencePage_0;
public static String LaunchBarPreferencePage_1;
public static String LaunchBarPreferencePage_EnableTargetSelector;
public static String LaunchBarPreferencePage_EnableBuildButton;
public static String LaunchConfigurationEditDialog_0;
public static String LaunchConfigurationEditDialog_1;
public static String LaunchConfigurationEditDialog_2;
public static String LaunchConfigurationEditDialog_3;
public static String LaunchConfigurationEditDialog_4;
public static String LaunchConfigurationEditDialog_5;
public static String LaunchConfigurationEditDialog_6;
public static String ModeSelector_0;
public static String ModeSelector_ToolTip;
public static String TargetSelector_ToolTipPrefix;
public static String TargetSelector_CreateNewTarget;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
@ -25,9 +25,8 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.ILaunchBarUIConstants;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
@ -36,10 +35,9 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem; import org.eclipse.swt.widgets.ToolItem;
@SuppressWarnings("restriction")
public class ModeSelector extends CSelector { public class ModeSelector extends CSelector {
private static final String[] noModes = new String[] { "---" }; //$NON-NLS-1$ private static final String[] noModes = new String[] { "---" }; //$NON-NLS-1$
private final LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager(); private final ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class);
private Map<String, Image> modeButtonImages = new HashMap<>(); private Map<String, Image> modeButtonImages = new HashMap<>();
public ModeSelector(Composite parent, int style) { public ModeSelector(Composite parent, int style) {
@ -61,7 +59,7 @@ public class ModeSelector extends CSelector {
if (modes.length > 0) if (modes.length > 0)
return modes; return modes;
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e.getStatus()); Activator.log(e);
} }
return noModes; return noModes;
} }
@ -175,7 +173,7 @@ public class ModeSelector extends CSelector {
try { try {
manager.setActiveLaunchMode(mode); manager.setActiveLaunchMode(mode);
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e.getStatus()); Activator.log(e);
} catch (Exception e) { } catch (Exception e) {
// manager can throw illegal state exception hopefully we never // manager can throw illegal state exception hopefully we never
// get it // get it
@ -200,7 +198,7 @@ public class ModeSelector extends CSelector {
} }
private ToolItem findLaunchButton() { private ToolItem findLaunchButton() {
String commandId = Activator.CMD_LAUNCH; String commandId = ILaunchBarUIConstants.CMD_LAUNCH;
for (Control control : getParent().getChildren()) { for (Control control : getParent().getChildren()) {
if (control instanceof ToolBar) { if (control instanceof ToolBar) {
for (ToolItem toolItem : ((ToolBar) control).getItems()) { for (ToolItem toolItem : ((ToolBar) control).getItems()) {
@ -229,7 +227,7 @@ public class ModeSelector extends CSelector {
String id = group.getIdentifier(); String id = group.getIdentifier();
Image image = modeButtonImages.get(id); Image image = modeButtonImages.get(id);
if (image == null) { if (image == null) {
Image bgImage = Activator.getDefault().getImage(Activator.IMG_BUTTON_BACKGROUND); Image bgImage = Activator.getDefault().getImageRegistry().get(Activator.IMG_BUTTON_BACKGROUND);
Image modeImage = getLabelProvider().getImage(mode); Image modeImage = getLabelProvider().getImage(mode);
ImageDescriptor imageDesc = new LaunchBarButtonImageDescriptor(modeImage, bgImage); ImageDescriptor imageDesc = new LaunchBarButtonImageDescriptor(modeImage, bgImage);
image = imageDesc.createImage(); image = imageDesc.createImage();
@ -244,7 +242,7 @@ public class ModeSelector extends CSelector {
try { try {
group = getLaunchGroup(mode.getIdentifier()); group = getLaunchGroup(mode.getIdentifier());
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e.getStatus()); Activator.log(e);
} }
if (group == null) { if (group == null) {
group = getDefaultLaunchGroup(mode.getIdentifier()); group = getDefaultLaunchGroup(mode.getIdentifier());

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia * Alena Laskavaia
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.commands; package org.eclipse.launchbar.ui.controls.internal;
import java.util.List; import java.util.List;
@ -21,7 +21,6 @@ import org.eclipse.e4.ui.internal.workbench.E4Workbench;
import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.launchbar.ui.internal.controls.LaunchBarControl;
public class OpenLaunchSelector extends AbstractHandler { public class OpenLaunchSelector extends AbstractHandler {
@Override @Override

View file

@ -8,10 +8,10 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.layout.GridLayoutFactory;
@ -26,17 +26,14 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.SameShellProvider; import org.eclipse.jface.window.SameShellProvider;
import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetListener; import org.eclipse.launchbar.core.target.ILaunchTargetListener;
import org.eclipse.launchbar.core.target.ILaunchTargetManager; import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.TargetStatus; import org.eclipse.launchbar.core.target.TargetStatus;
import org.eclipse.launchbar.core.target.TargetStatus.Code; import org.eclipse.launchbar.core.target.TargetStatus.Code;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.LaunchBarUIManager;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.launchbar.ui.internal.target.NewLaunchTargetWizardAction;
import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager; import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager;
import org.eclipse.launchbar.ui.target.NewLaunchTargetWizardAction;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
@ -55,7 +52,7 @@ import org.eclipse.ui.dialogs.PropertyDialogAction;
public class TargetSelector extends CSelector implements ILaunchTargetListener { public class TargetSelector extends CSelector implements ILaunchTargetListener {
private final LaunchBarUIManager uiManager = Activator.getDefault().getLaunchBarUIManager(); private final ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class);
private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class); private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class);
private final ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class); private final ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class);
@ -77,12 +74,12 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
@Override @Override
public Object[] getElements(Object inputElement) { public Object[] getElements(Object inputElement) {
LaunchBarManager manager = uiManager.getManager(); try {
List<ILaunchTarget> targets = manager.getLaunchTargets(manager.getActiveLaunchDescriptor()); return manager.getLaunchTargets(manager.getActiveLaunchDescriptor());
if (!targets.isEmpty()) { } catch (CoreException e) {
return targets.toArray(); Activator.log(e);
return noTargets;
} }
return noTargets;
} }
}); });
@ -92,7 +89,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
if (element instanceof ILaunchTarget) { if (element instanceof ILaunchTarget) {
ILaunchTarget target = (ILaunchTarget) element; ILaunchTarget target = (ILaunchTarget) element;
ILabelProvider provider = targetUIManager.getLabelProvider(target); ILabelProvider provider = targetUIManager.getLabelProvider(target);
return provider != null ? provider.getText(target) : target.getName(); return provider != null ? provider.getText(target) : target.getId();
} }
return super.getText(element); return super.getText(element);
} }
@ -225,6 +222,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
createButton.setBackground(highlightColor); createButton.setBackground(highlightColor);
createLabel.setBackground(highlightColor); createLabel.setBackground(highlightColor);
} }
@Override @Override
public void mouseExit(MouseEvent e) { public void mouseExit(MouseEvent e) {
Color backgroundColor = getBackground(); Color backgroundColor = getBackground();
@ -242,7 +240,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
if (selection instanceof ILaunchTarget) { if (selection instanceof ILaunchTarget) {
ILaunchTarget target = (ILaunchTarget) selection; ILaunchTarget target = (ILaunchTarget) selection;
try { try {
uiManager.getManager().setActiveLaunchTarget(target); manager.setActiveLaunchTarget(target);
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e); Activator.log(e);
} }
@ -289,8 +287,12 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
@Override @Override
public void launchTargetStatusChanged(ILaunchTarget target) { public void launchTargetStatusChanged(ILaunchTarget target) {
if (target.equals(uiManager.getManager().getActiveLaunchTarget())) { try {
refresh(); if (target.equals(manager.getActiveLaunchTarget())) {
refresh();
}
} catch (CoreException e) {
Activator.log(e);
} }
} }

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.controls; package org.eclipse.launchbar.ui.controls.internal;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;

View file

@ -0,0 +1,36 @@
################################################################################
# Copyright (c) 2016 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
################################################################################
ConfigSelector_0=No Launch Configurations
ConfigSelector_1=Launch Configuration
ConfigSelector_2=New Launch Configuration...
ConfigSelector_3=Create Launch Configuration
CSelector_0=Closing popup
CSelector_1=Updating launch bar selection
EditButton_0=Edit
FilterControl_0=type filter text
FilterControl_1={0} {1} matches.
LaunchBarControl_0=on
LaunchBarControl_Build=Build
LaunchBarControl_Launch=Launch
LaunchBarControl_Stop=Stop
LaunchBarListViewer_0=Increase/Decrease size of recently used elements pane
LaunchBarPreferencePage_0=Preferences for the Launch Bar
LaunchBarPreferencePage_1=Enable the Launch Bar
LaunchBarPreferencePage_EnableTargetSelector=Enable the target selector
LaunchBarPreferencePage_EnableBuildButton=Enable the Build button
LaunchConfigurationEditDialog_0=Delete
LaunchConfigurationEditDialog_1=Duplicate
LaunchConfigurationEditDialog_2=Launch
LaunchConfigurationEditDialog_3=Confirm Delete
LaunchConfigurationEditDialog_4=Are you sure you want to delete
LaunchConfigurationEditDialog_5=Deleting launch configuration
LaunchConfigurationEditDialog_6=Duplicating launch configuration
ModeSelector_0=Launch Mode
ModeSelector_ToolTip=Launch in ''{0}'' mode
TargetSelector_ToolTipPrefix=Launch Target
TargetSelector_CreateNewTarget=New Launch Target...

View file

@ -5,24 +5,16 @@ Bundle-SymbolicName: org.eclipse.launchbar.ui;singleton:=true
Bundle-Version: 2.0.0.qualifier Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.launchbar.ui.internal.Activator Bundle-Activator: org.eclipse.launchbar.ui.internal.Activator
Bundle-Vendor: Eclipse CDT Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.runtime, org.eclipse.ui,
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.launchbar.core,
org.eclipse.debug.ui,
org.eclipse.ui.ide, org.eclipse.ui.ide,
org.eclipse.e4.core.contexts, org.eclipse.debug.ui,
org.eclipse.ui.workbench org.eclipse.launchbar.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin Bundle-Localization: plugin
Export-Package: org.eclipse.launchbar.ui, Export-Package: org.eclipse.launchbar.ui,
org.eclipse.launchbar.ui.internal;x-internal:=true, org.eclipse.launchbar.ui.internal;x-internal:=true,
org.eclipse.launchbar.ui.internal.commands;x-internal:=true, org.eclipse.launchbar.ui.internal.commands;x-internal:=true,
org.eclipse.launchbar.ui.internal.controls;x-internal:=true, org.eclipse.launchbar.ui.internal.dialogs;x-internal:=true,
org.eclipse.launchbar.ui.internal.dialogs;x-internal:=true org.eclipse.launchbar.ui.target
Import-Package: javax.inject

View file

@ -3,15 +3,6 @@
<plugin> <plugin>
<extension-point id="launchBarUIContributions" name="launchBar UI Contributions" schema="schema/launchBarUIContributions.exsd"/> <extension-point id="launchBarUIContributions" name="launchBar UI Contributions" schema="schema/launchBarUIContributions.exsd"/>
<extension-point id="launchTargetTypeUI" name="Launch Target Type UI" schema="schema/launchTargetTypeUI.exsd"/> <extension-point id="launchTargetTypeUI" name="Launch Target Type UI" schema="schema/launchTargetTypeUI.exsd"/>
<extension
id="launchBarInjector"
point="org.eclipse.e4.workbench.model">
<processor
apply="always"
beforefragment="false"
class="org.eclipse.launchbar.ui.internal.LaunchBarInjector">
</processor>
</extension>
<extension <extension
point="org.eclipse.ui.commands"> point="org.eclipse.ui.commands">
<category <category
@ -42,33 +33,12 @@
id="org.eclipse.launchbar.ui.command.configureActiveLaunch" id="org.eclipse.launchbar.ui.command.configureActiveLaunch"
name="Edit Active Launch Configuration"> name="Edit Active Launch Configuration">
</command> </command>
<command
categoryId="org.eclipse.launchbar.ui.category.launchBar"
defaultHandler="org.eclipse.launchbar.ui.internal.commands.OpenLaunchSelector"
id="org.eclipse.launchbar.ui.command.openLaunchSelector"
name="Open Launch Bar Config Selector">
</command>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.eclipse.launchbar.ui.internal.LaunchBarPreferenceInitializer">
</initializer>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
category="org.eclipse.debug.ui.LaunchingPreferencePage"
class="org.eclipse.launchbar.ui.internal.LaunchBarPreferencePage"
id="org.eclipse.launchbar.ui.prefPage"
name="Launch Bar">
</page>
</extension> </extension>
<extension <extension
point="org.eclipse.launchbar.ui.launchBarUIContributions"> point="org.eclipse.launchbar.ui.launchBarUIContributions">
<descriptorUI <descriptorUI
descriptorTypeId="org.eclipse.launchbar.core.descriptor.default" descriptorTypeId="org.eclipse.launchbar.core.descriptor.default"
labelProvider="org.eclipse.launchbar.ui.internal.DefaultDescriptorLabelProvider"> labelProvider="org.eclipse.launchbar.ui.DefaultDescriptorLabelProvider">
</descriptorUI> </descriptorUI>
</extension> </extension>

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal; package org.eclipse.launchbar.ui;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -38,7 +38,7 @@ public class DefaultDescriptorLabelProvider extends LabelProvider {
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
if (element instanceof ILaunchDescriptor) { if (element instanceof ILaunchDescriptor) {
ILaunchConfiguration config = (ILaunchConfiguration) ((ILaunchDescriptor) element).getAdapter(ILaunchConfiguration.class); ILaunchConfiguration config = ((ILaunchDescriptor) element).getAdapter(ILaunchConfiguration.class);
if (config != null) { if (config != null) {
try { try {
ILaunchConfigurationType type = config.getType(); ILaunchConfigurationType type = config.getType();

View file

@ -10,6 +10,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui; package org.eclipse.launchbar.ui;
import org.eclipse.launchbar.ui.internal.Activator;
public interface ILaunchBarUIConstants { public interface ILaunchBarUIConstants {
/** /**
@ -17,4 +19,10 @@ public interface ILaunchBarUIConstants {
*/ */
public static final String TARGET_NAME = "targetName"; //$NON-NLS-1$ public static final String TARGET_NAME = "targetName"; //$NON-NLS-1$
// Command ids
public static final String CMD_BUILD = Activator.PLUGIN_ID + ".command.buildActive"; //$NON-NLS-1$
public static final String CMD_LAUNCH = Activator.PLUGIN_ID + ".command.launchActive"; //$NON-NLS-1$
public static final String CMD_STOP = Activator.PLUGIN_ID + ".command.stop"; //$NON-NLS-1$
public static final String CMD_CONFIG = Activator.PLUGIN_ID + ".command.configureActiveLaunch"; //$NON-NLS-1$
} }

View file

@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.launchbar.ui;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.launchbar.core.ILaunchDescriptor;
public interface ILaunchBarUIManager {
ILabelProvider getLabelProvider(ILaunchDescriptor descriptor) throws CoreException;
IStatus openConfigurationEditor(ILaunchDescriptor descriptor);
}

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer * Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.dialogs; package org.eclipse.launchbar.ui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -19,28 +19,92 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationListener;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages; import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigEditPage;
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigModePage;
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigTypePage;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
public class NewLaunchConfigWizard extends Wizard implements ILaunchConfigurationListener { public class NewLaunchConfigWizard extends Wizard implements ILaunchConfigurationListener {
NewLaunchConfigModePage modePage = new NewLaunchConfigModePage(); private NewLaunchConfigModePage modePage = new NewLaunchConfigModePage();
NewLaunchConfigTypePage typePage = new NewLaunchConfigTypePage(); private NewLaunchConfigTypePage typePage = new NewLaunchConfigTypePage();
NewLaunchConfigEditPage editPage = new NewLaunchConfigEditPage(); private NewLaunchConfigEditPage editPage = new NewLaunchConfigEditPage();
private List<ILaunchConfiguration> configsToDelete = new ArrayList<>(); private List<ILaunchConfiguration> configsToDelete = new ArrayList<>();
public NewLaunchConfigWizard() { public NewLaunchConfigWizard() {
setWindowTitle(Messages.NewLaunchConfigWizard_0); setWindowTitle(Messages.NewLaunchConfigWizard_0);
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);
}
@Override
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
// Link the pages
SelectionListener modePageListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
ILaunchGroup selectedGroup = modePage.getSelectedGroup();
typePage.setLaunchGroup(selectedGroup);
editPage.setLaunchGroup(selectedGroup);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
getContainer().showPage(modePage.getNextPage());
}
};
modePage.addGroupSelectionListener(modePageListener);
modePageListener.widgetSelected(null);
SelectionListener typePageListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
editPage.setLaunchConfigType(typePage.getSelectedType());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
getContainer().showPage(typePage.getNextPage());
}
};
typePage.addTypeSelectionListener(typePageListener);
typePageListener.widgetSelected(null);
editPage.setLaunchConfigType(typePage.getSelectedType());
}
@Override
public void setContainer(IWizardContainer wizardContainer) {
super.setContainer(wizardContainer);
if (wizardContainer != null) {
// Edit page wants to know when it's about to change to itself
((WizardDialog) wizardContainer).addPageChangingListener(editPage);
}
} }
@Override @Override
public void addPages() { public void addPages() {
addPage(modePage); addPage(modePage);
addPage(typePage); addPage(typePage);
//addPage(editPage); // add dynamically on the types page addPage(editPage);
} }
@Override @Override
@ -56,7 +120,7 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio
} }
public ILaunchMode getLaunchMode() { public ILaunchMode getLaunchMode() {
String initMode = modePage.selectedGroup.getMode(); String initMode = modePage.getSelectedGroup().getMode();
return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(initMode); return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(initMode);
} }
@ -72,14 +136,6 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio
return super.performCancel(); 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() { void cleanUpConfigs() {
DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this); DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this);
for (ILaunchConfiguration config : configsToDelete) { for (ILaunchConfiguration config : configsToDelete) {

View file

@ -12,26 +12,15 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal; package org.eclipse.launchbar.ui.internal;
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.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.ui.ILaunchBarUIManager;
import org.eclipse.launchbar.core.internal.LaunchBarManager;
import org.eclipse.launchbar.ui.internal.target.LaunchTargetUIManager; import org.eclipse.launchbar.ui.internal.target.LaunchTargetUIManager;
import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager; import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager;
import org.eclipse.swt.graphics.Image; 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.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceReference;
@ -45,30 +34,11 @@ public class Activator extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.eclipse.launchbar.ui"; //$NON-NLS-1$ public static final String PLUGIN_ID = "org.eclipse.launchbar.ui"; //$NON-NLS-1$
// Images // Images
public static final String IMG_BUTTON_BACKGROUND = "bgButton"; //$NON-NLS-1$
public static final String IMG_BUTTON_BUILD = "build"; //$NON-NLS-1$
public static final String IMG_BUTTON_LAUNCH = "launch"; //$NON-NLS-1$
public static final String IMG_BUTTON_STOP = "stop"; //$NON-NLS-1$
public static final String IMG_LOCAL_TARGET = "localTarget"; //$NON-NLS-1$ public static final String IMG_LOCAL_TARGET = "localTarget"; //$NON-NLS-1$
// Command ids
public static final String CMD_BUILD = PLUGIN_ID + ".command.buildActive"; //$NON-NLS-1$
public static final String CMD_LAUNCH = PLUGIN_ID + ".command.launchActive"; //$NON-NLS-1$
public static final String CMD_STOP = PLUGIN_ID + ".command.stop"; //$NON-NLS-1$
public static final String CMD_CONFIG = PLUGIN_ID + ".command.configureActiveLaunch"; //$NON-NLS-1$
// Preference ids
public static final String PREF_ENABLE_LAUNCHBAR = "enableLaunchBar"; //$NON-NLS-1$
public static final String PREF_ENABLE_TARGETSELECTOR = "enableTargetSelector"; //$NON-NLS-1$
public static final String PREF_ENABLE_BUILDBUTTON = "enableBuildButton"; //$NON-NLS-1$
public static final String PREF_LAUNCH_HISTORY_SIZE = "launchHistorySize"; //$NON-NLS-1$
// The shared instance // The shared instance
private static Activator plugin; private static Activator plugin;
// The cache of the Launch Bar UI Manager Object
private LaunchBarUIManager launchBarUIManager;
/** /**
* The constructor * The constructor
*/ */
@ -81,13 +51,10 @@ public class Activator extends AbstractUIPlugin {
plugin = this; plugin = this;
ImageRegistry imageRegistry = getImageRegistry(); ImageRegistry imageRegistry = getImageRegistry();
imageRegistry.put(IMG_BUTTON_BACKGROUND, imageDescriptorFromPlugin(PLUGIN_ID, "icons/bgButton.png")); //$NON-NLS-1$
imageRegistry.put(IMG_BUTTON_BUILD, imageDescriptorFromPlugin(PLUGIN_ID, "icons/build_16.png")); //$NON-NLS-1$
imageRegistry.put(IMG_BUTTON_LAUNCH, imageDescriptorFromPlugin(PLUGIN_ID, "icons/launch_16.png")); //$NON-NLS-1$
imageRegistry.put(IMG_BUTTON_STOP, imageDescriptorFromPlugin(PLUGIN_ID, "icons/stop_16.png")); //$NON-NLS-1$
imageRegistry.put(IMG_LOCAL_TARGET, imageDescriptorFromPlugin(PLUGIN_ID, "icons/localTarget.png")); //$NON-NLS-1$ imageRegistry.put(IMG_LOCAL_TARGET, imageDescriptorFromPlugin(PLUGIN_ID, "icons/localTarget.png")); //$NON-NLS-1$
context.registerService(ILaunchTargetUIManager.class, new LaunchTargetUIManager(), null); context.registerService(ILaunchTargetUIManager.class, new LaunchTargetUIManager(), null);
context.registerService(ILaunchBarUIManager.class, new LaunchBarUIManager(), null);
} }
@Override @Override
@ -105,14 +72,6 @@ public class Activator extends AbstractUIPlugin {
return plugin; return plugin;
} }
public LaunchBarUIManager getLaunchBarUIManager() {
if (launchBarUIManager == null) {
LaunchBarManager manager = (LaunchBarManager) getService(ILaunchBarManager.class);
launchBarUIManager = new LaunchBarUIManager(manager);
}
return launchBarUIManager;
}
public Image getImage(String id) { public Image getImage(String id) {
Image im = getImageRegistry().get(id); Image im = getImageRegistry().get(id);
if (im == null) { if (im == null) {
@ -129,36 +88,6 @@ public class Activator extends AbstractUIPlugin {
return imageDescriptorFromPlugin(PLUGIN_ID, path); return imageDescriptorFromPlugin(PLUGIN_ID, path);
} }
public static void runCommand(String commandId, String... params) {
final ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = commandService.getCommand(commandId);
final Event trigger = new Event();
final IHandlerService handlerService = 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) { public static void log(IStatus status) {
plugin.getLog().log(status); plugin.getLog().log(status);
} }

View file

@ -17,41 +17,163 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
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.LaunchConfigurationPresentationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.internal.ExecutableExtension; import org.eclipse.launchbar.core.internal.ExecutableExtension;
import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.ui.ILaunchBarUIManager;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
public class LaunchBarUIManager { public class LaunchBarUIManager implements ILaunchBarUIManager {
private LaunchBarManager manager; private Map<String, ExecutableExtension<ILabelProvider>> descriptorLabelProviders = null;
private Map<String, ExecutableExtension<ILabelProvider>> descriptorLabelProviders = new HashMap<>(); private ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class);
public LaunchBarUIManager(LaunchBarManager manager) { private void init() {
this.manager = manager; if (descriptorLabelProviders == null) {
descriptorLabelProviders = new HashMap<>();
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launchBarUIContributions"); //$NON-NLS-1$ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launchBarUIContributions"); //$NON-NLS-1$
IExtension[] extensions = point.getExtensions(); IExtension[] extensions = point.getExtensions();
for (IExtension extension : extensions) { for (IExtension extension : extensions) {
for (IConfigurationElement element : extension.getConfigurationElements()) { for (IConfigurationElement element : extension.getConfigurationElements()) {
String elementName = element.getName(); String elementName = element.getName();
if (elementName.equals("descriptorUI")) { //$NON-NLS-1$ if (elementName.equals("descriptorUI")) { //$NON-NLS-1$
String descriptorTypeId = element.getAttribute("descriptorTypeId"); //$NON-NLS-1$ String descriptorTypeId = element.getAttribute("descriptorTypeId"); //$NON-NLS-1$
ExecutableExtension<ILabelProvider> labelProvider = new ExecutableExtension<>(element, "labelProvider"); //$NON-NLS-1$ ExecutableExtension<ILabelProvider> labelProvider = new ExecutableExtension<>(element, "labelProvider"); //$NON-NLS-1$
descriptorLabelProviders.put(descriptorTypeId, labelProvider); descriptorLabelProviders.put(descriptorTypeId, labelProvider);
}
} }
} }
} }
} }
public LaunchBarManager getManager() { @Override
return manager;
}
public ILabelProvider getLabelProvider(ILaunchDescriptor descriptor) throws CoreException { public ILabelProvider getLabelProvider(ILaunchDescriptor descriptor) throws CoreException {
init();
ExecutableExtension<ILabelProvider> provider = descriptorLabelProviders.get(manager.getDescriptorTypeId(descriptor.getType())); ExecutableExtension<ILabelProvider> provider = descriptorLabelProviders.get(manager.getDescriptorTypeId(descriptor.getType()));
return provider != null ? provider.get() : null; return provider != null ? provider.get() : null;
} }
@Override
public IStatus openConfigurationEditor(ILaunchDescriptor descriptor) {
if (descriptor == null)
return Status.OK_STATUS;
// Display the error message
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
IStatus s = canOpenConfigurationEditor(descriptor);
if (!s.isOK()) {
MessageDialog.openError(shell, s.getMessage(),
s.getException() == null ? s.getMessage() : s.getException().getMessage());
return s;
}
// At this point, no error handling should be needed.
try {
ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class);
ILaunchMode mode = manager.getActiveLaunchMode();
ILaunchTarget target = manager.getActiveLaunchTarget();
ILaunchConfigurationType configType = manager.getLaunchConfigurationType(descriptor, target);
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType,
mode.getIdentifier());
ILaunchConfiguration config = manager.getLaunchConfiguration(descriptor, target);
if (config instanceof ILaunchConfigurationWorkingCopy
&& ((ILaunchConfigurationWorkingCopy) config).isDirty()) {
config = ((ILaunchConfigurationWorkingCopy) config).doSave();
}
// open real eclipse launch configurations dialog
DebugUIPlugin.openLaunchConfigurationsDialog(shell, new StructuredSelection(config),
group.getIdentifier(), false);
return Status.OK_STATUS;
} catch (CoreException e2) {
return e2.getStatus();
}
}
private IStatus canOpenConfigurationEditor(ILaunchDescriptor desc) {
if (desc == null)
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.DescriptorMustNotBeNull,
new Exception(Messages.DescriptorMustNotBeNullDesc));
ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class);
ILaunchMode mode = null;
ILaunchTarget target = null;
try {
mode = manager.getActiveLaunchMode();
target = manager.getActiveLaunchTarget();
} catch (CoreException e) {
return e.getStatus();
}
if (target == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoActiveTarget,
new Exception(Messages.NoActiveTargetDesc));
}
ILaunchConfigurationType configType = null;
try {
configType = manager.getLaunchConfigurationType(desc, target);
} catch (CoreException ce) {
return ce.getStatus();
}
if (mode == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected,
new Exception(Messages.NoLaunchModeSelected));
}
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType,
mode.getIdentifier());
if (group == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchGroupSelected,
new Exception(Messages.NoLaunchGroupSelected));
}
String mode2 = group.getMode();
if (mode2 == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected,
new Exception(Messages.CannotEditLaunchConfiguration));
}
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
.getLaunchGroup(group.getIdentifier());
if (groupExt != null) {
ILaunchConfiguration config = null;
try {
config = manager.getLaunchConfiguration(desc, target);
} catch (CoreException ce) {
// Ignore
}
if (config == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LaunchConfigurationNotFound,
new Exception(Messages.LaunchConfigurationNotFoundDesc));
}
try {
LaunchConfigurationPresentationManager mgr = LaunchConfigurationPresentationManager.getDefault();
ILaunchConfigurationTabGroup tabgroup = mgr.getTabGroup(config, mode.getIdentifier());
} catch (CoreException ce) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchTabsDefined,
new Exception(Messages.NoLaunchTabsDefinedDesc));
}
} else {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CannotEditLaunchConfiguration,
new Exception(Messages.CannotEditLaunchConfiguration));
}
return Status.OK_STATUS;
}
} }

View file

@ -1,14 +1,9 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014, 2015 QNX Software Systems and others. * Copyright (c) 2014, 2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer
* Torkild U. Resheim - add preference to control target selector
* Vincent Guignot - Ingenico - add preference to control Build button
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal; package org.eclipse.launchbar.ui.internal;
@ -16,35 +11,12 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS { public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.launchbar.ui.internal.messages"; //$NON-NLS-1$ private static final String BUNDLE_NAME = "org.eclipse.launchbar.ui.internal.messages"; //$NON-NLS-1$
public static String BuildActiveCommandHandler_0; public static String BuildActiveCommandHandler_0;
public static String BuildActiveCommandHandler_1; public static String BuildActiveCommandHandler_1;
public static String ConfigSelector_0; public static String StopActiveCommandHandler_0;
public static String ConfigSelector_1; public static String StopActiveCommandHandler_1;
public static String ConfigSelector_2;
public static String ConfigSelector_3;
public static String CSelector_0;
public static String CSelector_1;
public static String EditButton_0;
public static String FilterControl_0;
public static String FilterControl_1;
public static String LaunchBarControl_0;
public static String LaunchBarControl_Build;
public static String LaunchBarControl_Launch;
public static String LaunchBarControl_Stop;
public static String LaunchBarListViewer_0;
public static String LaunchBarPreferencePage_0;
public static String LaunchBarPreferencePage_1;
public static String LaunchBarPreferencePage_EnableTargetSelector;
public static String LaunchBarPreferencePage_EnableBuildButton;
public static String LaunchConfigurationEditDialog_0;
public static String LaunchConfigurationEditDialog_1;
public static String LaunchConfigurationEditDialog_2;
public static String LaunchConfigurationEditDialog_3;
public static String LaunchConfigurationEditDialog_4;
public static String LaunchConfigurationEditDialog_5;
public static String LaunchConfigurationEditDialog_6;
public static String ModeSelector_0;
public static String ModeSelector_ToolTip;
public static String NewLaunchConfigEditPage_0; public static String NewLaunchConfigEditPage_0;
public static String NewLaunchConfigEditPage_1; public static String NewLaunchConfigEditPage_1;
public static String NewLaunchConfigEditPage_2; public static String NewLaunchConfigEditPage_2;
@ -60,10 +32,6 @@ public class Messages extends NLS {
public static String NewLaunchConfigTypePage_1; public static String NewLaunchConfigTypePage_1;
public static String NewLaunchConfigTypePage_2; public static String NewLaunchConfigTypePage_2;
public static String NewLaunchConfigWizard_0; public static String NewLaunchConfigWizard_0;
public static String StopActiveCommandHandler_0;
public static String StopActiveCommandHandler_1;
public static String TargetSelector_ToolTipPrefix;
public static String TargetSelector_CreateNewTarget;
public static String DescriptorMustNotBeNull; public static String DescriptorMustNotBeNull;
public static String DescriptorMustNotBeNullDesc; public static String DescriptorMustNotBeNullDesc;

View file

@ -34,7 +34,7 @@ import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.ILaunchConfigurationTargetedDelegate; import org.eclipse.launchbar.core.target.launch.ILaunchConfigurationTargetedDelegate;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.internal.Activator;
@ -56,7 +56,7 @@ public class BuildActiveCommandHandler extends AbstractHandler {
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
try { try {
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager(); ILaunchBarManager launchBarManager = Activator.getService(ILaunchBarManager.class);
ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration(); ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration();
ILaunchMode launchMode = launchBarManager.getActiveLaunchMode(); ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
ILaunchTarget target = launchBarManager.getActiveLaunchTarget(); ILaunchTarget target = launchBarManager.getActiveLaunchTarget();
@ -67,6 +67,7 @@ public class BuildActiveCommandHandler extends AbstractHandler {
return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family); return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
} }
@Override
public IStatus runInUIThread(IProgressMonitor monitor) { public IStatus runInUIThread(IProgressMonitor monitor) {
final Collection<IProject> projects = getProjects(config); final Collection<IProject> projects = getProjects(config);
if (BuildAction.isSaveAllSet()) { if (BuildAction.isSaveAllSet()) {

View file

@ -1,12 +1,9 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014,2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.commands; package org.eclipse.launchbar.ui.internal.commands;
@ -14,136 +11,23 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.core.runtime.Status;
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.LaunchConfigurationPresentationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.ui.ILaunchBarUIManager;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
public class ConfigureActiveLaunchHandler extends AbstractHandler { public class ConfigureActiveLaunchHandler extends AbstractHandler {
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
ILaunchDescriptor launchDesc = launchBarManager.getActiveLaunchDescriptor();
if (launchDesc == null)
return Status.OK_STATUS;
openConfigurationEditor(launchDesc);
return Status.OK_STATUS;
}
public static IStatus canOpenConfigurationEditor(ILaunchDescriptor desc) {
if (desc == null)
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.DescriptorMustNotBeNull,
new Exception(Messages.DescriptorMustNotBeNullDesc));
LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
ILaunchMode mode = manager.getActiveLaunchMode();
ILaunchTarget target = manager.getActiveLaunchTarget();
if (target == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoActiveTarget,
new Exception(Messages.NoActiveTargetDesc));
}
ILaunchConfigurationType configType = null;
try { try {
configType = manager.getLaunchConfigurationType(desc, target); ILaunchBarManager launchBarManager = Activator.getService(ILaunchBarManager.class);
} catch (CoreException ce) { ILaunchDescriptor launchDesc = launchBarManager.getActiveLaunchDescriptor();
/* ignore */ } ILaunchBarUIManager uiManager = Activator.getService(ILaunchBarUIManager.class);
; return uiManager.openConfigurationEditor(launchDesc);
if (configType == null) { } catch (CoreException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchConfigType, return e.getStatus();
new Exception(Messages.CannotEditLaunchConfiguration));
}
if (mode == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected,
new Exception(Messages.NoLaunchModeSelected));
}
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType,
mode.getIdentifier());
if (group == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchGroupSelected,
new Exception(Messages.NoLaunchGroupSelected));
}
String mode2 = group.getMode();
if (mode2 == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected,
new Exception(Messages.CannotEditLaunchConfiguration));
}
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
.getLaunchGroup(group.getIdentifier());
if (groupExt != null) {
ILaunchConfiguration config = null;
try {
config = manager.getLaunchConfiguration(desc, target);
} catch (CoreException ce) {
// Ignore
}
if (config == null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LaunchConfigurationNotFound,
new Exception(Messages.LaunchConfigurationNotFoundDesc));
}
try {
LaunchConfigurationPresentationManager mgr = LaunchConfigurationPresentationManager.getDefault();
ILaunchConfigurationTabGroup tabgroup = mgr.getTabGroup(config, mode.getIdentifier());
} catch (CoreException ce) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchTabsDefined,
new Exception(Messages.NoLaunchTabsDefinedDesc));
}
} else {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CannotEditLaunchConfiguration,
new Exception(Messages.CannotEditLaunchConfiguration));
}
return Status.OK_STATUS;
}
public static void openConfigurationEditor(ILaunchDescriptor desc) {
if (desc == null)
return;
// Display the error message
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
IStatus s = canOpenConfigurationEditor(desc);
if (!s.isOK()) {
MessageDialog.openError(shell, s.getMessage(),
s.getException() == null ? s.getMessage() : s.getException().getMessage());
return;
}
// At this point, no error handling should be needed.
try {
LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
ILaunchMode mode = manager.getActiveLaunchMode();
ILaunchTarget target = manager.getActiveLaunchTarget();
ILaunchConfigurationType configType = manager.getLaunchConfigurationType(desc, target);
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType,
mode.getIdentifier());
ILaunchConfiguration config = manager.getLaunchConfiguration(desc, target);
if (config instanceof ILaunchConfigurationWorkingCopy && ((ILaunchConfigurationWorkingCopy) config).isDirty()) {
config = ((ILaunchConfigurationWorkingCopy) config).doSave();
}
// open real eclipse launch configurations dialog
DebugUIPlugin.openLaunchConfigurationsDialog(shell, new StructuredSelection(config),
group.getIdentifier(), false);
} catch (CoreException e2) {
Activator.log(e2);
} }
} }
} }

View file

@ -18,7 +18,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.internal.Activator;
public class LaunchActiveCommandHandler extends AbstractHandler { public class LaunchActiveCommandHandler extends AbstractHandler {
@ -26,7 +26,7 @@ public class LaunchActiveCommandHandler extends AbstractHandler {
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
try { try {
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager(); ILaunchBarManager launchBarManager = Activator.getService(ILaunchBarManager.class);
StopActiveCommandHandler.stopActiveLaunches(launchBarManager); StopActiveCommandHandler.stopActiveLaunches(launchBarManager);
ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration(); ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration();
if (config == null) if (config == null)

View file

@ -24,7 +24,7 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages; import org.eclipse.launchbar.ui.internal.Messages;
@ -38,10 +38,10 @@ public class StopActiveCommandHandler extends AbstractHandler {
public void stop() { public void stop() {
stopBuild(); stopBuild();
stopActiveLaunches(Activator.getDefault().getLaunchBarUIManager().getManager()); stopActiveLaunches(Activator.getService(ILaunchBarManager.class));
} }
static void stopActiveLaunches(LaunchBarManager launchBarManager) { static void stopActiveLaunches(ILaunchBarManager launchBarManager) {
final ILaunch[] activeLaunches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); final ILaunch[] activeLaunches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
if (activeLaunches != null && activeLaunches.length > 0) { if (activeLaunches != null && activeLaunches.length > 0) {
new Job(Messages.StopActiveCommandHandler_0) { new Job(Messages.StopActiveCommandHandler_0) {

View file

@ -24,6 +24,8 @@ import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDi
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchGroup; import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.dialogs.IPageChangingListener;
import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.internal.Activator;
@ -34,11 +36,13 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@SuppressWarnings("restriction") @SuppressWarnings("restriction")
public class NewLaunchConfigEditPage extends WizardPage { public class NewLaunchConfigEditPage extends WizardPage implements IPageChangingListener {
private ILaunchConfigurationWorkingCopy workingCopy; private ILaunchConfigurationWorkingCopy workingCopy;
private LaunchConfigurationDialogExt launchConfigurationDialog = new LaunchConfigurationDialogExt(); private LaunchConfigurationDialogExt launchConfigurationDialog = new LaunchConfigurationDialogExt();
private LaunchConfigurationTabGroupViewerExt tabViewer; private LaunchConfigurationTabGroupViewerExt tabViewer;
private ILaunchConfigurationType type;
private ILaunchGroup launchGroup;
private ILaunchConfigurationType launchConfigType;
public NewLaunchConfigEditPage() { public NewLaunchConfigEditPage() {
super(Messages.NewLaunchConfigEditPage_0); super(Messages.NewLaunchConfigEditPage_0);
@ -55,7 +59,6 @@ public class NewLaunchConfigEditPage extends WizardPage {
LaunchConfigurationsDialog.setCurrentlyVisibleLaunchConfigurationDialog(launchConfigurationDialog); LaunchConfigurationsDialog.setCurrentlyVisibleLaunchConfigurationDialog(launchConfigurationDialog);
tabViewer = new LaunchConfigurationTabGroupViewerExt(comp, launchConfigurationDialog); tabViewer = new LaunchConfigurationTabGroupViewerExt(comp, launchConfigurationDialog);
launchConfigurationDialog.setTabViewer(tabViewer); launchConfigurationDialog.setTabViewer(tabViewer);
changeLaunchConfigType(type);
GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
data.heightHint = 500; data.heightHint = 500;
tabViewer.getControl().setLayoutData(data); tabViewer.getControl().setLayoutData(data);
@ -63,6 +66,14 @@ public class NewLaunchConfigEditPage extends WizardPage {
validateFields(); validateFields();
} }
public void setLaunchGroup(ILaunchGroup launchGroup) {
this.launchGroup = launchGroup;
}
public void setLaunchConfigType(ILaunchConfigurationType type) {
this.launchConfigType = type;
}
/** /**
* @return the workingCopy * @return the workingCopy
*/ */
@ -70,26 +81,26 @@ public class NewLaunchConfigEditPage extends WizardPage {
return workingCopy; return workingCopy;
} }
void changeLaunchConfigType(ILaunchConfigurationType type) { @Override
if (type == null) public void handlePageChanging(PageChangingEvent event) {
if (launchConfigType == null) {
return; return;
try { }
this.type = type; LaunchConfigurationsDialog.setCurrentlyVisibleLaunchConfigurationDialog(launchConfigurationDialog);
LaunchConfigurationsDialog.setCurrentlyVisibleLaunchConfigurationDialog(launchConfigurationDialog); if (tabViewer != null) {
if (tabViewer != null) { try {
String name = launchConfigurationDialog.generateName("launchConfiguration"); //$NON-NLS-1$ String name = launchConfigurationDialog.generateName("launchConfiguration"); //$NON-NLS-1$
workingCopy = type.newInstance(null, name); workingCopy = launchConfigType.newInstance(null, name);
launchConfigurationDialog.doSetDefaults(workingCopy); launchConfigurationDialog.doSetDefaults(workingCopy);
tabViewer.setInput(workingCopy); tabViewer.setInput(workingCopy);
setTitle(String.format(Messages.NewLaunchConfigEditPage_7, type.getName())); setTitle(String.format(Messages.NewLaunchConfigEditPage_7, launchConfigType.getName()));
} catch (CoreException e) {
Activator.log(e);
} }
} catch (CoreException e) {
Activator.log(e);
return;
} }
} }
boolean performFinish() { public boolean performFinish() {
if (workingCopy == null) if (workingCopy == null)
return false; return false;
workingCopy.rename(tabViewer.getWorkingCopy().getName()); workingCopy.rename(tabViewer.getWorkingCopy().getName());
@ -139,11 +150,6 @@ public class NewLaunchConfigEditPage extends WizardPage {
return NewLaunchConfigEditPage.this.getLaunchGroup(); return NewLaunchConfigEditPage.this.getLaunchGroup();
} }
@Override
public String getMode() {
return NewLaunchConfigEditPage.this.getMode();
}
@Override @Override
public void updateMessage() { public void updateMessage() {
validateFields(); validateFields();
@ -193,24 +199,15 @@ public class NewLaunchConfigEditPage extends WizardPage {
} }
}; };
public String getMode() {
return ((NewLaunchConfigWizard) getWizard()).modePage.selectedGroup.getMode();
}
public LaunchGroupExtension getLaunchGroup() { public LaunchGroupExtension getLaunchGroup() {
try { if (workingCopy == null)
if (workingCopy == null) return null;
return null; if (launchGroup == null) {
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
.getLaunchGroup(workingCopy.getType(), getMode());
if (group == null) {
return null;
}
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
.getLaunchGroup(group.getIdentifier());
return groupExt;
} catch (CoreException e) {
return null; return null;
} }
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
.getLaunchGroup(launchGroup.getIdentifier());
return groupExt;
} }
} }

View file

@ -19,8 +19,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.launchbar.ui.internal.Messages; import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -30,7 +29,6 @@ import org.eclipse.swt.widgets.TableItem;
public class NewLaunchConfigModePage extends WizardPage { public class NewLaunchConfigModePage extends WizardPage {
private Table table; private Table table;
ILaunchGroup selectedGroup;
public NewLaunchConfigModePage() { public NewLaunchConfigModePage() {
super(Messages.NewLaunchConfigModePage_0); super(Messages.NewLaunchConfigModePage_0);
@ -85,23 +83,8 @@ public class NewLaunchConfigModePage extends WizardPage {
if (!hasDebug) { if (!hasDebug) {
table.select(0); 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();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
getContainer().showPage(getNextPage());
}
});
setControl(comp); setControl(comp);
} }
@ -118,4 +101,13 @@ public class NewLaunchConfigModePage extends WizardPage {
item.setData(group); item.setData(group);
} }
public ILaunchGroup getSelectedGroup() {
return (ILaunchGroup) table.getSelection()[0].getData();
}
public void addGroupSelectionListener(SelectionListener listener) {
table.addSelectionListener(listener);
}
} }

View file

@ -15,12 +15,12 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.ILaunchGroup; import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.launchbar.ui.internal.Messages; import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -51,13 +51,11 @@ public class NewLaunchConfigTypePage extends WizardPage {
getContainer().showPage(getNextPage()); getContainer().showPage(getNextPage());
} }
}); });
populateItems();
setControl(comp); setControl(comp);
} }
void populateItems() { public void setLaunchGroup(ILaunchGroup group) {
ILaunchGroup group = ((NewLaunchConfigWizard) getWizard()).modePage.selectedGroup;
if (group == null) if (group == null)
return; return;
@ -84,21 +82,12 @@ public class NewLaunchConfigTypePage extends WizardPage {
setPageComplete(haveItems); setPageComplete(haveItems);
} }
@Override public void addTypeSelectionListener(SelectionListener listener) {
public boolean canFlipToNextPage() { table.addSelectionListener(listener);
return isPageComplete();
} }
@Override public ILaunchConfigurationType getSelectedType() {
public IWizardPage getNextPage() { return (ILaunchConfigurationType) table.getSelection()[0].getData();
ILaunchConfigurationType type = (ILaunchConfigurationType) table.getSelection()[0].getData();
NewLaunchConfigWizard wiz = (NewLaunchConfigWizard) getWizard();
NewLaunchConfigEditPage editPage = wiz.editPage;
// lazy page creation
if (wiz.getPage(editPage.getName()) == null) {
wiz.addPage(editPage);
}
editPage.changeLaunchConfigType(type);
return editPage;
} }
} }

View file

@ -1,32 +1,15 @@
################################################################################
# Copyright (c) 2016 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
################################################################################
BuildActiveCommandHandler_0=Building Active Configuration BuildActiveCommandHandler_0=Building Active Configuration
BuildActiveCommandHandler_1=Building Active Configuration BuildActiveCommandHandler_1=Building Active Configuration
ConfigSelector_0=No Launch Configurations StopActiveCommandHandler_0=Stopping launches
ConfigSelector_1=Launch Configuration StopActiveCommandHandler_1=Stopping build
ConfigSelector_2=New Launch Configuration...
ConfigSelector_3=Create Launch Configuration
CSelector_0=Closing popup
CSelector_1=Updating launch bar selection
EditButton_0=Edit
FilterControl_0=type filter text
FilterControl_1={0} {1} matches.
LaunchBarControl_0=on
LaunchBarControl_Build=Build
LaunchBarControl_Launch=Launch
LaunchBarControl_Stop=Stop
LaunchBarListViewer_0=Increase/Decrease size of recently used elements pane
LaunchBarPreferencePage_0=Preferences for the Launch Bar
LaunchBarPreferencePage_1=Enable the Launch Bar
LaunchBarPreferencePage_EnableTargetSelector=Enable the target selector
LaunchBarPreferencePage_EnableBuildButton=Enable the Build button
LaunchConfigurationEditDialog_0=Delete
LaunchConfigurationEditDialog_1=Duplicate
LaunchConfigurationEditDialog_2=Launch
LaunchConfigurationEditDialog_3=Confirm Delete
LaunchConfigurationEditDialog_4=Are you sure you want to delete
LaunchConfigurationEditDialog_5=Deleting launch configuration
LaunchConfigurationEditDialog_6=Duplicating launch configuration
ModeSelector_0=Launch Mode
ModeSelector_ToolTip=Launch in ''{0}'' mode
NewLaunchConfigEditPage_0=NewLaunchConfigEditPage NewLaunchConfigEditPage_0=NewLaunchConfigEditPage
NewLaunchConfigEditPage_1=Launch Configuration Properties NewLaunchConfigEditPage_1=Launch Configuration Properties
NewLaunchConfigEditPage_2=Edit the new launch configuration properties NewLaunchConfigEditPage_2=Edit the new launch configuration properties
@ -42,10 +25,6 @@ NewLaunchConfigTypePage_0=Select Launch Configuration Type
NewLaunchConfigTypePage_1=Launch Configuration Type NewLaunchConfigTypePage_1=Launch Configuration Type
NewLaunchConfigTypePage_2=Select the type of launch configuration to create. NewLaunchConfigTypePage_2=Select the type of launch configuration to create.
NewLaunchConfigWizard_0=Create Launch Configuration NewLaunchConfigWizard_0=Create Launch Configuration
StopActiveCommandHandler_0=Stopping launches
StopActiveCommandHandler_1=Stopping build
TargetSelector_ToolTipPrefix=Launch Target
TargetSelector_CreateNewTarget=New Launch Target...
DescriptorMustNotBeNull=Descriptor must not be null DescriptorMustNotBeNull=Descriptor must not be null
DescriptorMustNotBeNullDesc=The launch descriptor must not be null. DescriptorMustNotBeNullDesc=The launch descriptor must not be null.

View file

@ -66,7 +66,7 @@ public class LaunchTargetUIManager implements ILaunchTargetUIManager {
@Override @Override
public String getText(Object element) { public String getText(Object element) {
if (element instanceof ILaunchTarget) { if (element instanceof ILaunchTarget) {
return ((ILaunchTarget) element).getName(); return ((ILaunchTarget) element).getId();
} }
return super.getText(element); return super.getText(element);
} }

View file

@ -8,11 +8,12 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.internal.target; package org.eclipse.launchbar.ui.target;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.launchbar.ui.internal.target.NewLaunchTargetWizard;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ISharedImages; import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;

View file

@ -33,4 +33,11 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.launchbar.ui.controls"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature> </feature>

17
pom.xml
View file

@ -38,14 +38,9 @@
</licenses> </licenses>
<repositories> <repositories>
<repository>
<id>eclipse</id>
<url>http://download.eclipse.org/releases/mars/</url>
<layout>p2</layout>
</repository>
<repository> <repository>
<id>platform</id> <id>platform</id>
<url>http://download.eclipse.org/eclipse/updates/4.5/</url> <url>http://download.eclipse.org/eclipse/updates/4.6milestones/</url>
<layout>p2</layout> <layout>p2</layout>
</repository> </repository>
<repository> <repository>
@ -55,12 +50,17 @@
</repository> </repository>
<repository> <repository>
<id>orbit</id> <id>orbit</id>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/R20150124073747/repository/</url> <url>http://download.eclipse.org/tools/orbit/downloads/drops/S20160501200945/repository/</url>
<layout>p2</layout>
</repository>
<repository>
<id>cdt</id>
<url>http://download.eclipse.org/tools/cdt/builds/neon/milestones/</url>
<layout>p2</layout> <layout>p2</layout>
</repository> </repository>
<repository> <repository>
<id>remote</id> <id>remote</id>
<url>http://download.eclipse.org/tools/ptp/builds/remote/2.0.0/</url> <url>http://download.eclipse.org/tools/ptp/builds/remote/neon/milestones/</url>
<layout>p2</layout> <layout>p2</layout>
</repository> </repository>
</repositories> </repositories>
@ -68,6 +68,7 @@
<modules> <modules>
<module>bundles/org.eclipse.launchbar.core</module> <module>bundles/org.eclipse.launchbar.core</module>
<module>bundles/org.eclipse.launchbar.ui</module> <module>bundles/org.eclipse.launchbar.ui</module>
<module>bundles/org.eclipse.launchbar.ui.controls</module>
<module>features/org.eclipse.launchbar</module> <module>features/org.eclipse.launchbar</module>
<module>tests/org.eclipse.launchbar.core.tests</module> <module>tests/org.eclipse.launchbar.core.tests</module>

View file

@ -31,7 +31,6 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.internal.preferences.EclipsePreferences;
import org.eclipse.core.internal.resources.Project; import org.eclipse.core.internal.resources.Project;
@ -355,9 +354,9 @@ public class LaunchBarManager2Test {
public void testGetLaunchTargets() throws CoreException { public void testGetLaunchTargets() throws CoreException {
manager.launchObjectAdded(launchObject); manager.launchObjectAdded(launchObject);
manager.setActiveLaunchDescriptor(descriptor); manager.setActiveLaunchDescriptor(descriptor);
List<ILaunchTarget> launchTargets = manager.getLaunchTargets(descriptor); ILaunchTarget[] launchTargets = manager.getLaunchTargets(descriptor);
assertEquals(1, launchTargets.size()); assertEquals(1, launchTargets.length);
assertEquals(otherTarget, launchTargets.get(0)); assertEquals(otherTarget, launchTargets[0]);
} }
@Test @Test
@ -369,8 +368,8 @@ public class LaunchBarManager2Test {
init(); init();
manager.launchObjectAdded(launchObject); manager.launchObjectAdded(launchObject);
ILaunchDescriptor desc = manager.getActiveLaunchDescriptor(); ILaunchDescriptor desc = manager.getActiveLaunchDescriptor();
List<ILaunchTarget> launchTargets = manager.getLaunchTargets(desc); ILaunchTarget[] launchTargets = manager.getLaunchTargets(desc);
assertEquals(1, launchTargets.size()); assertEquals(1, launchTargets.length);
} }
@Test @Test
@ -382,8 +381,8 @@ public class LaunchBarManager2Test {
init(); init();
manager.launchObjectAdded(launchObject); manager.launchObjectAdded(launchObject);
ILaunchDescriptor desc = manager.getActiveLaunchDescriptor(); ILaunchDescriptor desc = manager.getActiveLaunchDescriptor();
List<ILaunchTarget> launchTargets = manager.getLaunchTargets(desc); ILaunchTarget[] launchTargets = manager.getLaunchTargets(desc);
assertEquals(1, launchTargets.size()); assertEquals(1, launchTargets.length);
} }
@Test @Test