use of com.intellij.notification.Notification 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.notification.Notification in project intellij-community by JetBrains.
the class PyStudyShowTutorial method projectOpened.
@Override
public void projectOpened() {
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new DumbAwareRunnable() {
@Override
public void run() {
if (PropertiesComponent.getInstance().getBoolean(ourShowPopup, true)) {
final String content = "<html>If you'd like to learn more about PyCharm Edu, " + "click <a href=\"https://www.jetbrains.com/pycharm-edu/quickstart/\">here</a> to watch a tutorial</html>";
final Notification notification = new Notification("Watch Tutorials!", "", content, NotificationType.INFORMATION, new NotificationListener.UrlOpeningListener(true));
Notifications.Bus.notify(notification);
Balloon balloon = notification.getBalloon();
if (balloon != null) {
balloon.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
notification.expire();
}
});
}
notification.whenExpired(() -> PropertiesComponent.getInstance().setValue(ourShowPopup, false, true));
}
}
});
}
});
}
use of com.intellij.notification.Notification in project GsonFormat by zzz40500.
the class NotificationCenter method sendNotification.
public static void sendNotification(String message, NotificationType notificationType) {
if (message == null || message.trim().length() == 0) {
return;
}
Notification notification = new Notification("com.dim.plugin.Gsonformat", "Gsonformat ", espaceString(message), notificationType);
Notifications.Bus.notify(notification);
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class CompileDriver method notifyCompilationCompleted.
/** @noinspection SSBasedInspection*/
private long notifyCompilationCompleted(final CompileContextImpl compileContext, final CompileStatusNotification callback, final ExitStatus _status) {
final long duration = System.currentTimeMillis() - compileContext.getStartCompilationStamp();
if (!myProject.isDisposed()) {
// refresh on output roots is required in order for the order enumerator to see all roots via VFS
final Module[] affectedModules = compileContext.getCompileScope().getAffectedModules();
if (_status != ExitStatus.UP_TO_DATE && _status != ExitStatus.CANCELLED) {
// have to refresh in case of errors too, because run configuration may be set to ignore errors
Collection<String> affectedRoots = ContainerUtil.newHashSet(CompilerPathsEx.getOutputPaths(affectedModules));
if (!affectedRoots.isEmpty()) {
ProgressIndicator indicator = compileContext.getProgressIndicator();
indicator.setText("Synchronizing output directories...");
CompilerUtil.refreshOutputRoots(affectedRoots);
indicator.setText("");
}
}
}
SwingUtilities.invokeLater(() -> {
int errorCount = 0;
int warningCount = 0;
try {
errorCount = compileContext.getMessageCount(CompilerMessageCategory.ERROR);
warningCount = compileContext.getMessageCount(CompilerMessageCategory.WARNING);
} finally {
if (callback != null) {
callback.finished(_status == ExitStatus.CANCELLED, errorCount, warningCount, compileContext);
}
}
if (!myProject.isDisposed()) {
final String statusMessage = createStatusMessage(_status, warningCount, errorCount, duration);
final MessageType messageType = errorCount > 0 ? MessageType.ERROR : warningCount > 0 ? MessageType.WARNING : MessageType.INFO;
if (duration > ONE_MINUTE_MS && CompilerWorkspaceConfiguration.getInstance(myProject).DISPLAY_NOTIFICATION_POPUP) {
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.MESSAGES_WINDOW, messageType, statusMessage);
}
final String wrappedMessage = _status != ExitStatus.UP_TO_DATE ? "<a href='#'>" + statusMessage + "</a>" : statusMessage;
final Notification notification = CompilerManager.NOTIFICATION_GROUP.createNotification("", wrappedMessage, messageType.toNotificationType(), new MessagesActivationListener(compileContext)).setImportant(false);
compileContext.getBuildSession().registerCloseAction(notification::expire);
notification.notify(myProject);
if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) {
final String msg = DateFormatUtil.formatDateTime(new Date()) + " - " + statusMessage;
compileContext.addMessage(CompilerMessageCategory.INFORMATION, msg, null, -1, -1);
}
}
});
return duration;
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class FrameworkDetectionManager method doRunDetection.
private void doRunDetection() {
Set<Integer> detectorsToProcess;
synchronized (myLock) {
detectorsToProcess = new HashSet<>(myDetectorsToProcess);
detectorsToProcess.addAll(myDetectorsToProcess);
myDetectorsToProcess.clear();
}
if (detectorsToProcess.isEmpty())
return;
if (LOG.isDebugEnabled()) {
LOG.debug("Starting framework detectors: " + detectorsToProcess);
}
final FileBasedIndex index = FileBasedIndex.getInstance();
List<DetectedFrameworkDescription> newDescriptions = new ArrayList<>();
List<DetectedFrameworkDescription> oldDescriptions = new ArrayList<>();
final DetectionExcludesConfiguration excludesConfiguration = DetectionExcludesConfiguration.getInstance(myProject);
for (Integer id : detectorsToProcess) {
final List<? extends DetectedFrameworkDescription> frameworks = runDetector(id, index, excludesConfiguration, true);
oldDescriptions.addAll(frameworks);
final Collection<? extends DetectedFrameworkDescription> updated = myDetectedFrameworksData.updateFrameworksList(id, frameworks);
newDescriptions.addAll(updated);
oldDescriptions.removeAll(updated);
if (LOG.isDebugEnabled()) {
LOG.debug(frameworks.size() + " frameworks detected, " + updated.size() + " changed");
}
}
Set<String> frameworkNames = new HashSet<>();
for (final DetectedFrameworkDescription description : FrameworkDetectionUtil.removeDisabled(newDescriptions, oldDescriptions)) {
frameworkNames.add(description.getDetector().getFrameworkType().getPresentableName());
}
if (!frameworkNames.isEmpty()) {
String names = StringUtil.join(frameworkNames, ", ");
final String text = ProjectBundle.message("framework.detected.info.text", names, frameworkNames.size());
FRAMEWORK_DETECTION_NOTIFICATION.createNotification("Frameworks detected", text, NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
showSetupFrameworksDialog(notification);
}
}
}).notify(myProject);
}
}
Aggregations