use of javax.swing.event.HyperlinkEvent 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 javax.swing.event.HyperlinkEvent 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 javax.swing.event.HyperlinkEvent 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);
}
});
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class ConfigurationErrorEvent method process.
@Override
public void process(@NotNull final TestEventXmlView xml) throws TestEventXmlView.XmlParserException {
final String errorTitle = xml.getEventTitle();
final String configurationErrorMsg = xml.getEventMessage();
final boolean openSettings = xml.isEventOpenSettings();
final Project project = getProject();
assert project != null;
final String message = openSettings ? String.format("<br>\n%s<br><br>\n\n<a href=\"Gradle settings\">Open gradle settings</a>", configurationErrorMsg) : String.format("<br>\n%s", configurationErrorMsg);
GradleNotification.getInstance(project).showBalloon(errorTitle, message, NotificationType.WARNING, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
notification.expire();
if ("Gradle settings".equals(event.getDescription())) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
assert manager instanceof GradleManager;
GradleManager gradleManager = (GradleManager) manager;
Configurable configurable = gradleManager.getConfigurable(project);
ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
} else {
BrowserUtil.browse(event.getDescription());
}
}
});
}
use of javax.swing.event.HyperlinkEvent in project ChatGameFontificator by GlitchCog.
the class ControlWindow method constructAboutPopup.
/**
* Construct the popup dialog containing the About message
*/
private void constructAboutPopup() {
aboutPane = new JEditorPane("text/html", ABOUT_CONTENTS);
aboutPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (EventType.ACTIVATED.equals(e.getEventType())) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(URI.create("https://" + e.getDescription()));
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
});
aboutPane.setEditable(false);
}
Aggregations