void (@NotNull final Project project, @Nullable final Editor editor, @Nullable final VirtualFile file, final VirtualFile @Nullable [] files) { GithubSettings settings = GithubSettings.getInstance(); // Ask for description and other params GithubCreateGistDialog dialog = new GithubCreateGistDialog(project, getFileName(editor, files), settings.isPrivateGist(), settings.isOpenInBrowserGist(), settings.isCopyURLGist()); if (!dialog.showAndGet()) { return; } settings.setPrivateGist(dialog.isSecret()); settings.setOpenInBrowserGist(dialog.isOpenInBrowser()); settings.setCopyURLGist(dialog.isCopyURL()); GithubAccount account = requireNonNull(dialog.getAccount()); final Ref<String> url = new Ref<>(); new Task.Backgroundable(project, GithubBundle.message("create.gist.process")) { @Override public void run(@NotNull ProgressIndicator indicator) { String token = GHCompatibilityUtil.getOrRequestToken(account, project); if (token == null) return; GithubApiRequestExecutor requestExecutor = GithubApiRequestExecutor.Factory.getInstance().create(token); List<FileContent> contents = collectContents(project, editor, file, files); if (contents.isEmpty()) return; String gistUrl = createGist(project, requestExecutor, indicator, account.getServer(), contents, dialog.isSecret(), dialog.getDescription(), dialog.getFileName()); url.set(gistUrl); } @Override public void onSuccess() { if (url.isNull()) { return; } if (dialog.isCopyURL()) { StringSelection stringSelection = new StringSelection(url.get()); CopyPasteManager.getInstance().setContents(stringSelection); } if (dialog.isOpenInBrowser()) { BrowserUtil.browse(url.get()); } else { GithubNotifications .showInfoURL(project, GithubNotificationIdsHolder.GIST_CREATED, GithubBundle.message("create.gist.success"), GithubBundle.message("create.gist.url"), url.get()); } } }.queue(); }