Search in sources :

Example 41 with HyperlinkEvent

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

the class JstdServerStatusView method installLinkHandler.

private static void installLinkHandler(@NotNull JEditorPane pane) {
    final Ref<String> urlRef = Ref.create(null);
    pane.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
                urlRef.set(null);
            } else if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                urlRef.set(e.getDescription());
            } else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                BrowserUtil.browse(e.getDescription());
            }
        }
    });
    final CopyLinkAction copyLinkAction = new CopyLinkAction();
    final OpenLinkInBrowser openLinkInBrowserAction = new OpenLinkInBrowser();
    final DefaultActionGroup group = new DefaultActionGroup(openLinkInBrowserAction, copyLinkAction);
    pane.addMouseListener(new PopupHandler() {

        public void invokePopup(Component comp, int x, int y) {
            String url = urlRef.get();
            copyLinkAction.setUrl(url);
            openLinkInBrowserAction.setUrl(url);
            if (url != null) {
                ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
                popupMenu.getComponent().show(comp, x, y);
            }
        }
    });
}
Also used : PopupHandler(com.intellij.ui.PopupHandler) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener)

Example 42 with HyperlinkEvent

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

the class FlexmojosImporter method doShowFlexConfigWarning.

private synchronized void doShowFlexConfigWarning(final Project project) {
    final NotificationListener listener = new NotificationListener() {

        public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
            Messages.showWarningDialog(project, FlexBundle.message("flexmojos.warning.detailed"), FlexBundle.message("flexmojos.project.import"));
            notification.expire();
        }
    };
    myFlexConfigNotification = new Notification("Maven", FlexBundle.message("flexmojos.project.import"), FlexBundle.message("flexmojos.warning.short"), NotificationType.WARNING, listener);
    myFlexConfigNotification.notify(project);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 43 with HyperlinkEvent

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

the class Flexmojos4GenerateConfigTask method showWarningWithDetails.

private static void showWarningWithDetails(final Project project, final String details) {
    final NotificationListener listener = new NotificationListener.Adapter() {

        @Override
        protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
            Messages.showErrorDialog(project, FlexBundle.message("flexmojos4.details.start", details), FlexBundle.message("flexmojos.project.import"));
            notification.expire();
        }
    };
    new Notification("Maven", FlexBundle.message("flexmojos.project.import"), FlexBundle.message("flexmojos4.warning.with.link"), NotificationType.WARNING, listener).notify(project);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) MavenRootModelAdapter(org.jetbrains.idea.maven.importing.MavenRootModelAdapter) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 44 with HyperlinkEvent

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

the class FlexRunner method launchFlexConfig.

protected RunContentDescriptor launchFlexConfig(final Module module, final FlexBuildConfiguration bc, final FlashRunnerParameters runnerParameters, final RunProfileState state, final RunContentDescriptor contentToReuse, final ExecutionEnvironment environment) throws ExecutionException {
    switch(bc.getTargetPlatform()) {
        case Web:
            final String urlOrPath = runnerParameters.isLaunchUrl() ? runnerParameters.getUrl() : bc.isUseHtmlWrapper() ? PathUtil.getParentPath(bc.getActualOutputFilePath()) + "/" + BCUtils.getWrapperFileName(bc) : bc.getActualOutputFilePath();
            launchWithSelectedApplication(urlOrPath, runnerParameters.getLauncherParameters());
            break;
        case Desktop:
            return standardLaunch(module.getProject(), state, contentToReuse, environment);
        case Mobile:
            switch(runnerParameters.getMobileRunTarget()) {
                case Emulator:
                    return standardLaunch(module.getProject(), state, contentToReuse, environment);
                case AndroidDevice:
                    final String androidDescriptorPath = getAirDescriptorPath(bc, bc.getAndroidPackagingOptions());
                    final String androidAppId = getApplicationId(androidDescriptorPath);
                    if (androidAppId == null) {
                        Messages.showErrorDialog(module.getProject(), FlexBundle.message("failed.to.read.app.id", FileUtil.toSystemDependentName(androidDescriptorPath)), FlexBundle.message("error.title"));
                        return null;
                    }
                    if (packAndInstallToAndroidDevice(module, bc, runnerParameters, androidAppId, false)) {
                        launchOnAndroidDevice(module.getProject(), bc.getSdk(), runnerParameters.getDeviceInfo(), androidAppId, false);
                    }
                    return null;
                case iOSSimulator:
                    final String adtVersionSimulator = AirPackageUtil.getAdtVersion(module.getProject(), bc.getSdk());
                    final String iosSimulatorDescriptorPath = getAirDescriptorPath(bc, bc.getIosPackagingOptions());
                    final String iosSimulatorAppId = getApplicationId(iosSimulatorDescriptorPath);
                    if (iosSimulatorAppId == null) {
                        Messages.showErrorDialog(module.getProject(), FlexBundle.message("failed.to.read.app.id", FileUtil.toSystemDependentName(iosSimulatorDescriptorPath)), FlexBundle.message("error.title"));
                        return null;
                    }
                    if (packAndInstallToIOSSimulator(module, bc, runnerParameters, adtVersionSimulator, iosSimulatorAppId, false)) {
                        launchOnIosSimulator(module.getProject(), bc.getSdk(), iosSimulatorAppId, runnerParameters.getIOSSimulatorSdkPath(), false);
                    }
                    return null;
                case iOSDevice:
                    final String adtVersion = AirPackageUtil.getAdtVersion(module.getProject(), bc.getSdk());
                    if (StringUtil.compareVersionNumbers(adtVersion, "3.4") >= 0) {
                        if (packAndInstallToIOSDevice(module, bc, runnerParameters, adtVersion, false)) {
                            final String appName = getApplicationName(getAirDescriptorPath(bc, bc.getIosPackagingOptions()));
                            ToolWindowManager.getInstance(module.getProject()).notifyByBalloon(ToolWindowId.RUN, MessageType.INFO, FlexBundle.message("ios.application.installed.to.run", appName));
                        }
                    } else {
                        if (AirPackageUtil.packageIpaForDevice(module, bc, runnerParameters, adtVersion, false)) {
                            final String outputFolder = PathUtil.getParentPath(bc.getActualOutputFilePath());
                            final String ipaName = bc.getIosPackagingOptions().getPackageFileName() + ".ipa";
                            final String message = FlexBundle.message("ios.application.packaged.to.run", ipaName);
                            ToolWindowManager.getInstance(module.getProject()).notifyByBalloon(ToolWindowId.RUN, MessageType.INFO, message, null, new HyperlinkAdapter() {

                                protected void hyperlinkActivated(final HyperlinkEvent e) {
                                    ShowFilePathAction.openFile(new File(outputFolder + "/" + ipaName));
                                }
                            });
                        }
                    }
                    break;
            }
            break;
    }
    return null;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) File(java.io.File) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 45 with HyperlinkEvent

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

the class DesignerApplicationManager method notifyUser.

static void notifyUser(boolean debug, @NotNull String text, @NotNull Project project, @Nullable final Consumer<String> handler) {
    Notification notification = new Notification(FlashUIDesignerBundle.message("plugin.name"), getOpenActionTitle(debug), text, NotificationType.ERROR, handler == null ? null : new NotificationListener() {

        @Override
        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
                return;
            }
            notification.expire();
            if ("help".equals(event.getDescription())) {
                HelpManager.getInstance().invokeHelp("flex.ui.designer.launch");
            } else {
                handler.consume(event.getDescription());
            }
        }
    });
    notification.notify(project);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) 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