use of com.intellij.notification.Notification in project intellij-plugins by JetBrains.
the class AnalysisServerDiagnosticsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null)
return;
// Get the current analysis server.
DartAnalysisServerService server = DartAnalysisServerService.getInstance(project);
// Ask it for the diagnostics port.
server.diagnostic_getServerPort(new GetServerPortConsumer() {
@Override
public void computedServerPort(int port) {
// Open a new browser page.
final String url = "http://localhost:" + port + "/status";
OpenDartObservatoryUrlAction.openUrlInChromeFamilyBrowser(url);
}
@Override
public void onError(RequestError requestError) {
Notification notification = new Notification(GROUP_DISPLAY_ID, DartBundle.message("analysis.server.show.diagnostics.error"), requestError.getMessage(), NotificationType.ERROR);
Notifications.Bus.notify(notification);
}
});
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class GitBranchUiHandlerImpl method showUnmergedFilesNotification.
@Override
public void showUnmergedFilesNotification(@NotNull final String operationName, @NotNull final Collection<GitRepository> repositories) {
String title = unmergedFilesErrorTitle(operationName);
String description = unmergedFilesErrorNotificationDescription(operationName);
VcsNotifier.getInstance(myProject).notifyError(title, description, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && event.getDescription().equals("resolve")) {
GitConflictResolver.Params params = new GitConflictResolver.Params().setMergeDescription(String.format("The following files have unresolved conflicts. You need to resolve them before %s.", operationName)).setErrorNotificationTitle("Unresolved files remain.");
new GitConflictResolver(myProject, myGit, GitUtil.getRootsFromRepositories(repositories), params).merge();
}
}
});
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class GitDeleteBranchOperation method notifySuccess.
@Override
protected void notifySuccess() {
boolean unmergedCommits = !myUnmergedToBranches.isEmpty();
String message = "<b>Deleted Branch:</b> " + myBranchName;
if (unmergedCommits)
message += "<br/>Unmerged commits were discarded";
Notification notification = STANDARD_NOTIFICATION.createNotification("", message, NotificationType.INFORMATION, null);
notification.addAction(new NotificationAction(RESTORE) {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
restoreInBackground(notification);
}
});
if (unmergedCommits) {
notification.addAction(new NotificationAction(VIEW_COMMITS) {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
viewUnmergedCommitsInBackground(notification);
}
});
}
if (!myTrackedBranches.isEmpty() && hasOnlyTrackingBranch(myTrackedBranches, myBranchName)) {
notification.addAction(new NotificationAction(DELETE_TRACKED_BRANCH) {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
deleteTrackedBranchInBackground();
}
});
}
myNotifier.notify(notification);
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class GitUntrackedFilesHelper method notifyUntrackedFilesOverwrittenBy.
/**
* Displays notification about {@code untracked files would be overwritten by checkout} error.
* Clicking on the link in the notification opens a simple dialog with the list of these files.
* @param root
* @param relativePaths
* @param operation the name of the Git operation that caused the error: {@code rebase, merge, checkout}.
* @param description the content of the notification or null if the default content is to be used.
*/
public static void notifyUntrackedFilesOverwrittenBy(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull Collection<String> relativePaths, @NotNull final String operation, @Nullable String description) {
final String notificationTitle = StringUtil.capitalize(operation) + " failed";
final String notificationDesc = description == null ? createUntrackedFilesOverwrittenDescription(operation, true) : description;
final Collection<String> absolutePaths = GitUtil.toAbsolute(root, relativePaths);
final List<VirtualFile> untrackedFiles = ContainerUtil.mapNotNull(absolutePaths, new Function<String, VirtualFile>() {
@Override
public VirtualFile fun(String absolutePath) {
return GitUtil.findRefreshFileOrLog(absolutePath);
}
});
VcsNotifier.getInstance(project).notifyError(notificationTitle, notificationDesc, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
final String dialogDesc = createUntrackedFilesOverwrittenDescription(operation, false);
String title = "Untracked Files Preventing " + StringUtil.capitalize(operation);
if (untrackedFiles.isEmpty()) {
GitUtil.showPathsInDialog(project, absolutePaths, title, dialogDesc);
} else {
DialogWrapper dialog;
dialog = new UntrackedFilesDialog(project, untrackedFiles, dialogDesc);
dialog.setTitle(title);
dialog.show();
}
}
}
});
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class ImportMavenRepositoriesTask method performTask.
private void performTask() {
if (myProject.isDisposed())
return;
if (ApplicationManager.getApplication().isUnitTestMode())
return;
final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
final List<PsiFile> psiFileList = ContainerUtil.newArrayList();
final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
for (Module module : moduleManager.getModules()) {
if (!ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, module))
continue;
final String modulePath = ExternalSystemApiUtil.getExternalProjectPath(module);
if (modulePath == null)
continue;
String buildScript = FileUtil.findFileInProvidedPath(modulePath, GradleConstants.DEFAULT_SCRIPT_NAME);
if (StringUtil.isEmpty(buildScript))
continue;
VirtualFile virtualFile = localFileSystem.refreshAndFindFileByPath(buildScript);
if (virtualFile == null)
continue;
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
if (psiFile == null)
continue;
psiFileList.add(psiFile);
}
final PsiFile[] psiFiles = ArrayUtil.toObjectArray(psiFileList, PsiFile.class);
final Set<MavenRemoteRepository> mavenRemoteRepositories = new ReadAction<Set<MavenRemoteRepository>>() {
@Override
protected void run(@NotNull Result<Set<MavenRemoteRepository>> result) throws Throwable {
Set<MavenRemoteRepository> myRemoteRepositories = ContainerUtil.newHashSet();
for (PsiFile psiFile : psiFiles) {
List<GrClosableBlock> repositoriesBlocks = ContainerUtil.newArrayList();
repositoriesBlocks.addAll(findClosableBlocks(psiFile, "repositories"));
for (GrClosableBlock closableBlock : findClosableBlocks(psiFile, "buildscript", "subprojects", "allprojects", "project", "configure")) {
repositoriesBlocks.addAll(findClosableBlocks(closableBlock, "repositories"));
}
for (GrClosableBlock repositoriesBlock : repositoriesBlocks) {
myRemoteRepositories.addAll(findMavenRemoteRepositories(repositoriesBlock));
}
}
result.setResult(myRemoteRepositories);
}
}.execute().getResultObject();
if (mavenRemoteRepositories == null || mavenRemoteRepositories.isEmpty())
return;
// register imported maven repository URLs but do not force to download the index
// the index can be downloaded and/or updated later using Maven Configuration UI (Settings -> Build, Execution, Deployment -> Build tools -> Maven -> Repositories)
MavenRepositoriesHolder.getInstance(myProject).update(mavenRemoteRepositories);
MavenProjectIndicesManager.getInstance(myProject).scheduleUpdateIndicesList(indexes -> {
if (myProject.isDisposed())
return;
final List<String> repositoriesWithEmptyIndex = ContainerUtil.mapNotNull(indexes, index -> index.getUpdateTimestamp() == -1 && MavenRepositoriesHolder.getInstance(myProject).contains(index.getRepositoryPathOrUrl()) ? index.getRepositoryPathOrUrl() : null);
if (!repositoriesWithEmptyIndex.isEmpty()) {
final NotificationData notificationData = new NotificationData(GradleBundle.message("gradle.integrations.maven.notification.not_updated_repository.title"), "\n<br>" + GradleBundle.message("gradle.integrations.maven.notification.not_updated_repository.text", StringUtil.join(repositoriesWithEmptyIndex, "<br>")), NotificationCategory.WARNING, NotificationSource.PROJECT_SYNC);
notificationData.setBalloonNotification(true);
notificationData.setBalloonGroup(UNINDEXED_MAVEN_REPOSITORIES_NOTIFICATION_GROUP);
notificationData.setListener("#open", new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, MavenRepositoriesConfigurable.class);
}
});
notificationData.setListener("#disable", new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
final int result = Messages.showYesNoDialog(myProject, "Notification will be disabled for all projects.\n\n" + "Settings | Appearance & Behavior | Notifications | " + UNINDEXED_MAVEN_REPOSITORIES_NOTIFICATION_GROUP + "\ncan be used to configure the notification.", "Unindexed Maven Repositories Gradle Detection", "Disable Notification", CommonBundle.getCancelButtonText(), Messages.getWarningIcon());
if (result == Messages.YES) {
NotificationsConfigurationImpl.getInstanceImpl().changeSettings(UNINDEXED_MAVEN_REPOSITORIES_NOTIFICATION_GROUP, NotificationDisplayType.NONE, false, false);
notification.hideBalloon();
}
}
});
ExternalSystemNotificationManager.getInstance(myProject).showNotification(GradleConstants.SYSTEM_ID, notificationData);
}
});
}
Aggregations