use of org.jetbrains.plugins.github.ui.GithubCreateGistDialog in project intellij-community by JetBrains.
the class GithubCreateGistAction method createGistAction.
static void createGistAction(@NotNull final Project project, @Nullable final Editor editor, @Nullable final VirtualFile file, @Nullable final VirtualFile[] files) {
// Ask for description and other params
final GithubCreateGistDialog dialog = new GithubCreateGistDialog(project, editor, files, file);
if (!dialog.showAndGet()) {
return;
}
final GithubAuthDataHolder authHolder = getValidAuthData(project, dialog.isAnonymous());
if (authHolder == null) {
return;
}
final Ref<String> url = new Ref<>();
new Task.Backgroundable(project, "Creating Gist...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
List<FileContent> contents = collectContents(project, editor, file, files);
if (contents.isEmpty())
return;
String gistUrl = createGist(project, authHolder, indicator, contents, dialog.isPrivate(), dialog.getDescription(), dialog.getFileName());
url.set(gistUrl);
}
@Override
public void onSuccess() {
if (url.isNull()) {
return;
}
if (dialog.isOpenInBrowser()) {
BrowserUtil.browse(url.get());
} else {
GithubNotifications.showInfoURL(project, "Gist Created Successfully", "Your gist url", url.get());
}
}
}.queue();
}
Aggregations