Search in sources :

Example 76 with HyperlinkEvent

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

the class ServicePanelBuilder method addLink.

public HyperlinkLabel addLink(@NotNull String text, @NotNull final URI uri) {
    HyperlinkLabel linkLabel = new HyperlinkLabel(text);
    linkLabel.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            try {
                Desktop.getDesktop().browse(uri);
            } catch (IOException e1) {
            // Don't care
            }
        }
    });
    addComponent(linkLabel);
    return linkLabel;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) IOException(java.io.IOException) HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Example 77 with HyperlinkEvent

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

the class DeveloperServicePanel method addToLinkPanel.

private void addToLinkPanel(@NotNull String text, @NotNull final URI uri) {
    HyperlinkLabel hyperlinkLabel = new HyperlinkLabel(text);
    hyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            try {
                Desktop.getDesktop().browse(uri);
            } catch (IOException ex) {
            // Don't care
            }
        }
    });
    // apart using invisible rigid areas instead.
    if (myLinksPanel.getComponentCount() > 0) {
        myLinksPanel.add(Box.createRigidArea(new Dimension(JBUI.scale(10), 0)));
    }
    myLinksPanel.add(hyperlinkLabel);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) IOException(java.io.IOException) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 78 with HyperlinkEvent

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

the class AndroidCompileUtil method addSourceRoot.

@Nullable
public static SourceFolder addSourceRoot(final ModifiableRootModel model, @NotNull final VirtualFile root) {
    ContentEntry contentEntry = findContentEntryForRoot(model, root);
    if (contentEntry == null) {
        final Project project = model.getProject();
        final String message = "Cannot mark directory '" + FileUtil.toSystemDependentName(root.getPath()) + "' as source root, because it is not located under content root of module '" + model.getModule().getName() + "'\n<a href='fix'>Open Project Structure</a>";
        final Notification notification = new Notification(AndroidBundle.message("android.autogeneration.notification.group"), "Autogeneration Error", message, NotificationType.ERROR, new NotificationListener.Adapter() {

            @Override
            protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
                notification.expire();
                final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(project);
                ShowSettingsUtil.getInstance().editConfigurable(project, configurable, new Runnable() {

                    @Override
                    public void run() {
                        final Module module = model.getModule();
                        final AndroidFacet facet = AndroidFacet.getInstance(module);
                        if (facet != null) {
                            configurable.select(facet, true);
                        }
                    }
                });
            }
        });
        Notifications.Bus.notify(notification, project);
        LOG.debug(message);
        return null;
    } else {
        return contentEntry.addSourceFolder(root, JavaSourceRootType.SOURCE, JpsJavaExtensionService.getInstance().createSourceRootProperties("", true));
    }
}
Also used : Project(com.intellij.openapi.project.Project) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Module(com.intellij.openapi.module.Module) Notification(com.intellij.notification.Notification) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotificationListener(com.intellij.notification.NotificationListener) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) Nullable(org.jetbrains.annotations.Nullable)

Example 79 with HyperlinkEvent

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

the class HaxmAlert method refresh.

private void refresh() {
    if (myImageDescription == null) {
        setVisible(false);
        return;
    }
    boolean hasLink = false;
    StringBuilder warningTextBuilder = new StringBuilder();
    AccelerationErrorCode accelerationError = getAccelerationState(false);
    if (accelerationError != AccelerationErrorCode.ALREADY_INSTALLED) {
        hasLink = true;
        warningTextBuilder.append(accelerationError.getProblem());
        warningTextBuilder.append("<br>");
        myErrorInstructionsLink.setHyperlinkText(accelerationError.getSolution().getDescription());
        if (myErrorLinkListener != null) {
            myErrorInstructionsLink.removeHyperlinkListener(myErrorLinkListener);
        }
        Runnable refresh = new Runnable() {

            @Override
            public void run() {
                refresh();
            }
        };
        final Runnable action = AccelerationErrorSolution.getActionForFix(accelerationError, null, refresh, null);
        myErrorLinkListener = new HyperlinkAdapter() {

            @Override
            protected void hyperlinkActivated(HyperlinkEvent e) {
                action.run();
            }
        };
        myErrorInstructionsLink.addHyperlinkListener(myErrorLinkListener);
        myErrorInstructionsLink.setToolTipText(accelerationError.getSolution() != NONE ? accelerationError.getSolutionMessage() : null);
    }
    if (myImageDescription.getVersion().getApiLevel() < SdkVersionInfo.LOWEST_ACTIVE_API) {
        if (warningTextBuilder.length() > 0) {
            warningTextBuilder.append("<br>");
        }
        warningTextBuilder.append("This API Level is Deprecated<br>");
    }
    Abi abi = Abi.getEnum(myImageDescription.getAbiType());
    if (abi != Abi.X86 && abi != Abi.X86_64) {
        if (warningTextBuilder.length() > 0) {
            warningTextBuilder.append("<br>");
        }
        warningTextBuilder.append("Consider using an x86 system image on a x86 host for better emulation performance.<br>");
    }
    if (!TAGS_WITH_GOOGLE_API.contains(myImageDescription.getTag())) {
        if (warningTextBuilder.length() > 0) {
            warningTextBuilder.append("<br>");
        }
        warningTextBuilder.append("Consider using a system image with Google APIs to enable testing with Google Play Services.");
    }
    String warningText = warningTextBuilder.toString();
    if (!warningText.isEmpty()) {
        warningTextBuilder.insert(0, "<html>");
        warningTextBuilder.append("</html>");
        myWarningMessage.setText(warningTextBuilder.toString().replaceAll("\n", "<br>"));
        setVisible(true);
        myErrorInstructionsLink.setVisible(hasLink);
    } else {
        setVisible(false);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) Abi(com.android.sdklib.devices.Abi) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 80 with HyperlinkEvent

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

the class IdeSdksConfigurable method createNdkDownloadLink.

private void createNdkDownloadLink() {
    myNdkDownloadHyperlinkLabel = new HyperlinkLabel();
    myNdkDownloadHyperlinkLabel.setHyperlinkText("", "Download", " Android NDK.");
    myNdkDownloadHyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            if (validateAndroidSdkPath() != null) {
                Messages.showErrorDialog(getContentPanel(), "Please select a valid SDK before downloading the NDK.");
                return;
            }
            List<String> requested = ImmutableList.of(FD_NDK);
            ModelWizardDialog dialog = createDialogForPaths(myWholePanel, requested, false);
            if (dialog != null && dialog.showAndGet()) {
                File ndk = IdeSdks.getInstance().getAndroidNdkPath();
                if (ndk != null) {
                    myNdkLocationTextField.setText(ndk.getPath());
                }
                validateState();
            }
        }
    });
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) 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) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) 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