From 4bada0e6ab5dd73bd651fdafa729b45e7c7a3196 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Mon, 21 Nov 2016 10:49:44 -0500 Subject: [PATCH] Preference to Always show Launch Target. Default is auto. Default behavior is to only show the launch target selector when the active launch descriptor supports multiple targets. Add a pref to always show the launch target selector. Change-Id: I2615ab605be8a6cb706baca7407b265f8b832cf1 --- .../ui/controls/internal/Activator.java | 2 +- .../controls/internal/LaunchBarControl.java | 21 ++++++++++++------- .../controls/internal/LaunchBarInjector.java | 3 ++- .../LaunchBarPreferenceInitializer.java | 2 +- .../internal/LaunchBarPreferencePage.java | 6 ++++-- .../ui/controls/internal/Messages.java | 2 +- .../ui/controls/internal/messages.properties | 2 +- 7 files changed, 23 insertions(+), 15 deletions(-) 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 index 4e6169d8a52..363516acea0 100644 --- 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 @@ -33,7 +33,7 @@ public class Activator extends AbstractUIPlugin { // 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_ALWAYS_TARGETSELECTOR = "alwaysTargetSelector"; //$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$ diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java index a8c90aa7684..c390314f399 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java @@ -96,10 +96,9 @@ 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); boolean supportsTargets; - if (!enabled) { - supportsTargets = false; + if (store.getBoolean(Activator.PREF_ALWAYS_TARGETSELECTOR)) { + supportsTargets = true; } else { try { ILaunchDescriptor desc = manager.getActiveLaunchDescriptor(); @@ -192,11 +191,17 @@ public class LaunchBarControl implements ILaunchBarListener { configSelector.setDelayedSelection(descriptor, SELECTION_DELAY); } - boolean supportsTargets = true; - try { - supportsTargets = descriptor.getType().supportsTargets(); - } catch (CoreException e) { - Activator.log(e); + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + boolean supportsTargets; + if (store.getBoolean(Activator.PREF_ALWAYS_TARGETSELECTOR)) { + supportsTargets = true; + } else { + try { + supportsTargets = descriptor.getType().supportsTargets(); + } catch (CoreException e) { + supportsTargets = true; + Activator.log(e); + } } if (supportsTargets) { diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarInjector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarInjector.java index b8161e898f7..4bf0c648bbb 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarInjector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarInjector.java @@ -72,7 +72,8 @@ public class LaunchBarInjector { boolean enabled = Boolean.parseBoolean(event.getNewValue().toString()); injectIntoAll(enabled); } - if (event.getProperty().equals(Activator.PREF_ENABLE_TARGETSELECTOR)|| event.getProperty().equals(Activator.PREF_ENABLE_BUILDBUTTON)) { + if (event.getProperty().equals(Activator.PREF_ALWAYS_TARGETSELECTOR) + || event.getProperty().equals(Activator.PREF_ENABLE_BUILDBUTTON)) { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); boolean enabled = store.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR); if (enabled){ diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferenceInitializer.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferenceInitializer.java index 077ecacf4b9..e951b5eeb63 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferenceInitializer.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferenceInitializer.java @@ -22,7 +22,7 @@ public class LaunchBarPreferenceInitializer extends AbstractPreferenceInitialize IPreferenceStore store = Activator.getDefault().getPreferenceStore(); 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_ALWAYS_TARGETSELECTOR, false); store.setDefault(Activator.PREF_LAUNCH_HISTORY_SIZE, 3); } diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferencePage.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferencePage.java index b1ab27fdd0a..33163482d31 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferencePage.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarPreferencePage.java @@ -33,8 +33,10 @@ public class LaunchBarPreferencePage extends FieldEditorPreferencePage implement @Override protected void createFieldEditors() { addField(new BooleanFieldEditor(Activator.PREF_ENABLE_LAUNCHBAR, Messages.LaunchBarPreferencePage_1, getFieldEditorParent())); - addField(new BooleanFieldEditor(Activator.PREF_ENABLE_TARGETSELECTOR, Messages.LaunchBarPreferencePage_EnableTargetSelector, getFieldEditorParent())); - addField(new BooleanFieldEditor(Activator.PREF_ENABLE_BUILDBUTTON, Messages.LaunchBarPreferencePage_EnableBuildButton, getFieldEditorParent())); + addField(new BooleanFieldEditor(Activator.PREF_ENABLE_BUILDBUTTON, + Messages.LaunchBarPreferencePage_EnableBuildButton, getFieldEditorParent())); + addField(new BooleanFieldEditor(Activator.PREF_ALWAYS_TARGETSELECTOR, + Messages.LaunchBarPreferencePage_AlwaysTargetSelector, getFieldEditorParent())); } } 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 index d39471e3a17..9eac59043d4 100644 --- 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 @@ -32,7 +32,7 @@ public class Messages extends NLS { public static String LaunchBarListViewer_0; public static String LaunchBarPreferencePage_0; public static String LaunchBarPreferencePage_1; - public static String LaunchBarPreferencePage_EnableTargetSelector; + public static String LaunchBarPreferencePage_AlwaysTargetSelector; public static String LaunchBarPreferencePage_EnableBuildButton; public static String LaunchConfigurationEditDialog_0; public static String LaunchConfigurationEditDialog_1; 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 index 391f607abda..30e6ed1e228 100644 --- 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 @@ -21,7 +21,7 @@ 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_AlwaysTargetSelector=Always show the target selector LaunchBarPreferencePage_EnableBuildButton=Enable the Build button LaunchConfigurationEditDialog_0=Delete LaunchConfigurationEditDialog_1=Duplicate