commit 18c2867fb309f82d7d13ce51b1eaed3ec4d27230
parent d17845a6a9b22d0bdae1c79b69f8ca554dc5c479
Author: Dan Amlund <dan@danamlund.dk>
Date: Wed, 11 Oct 2017 20:57:31 +0200
initial
Diffstat:
9 files changed, 274 insertions(+), 0 deletions(-)
diff --git a/dk.danamlund.quicklaunch/.classpath b/dk.danamlund.quicklaunch/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/dk.danamlund.quicklaunch/.project b/dk.danamlund.quicklaunch/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dk.danamlund.quicklaunch</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/dk.danamlund.quicklaunch/META-INF/MANIFEST.MF b/dk.danamlund.quicklaunch/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Quick Launch Configuration
+Bundle-SymbolicName: dk.danamlund.quicklaunch;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.debug.core;bundle-version="3.10.100",
+ org.eclipse.equinox.common;bundle-version="3.8.0",
+ org.eclipse.debug.ui
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/dk.danamlund.quicklaunch/build.properties b/dk.danamlund.quicklaunch/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,
+
diff --git a/dk.danamlund.quicklaunch/plugin.xml b/dk.danamlund.quicklaunch/plugin.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="dk.danamlund.quicklaunch.commands.run"
+ name="Run Launch Configuration">
+ </command>
+ <command
+ id="dk.danamlund.quicklaunch.commands.debug"
+ name="Debug Launch Configuration">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="dk.danamlund.quicklaunch.QuickRunLaunchConfigurationHandler"
+ commandId="dk.danamlund.quicklaunch.commands.run">
+ </handler>
+ <handler
+ class="dk.danamlund.quicklaunch.QuickDebugLaunchConfigurationHandler"
+ commandId="dk.danamlund.quicklaunch.commands.debug">
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="dk.danamlund.quicklaunch.commands.run"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="Shift+Ctrl+Y">
+ </key>
+ <key
+ commandId="dk.danamlund.quicklaunch.commands.debug"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="Shift+Ctrl+D">
+ </key>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="menu:org.eclipse.ui.run?endof=stepIntoGroup">
+ <separator
+ name="dk.danamlund.quicklaunch.separator"
+ visible="true">
+ </separator>
+ <menu
+ label="Quick Launch Configuration">
+ <command
+ commandId="dk.danamlund.quicklaunch.commands.run"
+ style="push">
+ </command>
+ <command
+ commandId="dk.danamlund.quicklaunch.commands.debug"
+ style="push">
+ </command>
+ </menu>
+ </menuContribution>
+ </extension>
+
+</plugin>
diff --git a/dk.danamlund.quicklaunch/src/dk/danamlund/quicklaunch/QuickDebugLaunchConfigurationHandler.java b/dk.danamlund.quicklaunch/src/dk/danamlund/quicklaunch/QuickDebugLaunchConfigurationHandler.java
@@ -0,0 +1,17 @@
+package dk.danamlund.quicklaunch;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class QuickDebugLaunchConfigurationHandler extends AbstractHandler {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+ QuickLaunchConfigurationDialog dialog = QuickLaunchConfigurationDialog.newDebugDialog(window.getShell());
+ dialog.open();
+ return null;
+ }
+}
diff --git a/dk.danamlund.quicklaunch/src/dk/danamlund/quicklaunch/QuickLaunchConfigurationDialog.java b/dk.danamlund.quicklaunch/src/dk/danamlund/quicklaunch/QuickLaunchConfigurationDialog.java
@@ -0,0 +1,117 @@
+package dk.danamlund.quicklaunch;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.FilteredList;
+import org.eclipse.ui.dialogs.FilteredList.FilterMatcher;
+
+public class QuickLaunchConfigurationDialog extends ElementListSelectionDialog {
+ private final String runMode;
+
+ public static QuickLaunchConfigurationDialog newRunDialog(Shell parent) {
+ QuickLaunchConfigurationDialog dialog = new QuickLaunchConfigurationDialog(parent, ILaunchManager.RUN_MODE);
+ dialog.setTitle("Run Launch Configuration");
+ return dialog;
+ }
+
+ public static QuickLaunchConfigurationDialog newDebugDialog(Shell parent) {
+ QuickLaunchConfigurationDialog dialog = new QuickLaunchConfigurationDialog(parent, ILaunchManager.DEBUG_MODE);
+ dialog.setTitle("Debug Launch Configuration");
+ return dialog;
+ }
+
+ private QuickLaunchConfigurationDialog(Shell parent, String runMode) {
+ super(parent, new QuickLaunchConfigurationLabelProvider());
+ this.runMode = runMode;
+ try {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ List<ILaunchConfiguration> launchConfigurations = new ArrayList<>();
+ for (ILaunchConfiguration launchConfiguration : launchManager.getLaunchConfigurations()) {
+ if (launchConfiguration.supportsMode(runMode)) {
+ launchConfigurations.add(launchConfiguration);
+ }
+ }
+ setElements(launchConfigurations.toArray());
+ setInitialSelections(new Object[] { launchConfigurations.get(launchConfigurations.size() - 1) });
+ } catch (CoreException e) {
+ throw new IllegalStateException(e);
+ }
+
+ setBlockOnOpen(true);
+ }
+
+ @Override
+ protected FilteredList createFilteredList(Composite parent) {
+ FilteredList list = super.createFilteredList(parent);
+ list.setFilterMatcher(new FuzzyFilterMatcher());
+ return list;
+ }
+
+ @Override
+ protected void okPressed() {
+ super.okPressed();
+ Object[] results = getResult();
+ if (results.length == 1) {
+ ILaunchConfiguration launchConfiguration = (ILaunchConfiguration) results[0];
+ try {
+ launchConfiguration.launch(runMode, new NullProgressMonitor(), true, true);
+ } catch (CoreException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ private static class QuickLaunchConfigurationLabelProvider extends LabelProvider {
+ final IDebugModelPresentation debugModelPresentation = DebugUITools.newDebugModelPresentation();
+
+ @Override
+ public Image getImage(Object element) {
+ return debugModelPresentation.getImage(element);
+ }
+ }
+
+ /**
+ * fuzzy 'foo' is same as regular '*f*o*o*'.
+ */
+ private static class FuzzyFilterMatcher implements FilterMatcher {
+ private String pattern = "";
+
+ @Override
+ public void setFilter(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
+ this.pattern = pattern.toLowerCase().trim();
+ }
+
+ @Override
+ public boolean match(Object element) {
+ if (pattern.isEmpty()) {
+ return true;
+ }
+ String s = element.toString().toLowerCase().trim();
+ int sIndex = 0;
+ for (int i = 0; i < pattern.length(); i++) {
+ if (sIndex >= s.length()) {
+ return false;
+ }
+ sIndex = s.indexOf(pattern.charAt(i), sIndex);
+ if (sIndex < 0) {
+ return false;
+ }
+ sIndex++;
+ }
+ return true;
+ }
+ }
+}
diff --git a/dk.danamlund.quicklaunch/src/dk/danamlund/quicklaunch/QuickRunLaunchConfigurationHandler.java b/dk.danamlund.quicklaunch/src/dk/danamlund/quicklaunch/QuickRunLaunchConfigurationHandler.java
@@ -0,0 +1,17 @@
+package dk.danamlund.quicklaunch;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class QuickRunLaunchConfigurationHandler extends AbstractHandler {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+ QuickLaunchConfigurationDialog dialog = QuickLaunchConfigurationDialog.newRunDialog(window.getShell());
+ dialog.open();
+ return null;
+ }
+}
diff --git a/readme.txt b/readme.txt
@@ -0,0 +1,8 @@
+Eclipse quick launch
+
+Run launch configurations like Ctrl-Shfit-T
+
+Tested when built on
+ Eclipse for eclipse comitters Neon 3
+and installed (put into dropins/ folder)
+ Eclipse oxygen a1