From 6e58dc7b4e5dd0f8ec44e22aa5f4524517b1797d Mon Sep 17 00:00:00 2001 From: Bogdan Popescu Date: Sat, 21 Dec 2013 20:35:45 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eda9afc..27c9c15 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ Eclipse plugin to enable lookups in Dash.app for selected text # Instructions -Clone, import the project into Eclipse workspace, export it as deployable plugin and choose install into host. - -After restarting, under Keys in preferences, bind the "Lookup in Dash" command to whatever you desire. +* Clone or download this repo +* Import the project into Eclipse workspace (File > Import > General > Existing Projects into Workspace) +* Export it as deployable plugin (File > Export > Plug-in Development > Deployable Plug-ins and Fragments) + * If you don't see a "Plug-in Development" option in File > Export, you need to install the "Eclipse Plug-in Development Environment" which can be done by going to Help > Install New Software > General Purpose Tools > Eclipse Plug-in Development Environment +* Choose install into host +* Restart Eclipse +* Go to Preferences > General > Keys and bind the "Lookup in Dash" command to whatever you desire From 05910baf3c7d34a91efdbcfe6a4d07ac9f03831d Mon Sep 17 00:00:00 2001 From: Bogdan Popescu Date: Sat, 21 Dec 2013 20:36:23 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 27c9c15..af068fa 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ Eclipse plugin to enable lookups in Dash.app for selected text * Clone or download this repo * Import the project into Eclipse workspace (File > Import > General > Existing Projects into Workspace) -* Export it as deployable plugin (File > Export > Plug-in Development > Deployable Plug-ins and Fragments) - * If you don't see a "Plug-in Development" option in File > Export, you need to install the "Eclipse Plug-in Development Environment" which can be done by going to Help > Install New Software > General Purpose Tools > Eclipse Plug-in Development Environment -* Choose install into host +* Export it as deployable plugin (File > Export > Plug-in Development > Deployable Plug-ins and Fragments) and choose install into host + * Note: If you don't see a "Plug-in Development" option in File > Export, you need to install the "Eclipse Plug-in Development Environment" which can be done by going to Help > Install New Software > General Purpose Tools > Eclipse Plug-in Development Environment * Restart Eclipse * Go to Preferences > General > Keys and bind the "Lookup in Dash" command to whatever you desire From 9eebe75f5e78ff68624ed952105f3837378e07ac Mon Sep 17 00:00:00 2001 From: Toomas Uudisaru Date: Sat, 26 Sep 2015 15:11:16 +0300 Subject: [PATCH 3/4] Fix for the text selection in Eclipse Mars. The selected text in text editor is not correctly looked up in Eclipse Mars. Add alternative selection lookup from the active page (see http://wiki.eclipse.org/FAQ_How_do_I_find_out_what_object_is_selected%3F) --- .gitignore | 1 + META-INF/MANIFEST.MF | 5 ++- .../handlers/DashLookupHandler.java | 44 ++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index de63549..939767f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.jar *.war *.ear +/bin/ diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 83c3179..278e1c6 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -2,11 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: DashLookup Bundle-SymbolicName: com.jkb.dashlookup;singleton:=true -Bundle-Version: 1.0.5 +Bundle-Version: 1.0.6 Bundle-Activator: dashlookup.Activator Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: org.eclipse.jface.text +Import-Package: org.eclipse.jface.text, + org.eclipse.ui.texteditor Bundle-Vendor: Quaerendo Games diff --git a/src/dashlookup/handlers/DashLookupHandler.java b/src/dashlookup/handlers/DashLookupHandler.java index 63146a6..6087cb9 100644 --- a/src/dashlookup/handlers/DashLookupHandler.java +++ b/src/dashlookup/handlers/DashLookupHandler.java @@ -3,12 +3,14 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.program.Program; import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.texteditor.ITextEditor; /** * Our sample handler extends AbstractHandler, an IHandler base class. @@ -29,16 +31,38 @@ public DashLookupHandler() { @Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); - ISelectionService service = window.getSelectionService(); - if (service != null) { - ISelection selection = service.getSelection(); - if (selection instanceof ITextSelection) { - String selectedText = ((ITextSelection) selection).getText(); - if (!selectedText.isEmpty()) - Program.launch("dash://" + selectedText); - } + String selectedText = getSelectedText(window); + + if (selectedText.isEmpty() && window.getActivePage() != null) { + selectedText = getTextFromSelection(window.getActivePage().getSelection()); + } + + if (!selectedText.isEmpty()) { + Program.launch("dash://" + selectedText); } + return null; } + + private String getTextFromSelection(ISelection selection) { + String selectedText = ""; + if (selection instanceof ITextSelection) { + selectedText = ((ITextSelection) selection).getText(); + } + + return selectedText; + } + + private String getSelectedText(IWorkbenchWindow window) { + String selectedText = ""; + final ISelectionService service = window.getSelectionService(); + + if (service != null) { + selectedText = getTextFromSelection(service.getSelection()); + } + + return selectedText; + } + } From e6a40f3390da228955ca963d2b5d7a13d35d19ef Mon Sep 17 00:00:00 2001 From: Toomas Uudisaru Date: Sat, 26 Sep 2015 15:26:40 +0300 Subject: [PATCH 4/4] Unneccessary imports removed. --- src/dashlookup/handlers/DashLookupHandler.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/dashlookup/handlers/DashLookupHandler.java b/src/dashlookup/handlers/DashLookupHandler.java index 6087cb9..01b3fb6 100644 --- a/src/dashlookup/handlers/DashLookupHandler.java +++ b/src/dashlookup/handlers/DashLookupHandler.java @@ -7,10 +7,8 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.program.Program; import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.ui.texteditor.ITextEditor; /** * Our sample handler extends AbstractHandler, an IHandler base class.