Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-03-29 09:29:55 -0400
committerMickael Istria2019-04-02 16:01:33 -0400
commit27ffa28c237adb1de4de7339c16583845b0f79a0 (patch)
tree4ed99f33e9976439e2f47572ff5065ac425c2a01 /org.eclipse.debug.ui/ui/org/eclipse/debug/internal
parentb037e13091441bad5d98acc54d1da88421a85fa8 (diff)
downloadeclipse.platform.debug-27ffa28c237adb1de4de7339c16583845b0f79a0.tar.gz
eclipse.platform.debug-27ffa28c237adb1de4de7339c16583845b0f79a0.tar.xz
eclipse.platform.debug-27ffa28c237adb1de4de7339c16583845b0f79a0.zip
Bug 545544 - Contribute Launch/Debug configuration to Quick AccessI20190408-0600I20190407-1800I20190406-1800
Change-Id: Ic0cc44a599bc749953db99d885ff31e38132bcbc Signed-off-by: Mickael Istria <mistria@redhat.com>
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessProvider.java95
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessProvider.java25
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java67
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/ProfileQuickAccessProvider.java24
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessProvider.java24
5 files changed, 235 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessProvider.java
new file mode 100644
index 000000000..dca05cb4e
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessProvider.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc. others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.quickaccess;
+
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationListener;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchMode;
+import org.eclipse.debug.internal.ui.DebugPluginImages;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.quickaccess.QuickAccessElement;
+import org.eclipse.ui.quickaccess.QuickAccessProvider;
+
+public abstract class AbstractLaunchQuickAccessProvider extends QuickAccessProvider {
+
+ protected final ILaunchManager manager;
+ protected final ILaunchMode launchMode;
+
+ public AbstractLaunchQuickAccessProvider(ILaunchMode launchMode) {
+ super();
+ manager = DebugPlugin.getDefault().getLaunchManager();
+ this.launchMode = launchMode;
+ manager.addLaunchConfigurationListener(new ILaunchConfigurationListener() {
+ @Override
+ public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+ reset();
+ }
+
+ @Override
+ public void launchConfigurationChanged(ILaunchConfiguration configuration) {
+ reset();
+ }
+
+ @Override
+ public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+ reset();
+ }
+ });
+ }
+
+ @Override
+ public String getId() {
+ return getClass().getName();
+ }
+
+ @Override
+ public String getName() {
+ return Action.removeMnemonics(launchMode.getLabel());
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_LAUNCH_RUN);
+ }
+
+ @Override
+ public QuickAccessElement[] getElements() {
+ try {
+ return Arrays.stream(manager.getLaunchConfigurations()).filter(config -> {
+ try {
+ return config.getType().supportsMode(launchMode.getIdentifier());
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ return false;
+ }
+ }).map(config -> new LaunchQuickAccessElement(this, config, launchMode)).toArray(QuickAccessElement[]::new);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ return new QuickAccessElement[0];
+ }
+ }
+
+ @Override
+ protected void doReset() {
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessProvider.java
new file mode 100644
index 000000000..b1a9590b1
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessProvider.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc. others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.quickaccess;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchManager;
+
+public class DebugQuickAccessProvider extends AbstractLaunchQuickAccessProvider {
+
+ public DebugQuickAccessProvider() {
+ super(DebugPlugin.getDefault().getLaunchManager().getLaunchMode(ILaunchManager.DEBUG_MODE));
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java
new file mode 100644
index 000000000..82e726b08
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc. others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.quickaccess;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchMode;
+import org.eclipse.debug.internal.ui.DebugPluginImages;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.quickaccess.QuickAccessElement;
+import org.eclipse.ui.quickaccess.QuickAccessProvider;
+
+public class LaunchQuickAccessElement extends QuickAccessElement {
+
+ private ILaunchConfiguration launch;
+ private ILaunchMode launchMode;
+
+ public LaunchQuickAccessElement(QuickAccessProvider provider, ILaunchConfiguration launch, ILaunchMode launchMode) {
+ super(provider);
+ this.launch = launch;
+ this.launchMode = launchMode;
+ }
+
+ @Override
+ public String getLabel() {
+ return launch.getName();
+ }
+
+ @Override
+ public String getMatchLabel() {
+ return getLabel() + ' ' + launchMode.getLabel();
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ try {
+ return DebugPluginImages.getImageDescriptor(launch.getType().getIdentifier());
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ return null;
+ }
+ }
+
+ @Override
+ public String getId() {
+ return launch.getName() + '/' + launchMode.getIdentifier();
+ }
+
+ @Override
+ public void execute() {
+ DebugUITools.launch(launch, launchMode.getIdentifier());
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/ProfileQuickAccessProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/ProfileQuickAccessProvider.java
new file mode 100644
index 000000000..2e3186f7c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/ProfileQuickAccessProvider.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc. others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.quickaccess;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchManager;
+
+public class ProfileQuickAccessProvider extends AbstractLaunchQuickAccessProvider {
+
+ public ProfileQuickAccessProvider() {
+ super(DebugPlugin.getDefault().getLaunchManager().getLaunchMode(ILaunchManager.PROFILE_MODE));
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessProvider.java
new file mode 100644
index 000000000..deb23c295
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessProvider.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc. others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.quickaccess;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchManager;
+
+public class RunQuickAccessProvider extends AbstractLaunchQuickAccessProvider {
+
+ public RunQuickAccessProvider() {
+ super(DebugPlugin.getDefault().getLaunchManager().getLaunchMode(ILaunchManager.RUN_MODE));
+ }
+}

Back to the top