Output text in default editor [message #841502] |
Wed, 11 April 2012 07:58  |
Eclipse User |
|
|
|
Hi, I am new in Elcipse, and have a question about output text in default editor. Here is the thing...
I create a contextmenu based on the contextmenu from default texteditor (org.eclipse.ui.DefaultTextEditor), when I click one button from contextmenu,it should add a string to the current texteditor, just output a string follow the current cursor position.I am a new user of eclipse.
Now I create a action, and want to output s1 in editor, but have no idea how to do it.
public class ActionCopy implements IEditorActionDelegate {
public ActionCopy() {
// TODO Auto-generated constructor stub
}
@Override
public void run(IAction action) {
// TODO Auto-generated method stub
//MessageDialog.openInformation(shell,"Editor","New Action was executed.");
s1= action.getText(); // get the action label
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
// TODO Auto-generated method stub
}
@Override
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
// TODO Auto-generated method stub
}
}
Thanks!
[Updated on: Thu, 12 April 2012 03:11] by Moderator
|
|
|
Re: Output text in default editor [message #842402 is a reply to message #841502] |
Thu, 12 April 2012 05:04  |
Eclipse User |
|
|
|
Currentl, I try it this way, but still not work...
Text text;
text = new Text(EditorsUI.DEFAULT_TEXT_EDITOR_ID, 0);
text.setText(s1);
text.paste;
in order to output string s1 to the current default editor.
Is it a possible way?
|
|
|
Powered by
FUDForum. Page generated in 0.04960 seconds