@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)); } }
/* * @see ICompletionProposal#apply(IDocument) */ @Override public void apply(IDocument document) { try { performChange(CUIPlugin.getActivePage().getActiveEditor(), document); } catch (CoreException e) { ExceptionHandler.handle( e, CorrectionMessages.ChangeCorrectionProposal_error_title, CorrectionMessages.ChangeCorrectionProposal_error_message); } }