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);
}
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);
}
}
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();
}
}
});
}
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);
}
}
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);
}
}
Aggregations