Search in sources :

Example 66 with HyperlinkEvent

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);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification)

Example 67 with HyperlinkEvent

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();
                    }
                }
            }
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotificationSettings(com.intellij.notification.impl.NotificationSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 68 with HyperlinkEvent

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);
        }
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 69 with HyperlinkEvent

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);
                }
            }
        });
    }
}
Also used : GradleProjectImportProvider(org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ProjectDataManager(com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager) GradleProjectImportBuilder(org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) File(java.io.File) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 70 with HyperlinkEvent

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);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) Notification(com.intellij.notification.Notification) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Project(com.intellij.openapi.project.Project) MavenGeneralSettings(org.jetbrains.idea.maven.project.MavenGeneralSettings) File(java.io.File) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

HyperlinkEvent (javax.swing.event.HyperlinkEvent)90 NotNull (org.jetbrains.annotations.NotNull)36 Notification (com.intellij.notification.Notification)33 NotificationListener (com.intellij.notification.NotificationListener)31 HyperlinkListener (javax.swing.event.HyperlinkListener)30 Project (com.intellij.openapi.project.Project)14 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)14 File (java.io.File)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 HyperlinkLabel (com.intellij.ui.HyperlinkLabel)9 IOException (java.io.IOException)7 URL (java.net.URL)5 AnAction (com.intellij.openapi.actionSystem.AnAction)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 IdeFrame (com.intellij.openapi.wm.IdeFrame)3 MultiMap (com.intellij.util.containers.MultiMap)3 NonNls (org.jetbrains.annotations.NonNls)3 Nullable (org.jetbrains.annotations.Nullable)3 UISettings (com.intellij.ide.ui.UISettings)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2