use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class MavenShowEffectivePom method showUnsupportedNotification.
private static void showUnsupportedNotification(@NotNull final Project project) {
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Unsupported action", "<html>Maven3 required to use Show Effective POM action. \n" + "Please <a href='#'>select Maven3 home directory</a> or use \"Bundled (Maven 3)\"</html>", NotificationType.ERROR, new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
notification.expire();
ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
}
}).notify(project);
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class MavenProjectsManager method showNotificationOrphanMavenProject.
private void showNotificationOrphanMavenProject(final Project project) {
final NotificationSettings notificationSettings = NotificationsConfigurationImpl.getSettings(NON_MANAGED_POM_NOTIFICATION_GROUP_ID);
if (!notificationSettings.isShouldLog() && notificationSettings.getDisplayType().equals(NotificationDisplayType.NONE)) {
return;
}
File baseDir = VfsUtilCore.virtualToIoFile(project.getBaseDir());
File pomXml = new File(baseDir, "pom.xml");
if (pomXml.exists()) {
final VirtualFile file = VfsUtil.findFileByIoFile(pomXml, true);
if (file == null)
return;
showBalloon(ProjectBundle.message("maven.orphan.notification.title"), ProjectBundle.message("maven.orphan.notification.msg", file.getPresentableUrl()), NON_MANAGED_POM_NOTIFICATION_GROUP, NotificationType.INFORMATION, new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
if ("#add".equals(e.getDescription())) {
addManagedFilesOrUnignore(ContainerUtil.list(file));
notification.expire();
} else if ("#disable".equals(e.getDescription())) {
final int result = Messages.showYesNoDialog(myProject, "Notification will be disabled for all projects.\n\n" + "Settings | Appearance & Behavior | Notifications | " + NON_MANAGED_POM_NOTIFICATION_GROUP_ID + "\ncan be used to configure the notification.", "Non-Managed Maven Project Detection", "Disable Notification", CommonBundle.getCancelButtonText(), Messages.getWarningIcon());
if (result == Messages.YES) {
NotificationsConfigurationImpl.getInstanceImpl().changeSettings(NON_MANAGED_POM_NOTIFICATION_GROUP_ID, NotificationDisplayType.NONE, false, false);
notification.expire();
} else {
notification.hideBalloon();
}
}
}
});
}
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class HgVcs method checkVersion.
/**
* Checks Hg version and updates the myVersion variable.
* In the case of nullable or unsupported version reports the problem.
*/
public void checkVersion() {
final String executable = getGlobalSettings().getHgExecutable();
VcsNotifier vcsNotifier = VcsNotifier.getInstance(myProject);
final String SETTINGS_LINK = "settings";
final String UPDATE_LINK = "update";
NotificationListener linkAdapter = new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
if (SETTINGS_LINK.equals(e.getDescription())) {
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, getConfigurable().getDisplayName());
} else if (UPDATE_LINK.equals(e.getDescription())) {
BrowserUtil.browse("http://mercurial.selenic.com");
}
}
};
try {
myVersion = HgVersion.identifyVersion(executable);
//if version is not supported, but have valid hg executable
if (!myVersion.isSupported()) {
LOG.info("Unsupported Hg version: " + myVersion);
String message = String.format("The <a href='" + SETTINGS_LINK + "'>configured</a> version of Hg is not supported: %s.<br/> " + "The minimal supported version is %s. Please <a href='" + UPDATE_LINK + "'>update</a>.", myVersion, HgVersion.MIN);
vcsNotifier.notifyError("Unsupported Hg version", message, linkAdapter);
} else if (myVersion.hasUnsupportedExtensions()) {
String unsupportedExtensionsAsString = myVersion.getUnsupportedExtensions().toString();
LOG.warn("Unsupported Hg extensions: " + unsupportedExtensionsAsString);
String message = String.format("Some hg extensions %s are not found or not supported by your hg version and will be ignored.\n" + "Please, update your hgrc or Mercurial.ini file", unsupportedExtensionsAsString);
vcsNotifier.notifyWarning("Unsupported Hg version", message);
}
} catch (Exception e) {
if (getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
//sometimes not hg application has version command, but we couldn't parse an answer as valid hg,
// so parse(output) throw ParseException, but hg and git executable seems to be valid in this case
final String reason = (e.getCause() != null ? e.getCause() : e).getMessage();
String message = HgVcsMessages.message("hg4idea.unable.to.run.hg", executable);
vcsNotifier.notifyError(message, reason + "<br/> Please check your hg executable path in <a href='" + SETTINGS_LINK + "'> settings </a>", linkAdapter);
}
}
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class GradleStartupActivity method showNotificationForUnlinkedGradleProject.
private static void showNotificationForUnlinkedGradleProject(@NotNull final Project project) {
if (!PropertiesComponent.getInstance(project).getBoolean(SHOW_UNLINKED_GRADLE_POPUP, true) || !GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty() || project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) == Boolean.TRUE || project.getBaseDir() == null) {
return;
}
File baseDir = VfsUtilCore.virtualToIoFile(project.getBaseDir());
final File gradleFile = new File(baseDir, GradleConstants.DEFAULT_SCRIPT_NAME);
if (gradleFile.exists()) {
String message = String.format("%s<br>\n%s", GradleBundle.message("gradle.notifications.unlinked.project.found.msg", IMPORT_EVENT_DESCRIPTION), GradleBundle.message("gradle.notifications.do.not.show"));
GradleNotification.getInstance(project).showBalloon(GradleBundle.message("gradle.notifications.unlinked.project.found.title"), message, NotificationType.INFORMATION, new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
notification.expire();
if (IMPORT_EVENT_DESCRIPTION.equals(e.getDescription())) {
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
GradleProjectImportBuilder gradleProjectImportBuilder = new GradleProjectImportBuilder(projectDataManager);
final GradleProjectImportProvider gradleProjectImportProvider = new GradleProjectImportProvider(gradleProjectImportBuilder);
AddModuleWizard wizard = new AddModuleWizard(project, gradleFile.getPath(), gradleProjectImportProvider);
if ((wizard.getStepCount() <= 0 || wizard.showAndGet())) {
ImportModuleAction.createFromWizard(project, wizard);
}
} else if (DO_NOT_SHOW_EVENT_DESCRIPTION.equals(e.getDescription())) {
PropertiesComponent.getInstance(project).setValue(SHOW_UNLINKED_GRADLE_POPUP, false, true);
}
}
});
}
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class MavenExecuteGoalAction method actionPerformed.
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
ExecuteMavenGoalHistoryService historyService = ExecuteMavenGoalHistoryService.getInstance(project);
MavenExecuteGoalDialog dialog = new MavenExecuteGoalDialog(project, historyService.getHistory());
String lastWorkingDirectory = historyService.getWorkDirectory();
if (lastWorkingDirectory.length() == 0) {
lastWorkingDirectory = obtainAppropriateWorkingDirectory(project);
}
dialog.setWorkDirectory(lastWorkingDirectory);
if (StringUtil.isEmptyOrSpaces(historyService.getCanceledCommand())) {
if (historyService.getHistory().size() > 0) {
dialog.setGoals(historyService.getHistory().get(0));
}
} else {
dialog.setGoals(historyService.getCanceledCommand());
}
if (!dialog.showAndGet()) {
historyService.setCanceledCommand(dialog.getGoals());
return;
}
historyService.setCanceledCommand(null);
String goals = dialog.getGoals();
goals = goals.trim();
if (goals.startsWith("mvn ")) {
goals = goals.substring("mvn ".length()).trim();
}
String workDirectory = dialog.getWorkDirectory();
historyService.addCommand(goals, workDirectory);
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
File mavenHome = MavenUtil.resolveMavenHomeDirectory(projectsManager.getGeneralSettings().getMavenHome());
if (mavenHome == null) {
Notification notification = new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Failed to execute goal", RunnerBundle.message("external.maven.home.no.default.with.fix"), NotificationType.ERROR, new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
}
});
Notifications.Bus.notify(notification, project);
return;
}
MavenRunnerParameters parameters = new MavenRunnerParameters(true, workDirectory, Arrays.asList(ParametersList.parse(goals)), Collections.<String>emptyList());
MavenGeneralSettings generalSettings = new MavenGeneralSettings();
generalSettings.setMavenHome(mavenHome.getPath());
MavenRunnerSettings runnerSettings = MavenRunner.getInstance(project).getSettings().clone();
runnerSettings.setMavenProperties(new LinkedHashMap<>());
runnerSettings.setSkipTests(false);
MavenRunConfigurationType.runConfiguration(project, parameters, generalSettings, runnerSettings, null);
}
Aggregations