/**
  * Creates page 1 of the multi-page editor, which allows you to change the font used in page 2.
  */
 void createPage1() {
   try {
     m_editor = new TextEditor();
     int index = addPage(m_editor, getEditorInput());
     setPageText(index, m_editor.getTitle());
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
  /** Opens the given editor on the selected file revision. */
  protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
    IFileRevision fileRevision = getFileRevision();
    if (fileRevision == null) {
      return;
    }
    try {
      IProgressMonitor monitor = new NullProgressMonitor();
      IStorage storage = fileRevision.getStorage(monitor);
      boolean isFile = storage instanceof IFile;

      if (openUsingDescriptor) {
        // discouraged access to open system editors
        ((WorkbenchPage) (page.getSite().getPage()))
            .openEditorFromDescriptor(
                isFile
                    ? new FileEditorInput((IFile) storage)
                    : (IEditorInput)
                        FileRevisionEditorInput.createEditorInputFor(fileRevision, monitor),
                editorDescriptor,
                true,
                null);
      } else {
        String editorId =
            editorDescriptor == null
                ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID
                : editorDescriptor.getId();
        page.getSite()
            .getPage()
            .openEditor(
                isFile
                    ? new FileEditorInput((IFile) storage)
                    : (IEditorInput)
                        FileRevisionEditorInput.createEditorInputFor(fileRevision, monitor),
                editorId,
                true,
                MATCH_BOTH);
      }
    } catch (PartInitException e) {
      StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
      statusAdapter.setProperty(
          IStatusAdapterConstants.TITLE_PROPERTY, TeamUIMessages.LocalHistoryPage_OpenEditorError);
      StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);
    } catch (CoreException e) {
      StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
      statusAdapter.setProperty(
          IStatusAdapterConstants.TITLE_PROPERTY, TeamUIMessages.LocalHistoryPage_OpenEditorError);
      StatusManager.getManager().handle(statusAdapter, StatusManager.LOG);
    }
  }