Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-03-29 09:29:55 -0400
committerMickael Istria2019-05-08 13:41:38 -0400
commit7d5d115ce594f8f8379b1311a9d63a535f292484 (patch)
tree2b566cf6ecdacd3bd538bd085bd62d3a7c03d784 /org.eclipse.debug.ui/ui
parent194c7e64b3eb37217a6b880827c4def091ffd888 (diff)
downloadeclipse.platform.debug-7d5d115ce594f8f8379b1311a9d63a535f292484.tar.gz
eclipse.platform.debug-7d5d115ce594f8f8379b1311a9d63a535f292484.tar.xz
eclipse.platform.debug-7d5d115ce594f8f8379b1311a9d63a535f292484.zip
Bug 545544 - Contribute Launch/Debug configuration to Quick AccessI20190509-1800I20190508-1800
Change-Id: I046fb61551c60a54c6a726f32f2f3b01ba129e91 Signed-off-by: Mickael Istria <mistria@redhat.com>
Diffstat (limited to 'org.eclipse.debug.ui/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessComputer.java82
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessComputer.java25
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java65
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/ProfileQuickAccessComputer.java24
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessComputer.java24
5 files changed, 220 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessComputer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessComputer.java
new file mode 100644
index 000000000..c4bd6b22b
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/AbstractLaunchQuickAccessComputer.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.DebugUIPlugin;
+import org.eclipse.ui.quickaccess.IQuickAccessComputer;
+import org.eclipse.ui.quickaccess.QuickAccessElement;
+
+public abstract class AbstractLaunchQuickAccessComputer implements IQuickAccessComputer {
+
+ protected final ILaunchManager manager;
+ protected final ILaunchMode launchMode;
+
+ private boolean launchConfigurationsChanged = false;
+
+ public AbstractLaunchQuickAccessComputer(ILaunchMode launchMode) {
+ super();
+ manager = DebugPlugin.getDefault().getLaunchManager();
+ this.launchMode = launchMode;
+ manager.addLaunchConfigurationListener(new ILaunchConfigurationListener() {
+ @Override
+ public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+ launchConfigurationsChanged = true;
+ }
+
+ @Override
+ public void launchConfigurationChanged(ILaunchConfiguration configuration) {
+ launchConfigurationsChanged = true;
+ }
+
+ @Override
+ public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+ launchConfigurationsChanged = true;
+ }
+ });
+ }
+
+ @Override
+ public QuickAccessElement[] computeElements() {
+ 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(config, launchMode)).toArray(QuickAccessElement[]::new);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ return new QuickAccessElement[0];
+ }
+ }
+
+ @Override
+ public void resetState() {
+ }
+
+ @Override
+ public boolean needsRefresh() {
+ return launchConfigurationsChanged;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessComputer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessComputer.java
new file mode 100644
index 000000000..185bf9fa2
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/DebugQuickAccessComputer.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 DebugQuickAccessComputer extends AbstractLaunchQuickAccessComputer {
+
+ public DebugQuickAccessComputer() {
+ 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..0bc425f7d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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;
+
+public class LaunchQuickAccessElement extends QuickAccessElement {
+
+ private ILaunchConfiguration launch;
+ private ILaunchMode launchMode;
+
+ public LaunchQuickAccessElement(ILaunchConfiguration launch, ILaunchMode launchMode) {
+ 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/ProfileQuickAccessComputer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/ProfileQuickAccessComputer.java
new file mode 100644
index 000000000..01d3f41bb
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/ProfileQuickAccessComputer.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 ProfileQuickAccessComputer extends AbstractLaunchQuickAccessComputer {
+
+ public ProfileQuickAccessComputer() {
+ super(DebugPlugin.getDefault().getLaunchManager().getLaunchMode(ILaunchManager.PROFILE_MODE));
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessComputer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessComputer.java
new file mode 100644
index 000000000..fced026d0
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/RunQuickAccessComputer.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 RunQuickAccessComputer extends AbstractLaunchQuickAccessComputer {
+
+ public RunQuickAccessComputer() {
+ super(DebugPlugin.getDefault().getLaunchManager().getLaunchMode(ILaunchManager.RUN_MODE));
+ }
+}

Back to the top