コード例 #1
0
  @Override
  protected void performChange(IEditorPart part, IDocument document) throws CoreException {
    try {
      super.performChange(part, document);
      if (part == null) {
        return;
      }

      if (fLinkedProposalModel != null) {
        if (fLinkedProposalModel.hasLinkedPositions() && part instanceof CEditor) {
          // enter linked mode
          ITextViewer viewer = ((CEditor) part).getViewer();
          new LinkedProposalModelPresenter().enterLinkedMode(viewer, part, fLinkedProposalModel);
        } else if (part instanceof ITextEditor) {
          LinkedProposalPositionGroup.PositionInformation endPosition =
              fLinkedProposalModel.getEndPosition();
          if (endPosition != null) {
            // select a result
            int pos = endPosition.getOffset() + endPosition.getLength();
            ((ITextEditor) part).selectAndReveal(pos, 0);
          }
        }
      }
    } catch (BadLocationException e) {
      throw new CoreException(CUIStatus.createError(IStatus.ERROR, e));
    }
  }