Search in sources :

Example 81 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent 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 82 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent 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 83 with HyperlinkEvent

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

the class AndroidFrameworkDetector method showDexOptionNotification.

@NotNull
public static Notification showDexOptionNotification(@NotNull Module module, @NotNull String propertyName) {
    Project project = module.getProject();
    Notification notification = ANDROID_MODULE_IMPORTING_NOTIFICATION.createNotification(AndroidBundle.message("android.facet.importing.title", module.getName()), "'" + propertyName + "' property is detected in " + SdkConstants.FN_PROJECT_PROPERTIES + " file.<br>You may enable related option in <a href='configure'>Settings | Compiler | Android DX</a>", NotificationType.INFORMATION, new NotificationListener.Adapter() {

        @Override
        protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            notification.expire();
            ShowSettingsUtil.getInstance().showSettingsDialog(project, AndroidBundle.message("android.dex.compiler.configurable.display.name"));
        }
    });
    notification.notify(project);
    return notification;
}
Also used : Project(com.intellij.openapi.project.Project) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener) NotNull(org.jetbrains.annotations.NotNull)

Example 84 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent 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 85 with HyperlinkEvent

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

the class ValidateFlashConfigurationsPrecompileTask method suggestParallelCompilationIfNeeded.

private void suggestParallelCompilationIfNeeded(final Project project, final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile) {
    if (myParallelCompilationSuggested)
        return;
    if (CompilerWorkspaceConfiguration.getInstance(project).PARALLEL_COMPILATION)
        return;
    if (modulesAndBCsToCompile.size() < 2)
        return;
    if (!independentBCsExist(modulesAndBCsToCompile))
        return;
    final NotificationListener listener = new NotificationListener() {

        public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
            notification.expire();
            if ("enable".equals(event.getDescription())) {
                CompilerWorkspaceConfiguration.getInstance(project).PARALLEL_COMPILATION = true;
                final NotificationListener listener1 = new NotificationListener() {

                    public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
                        notification.expire();
                        ShowSettingsUtil.getInstance().showSettingsDialog(project, CompilerBundle.message("compiler.configurable.display.name"));
                    }
                };
                new Notification(FLASH_COMPILER_GROUP_ID, FlexBundle.message("parallel.compilation.enabled"), FlexBundle.message("see.settings.compiler"), NotificationType.INFORMATION, listener1).notify(project);
            } else if ("open".equals(event.getDescription())) {
                ShowSettingsUtil.getInstance().showSettingsDialog(project, CompilerBundle.message("compiler.configurable.display.name"));
            }
        }
    };
    new Notification(FLASH_COMPILER_GROUP_ID, FlexBundle.message("parallel.compilation.hint.title"), FlexBundle.message("parallel.compilation.hint"), NotificationType.INFORMATION, listener).notify(project);
    myParallelCompilationSuggested = true;
}
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