private JComponent createToolbar() {
    final JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0, 1, GridBagConstraints.NORTHWEST,
                                                   GridBagConstraints.NONE, JBUI.insets(5, 10, 5, 0), 0, 0);
    final JButton performButton = new JButton(JavaRefactoringBundle.message("type.migration.migrate.button.text"));
    performButton.addActionListener(new ActionListener() {
      private static void expandTree(MigrationNode migrationNode) {
        if (!migrationNode.getInfo().isExcluded() || migrationNode.areChildrenInitialized()) { //do not walk into excluded collapsed nodes: nothing to migrate can be found
          final Collection<? extends AbstractTreeNode<?>> nodes = migrationNode.getChildren();
          for (final AbstractTreeNode<?> node : nodes) {
            ApplicationManager.getApplication().runReadAction(() -> expandTree((MigrationNode)node));
          }
        }
      }

      @Override
      public void actionPerformed(final ActionEvent e) {
        final Object root = myRootsTree.getModel().getRoot();
        if (root instanceof DefaultMutableTreeNode) {
          final Object userObject = ((DefaultMutableTreeNode)root).getUserObject();
          if (userObject instanceof MigrationRootNode) {
            ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
              final Set<VirtualFile> files = new HashSet<>();
              final TypeMigrationUsageInfo[] usages = ReadAction.compute(() -> {
                  final Collection<? extends AbstractTreeNode<?>> children = ((MigrationRootNode)userObject).getChildren();
                  for (AbstractTreeNode<?> child : children) {
                    expandTree((MigrationNode)child);
                  }
                  final TypeMigrationUsageInfo[] usages1 = myLabeler.getMigratedUsages();
                  for (TypeMigrationUsageInfo usage : usages1) {
                    if (!usage.isExcluded()) {
                      final PsiElement element = usage.getElement();
                      if (element != null) {
                        files.add(element.getContainingFile().getVirtualFile());
                      }
                    }
                  }
                  return usages1;
                });


              ApplicationManager.getApplication().invokeLater(() -> {
                if (ReadonlyStatusHandler.getInstance(myProject).
                  ensureFilesWritable(files).hasReadonlyFiles()) {
                  return;
                }
                WriteCommandAction.writeCommandAction(myProject).run(() -> TypeMigrationProcessor.change(usages, myLabeler, myProject));
              }, myProject.getDisposed());
            }, JavaRefactoringBundle.message("type.migration.action.name"), false, myProject);
          }
        }
        UsageViewContentManager.getInstance(myProject).closeContent(myContent);
      }
    });
    panel.add(performButton, gc);
    final JButton closeButton = new JButton(CommonBundle.getCancelButtonText());
    closeButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(final ActionEvent e) {
        UsageViewContentManager.getInstance(myProject).closeContent(myContent);

      }
    });
    panel.add(closeButton, gc);
    final JButton rerunButton = new JButton(JavaRefactoringBundle.message("type.migration.rerun.button.text"));
    rerunButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(final ActionEvent e) {
        UsageViewContentManager.getInstance(myProject).closeContent(myContent);
        final TypeMigrationDialog.MultipleElements dialog =
          new TypeMigrationDialog.MultipleElements(myProject, myInitialRoots, myLabeler.getMigrationRootTypeFunction(), myLabeler.getRules());
        dialog.show();
      }
    });
    panel.add(rerunButton, gc);
    final JButton helpButton = new JButton(CommonBundle.getHelpButtonText());
    helpButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(final ActionEvent e) {
        HelpManager.getInstance().invokeHelp("reference.typeMigrationPreview");
      }
    });
    gc.weightx = 1;
    panel.add(helpButton, gc);

    return panel;
  }
private JComponent createToolbar()