Ejemplo n.º 1
0
 public Object execute(ExecutionEvent event) throws ExecutionException {
   XtextEditor editor = EditorUtils.getActiveXtextEditor(event);
   if (editor != null) {
     // Hack, would be nicer with document edits, but this way we don't loose auto edit
     StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
     Event e = new Event();
     e.character = replaceChar;
     e.type = SWT.KeyDown;
     e.doit = true;
     textWidget.notifyListeners(SWT.KeyDown, e);
   }
   return null;
 }
 @SuppressWarnings("finally")
 public static IProject getActualProject(ISelection selection) {
   IProject actualProject = ProjectManager.getActualProject();
   System.out.println("Project: " + actualProject);
   try {
     XtextEditor editor = EditorUtils.getActiveXtextEditor();
     if (editor != null) {
       IEditorInput input = editor.getEditorInput();
       System.out.println("Editor Input: " + input);
       if (input instanceof IFileEditorInput) {
         IFileEditorInput fileInput = (IFileEditorInput) input;
         actualProject = fileInput.getFile().getProject();
         System.out.println("Project: " + actualProject);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     return actualProject;
   }
 }