diff --git a/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF index dad42f94192..ede7d846f4b 100644 --- a/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF @@ -11,6 +11,6 @@ Require-Bundle: org.eclipse.core.runtime, Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.launchbar.core, - org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui", + org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests", org.eclipse.launchbar.core.target, org.eclipse.launchbar.core.target.launch diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java index 6817509f546..b80b6ef1734 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java @@ -11,7 +11,11 @@ package org.eclipse.launchbar.core; import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; 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. @@ -21,8 +25,7 @@ import org.eclipse.debug.core.ILaunchConfigurationListener; public interface ILaunchBarManager extends ILaunchConfigurationListener { /** - * A launch object has been added. Create a matching launch descriptor if - * available. + * A launch object has been added. Create a matching launch descriptor if available. * * @param element * launch object @@ -32,8 +35,7 @@ public interface ILaunchBarManager extends ILaunchConfigurationListener { ILaunchDescriptor launchObjectAdded(Object launchObject) throws CoreException; /** - * A launch object has been removed. Remove the associated launch descriptor - * if there is one. + * A launch object has been removed. Remove the associated launch descriptor if there is one. * * @param element * launch object @@ -49,16 +51,52 @@ public interface ILaunchBarManager extends ILaunchConfigurationListener { */ 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 */ - public void addListener(ILaunchBarListener listener); + void addListener(ILaunchBarListener listener); /** - * Remove a linstener + * Remove a 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; + } diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java index 040838b3a20..99aa6346ac2 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java @@ -11,7 +11,6 @@ package org.eclipse.launchbar.core.internal; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -290,19 +289,20 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene if (i < 0) { return null; } - return new Pair(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) { return descriptorTypeInfo.get(type).getId(); } private Pair getDescriptorId(ILaunchDescriptor descriptor) { - return new Pair(getDescriptorTypeId(descriptor.getType()), descriptor.getName()); + return new Pair<>(getDescriptorTypeId(descriptor.getType()), descriptor.getName()); } private Pair getTargetId(ILaunchTarget target) { - return new Pair(target.getTypeId(), target.getName()); + return new Pair<>(target.getTypeId(), target.getId()); } private void addDescriptor(Object launchObject, ILaunchDescriptor descriptor) throws CoreException { @@ -311,6 +311,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene setActiveLaunchDescriptor(descriptor); } + @Override public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { if (descriptor == null) @@ -408,6 +409,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene return descs[descs.length - 1]; } + @Override public ILaunchDescriptor[] getLaunchDescriptors() { // return descriptor in usage order (most used first). UI can sort them // later as it wishes @@ -416,6 +418,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene return values.toArray(new ILaunchDescriptor[values.size()]); } + @Override public ILaunchDescriptor getActiveLaunchDescriptor() { return activeLaunchDesc; } @@ -453,6 +456,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } } + @Override public void setActiveLaunchDescriptor(ILaunchDescriptor descriptor) throws CoreException { Activator.trace("set active descriptor " + descriptor); //$NON-NLS-1$ if (activeLaunchDesc == descriptor) { @@ -614,6 +618,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } } + @Override public ILaunchMode[] getLaunchModes() throws CoreException { ILaunchConfigurationType configType = getLaunchConfigurationType(activeLaunchDesc, activeLaunchTarget); if (configType == null) @@ -628,6 +633,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene return modeList.toArray(new ILaunchMode[modeList.size()]); } + @Override public ILaunchMode getActiveLaunchMode() { return activeLaunchMode; } @@ -647,6 +653,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } } + @Override public void setActiveLaunchMode(ILaunchMode mode) throws CoreException { if (activeLaunchMode == mode) { // we have to modify listeners here because same mode does not mean @@ -681,16 +688,17 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } } - public List getLaunchTargets(ILaunchDescriptor descriptor) { + @Override + public ILaunchTarget[] getLaunchTargets(ILaunchDescriptor descriptor) { if (descriptor == null) - return Arrays.asList(launchTargetManager.getLaunchTargets()); + return launchTargetManager.getLaunchTargets(); List targets = new ArrayList<>(); for (ILaunchTarget target : launchTargetManager.getLaunchTargets()) { if (supportsTarget(descriptor, target)) { targets.add(target); } } - return targets; + return targets.toArray(new ILaunchTarget[targets.size()]); } boolean supportsTarget(ILaunchDescriptor descriptor, ILaunchTarget target) { @@ -709,6 +717,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene return false; } + @Override public ILaunchTarget getActiveLaunchTarget() { return activeLaunchTarget; } @@ -728,6 +737,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } } + @Override public void setActiveLaunchTarget(ILaunchTarget target) throws CoreException { if (target == null) target = ILaunchTarget.NULL_TARGET; @@ -763,12 +773,13 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } private ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) { - List targets = getLaunchTargets(descriptor); + ILaunchTarget[] targets = getLaunchTargets(descriptor); // chances are that better target is most recently added, rather then // 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 { ILaunchConfiguration configuration = getLaunchConfiguration(activeLaunchDesc, activeLaunchTarget); // This is the only concrete time we have the mapping from launch @@ -780,6 +791,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene return configuration; } + @Override public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { if (descriptor == null) { diff --git a/bundles/org.eclipse.launchbar.ui.controls/.classpath b/bundles/org.eclipse.launchbar.ui.controls/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.eclipse.launchbar.ui.controls/.project b/bundles/org.eclipse.launchbar.ui.controls/.project new file mode 100644 index 00000000000..16aad7cf740 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/.project @@ -0,0 +1,28 @@ + + + org.eclipse.launchbar.ui.controls + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.eclipse.launchbar.ui.controls/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.launchbar.ui.controls/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..a872488efe2 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF @@ -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 diff --git a/bundles/org.eclipse.launchbar.ui.controls/about.html b/bundles/org.eclipse.launchbar.ui.controls/about.html new file mode 100644 index 00000000000..d7c511887d6 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/about.html @@ -0,0 +1,24 @@ + + +About + + +

About This Content

+ +

June 22, 2007

+

License

+ +

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 http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

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 http://www.eclipse.org.

+ + \ No newline at end of file diff --git a/bundles/org.eclipse.launchbar.ui.controls/build.properties b/bundles/org.eclipse.launchbar.ui.controls/build.properties new file mode 100644 index 00000000000..5ac60bf9b00 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/build.properties @@ -0,0 +1,8 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.xml,\ + plugin.properties,\ + icons/ diff --git a/bundles/org.eclipse.launchbar.ui/icons/bgButton.png b/bundles/org.eclipse.launchbar.ui.controls/icons/bgButton.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/bgButton.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/bgButton.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/build.png b/bundles/org.eclipse.launchbar.ui.controls/icons/build.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/build.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/build.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/build2_24.png b/bundles/org.eclipse.launchbar.ui.controls/icons/build2_24.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/build2_24.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/build2_24.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/build2_hot_24.png b/bundles/org.eclipse.launchbar.ui.controls/icons/build2_hot_24.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/build2_hot_24.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/build2_hot_24.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/build_16.png b/bundles/org.eclipse.launchbar.ui.controls/icons/build_16.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/build_16.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/build_16.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/config_config.png b/bundles/org.eclipse.launchbar.ui.controls/icons/config_config.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/config_config.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/config_config.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/connected.png b/bundles/org.eclipse.launchbar.ui.controls/icons/connected.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/connected.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/connected.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/disconnected.png b/bundles/org.eclipse.launchbar.ui.controls/icons/disconnected.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/disconnected.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/disconnected.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/edit_cold.png b/bundles/org.eclipse.launchbar.ui.controls/icons/edit_cold.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/edit_cold.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/edit_cold.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/icon_debug_32x32.png b/bundles/org.eclipse.launchbar.ui.controls/icons/icon_debug_32x32.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/icon_debug_32x32.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/icon_debug_32x32.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/icon_profile_32x32.png b/bundles/org.eclipse.launchbar.ui.controls/icons/icon_profile_32x32.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/icon_profile_32x32.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/icon_profile_32x32.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/icon_run_32x32.png b/bundles/org.eclipse.launchbar.ui.controls/icons/icon_run_32x32.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/icon_run_32x32.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/icon_run_32x32.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/launch.png b/bundles/org.eclipse.launchbar.ui.controls/icons/launch.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/launch.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/launch.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/launch2_24.png b/bundles/org.eclipse.launchbar.ui.controls/icons/launch2_24.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/launch2_24.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/launch2_24.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/launch2_hot_24.png b/bundles/org.eclipse.launchbar.ui.controls/icons/launch2_hot_24.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/launch2_hot_24.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/launch2_hot_24.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/launch_16.png b/bundles/org.eclipse.launchbar.ui.controls/icons/launch_16.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/launch_16.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/launch_16.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/launch_base_blank.png b/bundles/org.eclipse.launchbar.ui.controls/icons/launch_base_blank.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/launch_base_blank.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/launch_base_blank.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/stop.png b/bundles/org.eclipse.launchbar.ui.controls/icons/stop.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/stop.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/stop.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/stop2_24.png b/bundles/org.eclipse.launchbar.ui.controls/icons/stop2_24.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/stop2_24.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/stop2_24.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/stop2_hot_24.png b/bundles/org.eclipse.launchbar.ui.controls/icons/stop2_hot_24.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/stop2_hot_24.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/stop2_hot_24.png diff --git a/bundles/org.eclipse.launchbar.ui/icons/stop_16.png b/bundles/org.eclipse.launchbar.ui.controls/icons/stop_16.png similarity index 100% rename from bundles/org.eclipse.launchbar.ui/icons/stop_16.png rename to bundles/org.eclipse.launchbar.ui.controls/icons/stop_16.png diff --git a/bundles/org.eclipse.launchbar.ui.controls/plugin.properties b/bundles/org.eclipse.launchbar.ui.controls/plugin.properties new file mode 100644 index 00000000000..1a942c2caa3 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/plugin.properties @@ -0,0 +1,3 @@ +launchToolBar.label = LaunchBar +targetsView.name = Launch Targets +targetsContent.name = Launch Targets diff --git a/bundles/org.eclipse.launchbar.ui.controls/plugin.xml b/bundles/org.eclipse.launchbar.ui.controls/plugin.xml new file mode 100644 index 00000000000..653a81b1021 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/plugin.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.eclipse.launchbar.ui.controls/pom.xml b/bundles/org.eclipse.launchbar.ui.controls/pom.xml new file mode 100644 index 00000000000..5d02eb5e7c8 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + + org.eclipse.launchbar + parent + 1.0.0-SNAPSHOT + ../../pom.xml + + + org.eclipse.launchbar.ui.controls + 1.0.0-SNAPSHOT + + eclipse-plugin + diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Activator.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Activator.java new file mode 100644 index 00000000000..4e6169d8a52 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Activator.java @@ -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 getService(Class service) { + BundleContext context = plugin.getBundle().getBundleContext(); + ServiceReference 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); + } + +} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/CButton.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CButton.java similarity index 98% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/CButton.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CButton.java index df1dbe4443d..24d53787c51 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/CButton.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CButton.java @@ -8,7 +8,7 @@ * Contributors: * 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.events.MouseAdapter; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/CSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CSelector.java similarity index 99% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/CSelector.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CSelector.java index 37ed62b8647..55948f7745c 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/CSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/CSelector.java @@ -8,7 +8,7 @@ * Contributors: * Doug Schaefer *******************************************************************************/ -package org.eclipse.launchbar.ui.internal.controls; +package org.eclipse.launchbar.ui.controls.internal; 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.SelectionChangedEvent; 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.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ConfigSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java similarity index 85% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ConfigSelector.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java index ef7712a0cc0..a0107cdc858 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ConfigSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java @@ -8,7 +8,7 @@ * Contributors: * Doug Schaefer *******************************************************************************/ -package org.eclipse.launchbar.ui.internal.controls; +package org.eclipse.launchbar.ui.controls.internal; import java.util.Comparator; @@ -25,13 +25,11 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.ui.internal.Activator; -import org.eclipse.launchbar.ui.internal.DefaultDescriptorLabelProvider; -import org.eclipse.launchbar.ui.internal.LaunchBarUIManager; -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.launchbar.ui.DefaultDescriptorLabelProvider; +import org.eclipse.launchbar.ui.ILaunchBarUIManager; +import org.eclipse.launchbar.ui.NewLaunchConfigWizard; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; @@ -45,7 +43,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; 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 static final String[] noConfigs = new String[] { Messages.ConfigSelector_0 }; @@ -60,16 +59,21 @@ public class ConfigSelector extends CSelector { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } + @Override public void dispose() { } @Override public Object[] getElements(Object inputElement) { - ILaunchDescriptor[] descs = uiManager.getManager().getLaunchDescriptors(); - if (descs.length == 0) + try { + ILaunchDescriptor[] descs = manager.getLaunchDescriptors(); + if (descs.length == 0) + return noConfigs; + return descs; + } catch (CoreException e) { return noConfigs; - return descs; + } } }); @@ -78,7 +82,7 @@ public class ConfigSelector extends CSelector { public Image getImage(Object element) { if (element instanceof ILaunchDescriptor) { try { - ILaunchDescriptor configDesc = (ILaunchDescriptor)element; + ILaunchDescriptor configDesc = (ILaunchDescriptor) element; ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc); if (labelProvider != null) { Image img = labelProvider.getImage(element); @@ -86,18 +90,19 @@ public class ConfigSelector extends CSelector { return img; } } catch (CoreException e) { - Activator.log(e.getStatus()); + Activator.log(e); } } return defaultProvider.getImage(element); } + @Override public String getText(Object element) { if (element instanceof String) { - return (String)element; + return (String) element; } else if (element instanceof ILaunchDescriptor) { try { - ILaunchDescriptor configDesc = (ILaunchDescriptor)element; + ILaunchDescriptor configDesc = (ILaunchDescriptor) element; ILabelProvider labelProvider = uiManager.getLabelProvider(configDesc); if (labelProvider != null) { String text = labelProvider.getText(element); @@ -105,7 +110,7 @@ public class ConfigSelector extends CSelector { return text; } } catch (CoreException e) { - Activator.log(e.getStatus()); + Activator.log(e); } } return defaultProvider.getText(element); @@ -136,9 +141,9 @@ public class ConfigSelector extends CSelector { if (selected instanceof ILaunchDescriptor) { ILaunchDescriptor configDesc = (ILaunchDescriptor) selected; try { - uiManager.getManager().setActiveLaunchDescriptor(configDesc); + manager.setActiveLaunchDescriptor(configDesc); } catch (CoreException e) { - Activator.log(e.getStatus()); + Activator.log(e); } } } @@ -150,7 +155,7 @@ public class ConfigSelector extends CSelector { @Override public void handleEdit(Object element) { - ConfigureActiveLaunchHandler.openConfigurationEditor((ILaunchDescriptor) element); + uiManager.openConfigurationEditor((ILaunchDescriptor) element); } @Override @@ -170,7 +175,6 @@ public class ConfigSelector extends CSelector { createLabel.setBackground(getBackground()); createLabel.setText(Messages.ConfigSelector_2); - MouseListener mouseListener = new MouseAdapter() { @Override public void mouseUp(org.eclipse.swt.events.MouseEvent e) { @@ -202,6 +206,7 @@ public class ConfigSelector extends CSelector { createButton.setBackground(highlightColor); createLabel.setBackground(highlightColor); } + @Override public void mouseExit(MouseEvent e) { Color backgroundColor = getBackground(); diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/EditButton.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/EditButton.java similarity index 68% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/EditButton.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/EditButton.java index f66a173c3b2..287188b5a36 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/EditButton.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/EditButton.java @@ -8,17 +8,17 @@ * Contributors: * 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; public class EditButton extends CButton { + public EditButton(Composite parent, int style) { super(parent, style); - setHotImage(Activator.getDefault().getImage("icons/config_config.png")); //$NON-NLS-1$ - setColdImage(Activator.getDefault().getImage("icons/edit_cold.png")); //$NON-NLS-1$ + setHotImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_CONFIG_CONFIG)); + setColdImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_EDIT_COLD)); setToolTipText(Messages.EditButton_0); } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/FilterControl.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/FilterControl.java similarity index 99% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/FilterControl.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/FilterControl.java index 718da8e3e4f..491d03ebe68 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/FilterControl.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/FilterControl.java @@ -8,7 +8,7 @@ * Contributors: * 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.IStatus; @@ -20,7 +20,6 @@ import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.launchbar.ui.internal.Messages; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleAdapter; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarButtonImageDescriptor.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarButtonImageDescriptor.java similarity index 97% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarButtonImageDescriptor.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarButtonImageDescriptor.java index 302cf789806..6fc5dca1c31 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarButtonImageDescriptor.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarButtonImageDescriptor.java @@ -9,7 +9,7 @@ * Doug Schaefer - initial API and implementation * 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.swt.graphics.Image; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarControl.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java similarity index 72% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarControl.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java index 503f691c9eb..80668df5945 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarControl.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java @@ -10,20 +10,23 @@ * Torkild U. Resheim - add preference to control target selector * 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.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.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.launchbar.core.ILaunchBarListener; +import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.ui.internal.Activator; -import org.eclipse.launchbar.ui.internal.Messages; +import org.eclipse.launchbar.ui.ILaunchBarUIConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; 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.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ToolBar; 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 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$ + LaunchBarControl.class.getName(); - private LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager(); + private ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class); private ConfigSelector configSelector; private ModeSelector modeSelector; @@ -70,11 +77,14 @@ public class LaunchBarControl implements ILaunchBarListener { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); boolean buildEnabled = store.getBoolean(Activator.PREF_ENABLE_BUILDBUTTON); 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_STOP, Messages.LaunchBarControl_Stop, Activator.CMD_STOP); + createButton(toolBar, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch, + ILaunchBarUIConstants.CMD_LAUNCH); + createButton(toolBar, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop, + ILaunchBarUIConstants.CMD_STOP); modeSelector = new ModeSelector(container, SWT.NONE); 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.setInput(manager); - boolean enabled = store.getBoolean(Activator.PREF_ENABLE_TARGETSELECTOR); if (enabled) { Label label = new Label(container, SWT.NONE); @@ -100,12 +109,16 @@ public class LaunchBarControl implements ILaunchBarListener { } protected void syncSelectors() { - if (configSelector != null) - configSelector.setSelection(manager.getActiveLaunchDescriptor()); - if (modeSelector != null) - modeSelector.setSelection(manager.getActiveLaunchMode()); - if (targetSelector != null) - targetSelector.setSelection(manager.getActiveLaunchTarget()); + try { + if (configSelector != null) + configSelector.setSelection(manager.getActiveLaunchDescriptor()); + if (modeSelector != null) + modeSelector.setSelection(manager.getActiveLaunchMode()); + if (targetSelector != null) + targetSelector.setSelection(manager.getActiveLaunchTarget()); + } catch (CoreException e) { + Activator.log(e); + } } @PreDestroy @@ -113,21 +126,32 @@ public class LaunchBarControl implements ILaunchBarListener { 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); - Image bgImage = Activator.getDefault().getImage(Activator.IMG_BUTTON_BACKGROUND); - Image fgImage = Activator.getDefault().getImage(imageName); + Image bgImage = Activator.getDefault().getImageRegistry().get(Activator.IMG_BUTTON_BACKGROUND); + Image fgImage = Activator.getDefault().getImageRegistry().get(imageName); ImageDescriptor imageDesc = new LaunchBarButtonImageDescriptor(fgImage, bgImage); Image image = imageDesc.createImage(); button.setImage(image); button.setToolTipText(toolTipText); - button.setData("command", command); //$NON-NLS-1$ + button.setData("command", commandId); //$NON-NLS-1$ button.addSelectionListener(new SelectionAdapter() { @Override 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() { @@ -170,4 +194,5 @@ public class LaunchBarControl implements ILaunchBarListener { public ConfigSelector getConfigSelector() { return configSelector; } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarInjector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarInjector.java similarity index 91% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarInjector.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarInjector.java index f5c5629073a..b8161e898f7 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarInjector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarInjector.java @@ -10,7 +10,7 @@ * 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.controls.internal; 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.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.launchbar.ui.internal.controls.LaunchBarControl; import org.eclipse.swt.widgets.Widget; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; @@ -100,19 +99,25 @@ public class LaunchBarInjector { private void injectLaunchBar(MTrimBar trimBar, boolean enabled) { // are we enabled or not + // and fix up the class URI for 2.0 // Search for control in trimbar - MTrimElement launchBarElement = null; + MToolControl launchBarElement = null; for (MTrimElement trimElement : trimBar.getChildren()) { if (LaunchBarControl.ID.equals(trimElement.getElementId())) { - launchBarElement = trimElement; + launchBarElement = (MToolControl) trimElement; break; } } 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) { - // remove it if we're disabled trimBar.getChildren().remove(launchBarElement); // This seems to be a bug in the platform but for now, dispose of the widget Widget widget = (Widget)launchBarElement.getWidget(); diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarListViewer.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarListViewer.java similarity index 99% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarListViewer.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarListViewer.java index cf3a08eaf8b..3bd71a4cb2c 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarListViewer.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarListViewer.java @@ -8,7 +8,7 @@ * Contributors: * Alena Laskavaia *******************************************************************************/ -package org.eclipse.launchbar.ui.internal.controls; +package org.eclipse.launchbar.ui.controls.internal; import java.util.ArrayList; 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.ViewerFilter; 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.custom.ScrolledComposite; import org.eclipse.swt.events.DisposeEvent; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarPreferenceInitializer.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferenceInitializer.java similarity index 96% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarPreferenceInitializer.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferenceInitializer.java index 26369dd1e3a..077ecacf4b9 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarPreferenceInitializer.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferenceInitializer.java @@ -10,7 +10,7 @@ * 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.controls.internal; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; @@ -20,8 +20,8 @@ public class LaunchBarPreferenceInitializer extends AbstractPreferenceInitialize @Override public void initializeDefaultPreferences() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - store.setDefault(Activator.PREF_ENABLE_BUILDBUTTON, 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_LAUNCH_HISTORY_SIZE, 3); } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarPreferencePage.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferencePage.java similarity index 97% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarPreferencePage.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferencePage.java index 96e4d818234..b1ab27fdd0a 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarPreferencePage.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferencePage.java @@ -10,7 +10,7 @@ * 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.controls.internal; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Messages.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Messages.java new file mode 100644 index 00000000000..d39471e3a17 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Messages.java @@ -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() { + } +} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ModeSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ModeSelector.java similarity index 92% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ModeSelector.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ModeSelector.java index 7b6212f8c13..04f93de342a 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ModeSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ModeSelector.java @@ -8,7 +8,7 @@ * Contributors: * Doug Schaefer *******************************************************************************/ -package org.eclipse.launchbar.ui.internal.controls; +package org.eclipse.launchbar.ui.controls.internal; import java.util.Comparator; 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.LabelProvider; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.launchbar.core.internal.LaunchBarManager; -import org.eclipse.launchbar.ui.internal.Activator; -import org.eclipse.launchbar.ui.internal.Messages; +import org.eclipse.launchbar.core.ILaunchBarManager; +import org.eclipse.launchbar.ui.ILaunchBarUIConstants; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.graphics.Image; 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.ToolItem; -@SuppressWarnings("restriction") public class ModeSelector extends CSelector { 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 modeButtonImages = new HashMap<>(); public ModeSelector(Composite parent, int style) { @@ -61,7 +59,7 @@ public class ModeSelector extends CSelector { if (modes.length > 0) return modes; } catch (CoreException e) { - Activator.log(e.getStatus()); + Activator.log(e); } return noModes; } @@ -175,7 +173,7 @@ public class ModeSelector extends CSelector { try { manager.setActiveLaunchMode(mode); } catch (CoreException e) { - Activator.log(e.getStatus()); + Activator.log(e); } catch (Exception e) { // manager can throw illegal state exception hopefully we never // get it @@ -200,7 +198,7 @@ public class ModeSelector extends CSelector { } private ToolItem findLaunchButton() { - String commandId = Activator.CMD_LAUNCH; + String commandId = ILaunchBarUIConstants.CMD_LAUNCH; for (Control control : getParent().getChildren()) { if (control instanceof ToolBar) { for (ToolItem toolItem : ((ToolBar) control).getItems()) { @@ -229,7 +227,7 @@ public class ModeSelector extends CSelector { String id = group.getIdentifier(); Image image = modeButtonImages.get(id); 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); ImageDescriptor imageDesc = new LaunchBarButtonImageDescriptor(modeImage, bgImage); image = imageDesc.createImage(); @@ -244,7 +242,7 @@ public class ModeSelector extends CSelector { try { group = getLaunchGroup(mode.getIdentifier()); } catch (CoreException e) { - Activator.log(e.getStatus()); + Activator.log(e); } if (group == null) { group = getDefaultLaunchGroup(mode.getIdentifier()); diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/OpenLaunchSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/OpenLaunchSelector.java similarity index 93% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/OpenLaunchSelector.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/OpenLaunchSelector.java index dce499ae1b4..e24f46084f7 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/OpenLaunchSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/OpenLaunchSelector.java @@ -8,7 +8,7 @@ * Contributors: * Alena Laskavaia *******************************************************************************/ -package org.eclipse.launchbar.ui.internal.commands; +package org.eclipse.launchbar.ui.controls.internal; 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.ui.menu.MToolControl; import org.eclipse.e4.ui.workbench.modeling.EModelService; -import org.eclipse.launchbar.ui.internal.controls.LaunchBarControl; public class OpenLaunchSelector extends AbstractHandler { @Override diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/TargetSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/TargetSelector.java similarity index 91% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/TargetSelector.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/TargetSelector.java index ead2d16d02c..edc1313d3ca 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/TargetSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/TargetSelector.java @@ -8,10 +8,10 @@ * Contributors: * Doug Schaefer *******************************************************************************/ -package org.eclipse.launchbar.ui.internal.controls; +package org.eclipse.launchbar.ui.controls.internal; import java.util.Comparator; -import java.util.List; + import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.layout.GridDataFactory; 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.Viewer; 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.ILaunchTargetListener; import org.eclipse.launchbar.core.target.ILaunchTargetManager; import org.eclipse.launchbar.core.target.TargetStatus; import org.eclipse.launchbar.core.target.TargetStatus.Code; -import org.eclipse.launchbar.ui.internal.Activator; -import org.eclipse.launchbar.ui.internal.LaunchBarUIManager; -import org.eclipse.launchbar.ui.internal.Messages; -import org.eclipse.launchbar.ui.internal.target.NewLaunchTargetWizardAction; import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager; +import org.eclipse.launchbar.ui.target.NewLaunchTargetWizardAction; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; @@ -55,7 +52,7 @@ import org.eclipse.ui.dialogs.PropertyDialogAction; 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 ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class); @@ -77,12 +74,12 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener { @Override public Object[] getElements(Object inputElement) { - LaunchBarManager manager = uiManager.getManager(); - List targets = manager.getLaunchTargets(manager.getActiveLaunchDescriptor()); - if (!targets.isEmpty()) { - return targets.toArray(); + try { + return manager.getLaunchTargets(manager.getActiveLaunchDescriptor()); + } catch (CoreException e) { + Activator.log(e); + return noTargets; } - return noTargets; } }); @@ -92,7 +89,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener { if (element instanceof ILaunchTarget) { ILaunchTarget target = (ILaunchTarget) element; 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); } @@ -225,6 +222,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener { createButton.setBackground(highlightColor); createLabel.setBackground(highlightColor); } + @Override public void mouseExit(MouseEvent e) { Color backgroundColor = getBackground(); @@ -242,7 +240,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener { if (selection instanceof ILaunchTarget) { ILaunchTarget target = (ILaunchTarget) selection; try { - uiManager.getManager().setActiveLaunchTarget(target); + manager.setActiveLaunchTarget(target); } catch (CoreException e) { Activator.log(e); } @@ -289,8 +287,12 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener { @Override public void launchTargetStatusChanged(ILaunchTarget target) { - if (target.equals(uiManager.getManager().getActiveLaunchTarget())) { - refresh(); + try { + if (target.equals(manager.getActiveLaunchTarget())) { + refresh(); + } + } catch (CoreException e) { + Activator.log(e); } } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/Transition.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Transition.java similarity index 96% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/Transition.java rename to bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Transition.java index 63c01d0c2a8..1fa7b023ff8 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/Transition.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Transition.java @@ -8,7 +8,7 @@ * Contributors: * 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.Display; diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/messages.properties b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/messages.properties new file mode 100644 index 00000000000..391f607abda --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/messages.properties @@ -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... diff --git a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF index ea9b0354427..9cb89b14495 100644 --- a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF @@ -5,24 +5,16 @@ Bundle-SymbolicName: org.eclipse.launchbar.ui;singleton:=true Bundle-Version: 2.0.0.qualifier Bundle-Activator: org.eclipse.launchbar.ui.internal.Activator Bundle-Vendor: Eclipse CDT -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.e4.ui.workbench, - org.eclipse.e4.ui.model.workbench, - org.eclipse.e4.core.di, - org.eclipse.e4.core.services, - org.eclipse.osgi.services, - org.eclipse.launchbar.core, - org.eclipse.debug.ui, +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui, org.eclipse.ui.ide, - org.eclipse.e4.core.contexts, - org.eclipse.ui.workbench + org.eclipse.debug.ui, + org.eclipse.launchbar.core Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin Export-Package: org.eclipse.launchbar.ui, org.eclipse.launchbar.ui.internal;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 -Import-Package: javax.inject + org.eclipse.launchbar.ui.internal.dialogs;x-internal:=true, + org.eclipse.launchbar.ui.target diff --git a/bundles/org.eclipse.launchbar.ui/plugin.xml b/bundles/org.eclipse.launchbar.ui/plugin.xml index 34f16b217a4..da51d5e03f3 100644 --- a/bundles/org.eclipse.launchbar.ui/plugin.xml +++ b/bundles/org.eclipse.launchbar.ui/plugin.xml @@ -3,15 +3,6 @@ - - - - - - - - - - - - - - + labelProvider="org.eclipse.launchbar.ui.DefaultDescriptorLabelProvider"> diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/DefaultDescriptorLabelProvider.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/DefaultDescriptorLabelProvider.java similarity index 92% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/DefaultDescriptorLabelProvider.java rename to bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/DefaultDescriptorLabelProvider.java index 848b96195d6..284c698b5ee 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/DefaultDescriptorLabelProvider.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/DefaultDescriptorLabelProvider.java @@ -8,7 +8,7 @@ * Contributors: * Doug Schaefer *******************************************************************************/ -package org.eclipse.launchbar.ui.internal; +package org.eclipse.launchbar.ui; import java.util.HashMap; import java.util.Map; @@ -38,7 +38,7 @@ public class DefaultDescriptorLabelProvider extends LabelProvider { @Override public Image getImage(Object element) { if (element instanceof ILaunchDescriptor) { - ILaunchConfiguration config = (ILaunchConfiguration) ((ILaunchDescriptor) element).getAdapter(ILaunchConfiguration.class); + ILaunchConfiguration config = ((ILaunchDescriptor) element).getAdapter(ILaunchConfiguration.class); if (config != null) { try { ILaunchConfigurationType type = config.getType(); diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java index d41cd7e49df..8a204e10696 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.launchbar.ui; +import org.eclipse.launchbar.ui.internal.Activator; + public interface ILaunchBarUIConstants { /** @@ -17,4 +19,10 @@ public interface ILaunchBarUIConstants { */ 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$ + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIManager.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIManager.java new file mode 100644 index 00000000000..f677a1deb8d --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIManager.java @@ -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); + +} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigWizard.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizard.java similarity index 56% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigWizard.java rename to bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizard.java index ea52f0bdfc0..b6adf46ac13 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigWizard.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizard.java @@ -8,7 +8,7 @@ * Contributors: * Doug Schaefer *******************************************************************************/ -package org.eclipse.launchbar.ui.internal.dialogs; +package org.eclipse.launchbar.ui; import java.util.ArrayList; 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.ILaunchConfigurationWorkingCopy; 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.WizardDialog; import org.eclipse.launchbar.ui.internal.Activator; 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 { - NewLaunchConfigModePage modePage = new NewLaunchConfigModePage(); - NewLaunchConfigTypePage typePage = new NewLaunchConfigTypePage(); - NewLaunchConfigEditPage editPage = new NewLaunchConfigEditPage(); + private NewLaunchConfigModePage modePage = new NewLaunchConfigModePage(); + private NewLaunchConfigTypePage typePage = new NewLaunchConfigTypePage(); + private NewLaunchConfigEditPage editPage = new NewLaunchConfigEditPage(); private List configsToDelete = new ArrayList<>(); public NewLaunchConfigWizard() { 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 public void addPages() { addPage(modePage); addPage(typePage); - //addPage(editPage); // add dynamically on the types page + addPage(editPage); } @Override @@ -56,7 +120,7 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio } public ILaunchMode getLaunchMode() { - String initMode = modePage.selectedGroup.getMode(); + String initMode = modePage.getSelectedGroup().getMode(); return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(initMode); } @@ -72,14 +136,6 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio return super.performCancel(); } - private void initListeners() { - // while the wizard is open, some ill behaved launch config tabs save the working copy. - // We need to make sure those saves are deleted when the dialog is finished. - // We also need to turn off listening in the tool bar manager so that we don't treat these - // as real launch configs. - DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this); - } - void cleanUpConfigs() { DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this); for (ILaunchConfiguration config : configsToDelete) { diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java index 9c18a7ab3b7..85b8303cf52 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java @@ -12,26 +12,15 @@ *******************************************************************************/ 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.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.launchbar.core.ILaunchBarManager; -import org.eclipse.launchbar.core.internal.LaunchBarManager; +import org.eclipse.launchbar.ui.ILaunchBarUIManager; import org.eclipse.launchbar.ui.internal.target.LaunchTargetUIManager; import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.commands.ICommandService; -import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -45,30 +34,11 @@ public class Activator extends AbstractUIPlugin { public static final String PLUGIN_ID = "org.eclipse.launchbar.ui"; //$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_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 private static Activator plugin; - // The cache of the Launch Bar UI Manager Object - private LaunchBarUIManager launchBarUIManager; - /** * The constructor */ @@ -81,13 +51,10 @@ public class Activator extends AbstractUIPlugin { 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_LOCAL_TARGET, imageDescriptorFromPlugin(PLUGIN_ID, "icons/localTarget.png")); //$NON-NLS-1$ context.registerService(ILaunchTargetUIManager.class, new LaunchTargetUIManager(), null); + context.registerService(ILaunchBarUIManager.class, new LaunchBarUIManager(), null); } @Override @@ -105,14 +72,6 @@ public class Activator extends AbstractUIPlugin { 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) { Image im = getImageRegistry().get(id); if (im == null) { @@ -129,36 +88,6 @@ public class Activator extends AbstractUIPlugin { 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) { plugin.getLog().log(status); } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java index 904e16c9499..907ad6234b3 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java @@ -17,41 +17,163 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IStatus; 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.StructuredSelection; +import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.ILaunchDescriptor; 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> descriptorLabelProviders = new HashMap<>(); + private Map> descriptorLabelProviders = null; + private ILaunchBarManager manager = Activator.getService(ILaunchBarManager.class); - public LaunchBarUIManager(LaunchBarManager manager) { - this.manager = manager; - - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launchBarUIContributions"); //$NON-NLS-1$ - IExtension[] extensions = point.getExtensions(); - for (IExtension extension : extensions) { - for (IConfigurationElement element : extension.getConfigurationElements()) { - String elementName = element.getName(); - if (elementName.equals("descriptorUI")) { //$NON-NLS-1$ - String descriptorTypeId = element.getAttribute("descriptorTypeId"); //$NON-NLS-1$ - ExecutableExtension labelProvider = new ExecutableExtension<>(element, "labelProvider"); //$NON-NLS-1$ - descriptorLabelProviders.put(descriptorTypeId, labelProvider); + private void init() { + if (descriptorLabelProviders == null) { + descriptorLabelProviders = new HashMap<>(); + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launchBarUIContributions"); //$NON-NLS-1$ + IExtension[] extensions = point.getExtensions(); + for (IExtension extension : extensions) { + for (IConfigurationElement element : extension.getConfigurationElements()) { + String elementName = element.getName(); + if (elementName.equals("descriptorUI")) { //$NON-NLS-1$ + String descriptorTypeId = element.getAttribute("descriptorTypeId"); //$NON-NLS-1$ + ExecutableExtension labelProvider = new ExecutableExtension<>(element, "labelProvider"); //$NON-NLS-1$ + descriptorLabelProviders.put(descriptorTypeId, labelProvider); + } } } } } - public LaunchBarManager getManager() { - return manager; - } - + @Override public ILabelProvider getLabelProvider(ILaunchDescriptor descriptor) throws CoreException { + init(); ExecutableExtension provider = descriptorLabelProviders.get(manager.getDescriptorTypeId(descriptor.getType())); 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; + } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java index 15a3c18d6e8..ed4c60c346e 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java @@ -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 * 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.internal; @@ -16,35 +11,12 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.launchbar.ui.internal.messages"; //$NON-NLS-1$ + public static String BuildActiveCommandHandler_0; public static String BuildActiveCommandHandler_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 StopActiveCommandHandler_0; + public static String StopActiveCommandHandler_1; + public static String NewLaunchConfigEditPage_0; public static String NewLaunchConfigEditPage_1; public static String NewLaunchConfigEditPage_2; @@ -60,10 +32,6 @@ public class Messages extends NLS { public static String NewLaunchConfigTypePage_1; public static String NewLaunchConfigTypePage_2; public static String NewLaunchConfigWizard_0; - public static String StopActiveCommandHandler_0; - public static String StopActiveCommandHandler_1; - public static String TargetSelector_ToolTipPrefix; - public static String TargetSelector_CreateNewTarget; public static String DescriptorMustNotBeNull; public static String DescriptorMustNotBeNullDesc; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java index e37b944353e..b1f18f4968e 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java @@ -34,7 +34,7 @@ import org.eclipse.debug.core.ILaunchDelegate; import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2; -import org.eclipse.launchbar.core.internal.LaunchBarManager; +import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.launch.ILaunchConfigurationTargetedDelegate; import org.eclipse.launchbar.ui.internal.Activator; @@ -56,7 +56,7 @@ public class BuildActiveCommandHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { try { - LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager(); + ILaunchBarManager launchBarManager = Activator.getService(ILaunchBarManager.class); ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration(); ILaunchMode launchMode = launchBarManager.getActiveLaunchMode(); ILaunchTarget target = launchBarManager.getActiveLaunchTarget(); @@ -67,6 +67,7 @@ public class BuildActiveCommandHandler extends AbstractHandler { return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family); } + @Override public IStatus runInUIThread(IProgressMonitor monitor) { final Collection projects = getProjects(config); if (BuildAction.isSaveAllSet()) { diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/ConfigureActiveLaunchHandler.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/ConfigureActiveLaunchHandler.java index df7cd0cebc1..a7b3c593f0f 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/ConfigureActiveLaunchHandler.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/ConfigureActiveLaunchHandler.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Doug Schaefer *******************************************************************************/ package org.eclipse.launchbar.ui.internal.commands; @@ -14,136 +11,23 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -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.ILaunchBarManager; import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.internal.LaunchBarManager; -import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.launchbar.ui.ILaunchBarUIManager; 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 { + @Override 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 { - configType = manager.getLaunchConfigurationType(desc, target); - } catch (CoreException ce) { - /* ignore */ } - ; - if (configType == null) { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchConfigType, - new Exception(Messages.CannotEditLaunchConfiguration)); - } - - if (mode == null) { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected, - new Exception(Messages.NoLaunchModeSelected)); - } - - 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); + ILaunchBarManager launchBarManager = Activator.getService(ILaunchBarManager.class); + ILaunchDescriptor launchDesc = launchBarManager.getActiveLaunchDescriptor(); + ILaunchBarUIManager uiManager = Activator.getService(ILaunchBarUIManager.class); + return uiManager.openConfigurationEditor(launchDesc); + } catch (CoreException e) { + return e.getStatus(); } } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/LaunchActiveCommandHandler.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/LaunchActiveCommandHandler.java index 25e954978d6..45ff856928e 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/LaunchActiveCommandHandler.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/LaunchActiveCommandHandler.java @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.launchbar.core.internal.LaunchBarManager; +import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.ui.internal.Activator; public class LaunchActiveCommandHandler extends AbstractHandler { @@ -26,7 +26,7 @@ public class LaunchActiveCommandHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { try { - LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager(); + ILaunchBarManager launchBarManager = Activator.getService(ILaunchBarManager.class); StopActiveCommandHandler.stopActiveLaunches(launchBarManager); ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration(); if (config == null) diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/StopActiveCommandHandler.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/StopActiveCommandHandler.java index bc7dd66af10..06276c71420 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/StopActiveCommandHandler.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/StopActiveCommandHandler.java @@ -24,7 +24,7 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; 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.Messages; @@ -38,10 +38,10 @@ public class StopActiveCommandHandler extends AbstractHandler { public void stop() { 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(); if (activeLaunches != null && activeLaunches.length > 0) { new Job(Messages.StopActiveCommandHandler_0) { diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java index 1c888382b89..9e32ba076a0 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java @@ -24,6 +24,8 @@ import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDi import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension; import org.eclipse.debug.ui.ILaunchConfigurationDialog; 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.wizard.WizardPage; import org.eclipse.launchbar.ui.internal.Activator; @@ -34,11 +36,13 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @SuppressWarnings("restriction") -public class NewLaunchConfigEditPage extends WizardPage { +public class NewLaunchConfigEditPage extends WizardPage implements IPageChangingListener { private ILaunchConfigurationWorkingCopy workingCopy; private LaunchConfigurationDialogExt launchConfigurationDialog = new LaunchConfigurationDialogExt(); private LaunchConfigurationTabGroupViewerExt tabViewer; - private ILaunchConfigurationType type; + + private ILaunchGroup launchGroup; + private ILaunchConfigurationType launchConfigType; public NewLaunchConfigEditPage() { super(Messages.NewLaunchConfigEditPage_0); @@ -55,7 +59,6 @@ public class NewLaunchConfigEditPage extends WizardPage { LaunchConfigurationsDialog.setCurrentlyVisibleLaunchConfigurationDialog(launchConfigurationDialog); tabViewer = new LaunchConfigurationTabGroupViewerExt(comp, launchConfigurationDialog); launchConfigurationDialog.setTabViewer(tabViewer); - changeLaunchConfigType(type); GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); data.heightHint = 500; tabViewer.getControl().setLayoutData(data); @@ -63,6 +66,14 @@ public class NewLaunchConfigEditPage extends WizardPage { validateFields(); } + public void setLaunchGroup(ILaunchGroup launchGroup) { + this.launchGroup = launchGroup; + } + + public void setLaunchConfigType(ILaunchConfigurationType type) { + this.launchConfigType = type; + } + /** * @return the workingCopy */ @@ -70,26 +81,26 @@ public class NewLaunchConfigEditPage extends WizardPage { return workingCopy; } - void changeLaunchConfigType(ILaunchConfigurationType type) { - if (type == null) + @Override + public void handlePageChanging(PageChangingEvent event) { + if (launchConfigType == null) { return; - try { - this.type = type; - LaunchConfigurationsDialog.setCurrentlyVisibleLaunchConfigurationDialog(launchConfigurationDialog); - if (tabViewer != null) { + } + LaunchConfigurationsDialog.setCurrentlyVisibleLaunchConfigurationDialog(launchConfigurationDialog); + if (tabViewer != null) { + try { String name = launchConfigurationDialog.generateName("launchConfiguration"); //$NON-NLS-1$ - workingCopy = type.newInstance(null, name); + workingCopy = launchConfigType.newInstance(null, name); launchConfigurationDialog.doSetDefaults(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) return false; workingCopy.rename(tabViewer.getWorkingCopy().getName()); @@ -139,11 +150,6 @@ public class NewLaunchConfigEditPage extends WizardPage { return NewLaunchConfigEditPage.this.getLaunchGroup(); } - @Override - public String getMode() { - return NewLaunchConfigEditPage.this.getMode(); - } - @Override public void updateMessage() { validateFields(); @@ -193,24 +199,15 @@ public class NewLaunchConfigEditPage extends WizardPage { } }; - public String getMode() { - return ((NewLaunchConfigWizard) getWizard()).modePage.selectedGroup.getMode(); - } - public LaunchGroupExtension getLaunchGroup() { - try { - if (workingCopy == null) - return 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) { + if (workingCopy == null) + return null; + if (launchGroup == null) { return null; } + LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager() + .getLaunchGroup(launchGroup.getIdentifier()); + return groupExt; } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigModePage.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigModePage.java index 30536c6ff2b..44b576a7e3d 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigModePage.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigModePage.java @@ -19,8 +19,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.launchbar.ui.internal.Messages; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -30,7 +29,6 @@ import org.eclipse.swt.widgets.TableItem; public class NewLaunchConfigModePage extends WizardPage { private Table table; - ILaunchGroup selectedGroup; public NewLaunchConfigModePage() { super(Messages.NewLaunchConfigModePage_0); @@ -85,23 +83,8 @@ public class NewLaunchConfigModePage extends WizardPage { if (!hasDebug) { table.select(0); } - selectedGroup = (ILaunchGroup) table.getSelection()[0].getData(); } - table.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectedGroup = (ILaunchGroup) table.getSelection()[0].getData(); - ((NewLaunchConfigWizard) getWizard()).typePage.populateItems(); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - getContainer().showPage(getNextPage()); - } - }); - setControl(comp); } @@ -118,4 +101,13 @@ public class NewLaunchConfigModePage extends WizardPage { item.setData(group); } + + public ILaunchGroup getSelectedGroup() { + return (ILaunchGroup) table.getSelection()[0].getData(); + } + + public void addGroupSelectionListener(SelectionListener listener) { + table.addSelectionListener(listener); + } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java index ad24719705f..4e42cf2c8e9 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java @@ -15,12 +15,12 @@ import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.ILaunchGroup; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.launchbar.ui.internal.Messages; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -51,13 +51,11 @@ public class NewLaunchConfigTypePage extends WizardPage { getContainer().showPage(getNextPage()); } }); - populateItems(); setControl(comp); } - void populateItems() { - ILaunchGroup group = ((NewLaunchConfigWizard) getWizard()).modePage.selectedGroup; + public void setLaunchGroup(ILaunchGroup group) { if (group == null) return; @@ -84,21 +82,12 @@ public class NewLaunchConfigTypePage extends WizardPage { setPageComplete(haveItems); } - @Override - public boolean canFlipToNextPage() { - return isPageComplete(); + public void addTypeSelectionListener(SelectionListener listener) { + table.addSelectionListener(listener); } - - @Override - public IWizardPage getNextPage() { - 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; + + public ILaunchConfigurationType getSelectedType() { + return (ILaunchConfigurationType) table.getSelection()[0].getData(); } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties index 0dcac33a4db..31942645c4c 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties @@ -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_1=Building Active Configuration -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 +StopActiveCommandHandler_0=Stopping launches +StopActiveCommandHandler_1=Stopping build + NewLaunchConfigEditPage_0=NewLaunchConfigEditPage NewLaunchConfigEditPage_1=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_2=Select the type of launch configuration to create. NewLaunchConfigWizard_0=Create Launch Configuration -StopActiveCommandHandler_0=Stopping launches -StopActiveCommandHandler_1=Stopping build -TargetSelector_ToolTipPrefix=Launch Target -TargetSelector_CreateNewTarget=New Launch Target... DescriptorMustNotBeNull=Descriptor must not be null DescriptorMustNotBeNullDesc=The launch descriptor must not be null. diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java index 7c4a10a4431..e32c6b4cfd4 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java @@ -66,7 +66,7 @@ public class LaunchTargetUIManager implements ILaunchTargetUIManager { @Override public String getText(Object element) { if (element instanceof ILaunchTarget) { - return ((ILaunchTarget) element).getName(); + return ((ILaunchTarget) element).getId(); } return super.getText(element); } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardAction.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/NewLaunchTargetWizardAction.java similarity index 97% rename from bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardAction.java rename to bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/NewLaunchTargetWizardAction.java index ec026074e81..dff15f08065 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardAction.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/NewLaunchTargetWizardAction.java @@ -8,11 +8,12 @@ * Contributors: * 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.dialogs.IDialogSettings; import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.launchbar.ui.internal.target.NewLaunchTargetWizard; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbenchWindow; diff --git a/features/org.eclipse.launchbar/feature.xml b/features/org.eclipse.launchbar/feature.xml index b985d758bfe..ad98a06df76 100644 --- a/features/org.eclipse.launchbar/feature.xml +++ b/features/org.eclipse.launchbar/feature.xml @@ -33,4 +33,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/pom.xml b/pom.xml index 4e1521bd7fd..cb4bf1ac8a9 100644 --- a/pom.xml +++ b/pom.xml @@ -38,14 +38,9 @@ - - eclipse - http://download.eclipse.org/releases/mars/ - p2 - platform - http://download.eclipse.org/eclipse/updates/4.5/ + http://download.eclipse.org/eclipse/updates/4.6milestones/ p2 @@ -55,12 +50,17 @@ orbit - http://download.eclipse.org/tools/orbit/downloads/drops/R20150124073747/repository/ + http://download.eclipse.org/tools/orbit/downloads/drops/S20160501200945/repository/ + p2 + + + cdt + http://download.eclipse.org/tools/cdt/builds/neon/milestones/ p2 remote - http://download.eclipse.org/tools/ptp/builds/remote/2.0.0/ + http://download.eclipse.org/tools/ptp/builds/remote/neon/milestones/ p2 @@ -68,6 +68,7 @@ bundles/org.eclipse.launchbar.core bundles/org.eclipse.launchbar.ui + bundles/org.eclipse.launchbar.ui.controls features/org.eclipse.launchbar tests/org.eclipse.launchbar.core.tests diff --git a/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/internal/LaunchBarManager2Test.java b/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/internal/LaunchBarManager2Test.java index 2e000a0d190..92b71cbef91 100644 --- a/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/internal/LaunchBarManager2Test.java +++ b/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/internal/LaunchBarManager2Test.java @@ -31,7 +31,6 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.List; import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.internal.resources.Project; @@ -355,9 +354,9 @@ public class LaunchBarManager2Test { public void testGetLaunchTargets() throws CoreException { manager.launchObjectAdded(launchObject); manager.setActiveLaunchDescriptor(descriptor); - List launchTargets = manager.getLaunchTargets(descriptor); - assertEquals(1, launchTargets.size()); - assertEquals(otherTarget, launchTargets.get(0)); + ILaunchTarget[] launchTargets = manager.getLaunchTargets(descriptor); + assertEquals(1, launchTargets.length); + assertEquals(otherTarget, launchTargets[0]); } @Test @@ -369,8 +368,8 @@ public class LaunchBarManager2Test { init(); manager.launchObjectAdded(launchObject); ILaunchDescriptor desc = manager.getActiveLaunchDescriptor(); - List launchTargets = manager.getLaunchTargets(desc); - assertEquals(1, launchTargets.size()); + ILaunchTarget[] launchTargets = manager.getLaunchTargets(desc); + assertEquals(1, launchTargets.length); } @Test @@ -382,8 +381,8 @@ public class LaunchBarManager2Test { init(); manager.launchObjectAdded(launchObject); ILaunchDescriptor desc = manager.getActiveLaunchDescriptor(); - List launchTargets = manager.getLaunchTargets(desc); - assertEquals(1, launchTargets.size()); + ILaunchTarget[] launchTargets = manager.getLaunchTargets(desc); + assertEquals(1, launchTargets.length); } @Test