List of usage examples for com.intellij.openapi.ui Messages getErrorIcon
@NotNull public static Icon getErrorIcon()
From source file:bazaar4idea.util.BzrErrorReportSubmitter.java
License:Apache License
/** * @noinspection ThrowablePrintStackTrace,ThrowableResultOfMethodCallIgnored *///from w w w. j ava 2s . com private static SubmittedReportInfo sendError(IdeaLoggingEvent event, Component parentComponent) { NotifierBean notifierBean = new NotifierBean(); ErrorBean errorBean = new ErrorBean(); errorBean.autoInit(); // errorBean.setLastAction(IdeaLogger.ourLastActionId); int threadId = 0; SubmittedReportInfo.SubmissionStatus submissionStatus = SubmittedReportInfo.SubmissionStatus.FAILED; final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent); Project project = PlatformDataKeys.PROJECT.getData(dataContext); String description = ""; do { // prepare try { ErrorReportSender sender = ErrorReportSender.getInstance(); // sender.prepareError(project, event.getThrowable()); // BzrSendErrorForm dlg = new BzrSendErrorForm(); dlg.setErrorDescription(description); dlg.show(); BzrErrorReportConfigurable reportConf = BzrErrorReportConfigurable.getInstance(); @NonNls String senderEmail = reportConf.EMAIL_ADDRESS; @NonNls String smtpServer = reportConf.SMTP_SERVER; @NonNls String itnLogin = reportConf.AUTH_USERNAME; @NonNls String itnPassword = reportConf.getPlainItnPassword(); notifierBean.setEmailAddress(senderEmail); notifierBean.setSmtpServer(smtpServer); notifierBean.setItnLogin(itnLogin); notifierBean.setItnPassword(itnPassword); // description = dlg.getErrorDescription(); String message = event.getMessage(); // @NonNls StringBuilder descBuilder = new StringBuilder(); if (description.length() > 0) { descBuilder.append("User description: ").append(description).append("\n"); } if (message != null) { descBuilder.append("Error message: ").append(message).append("\n"); } Throwable t = event.getThrowable(); if (t != null) { // final PluginId pluginId = IdeErrorsDialog.findPluginId(t); // if (pluginId != null) { // final IdeaPluginDescriptor ideaPluginDescriptor = ApplicationManager.getApplication().getPlugin(pluginId); // if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) { // descBuilder.append("Plugin version: ").append(ideaPluginDescriptor.getVersion()).append("\n"); // } // } } if (previousExceptionThreadId != 0) { descBuilder.append("Previous exception is: ").append(URL_HEADER) .append(previousExceptionThreadId).append("\n"); } if (wasException) { descBuilder.append("There was at least one exception before this one.\n"); } errorBean.setDescription(descBuilder.toString()); if (dlg.isShouldSend()) { threadId = sender.sendError(notifierBean, errorBean); previousExceptionThreadId = threadId; wasException = true; submissionStatus = SubmittedReportInfo.SubmissionStatus.NEW_ISSUE; Messages.showInfoMessage(parentComponent, BzrBundle.message("error.report.confirmation"), ERROR_REPORT); break; } else { break; } // } catch (NoSuchEAPUserException e) { // if (Messages.showYesNoDialog(parentComponent, DiagnosticBundle.message("error.report.authentication.failed"), // ReportMessages.ERROR_REPORT, Messages.getErrorIcon()) != 0) { // break; // } // } catch (InternalEAPException e) { // if (Messages.showYesNoDialog(parentComponent, DiagnosticBundle.message("error.report.posting.failed", e.getMessage()), // ReportMessages.ERROR_REPORT, Messages.getErrorIcon()) != 0) { // break; // } // } catch (IOException e) { // if (!IOExceptionDialog.showErrorDialog(BzrVcsMessages.message("error.report.exception.title"), // BzrVcsMessages.message("error.report.failure.message"))) { // break; // } // } catch (NewBuildException e) { // Messages.showMessageDialog(parentComponent, // DiagnosticBundle.message("error.report.new.eap.build.message", e.getMessage()), CommonBundle.getWarningTitle(), // Messages.getWarningIcon()); // break; } catch (Exception e) { LOG.info(e); if (Messages.showYesNoDialog(JOptionPane.getRootFrame(), BzrBundle.message("error.report.sending.failure"), ERROR_REPORT, Messages.getErrorIcon()) != 0) { break; } } } while (true); return new SubmittedReportInfo( submissionStatus != SubmittedReportInfo.SubmissionStatus.FAILED ? URL_HEADER + threadId : null, String.valueOf(threadId), submissionStatus); }
From source file:com.android.tools.idea.actions.AndroidInferNullityAnnotationAction.java
License:Apache License
protected boolean checkModules(@NotNull Project project, @NotNull AnalysisScope scope, @NotNull Map<Module, PsiFile> modules) { Set<Module> modulesWithoutAnnotations = new HashSet<>(); Set<Module> modulesWithLowVersion = new HashSet<>(); for (Module module : modules.keySet()) { AndroidModuleInfo info = AndroidModuleInfo.get(module); if (info != null && info.getBuildSdkVersion() != null && info.getBuildSdkVersion().getFeatureLevel() < MIN_SDK_WITH_NULLABLE) { modulesWithLowVersion.add(module); }//from ww w.j av a 2 s.c o m GradleBuildModel buildModel = GradleBuildModel.get(module); if (buildModel == null) { LOG.warn("Unable to find Gradle build model for module " + module.getModuleFilePath()); continue; } boolean dependencyFound = false; DependenciesModel dependenciesModel = buildModel.dependencies(); if (dependenciesModel != null) { for (ArtifactDependencyModel dependency : dependenciesModel.artifacts(COMPILE)) { String notation = dependency.compactNotation().value(); if (notation.startsWith(SdkConstants.APPCOMPAT_LIB_ARTIFACT) || notation.startsWith(SdkConstants.SUPPORT_LIB_ARTIFACT) || notation.startsWith(SdkConstants.ANNOTATIONS_LIB_ARTIFACT)) { dependencyFound = true; break; } } } if (!dependencyFound) { modulesWithoutAnnotations.add(module); } } if (!modulesWithLowVersion.isEmpty()) { Messages.showErrorDialog(project, String.format( "Infer Nullity Annotations requires the project sdk level be set to %1$d or greater.", MIN_SDK_WITH_NULLABLE), "Infer Nullity Annotations"); return false; } if (modulesWithoutAnnotations.isEmpty()) { return true; } String moduleNames = StringUtil.join(modulesWithoutAnnotations, Module::getName, ", "); int count = modulesWithoutAnnotations.size(); String message = String.format( "The %1$s %2$s %3$sn't refer to the existing '%4$s' library with Android nullity annotations. \n\n" + "Would you like to add the %5$s now?", pluralize("module", count), moduleNames, count > 1 ? "do" : "does", SupportLibrary.SUPPORT_ANNOTATIONS.getArtifactId(), pluralize("dependency", count)); if (Messages.showOkCancelDialog(project, message, "Infer Nullity Annotations", Messages.getErrorIcon()) == Messages.OK) { LocalHistoryAction action = LocalHistory.getInstance().startAction(ADD_DEPENDENCY); try { new WriteCommandAction(project, ADD_DEPENDENCY) { @Override protected void run(@NotNull Result result) throws Throwable { RepositoryUrlManager manager = RepositoryUrlManager.get(); String annotationsLibraryCoordinate = manager .getLibraryStringCoordinate(SupportLibrary.SUPPORT_ANNOTATIONS, true); for (Module module : modulesWithoutAnnotations) { addDependency(module, annotationsLibraryCoordinate); } GradleSyncInvoker.Request request = new GradleSyncInvoker.Request() .setGenerateSourcesOnSuccess(false); GradleSyncInvoker.getInstance().requestProjectSync(project, request, new GradleSyncListener.Adapter() { @Override public void syncSucceeded(@NotNull Project project) { restartAnalysis(project, scope); } }); } }.execute(); } finally { action.finish(); } } return false; }
From source file:com.android.tools.idea.actions.annotations.InferSupportAnnotationsAction.java
License:Apache License
protected boolean checkModules(@NotNull Project project, @NotNull AnalysisScope scope, @NotNull Map<Module, PsiFile> modules) { Set<Module> modulesWithoutAnnotations = new HashSet<>(); Set<Module> modulesWithLowVersion = new HashSet<>(); for (Module module : modules.keySet()) { AndroidModuleInfo info = AndroidModuleInfo.get(module); if (info != null && info.getBuildSdkVersion() != null && info.getBuildSdkVersion().getFeatureLevel() < MIN_SDK_WITH_NULLABLE) { modulesWithLowVersion.add(module); }//from w w w . j a v a2s. c o m GradleBuildModel buildModel = GradleBuildModel.get(module); if (buildModel == null) { Logger.getInstance(InferSupportAnnotationsAction.class) .warn("Unable to find Gradle build model for module " + module.getModuleFilePath()); continue; } boolean dependencyFound = false; DependenciesModel dependenciesModel = buildModel.dependencies(); if (dependenciesModel != null) { for (ArtifactDependencyModel dependency : dependenciesModel.artifacts(COMPILE)) { String notation = dependency.compactNotation().value(); if (notation.startsWith(SdkConstants.APPCOMPAT_LIB_ARTIFACT) || notation.startsWith(SdkConstants.SUPPORT_LIB_ARTIFACT) || notation.startsWith(SdkConstants.ANNOTATIONS_LIB_ARTIFACT)) { dependencyFound = true; break; } } } if (!dependencyFound) { modulesWithoutAnnotations.add(module); } } if (!modulesWithLowVersion.isEmpty()) { Messages.showErrorDialog(project, String.format( "Infer Support Annotations requires the project sdk level be set to %1$d or greater.", MIN_SDK_WITH_NULLABLE), "Infer Support Annotations"); return false; } if (modulesWithoutAnnotations.isEmpty()) { return true; } String moduleNames = StringUtil.join(modulesWithoutAnnotations, Module::getName, ", "); int count = modulesWithoutAnnotations.size(); String message = String.format( "The %1$s %2$s %3$sn't refer to the existing '%4$s' library with Android nullity annotations. \n\n" + "Would you like to add the %5$s now?", pluralize("module", count), moduleNames, count > 1 ? "do" : "does", SupportLibrary.SUPPORT_ANNOTATIONS.getArtifactId(), pluralize("dependency", count)); if (Messages.showOkCancelDialog(project, message, "Infer Nullity Annotations", Messages.getErrorIcon()) == Messages.OK) { LocalHistoryAction action = LocalHistory.getInstance().startAction(ADD_DEPENDENCY); try { new WriteCommandAction(project, ADD_DEPENDENCY) { @Override protected void run(@NotNull Result result) throws Throwable { RepositoryUrlManager manager = RepositoryUrlManager.get(); String annotationsLibraryCoordinate = manager .getLibraryStringCoordinate(SupportLibrary.SUPPORT_ANNOTATIONS, true); for (Module module : modulesWithoutAnnotations) { addDependency(module, annotationsLibraryCoordinate); } GradleSyncInvoker.Request request = new GradleSyncInvoker.Request() .setGenerateSourcesOnSuccess(false); GradleSyncInvoker.getInstance().requestProjectSync(project, request, new GradleSyncListener.Adapter() { @Override public void syncSucceeded(@NotNull Project project) { restartAnalysis(project, scope); } }); } }.execute(); } finally { action.finish(); } } return false; }
From source file:com.android.tools.idea.debug.BitmapPopupEvaluator.java
License:Apache License
@Override protected JComponent createComponent(BufferedImage image) { if (image == null) { String message = myError == null ? "Unexpected error while obtaining image" : myError; return new JLabel(message, Messages.getErrorIcon(), SwingConstants.CENTER); } else {/*from www. ja v a2 s .co m*/ return ImageEditorManagerImpl.createImageEditorUI(image); } }
From source file:com.android.tools.idea.editors.hprof.views.ViewBitmapAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { ClassInstance selectedClassInstance = e.getData(InstancesTreeView.SELECTED_CLASS_INSTANCE); if (selectedClassInstance == null) { return;/*from w w w . ja v a2 s . c o m*/ } try { BufferedImage img = BitmapDecoder.getBitmap(new HprofBitmapProvider(selectedClassInstance)); final JComponent comp; if (img != null) { comp = ImageEditorManagerImpl.createImageEditorUI(img); } else { String errorMessage = AndroidBundle.message("android.profiler.hprof.actions.view.bitmap.fail"); comp = new JLabel(errorMessage, Messages.getErrorIcon(), SwingConstants.CENTER); } Project project = e.getData(CommonDataKeys.PROJECT); JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null); JFrame frame = WindowManager.getInstance().getFrame(project); Dimension frameSize = frame.getSize(); Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2); popup.setSize(size); popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2))); } catch (Exception ignored) { } }
From source file:com.android.tools.idea.gradle.dependencies.GradleDependencyManager.java
License:Apache License
private static boolean userWantToAddDependencies(@NotNull Module module, @NotNull Collection<GradleCoordinate> missing) { String libraryNames = StringUtil.join(missing, GradleCoordinate::getArtifactId, ", "); String message = String.format( "This operation requires the %1$s %2$s. \n\nWould you like to add %3$s %1$s now?", pluralize("library", missing.size()), libraryNames, pluralize("this", missing.size())); Project project = module.getProject(); return Messages.showOkCancelDialog(project, message, "Add Project Dependency", Messages.getErrorIcon()) == Messages.OK; }
From source file:com.android.tools.idea.startup.AndroidStudioInitializer.java
License:Apache License
private static void checkInstallation() { String studioHome = PathManager.getHomePath(); if (isEmpty(studioHome)) { LOG.info("Unable to find Studio home directory"); return;// www . j ava2s.c om } File studioHomePath = new File(toSystemDependentName(studioHome)); if (!studioHomePath.isDirectory()) { LOG.info(String.format("The path '%1$s' does not belong to an existing directory", studioHomePath.getPath())); return; } File androidPluginLibFolderPath = new File(studioHomePath, join("plugins", "android", "lib")); if (!androidPluginLibFolderPath.isDirectory()) { LOG.info(String.format("The path '%1$s' does not belong to an existing directory", androidPluginLibFolderPath.getPath())); return; } // Look for signs that the installation is corrupt due to improper updates (typically unzipping on top of previous install) // which doesn't delete files that have been removed or renamed String cause = null; File[] children = notNullize(androidPluginLibFolderPath.listFiles()); if (hasMoreThanOneBuilderModelFile(children)) { cause = "(Found multiple versions of builder-model-*.jar in plugins/android/lib.)"; } else if (new File(studioHomePath, join("plugins", "android-designer")).exists()) { cause = "(Found plugins/android-designer which should not be present.)"; } if (cause != null) { String msg = "Your Android Studio installation is corrupt and will not work properly.\n" + cause + "\n" + "This usually happens if Android Studio is extracted into an existing older version.\n\n" + "Please reinstall (and make sure the new installation directory is empty first.)"; String title = "Corrupt Installation"; int option = Messages.showDialog(msg, title, new String[] { "Quit", "Proceed Anyway" }, 0, Messages.getErrorIcon()); if (option == 0) { ApplicationManagerEx.getApplicationEx().exit(); } } }
From source file:com.android.tools.idea.welcome.install.CheckSdkOperation.java
License:Apache License
private static boolean retryPrompt() { int button = Messages.showOkCancelDialog(MESSAGE_CANT_RUN_TOOL, "Android Studio", "Retry", "Cancel", Messages.getErrorIcon()); return button == Messages.OK; }
From source file:com.android.tools.idea.welcome.install.InstallOperation.java
License:Apache License
/** * Shows a retry prompt. Throws an exception to stop the setup process if the user preses cancel or returns normally otherwise. *///from w w w. ja v a 2s . c om protected final void promptToRetry(@NotNull final String prompt, @NotNull String failureDescription, @Nullable Exception e) throws WizardException { final AtomicBoolean response = new AtomicBoolean(false); Application application = ApplicationManager.getApplication(); application.invokeAndWait(new Runnable() { @Override public void run() { int i = Messages.showYesNoDialog(null, prompt, "Android Studio Setup", "Retry", "Cancel", Messages.getErrorIcon()); response.set(i == Messages.YES); } }, application.getAnyModalityState()); if (!response.get()) { Throwables.propagateIfInstanceOf(e, WizardException.class); throw new WizardException(failureDescription, e); } else { myContext.print(failureDescription + "\n", ConsoleViewContentType.ERROR_OUTPUT); } }
From source file:com.android.tools.idea.welcome.wizard.AndroidStudioWelcomeScreenProvider.java
License:Apache License
@Nullable private static ConnectionState promptUserForProxy() { int selection = Messages.showIdeaMessageDialog(null, "Unable to access Android SDK add-on list", "Android Studio First Run", new String[] { "Setup Proxy", "Cancel" }, 1, Messages.getErrorIcon(), null);/*from w w w. java 2 s. c o m*/ if (selection == 0) { //noinspection ConstantConditions HttpConfigurable.editConfigurable(null); return null; } else { return ConnectionState.NO_CONNECTION; } }