@Override
 public void apply(IDocument document) {
   try {
     ITranslationUnit unit = getTranslationUnit();
     IEditorPart part = null;
     if (unit.getResource().exists()) {
       boolean canEdit = performValidateEdit(unit);
       if (!canEdit) {
         return;
       }
       part = EditorUtility.isOpenInEditor(unit);
       if (part == null) {
         part = EditorUtility.openInEditor(unit);
         if (part != null) {
           document =
               CUIPlugin.getDefault().getDocumentProvider().getDocument(part.getEditorInput());
         }
       }
       IWorkbenchPage page = CUIPlugin.getActivePage();
       if (page != null && part != null) {
         page.bringToTop(part);
       }
       if (part != null) {
         part.setFocus();
       }
     }
     performChange(part, document);
   } catch (CoreException e) {
     ExceptionHandler.handle(
         e,
         CorrectionMessages.TUCorrectionProposal_error_title,
         CorrectionMessages.TUCorrectionProposal_error_message);
   }
 }
Example #2
0
 /*
  * @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);
   }
 }