Search in sources :

Example 6 with HyperlinkAdapter

use of com.intellij.ui.HyperlinkAdapter 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 7 with HyperlinkAdapter

use of com.intellij.ui.HyperlinkAdapter 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 8 with HyperlinkAdapter

use of com.intellij.ui.HyperlinkAdapter 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)

Example 9 with HyperlinkAdapter

use of com.intellij.ui.HyperlinkAdapter in project intellij-plugins by JetBrains.

the class FlexBaseRunner method checkDebuggerFromSdk4.

private static void checkDebuggerFromSdk4(final Project project, final RunProfile runProfile, final FlashRunnerParameters params, final FlexBuildConfiguration bc) {
    final Sdk sdk = bc.getSdk();
    assert sdk != null;
    final Sdk sdkForDebugger = FlexDebugProcess.getDebuggerSdk(params.getDebuggerSdkRaw(), sdk);
    if (!FlexSdkUtils.isAirSdkWithoutFlex(sdk) && StringUtil.compareVersionNumbers(sdkForDebugger.getVersionString(), "4") < 0) {
        final HyperlinkListener listener = new HyperlinkAdapter() {

            @Override
            protected void hyperlinkActivated(final HyperlinkEvent e) {
                if ("RunConfiguration".equals(e.getDescription())) {
                    for (RunnerAndConfigurationSettings configuration : RunManager.getInstance(project).getConfigurationSettingsList(((RunConfiguration) runProfile).getType())) {
                        if (configuration.getConfiguration() == runProfile) {
                            RunDialog.editConfiguration(project, configuration, FlexBundle.message("edit.configuration.title"));
                            break;
                        }
                    }
                }
            }
        };
        final String message = FlexBundle.message("flex.sdk.3.mac.debug.problem", sdkForDebugger.getVersionString());
        ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.DEBUG, MessageType.WARNING, message, null, listener);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) Sdk(com.intellij.openapi.projectRoots.Sdk) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 10 with HyperlinkAdapter

use of com.intellij.ui.HyperlinkAdapter in project android by JetBrains.

the class FormFactorSdkControls method init.

/**
   * @param state The ScopedStateStore in which to store our selections
   * @param downloadSuccess A Runnable that will be run if any valid items were found for this form factor.
   * @param downloadFailed A Runnable that will be run if no valid items were found for this form factor.
   */
public void init(final ScopedStateStore state, final Runnable loadComplete) {
    myBinder.register(myInclusionKey, myInclusionCheckBox);
    myHelpMeChooseLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            Integer minApiLevel = state.get(getMinApiLevelKey(MOBILE));
            ChooseApiLevelDialog chooseApiLevelDialog = new ChooseApiLevelDialog(null, minApiLevel == null ? 0 : minApiLevel);
            Disposer.register(myDisposable, chooseApiLevelDialog.getDisposable());
            if (chooseApiLevelDialog.showAndGet()) {
                int selectedApiLevel = chooseApiLevelDialog.getSelectedApiLevel();
                ScopedDataBinder.setSelectedItem(myMinSdkCombobox, Integer.toString(selectedApiLevel));
            }
        }
    });
    // (that is, Mobile).
    if (myStatsPanel.isVisible()) {
        myBinder.register(API_FEEDBACK_KEY, myHelpMeChooseLabel2, new ScopedDataBinder.ComponentBinding<String, JBLabel>() {

            @Override
            public void setValue(@Nullable String newValue, @NotNull JBLabel label) {
                final JBLabel referenceLabel = label;
                final String referenceString = newValue;
                ApplicationManager.getApplication().invokeLater(() -> referenceLabel.setText(referenceString));
            }
        });
        myBinder.registerValueDeriver(API_FEEDBACK_KEY, new ScopedDataBinder.ValueDeriver<String>() {

            @Nullable
            @Override
            public Set<ScopedStateStore.Key<?>> getTriggerKeys() {
                return makeSetOf(getTargetComboBoxKey(MOBILE));
            }

            @Nullable
            @Override
            public String deriveValue(@NotNull ScopedStateStore state, ScopedStateStore.Key changedKey, @Nullable String currentValue) {
                FormFactorApiComboBox.AndroidTargetComboBoxItem selectedItem = state.get(getTargetComboBoxKey(MOBILE));
                String name = Integer.toString(selectedItem == null ? 0 : selectedItem.getApiLevel());
                if (selectedItem != null && selectedItem.target != null) {
                    name = selectedItem.target.getVersion().getApiString();
                }
                return getApiHelpText(selectedItem == null || !myStatsPanel.isVisible() ? 0 : selectedItem.getApiLevel(), name);
            }
        });
    }
    myMinSdkCombobox.init(myFormFactor, myMinApi, loadComplete, () -> {
        myInclusionCheckBox.setEnabled(true);
        myLabel.setEnabled(true);
        myMinSdkCombobox.setEnabled(true);
    }, () -> {
        myInclusionCheckBox.setSelected(false);
        myNotAvailableLabel.setVisible(true);
    });
    myMinSdkCombobox.registerWith(myBinder);
    myMinSdkCombobox.loadSavedApi();
    if (myStatsPanel.isVisible()) {
        DistributionService.getInstance().refresh(() -> ApplicationManager.getApplication().invokeLater(() -> {
            ((CardLayout) myStatsPanel.getLayout()).show(myStatsPanel, "stats");
            myBinder.invokeUpdate(getTargetComboBoxKey(MOBILE));
        }), () -> ApplicationManager.getApplication().invokeLater(() -> {
            ((CardLayout) myStatsPanel.getLayout()).show(myStatsPanel, "stats");
            myBinder.invokeUpdate(getTargetComboBoxKey(MOBILE));
            myStatsLoadFailedLabel.setVisible(true);
        }));
    }
    if (myFormFactor.equals(MOBILE) && state.getNotNull(WH_SDK_ENABLED_KEY, false)) {
        myBinder.register(IS_INSTANT_APP_KEY, myInstantAppCheckbox);
        myInstantAppCheckbox.setVisible(true);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) Set(java.util.Set) ScopedStateStore(com.android.tools.idea.wizard.dynamic.ScopedStateStore) JBLabel(com.intellij.ui.components.JBLabel) ScopedDataBinder(com.android.tools.idea.wizard.dynamic.ScopedDataBinder) Nullable(org.jetbrains.annotations.Nullable) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Aggregations

HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)14 HyperlinkEvent (javax.swing.event.HyperlinkEvent)14 HyperlinkLabel (com.intellij.ui.HyperlinkLabel)5 File (java.io.File)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 NotNull (org.jetbrains.annotations.NotNull)3 DataContext (com.intellij.openapi.actionSystem.DataContext)2 FileChooser.chooseFile (com.intellij.openapi.fileChooser.FileChooser.chooseFile)2 Project (com.intellij.openapi.project.Project)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 HyperlinkListener (javax.swing.event.HyperlinkListener)2 Abi (com.android.sdklib.devices.Abi)1 InstallComponentsPath (com.android.tools.idea.welcome.wizard.InstallComponentsPath)1 DialogWrapperHost (com.android.tools.idea.wizard.dynamic.DialogWrapperHost)1 DynamicWizard (com.android.tools.idea.wizard.dynamic.DynamicWizard)1 DynamicWizardHost (com.android.tools.idea.wizard.dynamic.DynamicWizardHost)1 ScopedDataBinder (com.android.tools.idea.wizard.dynamic.ScopedDataBinder)1 ScopedStateStore (com.android.tools.idea.wizard.dynamic.ScopedStateStore)1 SingleStepPath (com.android.tools.idea.wizard.dynamic.SingleStepPath)1