private void createLink(IWorkbenchWindow workbenchWindow, IFolder folder, String fsFolder) {
   final File externalFolder = new File(fsFolder);
   try {
     final IFolder linkedFolder = folder.getFolder(externalFolder.getName());
     workbenchWindow.run(
         true,
         true,
         new IRunnableWithProgress() {
           @Override
           public void run(IProgressMonitor monitor)
               throws InvocationTargetException, InterruptedException {
             try {
               linkedFolder.createLink(externalFolder.toURI(), IResource.NONE, monitor);
             } catch (CoreException e) {
               throw new InvocationTargetException(e);
             }
           }
         });
   } catch (InvocationTargetException e) {
     UIUtils.showErrorDialog(workbenchWindow.getShell(), "Create link", "Can't create link", e);
   } catch (InterruptedException e) {
     // skip
   }
 }
  private RenameSupport undoAndCreateRenameSupport(String newName) throws CoreException {
    // Assumption: the linked mode model should be shut down by now.

    final ISourceViewer viewer = fEditor.getViewer();

    try {
      if (!fOriginalName.equals(newName)) {
        IWorkbenchWindow workbenchWindow = fEditor.getSite().getWorkbenchWindow();
        // undo
        workbenchWindow.run(
            false,
            true,
            new IRunnableWithProgress() {
              @Override
              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                if (viewer instanceof ITextViewerExtension6) {
                  IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
                  if (undoManager instanceof IUndoManagerExtension) {
                    IUndoManagerExtension undoManagerExtension =
                        (IUndoManagerExtension) undoManager;
                    IUndoContext undoContext = undoManagerExtension.getUndoContext();
                    IOperationHistory operationHistory =
                        OperationHistoryFactory.getOperationHistory();
                    while (undoManager.undoable()) {
                      if (fStartingUndoOperation != null
                          && fStartingUndoOperation.equals(
                              operationHistory.getUndoOperation(undoContext))) {
                        return;
                      }
                      undoManager.undo();
                    }
                  }
                }
              }
            });
        // wait for analysis
        IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
        progressService.busyCursorWhile(
            new IRunnableWithProgress() {
              @Override
              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Waiting for background analysis...", IProgressMonitor.UNKNOWN);
                try {
                  RefactoringUtils.waitResolvedCompilationUnit(fEditor, monitor);
                  RefactoringUtils.waitReadyForRefactoring(monitor);
                } finally {
                  monitor.done();
                }
              }
            });
        // by some reason "busyCursorWhile" looses focus, so restore it
        fEditor.setFocus();
        // get new Element, after background build finished
        prepareElement();
        if (fDartElement == null) {
          return null;
        }
      }
    } catch (InvocationTargetException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              DartToolsPlugin.getPluginId(),
              ReorgMessages.RenameLinkedMode_error_saving_editor,
              e));
    } catch (InterruptedException e) {
      // canceling is OK
      return null;
    }

    viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y);

    if (newName.length() == 0) {
      return null;
    }

    return RenameSupport.create(fDartElement, newName);
  }