Community
Participate
Working Groups
Build Identifier: I20090611-1540 Hi, Please have a look at the below code. While debugging, i find that the selection is an instance of TextSelection but it is just failing while checking if it is an instance of TextSelection. Not sure about the reason. Please help me out. IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection != null) { if (selection instanceof TextSelection) { ITextSelection textSelection = (ITextSelection) selection; MessageDialog.openInformation(window.getShell(), "Auto Logging", textSelection.getText()); } } Reproducible: Always Steps to Reproduce: 1.Put the above mentioned code in the execute method of the handler of a hello World command plugin. 2.Run the eclipse application. 3.Write a piece of code and select a text and perform the action. 4.Nothing happens :(. The window will not be opened with the text. :(
This works fine for me on 3.6 RC2 and 3.5.2 (M20100211-1343). I generates the Hello World Command plugin and added your code in. I selected text in a java editor and used both the keybinding CTRL+6 and the toolbar button. I get a dialog with my text every time. Do you have anything other than Eclipse Classic installed (PDE,JDT,Platform, and Equinox)? Try downloading one of the above builds from http://download.eclipse.org/eclipse/downloads/ and put your test plugin into it. Does the test work? PW
Created attachment 170192 [details] Hello project I used Import existing project into workspace PW
(In reply to comment #2) > Created an attachment (id=170192) [details] > Hello project I used > Import existing project into workspace > PW Thanks a lot for your help. I had missed out the inclusion of the bundle org.eclipse.jface.text in the manifest file. Regards Archana
Bug 282969 makes HandlerUtil.getCurrentSelection(event) useless for text selections.
Works per attached project PW