Search in sources :

Example 11 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)

Example 12 with HyperlinkAdapter

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

the class AbstractDependencyScopesPanel method createInstructionsPane.

@NotNull
protected JEditorPane createInstructionsPane(@NotNull String instructions) {
    JEditorPane instructionsPane = new JEditorPane();
    setUpAsHtmlLabel(instructionsPane, getTreeFont());
    instructionsPane.setText("<html><body><b>Step 2.</b><br/>" + instructions + "</body></html>");
    instructionsPane.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            browse(e.getURL());
        }
    });
    instructionsPane.setBorder(createEmptyBorder(0, 5, 8, 5));
    return instructionsPane;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with HyperlinkAdapter

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

the class SdkUpdaterConfigPanel method setUpSingleSdkChooser.

private void setUpSingleSdkChooser() {
    myEditSdkLink.setHyperlinkText("Edit");
    myEditSdkLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final DynamicWizardHost host = new DialogWrapperHost(null);
            DynamicWizard wizard = new DynamicWizard(null, null, "SDK Setup", host) {

                @Override
                public void init() {
                    DownloadingComponentsStep progressStep = new DownloadingComponentsStep(myHost.getDisposable(), myHost);
                    String sdkPath = mySdkLocationTextField.getText();
                    File location;
                    if (StringUtil.isEmpty(sdkPath)) {
                        location = FirstRunWizardDefaults.getInitialSdkLocation(FirstRunWizardMode.MISSING_SDK);
                    } else {
                        location = new File(sdkPath);
                    }
                    InstallComponentsPath path = new InstallComponentsPath(FirstRunWizardMode.MISSING_SDK, location, progressStep, false);
                    progressStep.setInstallComponentsPath(path);
                    addPath(path);
                    addPath(new SingleStepPath(progressStep));
                    super.init();
                }

                @Override
                public void performFinishingActions() {
                    File sdkLocation = IdeSdks.getInstance().getAndroidSdkPath();
                    if (sdkLocation == null) {
                        return;
                    }
                    String stateSdkLocationPath = myState.get(WizardConstants.KEY_SDK_INSTALL_LOCATION);
                    assert stateSdkLocationPath != null;
                    File stateSdkLocation = new File(stateSdkLocationPath);
                    if (!FileUtil.filesEqual(sdkLocation, stateSdkLocation)) {
                        setAndroidSdkLocation(stateSdkLocation);
                        sdkLocation = stateSdkLocation;
                    }
                    mySelectedSdkLocation.setValue(sdkLocation);
                }

                @NotNull
                @Override
                protected String getProgressTitle() {
                    return "Setting up SDK...";
                }

                @Override
                protected String getWizardActionDescription() {
                    return "Setting up SDK...";
                }
            };
            wizard.init();
            wizard.show();
        }
    });
    mySdkLocationTextField.setEditable(false);
}
Also used : DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) SingleStepPath(com.android.tools.idea.wizard.dynamic.SingleStepPath) HyperlinkEvent(javax.swing.event.HyperlinkEvent) InstallComponentsPath(com.android.tools.idea.welcome.wizard.InstallComponentsPath) DialogWrapperHost(com.android.tools.idea.wizard.dynamic.DialogWrapperHost) DynamicWizardHost(com.android.tools.idea.wizard.dynamic.DynamicWizardHost) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 14 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)

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