Search in sources :

Example 36 with HyperlinkEvent

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

the class IdeSdksConfigurable method createNdkResetLink.

private void createNdkResetLink() {
    myNdkResetHyperlinkLabel = new HyperlinkLabel();
    myNdkResetHyperlinkLabel.setHyperlinkText("", "Select", " default NDK");
    myNdkResetHyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            // known non-null since otherwise we won't show the link
            File androidNdkPath = IdeSdks.getInstance().getAndroidNdkPath();
            assert androidNdkPath != null;
            myNdkLocationTextField.setText(androidNdkPath.getPath());
        }
    });
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) FileChooser.chooseFile(com.intellij.openapi.fileChooser.FileChooser.chooseFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 37 with HyperlinkEvent

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

the class InstallTask method showPrepareCompleteNotification.

private void showPrepareCompleteNotification(@NotNull final Collection<RepoPackage> packages) {
    final NotificationListener notificationListener = new NotificationListener.Adapter() {

        @Override
        protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            if ("install".equals(event.getDescription())) {
                ModelWizardDialog dialogForPaths = SdkQuickfixUtils.createDialogForPackages(null, myInstallRequests, myUninstallRequests, false);
                if (dialogForPaths != null) {
                    dialogForPaths.show();
                }
            }
            notification.expire();
        }
    };
    final NotificationGroup group = new NotificationGroup("SDK Installer", NotificationDisplayType.STICKY_BALLOON, false);
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    final Project[] openProjectsOrNull = openProjects.length == 0 ? new Project[] { null } : openProjects;
    ApplicationManager.getApplication().invokeLater(() -> {
        for (Project p : openProjectsOrNull) {
            String message;
            if (packages.size() == 1) {
                RepoPackage pack = packages.iterator().next();
                PackageOperation op = myRepoManager.getInProgressInstallOperation(pack);
                // op shouldn't be null. But just in case, we assume it's an install.
                String opName = op == null || op instanceof Installer ? "Install" : "Uninstall";
                message = String.format("%1$sation of '%2$s' is ready to continue<br/><a href=\"install\">%1$s Now</a>", opName, pack.getDisplayName());
            } else {
                message = packages.size() + " packages are ready to install or uninstall<br/><a href=\"install\">Continue</a>";
            }
            group.createNotification("SDK Install", message, NotificationType.INFORMATION, notificationListener).notify(p);
        }
    }, // Don't show while we're in a modal context (e.g. sdk manager)
    ModalityState.NON_MODAL, o -> {
        for (RepoPackage pack : packages) {
            PackageOperation installer = myRepoManager.getInProgressInstallOperation(pack);
            if (installer != null && installer.getInstallStatus() == PackageOperation.InstallStatus.PREPARED) {
                return false;
            }
        }
        return true;
    });
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog)

Example 38 with HyperlinkEvent

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

the class NotificationHyperlinkTest method testExecuteIfClickedWhenDescriptionMatchesUrl.

public void testExecuteIfClickedWhenDescriptionMatchesUrl() {
    HyperlinkEvent event = createMock(HyperlinkEvent.class);
    expect(event.getDescription()).andReturn("openFile");
    replay(event);
    assertTrue(myHyperlink.executeIfClicked(myProject, event));
    verify(event);
    assertTrue(myExecuted);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent)

Example 39 with HyperlinkEvent

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

the class NotificationHyperlinkTest method testExecuteIfClickedWhenDescriptionDoesNotMatchUrl.

public void testExecuteIfClickedWhenDescriptionDoesNotMatchUrl() {
    HyperlinkEvent event = createMock(HyperlinkEvent.class);
    expect(event.getDescription()).andReturn("browse");
    replay(event);
    assertFalse(myHyperlink.executeIfClicked(myProject, event));
    verify(event);
    assertFalse(myExecuted);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent)

Example 40 with HyperlinkEvent

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

the class DartProblemsFilterForm method createUIComponents.

private void createUIComponents() {
    myResetFilterHyperlink = new HoverHyperlinkLabel(DartBundle.message("reset.filter"));
    myResetFilterHyperlink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(final HyperlinkEvent e) {
            myListeners.forEach(FilterListener::filtersResetRequested);
        }
    });
}
Also used : HoverHyperlinkLabel(com.intellij.ui.HoverHyperlinkLabel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

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