| How to add a code segment into the current editor via popup menu? [message #1688568] | 
Fri, 20 March 2015 22:32   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, 
 
  I have add a popup menu to the XTextEditor and bind a handler to the menu. 
  the Handler code like this: 
 
public class GenFieldGroupHandler extends AbstractHandler {
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		
		IEditorPart editor=HandlerUtil.getActiveEditor(event);
		ISelection selection=HandlerUtil.getCurrentSelection(event);
		IEditorInput input=HandlerUtil.getActiveEditorInput(event);
		if (editor instanceof XtextEditor & selection instanceof TextSelection)
		 {
			XtextEditor textEditor=(XtextEditor)editor;
			TextSelection textSelection = (TextSelection) selection;		
			
			
			System.out.println("Gen Field Group Handler is executed.");
			 
		 }
		 
		return null;
	}
	
} 
 
My question is how to add a code segment into the editor at cursor position. 
could you give me a example or a suggestion. 
 
Thanks!
 |  
 |  
  | 
 | 
 | 
 | 
Powered by 
FUDForum. Page generated in 0.06630 seconds