plugin? I had no idea how to word that short question, sorry if it was unclear.
What I want to do is add a button to the menu bar of Eclipse. I can do that. But when clicked, I want my plugin to be able to use whatever the user has highlighted in whatever java OR txt OR c++ window is open at the time and then use it for the plugin. how do I do it?
That is to say, if the user had a java document open that read
public class HelloPulkse{
public static void main(String[] args){
System.out.print("Hello, Pulkse!");
}
}
...and they selected the words "System.out.print", then clicked my plugin, my plugin could use that text. But i want it to be able to use any text from any editor; that is, text, java, c++, xml, anything.
I read a FAQ that said it had something to do with this:
ITextEditor editor = // Insert your editor here
IselectionProvider sp = editor.getSelectedProvider();
ISelection selection = sp.getSelection();
ITextSelection text = (ITextSelection)selection;
But I don't want to create any editors or open any myself, I want it to use the selected text from whatever editor is open at the time. Can anybody help? Pleeeeease

Thanks in advance
FOUND IT!!!! Here it is for anyone who needs it:
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow ().getActivePage().getActiveEditor();
ITextEditor editor = (ITextEditor)part;
ISelectionProvider sp = editor.getSelectionProvider();
ISelection selection = sp.getSelection();
ITextSelection text = (ITextSelection)selection;
String text2 = text.getText();