2012-11-21 3 views
2

나는 이상한 문제를 가지고 있습니다. 이 코드와 이클립스의 편집기에서 파일을 엽니 다 Eclipse 편집기에서 파일 열기 및이 편집기의 포커스 설정

final IWorkbench wb = PlatformUI.getWorkbench(); 
    IWorkbenchWindow window = wb.getActiveWorkbenchWindow(); 
    final IWorkbenchPage page = window.getActivePage(); 

    wb.getProgressService().runInUI(window, new IRunnableWithProgress() { 

     @Override 
     public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { 

      if(null == monitor) { 
       monitor = new NullProgressMonitor(); 
      } 

      try { 
       monitor.beginTask("Append to file", 2); 

       ITextEditor editor = (ITextEditor) IDE.openEditor(page, file); 

       monitor.worked(1); 

       // TODO Bug: Editor is active, it has the focus but doesn't process keypress events :-(
      } catch(Exception e) { 
       throw new InvocationTargetException(e, "Error appending to file " + file); 
      } finally { 
       monitor.done(); 
      } 
     } 
    }, null); 

내가 인터넷에 여러 소스에서 비트와 조각을 수집했다.

이상한 문제는 에디터에 포커스가 갖고있는 것 같아요이다 (탭이 강조 표시를하고 난 주위에 파란색 테두리를 참조)

을하지만 눈에 보이는 더 커서가 편집기에서이없는 내가 뭔가를 입력 아무것도 (아무 것도 작업대의 다른 곳에서 발생하지 않음).

나는 또한 ITextEditor editor = (ITextEditor) IDE.openEditor(page, file, true);을 시도했지만 같은 결과를 보았습니다.

탭을 클릭하면 커서가 나타나고 편집기를 사용할 수 있습니다. 그러나 F12을 누르면 효과가 없습니다.

아이디어가 있습니까?

+0

어떤 버전의 Eclipse를 사용하고 있습니까? 내가 IDE.openEditor()를 보았고 그것이 어디서 오는지 확실하지 않기 때문에 묻습니다. –

+0

3.7. 이 코드는 FAQ에서 가져옵니다. http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_on_a_file_in_the_workspace%3F –

+0

이 질문은 해결되었습니다. 방문하십시오 : http://stackoverflow.com/questions/41606181/eclipse-rcp-have-the -same-editor-open-in-editor-window/41631205 # 41631205 –

답변

관련 문제