use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class ShowJavadoc method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
final DocumentationComponent component = new DocumentationComponent(documentationManager);
final Property property = myTable.getSelectionProperty();
if (property == null) {
return;
}
PsiElement javadocElement = property.getJavadocElement();
ActionCallback callback;
if (javadocElement == null) {
callback = new ActionCallback();
component.setText(property.getJavadocText(), null, true);
} else {
callback = documentationManager.queueFetchDocInfo(javadocElement, component);
}
callback.doWhenProcessed(() -> {
JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component).setProject(project).setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false).setResizable(true).setMovable(true).setRequestFocus(true).setTitle(DesignerBundle.message("designer.properties.javadoc.title", property.getName())).setCancelCallback(() -> {
Disposer.dispose(component);
return Boolean.TRUE;
}).createPopup();
component.setHint(hint);
Disposer.register(hint, component);
hint.show(new RelativePoint(myTable.getParent(), new Point(0, 0)));
});
if (javadocElement == null) {
callback.setDone();
}
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class EduStepicUpdater method updateCourseList.
private static ActionCallback updateCourseList() {
ActionCallback callback = new ActionCallback();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final List<CourseInfo> courses = EduStepicConnector.getCourses(null);
final List<CourseInfo> cachedCourses = StudyProjectGenerator.getCoursesFromCache();
StudyProjectGenerator.flushCache(courses);
StepicUpdateSettings.getInstance().setLastTimeChecked(System.currentTimeMillis());
courses.removeAll(cachedCourses);
if (!courses.isEmpty() && !cachedCourses.isEmpty()) {
final String message;
final String title;
if (courses.size() == 1) {
message = courses.get(0).getName();
title = "New course available";
} else {
title = "New courses available";
message = StringUtil.join(courses, CourseInfo::getName, ", ");
}
final Notification notification = new Notification("New.course", title, message, NotificationType.INFORMATION);
notification.notify(null);
}
});
return callback;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class MavenAttachSourcesProvider method getActions.
@Override
@NotNull
public Collection<AttachSourcesAction> getActions(final List<LibraryOrderEntry> orderEntries, final PsiFile psiFile) {
Collection<MavenProject> projects = getMavenProjects(psiFile);
if (projects.isEmpty())
return Collections.emptyList();
if (findArtifacts(projects, orderEntries).isEmpty())
return Collections.emptyList();
return Collections.singleton(new AttachSourcesAction() {
@Override
public String getName() {
return ProjectBundle.message("maven.action.download.sources");
}
@Override
public String getBusyText() {
return ProjectBundle.message("maven.action.download.sources.busy.text");
}
@Override
public ActionCallback perform(List<LibraryOrderEntry> orderEntries) {
// may have been changed by this time...
Collection<MavenProject> mavenProjects = getMavenProjects(psiFile);
if (mavenProjects.isEmpty()) {
return ActionCallback.REJECTED;
}
MavenProjectsManager manager = MavenProjectsManager.getInstance(psiFile.getProject());
Collection<MavenArtifact> artifacts = findArtifacts(mavenProjects, orderEntries);
if (artifacts.isEmpty())
return ActionCallback.REJECTED;
final AsyncResult<MavenArtifactDownloader.DownloadResult> result = new AsyncResult<>();
manager.scheduleArtifactsDownloading(mavenProjects, artifacts, true, false, result);
final ActionCallback resultWrapper = new ActionCallback();
result.doWhenDone(new Consumer<MavenArtifactDownloader.DownloadResult>() {
@Override
public void consume(MavenArtifactDownloader.DownloadResult downloadResult) {
if (!downloadResult.unresolvedSources.isEmpty()) {
final StringBuilder message = new StringBuilder();
message.append("<html>Sources not found for:");
int count = 0;
for (MavenId each : downloadResult.unresolvedSources) {
if (count++ > 5) {
message.append("<br>and more...");
break;
}
message.append("<br>").append(each.getDisplayString());
}
message.append("</html>");
Notifications.Bus.notify(new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Cannot download sources", message.toString(), NotificationType.WARNING), psiFile.getProject());
}
if (downloadResult.resolvedSources.isEmpty()) {
resultWrapper.setRejected();
} else {
resultWrapper.setDone();
}
}
});
return resultWrapper;
}
});
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class UpdaterTreeState method processHangByParent.
private ActionCallback processHangByParent(Object each) {
ActionCallback result = new ActionCallback();
processNextHang(each, result);
return result;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class JumpToColorsAndFontsAction method openSettingsAndSelectKey.
private static boolean openSettingsAndSelectKey(@NotNull Project project, @NotNull ColorSettingsPage page, @NotNull AttributesDescriptor descriptor) {
SettingsDialog dialog = (SettingsDialog) ShowSettingsUtilImpl.getDialog(project, ShowSettingsUtilImpl.getConfigurableGroups(project, true), null);
Settings settings = Settings.KEY.getData(dialog);
ColorAndFontOptions configurable0 = settings == null ? null : settings.find(ColorAndFontOptions.class);
SearchableConfigurable configurable = configurable0 == null ? null : configurable0.findSubConfigurable(page.getDisplayName());
if (configurable == null)
return false;
Runnable runnable = configurable.enableSearch(descriptor.getDisplayName());
ActionCallback callback = settings.select(configurable);
if (runnable != null)
callback.doWhenDone(runnable);
dialog.show();
return true;
}
Aggregations