- public void actionPerformed(AnActionEvent e) {
- final ActionExecuteHelper helper = new ActionExecuteHelper();
- checkState(e, helper);
- if (! helper.isOk()) return;
-
- final DataContext dc = e.getDataContext();
- final Project project = CommonDataKeys.PROJECT.getData(dc);
- final VirtualFile vf = CommonDataKeys.VIRTUAL_FILE.getData(dc);
-
- //1 select target
- final SelectCreateExternalTargetDialog dialog = new SelectCreateExternalTargetDialog(project, vf);
- dialog.show();
- if (DialogWrapper.OK_EXIT_CODE != dialog.getExitCode()) return;
-
- final String url = dialog.getSelectedURL();
- final boolean checkout = dialog.isCheckout();
- final String target = dialog.getLocalTarget().trim();
-
- ProgressManager.getInstance().run(new Task.Backgroundable(project, "Creating External", true, null) {
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- doInBackground(project, vf, url, checkout, target);
- }
- });
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ Project project = e.getRequiredData(CommonDataKeys.PROJECT);
+ VirtualFile file = notNull(getIfSingle(e.getData(VcsDataKeys.VIRTUAL_FILE_STREAM)));
+ SelectCreateExternalTargetDialog dialog = new SelectCreateExternalTargetDialog(project, file);
+
+ if (dialog.showAndGet()) {
+ String url = dialog.getSelectedURL();
+ boolean checkout = dialog.isCheckout();
+ String target = dialog.getLocalTarget().trim();
+
+ new Task.Backgroundable(project, "Creating External") {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ doInBackground(project, file, url, checkout, target);
+ }
+ }.queue();
+ }