Search in sources :

Example 71 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.

the class TaskManagerImpl method notifyAboutConnectionFailure.

private void notifyAboutConnectionFailure(final TaskRepository repository, String details) {
    Notifications.Bus.register(TASKS_NOTIFICATION_GROUP, NotificationDisplayType.BALLOON);
    String content = "<p><a href=\"\">Configure server...</a></p>";
    if (!StringUtil.isEmpty(details)) {
        content = "<p>" + details + "</p>" + content;
    }
    Notifications.Bus.notify(new Notification(TASKS_NOTIFICATION_GROUP, "Cannot connect to " + repository.getUrl(), content, NotificationType.WARNING, new NotificationListener() {

        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            TaskRepositoriesConfigurable configurable = new TaskRepositoriesConfigurable(myProject);
            ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable);
            if (!ArrayUtil.contains(repository, getAllRepositories())) {
                notification.expire();
            }
        }
    }), myProject);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) TaskRepositoriesConfigurable(com.intellij.tasks.config.TaskRepositoriesConfigurable) NotNull(org.jetbrains.annotations.NotNull)

Example 72 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.

the class StudyProjectComponent method projectOpened.

@Override
public void projectOpened() {
    Course course = StudyTaskManager.getInstance(myProject).getCourse();
    // Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside.
    if (StudyUtils.hasJavaFx()) {
        Platform.setImplicitExit(false);
    }
    if (course != null && !course.isAdaptive() && !course.isUpToDate()) {
        final Notification notification = new Notification("Update.course", "Course Updates", "Course is ready to <a href=\"update\">update</a>", NotificationType.INFORMATION, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                FileEditorManagerEx.getInstanceEx(myProject).closeAllFiles();
                ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
                    ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
                    return execCancelable(() -> {
                        updateCourse();
                        return true;
                    });
                }, "Updating Course", true, myProject);
                EduUtils.synchronize();
                course.setUpdated();
            }
        });
        notification.notify(myProject);
    }
    StudyUtils.registerStudyToolWindow(course, myProject);
    StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> ApplicationManager.getApplication().invokeLater((DumbAwareRunnable) () -> ApplicationManager.getApplication().runWriteAction((DumbAwareRunnable) () -> {
        Course course1 = StudyTaskManager.getInstance(myProject).getCourse();
        if (course1 != null) {
            UISettings instance = UISettings.getInstance();
            instance.setHideToolStripes(false);
            instance.fireUISettingsChanged();
            registerShortcuts();
            EduUsagesCollector.projectTypeOpened(course1.isAdaptive() ? EduNames.ADAPTIVE : EduNames.STUDY);
        }
    })));
    myBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
    myBusConnection.subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {

        @Override
        public void globalSchemeChange(EditorColorsScheme scheme) {
            final StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(myProject);
            if (toolWindow != null) {
                toolWindow.updateFonts(myProject);
            }
        }
    });
}
Also used : EditorColorsListener(com.intellij.openapi.editor.colors.EditorColorsListener) HyperlinkEvent(javax.swing.event.HyperlinkEvent) UISettings(com.intellij.ide.ui.UISettings) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) StudyToolWindow(com.jetbrains.edu.learning.ui.StudyToolWindow) StudyProjectGenerator.flushCourse(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator.flushCourse) Notification(com.intellij.notification.Notification) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable) NotificationListener(com.intellij.notification.NotificationListener)

Example 73 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.

the class PythonSdkType method notifyRemoteSdkSkeletonsFail.

public static void notifyRemoteSdkSkeletonsFail(final InvalidSdkException e, @Nullable final Runnable restartAction) {
    NotificationListener notificationListener;
    String notificationMessage;
    if (e.getCause() instanceof VagrantNotStartedException) {
        notificationListener = new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                final PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
                if (manager != null) {
                    try {
                        VagrantNotStartedException cause = (VagrantNotStartedException) e.getCause();
                        manager.runVagrant(cause.getVagrantFolder(), cause.getMachineName());
                    } catch (ExecutionException e1) {
                        throw new RuntimeException(e1);
                    }
                }
                if (restartAction != null) {
                    restartAction.run();
                }
            }
        };
        notificationMessage = e.getMessage() + "\n<a href=\"#\">Launch vagrant and refresh skeletons</a>";
    } else if (ExceptionUtil.causedBy(e, ExceptionFix.class)) {
        //noinspection ThrowableResultOfMethodCallIgnored
        final ExceptionFix fix = ExceptionUtil.findCause(e, ExceptionFix.class);
        notificationListener = new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                fix.apply();
                if (restartAction != null) {
                    restartAction.run();
                }
            }
        };
        notificationMessage = fix.getNotificationMessage(e.getMessage());
    } else {
        notificationListener = null;
        notificationMessage = e.getMessage();
    }
    Notifications.Bus.notify(new Notification(SKELETONS_TOPIC, "Couldn't refresh skeletons for remote interpreter", notificationMessage, NotificationType.WARNING, notificationListener));
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ExecutionException(com.intellij.execution.ExecutionException) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 74 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project android by JetBrains.

the class GradleRenderErrorContributor method reportIssue170841.

private void reportIssue170841(RenderLogger logger, AndroidFacet facet) {
    Map<String, Throwable> brokenClasses = logger.getBrokenClasses();
    if (brokenClasses == null || brokenClasses.isEmpty() || facet == null) {
        return;
    }
    AndroidModuleModel model = AndroidModuleModel.get(facet);
    if (model == null || !model.getFeatures().isLayoutRenderingIssuePresent()) {
        return;
    }
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            FixAndroidGradlePluginVersionHyperlink quickFix = new FixAndroidGradlePluginVersionHyperlink(GradleVersion.parse(GRADLE_PLUGIN_RECOMMENDED_VERSION), null);
            quickFix.executeIfClicked(facet.getModule().getProject(), new HyperlinkEvent(this, HyperlinkEvent.EventType.ACTIVATED, null, quickFix.getUrl()));
        }
    };
    HtmlBuilder builder = new HtmlBuilder();
    HtmlLinkManager linkManager = logger.getLinkManager();
    builder.add("Tip: Either ").addLink("update the Gradle plugin build version to 1.2.3", linkManager.createRunnableLink(runnable)).add(" or later, or downgrade to version 1.1.3, or as a workaround, ");
    builder.beginList().listItem().addLink("", "Build the project", ", then", linkManager.createBuildProjectUrl()).listItem().addLink("", "Gradle Sync the project", ", then", linkManager.createSyncProjectUrl()).listItem().addLink("Manually ", "refresh the layout", " (or restart the IDE)", linkManager.createRefreshRenderUrl()).endList();
    builder.newline();
    GradleVersion modelVersion = model.getModelVersion();
    addIssue().setSeverity(HighlightSeverity.ERROR).setSummary("Using an obsolete version of the Gradle plugin (" + modelVersion + "); " + "this can lead to layouts not rendering correctly.").setHtmlContent(builder).build();
}
Also used : FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HtmlLinkManager(com.android.tools.idea.rendering.HtmlLinkManager) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) HtmlBuilder(com.android.utils.HtmlBuilder) GradleVersion(com.android.ide.common.repository.GradleVersion)

Example 75 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project android by JetBrains.

the class AndroidPropertyFilesUpdater method askUserIfUpdatePropertyFile.

private void askUserIfUpdatePropertyFile(@NotNull Project project, @NotNull Collection<AndroidFacet> facets, @NotNull final Processor<MyResult> callback) {
    final StringBuilder moduleList = new StringBuilder();
    for (AndroidFacet facet : facets) {
        moduleList.append(facet.getModule().getName()).append("<br>");
    }
    myNotification = PROPERTY_FILES_UPDATING_NOTIFICATION.createNotification(AndroidBundle.message("android.update.project.properties.dialog.title"), AndroidBundle.message("android.update.project.properties.dialog.text", moduleList.toString()), NotificationType.INFORMATION, new NotificationListener.Adapter() {

        @Override
        protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            final String desc = event.getDescription();
            if ("once".equals(desc)) {
                callback.process(MyResult.ONCE);
            } else if ("never".equals(desc)) {
                callback.process(MyResult.NEVER);
            } else {
                callback.process(MyResult.ALWAYS);
            }
            notification.expire();
        }
    });
    myNotification.notify(project);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Notification(com.intellij.notification.Notification)

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