List of usage examples for com.intellij.openapi.ui Messages getInformationIcon
@NotNull public static Icon getInformationIcon()
From source file:org.ballerinalang.plugins.idea.completion.AutoImportInsertHandler.java
License:Open Source License
@Override public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item) { ApplicationManager.getApplication().invokeLater(() -> { CommandProcessor.getInstance().runUndoTransparentAction(() -> { PsiElement element = item.getPsiElement(); if (element == null || !(element instanceof PsiDirectory)) { return; }//www .j av a2s.c o m Editor editor = context.getEditor(); Project project = editor.getProject(); if (suggestAlias) { alias = Messages.showInputDialog(project, "Package '" + ((PsiDirectory) element).getName() + "' already imported. Please enter an alias:", "Enter Alias", Messages.getInformationIcon()); if (alias == null || alias.isEmpty()) { Messages.showErrorDialog("Alias cannot be null or empty.", "Error"); return; } } // Import the package. autoImport(context, element, alias); if (project == null) { return; } if (!isCompletionCharAtSpace(editor)) { if (suggestAlias) { // InsertHandler inserts the old package name. So we need to change it to the new alias. PsiFile file = context.getFile(); PsiElement currentPackageName = file.findElementAt(context.getStartOffset()); if (currentPackageName != null) { if (alias == null || alias.isEmpty()) { return; } ApplicationManager.getApplication().runWriteAction(() -> { // Add a new identifier node. PsiElement identifier = BallerinaElementFactory.createIdentifier(project, alias); currentPackageName.getParent().addBefore(identifier, currentPackageName); // Delete the current identifier node. currentPackageName.delete(); }); } } if (myTriggerAutoPopup) { ApplicationManager.getApplication().runWriteAction(() -> { PsiDocumentManager.getInstance(project) .doPostponedOperationsAndUnblockDocument(editor.getDocument()); EditorModificationUtil.insertStringAtCaret(editor, ":"); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); }); } } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + 1); } // Invoke the popup. if (myTriggerAutoPopup) { // We need to invoke the popup with a delay. Otherwise it might not show. ApplicationManager.getApplication().invokeLater( () -> AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)); } }); }); }
From source file:org.evosuite.intellij.IntelliJNotifier.java
License:Open Source License
@Override public void success(final String message) { SwingUtilities.invokeLater(new Runnable() { @Override//from w w w.j a va 2 s . c om public void run() { Messages.showMessageDialog(project, message, title, Messages.getInformationIcon()); } }); }
From source file:org.intellij.plugins.xpathView.XPathEvalAction.java
License:Apache License
private boolean evaluateExpression(EvalExpressionDialog.Context context, XmlElement contextNode, Editor editor, Config cfg) {/* www .ja va 2s . c om*/ final Project project = editor.getProject(); try { final XPathSupport support = XPathSupport.getInstance(); final XPath xpath = support.createXPath((XmlFile) contextNode.getContainingFile(), context.input.expression, context.input.namespaces); xpath.setVariableContext(new CachedVariableContext(context.input.variables, xpath, contextNode)); // evaluate the expression on the whole document final Object result = xpath.evaluate(contextNode); LOG.debug("result = " + result); LOG.assertTrue(result != null, "null result?"); if (result instanceof List<?>) { final List<?> list = (List<?>) result; if (!list.isEmpty()) { if (cfg.HIGHLIGHT_RESULTS) { highlightResult(contextNode, editor, list); } if (cfg.SHOW_USAGE_VIEW) { showUsageView(editor, xpath, contextNode, list); } if (!cfg.SHOW_USAGE_VIEW && !cfg.HIGHLIGHT_RESULTS) { final String s = StringUtil.pluralize("match", list.size()); Messages.showInfoMessage(project, "Expression produced " + list.size() + " " + s, "XPath Result"); } } else { return Messages.showOkCancelDialog(project, "Sorry, your expression did not return any result", "XPath Result", "OK", "Edit Expression", Messages.getInformationIcon()) == 1; } } else if (result instanceof String) { Messages.showMessageDialog("'" + result.toString() + "'", "XPath result (String)", Messages.getInformationIcon()); } else if (result instanceof Number) { Messages.showMessageDialog(result.toString(), "XPath result (Number)", Messages.getInformationIcon()); } else if (result instanceof Boolean) { Messages.showMessageDialog(result.toString(), "XPath result (Boolean)", Messages.getInformationIcon()); } else { LOG.error("Unknown XPath result: " + result); } } catch (XPathSyntaxException e) { LOG.debug(e); // TODO: Better layout of the error message with non-fixed size fonts return Messages.showOkCancelDialog(project, e.getMultilineMessage(), "XPath syntax error", "Edit Expression", "Cancel", Messages.getErrorIcon()) == 0; } catch (SAXPathException e) { LOG.debug(e); Messages.showMessageDialog(project, e.getMessage(), "XPath error", Messages.getErrorIcon()); } return false; }
From source file:org.jetbrains.android.exportSignedPackage.ExportSignedPackageWizard.java
License:Apache License
private void createAndAlignApk(final String apkPath) { AndroidPlatform platform = getFacet().getConfiguration().getAndroidPlatform(); assert platform != null; String sdkPath = platform.getSdkData().getLocation(); String zipAlignPath = sdkPath + File.separatorChar + AndroidCommonUtils.toolPath(SdkConstants.FN_ZIPALIGN); File zipalign = new File(zipAlignPath); final boolean runZipAlign = zipalign.isFile(); File destFile = null;//from www .j a va 2s . c om try { destFile = runZipAlign ? FileUtil.createTempFile("android", ".apk") : new File(apkPath); createApk(destFile); } catch (Exception e) { showErrorInDispatchThread(e.getMessage()); } if (destFile == null) return; if (runZipAlign) { File realDestFile = new File(apkPath); final String message = AndroidCommonUtils.executeZipAlign(zipAlignPath, destFile, realDestFile); if (message != null) { showErrorInDispatchThread(message); return; } } ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { String title = AndroidBundle.message("android.export.package.wizard.title"); final Project project = getProject(); final File apkFile = new File(apkPath); final VirtualFile vApkFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(apkFile); if (vApkFile != null) { vApkFile.refresh(true, false); } if (!runZipAlign) { Messages.showWarningDialog(project, AndroidCommonBundle.message("android.artifact.building.cannot.find.zip.align.error"), title); } if (ShowFilePathAction.isSupported()) { if (Messages.showOkCancelDialog(project, AndroidBundle.message("android.export.package.success.message", apkFile.getName()), title, RevealFileAction.getActionName(), IdeBundle.message("action.close"), Messages.getInformationIcon()) == Messages.OK) { ShowFilePathAction.openFile(apkFile); } } else { Messages.showInfoMessage(project, AndroidBundle.message("android.export.package.success.message", apkFile), title); } } }, ModalityState.NON_MODAL); }
From source file:org.jetbrains.idea.devkit.actions.ShowSerializedXmlAction.java
License:Apache License
private static void generateAndShowXml(final Module module, final String className) { final List<URL> urls = new ArrayList<URL>(); final List<String> list = OrderEnumerator.orderEntries(module).recursively().runtimeOnly().getPathsList() .getPathList();/* w ww. j av a 2 s . c o m*/ for (String path : list) { try { urls.add(new File(FileUtil.toSystemIndependentName(path)).toURI().toURL()); } catch (MalformedURLException e1) { LOG.info(e1); } } final Project project = module.getProject(); UrlClassLoader loader = UrlClassLoader.build().urls(urls).parent(XmlSerializer.class.getClassLoader()) .get(); final Class<?> aClass; try { aClass = Class.forName(className, true, loader); } catch (ClassNotFoundException e) { Messages.showErrorDialog(project, "Cannot find class '" + className + "'", CommonBundle.getErrorTitle()); LOG.info(e); return; } final Object o; try { o = new SampleObjectGenerator().createValue(aClass, FList.<Type>emptyList()); } catch (Exception e) { Messages.showErrorDialog(project, "Cannot generate class '" + className + "': " + e.getMessage(), CommonBundle.getErrorTitle()); LOG.info(e); return; } final Element element = XmlSerializer.serialize(o); final String text = JDOMUtil.writeElement(element, "\n"); Messages.showIdeaMessageDialog(project, text, "Serialized XML for '" + className + "'", new String[] { CommonBundle.getOkButtonText() }, 0, Messages.getInformationIcon(), null); }
From source file:org.jetbrains.idea.maven.indices.MavenRepositoriesConfigurable.java
License:Apache License
private void testServiceConnection(String url) { myTestButton.setEnabled(false);/*from w ww .j a v a 2 s. c o m*/ RepositoryAttachHandler.searchRepositories(myProject, Collections.singletonList(url), new Processor<Collection<MavenRepositoryInfo>>() { @Override public boolean process(Collection<MavenRepositoryInfo> infos) { myTestButton.setEnabled(true); if (infos.isEmpty()) { Messages.showMessageDialog("No repositories found", "Service Connection Failed", Messages.getWarningIcon()); } else { final StringBuilder sb = new StringBuilder(); sb.append(infos.size()).append(infos.size() == 1 ? "repository" : " repositories") .append(" found"); //for (MavenRepositoryInfo info : infos) { // sb.append("\n "); // sb.append(info.getId()).append(" (").append(info.getName()).append(")").append(": ").append(info.getUrl()); //} Messages.showMessageDialog(sb.toString(), "Service Connection Successful", Messages.getInformationIcon()); } return true; } }); }
From source file:org.jetbrains.idea.svn.integrate.SvnIntegrateChangesTask.java
License:Apache License
private void afterExecution(final boolean wasCanceled) { if (!myRecentlyUpdatedFiles.isEmpty()) { myResolveWorker.execute(myRecentlyUpdatedFiles); }/*from w w w. j av a 2 s . com*/ final boolean haveConflicts = ResolveWorker.haveUnresolvedConflicts(myRecentlyUpdatedFiles); accomulate(); if ((!myMerger.hasNext()) || haveConflicts || (!myExceptions.isEmpty()) || myAccomulatedFiles.containErrors() || wasCanceled) { initMergeTarget(); if (myAccomulatedFiles.isEmpty() && myExceptions.isEmpty() && (myMergeTarget == null) && (!wasCanceled)) { Messages.showMessageDialog( SvnBundle.message("action.Subversion.integrate.changes.message.files.up.to.date.text"), myTitle, Messages.getInformationIcon()); } else { if (haveConflicts) { final VcsException exception = new VcsException( SvnBundle.message("svn.integrate.changelist.warning.unresolved.conflicts.text")); exception.setIsWarning(true); myExceptions.add(exception); } if (wasCanceled) { final List<String> details = new LinkedList<String>(); details.add("Integration was canceled"); myMerger.getSkipped(new Consumer<String>() { public void consume(String s) { if (!StringUtil.isEmptyOrSpaces(s)) { details.add(s); } } }); final VcsException exception = new VcsException(details); exception.setIsWarning(true); myExceptions.add(exception); } finishActions(wasCanceled); } myMerger.afterProcessing(); } else { stepToNextChangeList(); } }
From source file:org.jetbrains.plugins.ruby.ruby.run.confuguration.tests.ui.TestMethodBrowser.java
License:Apache License
@Override protected String showDialog() { //check script final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(myForm.getTestScriptPath()); if (file == null) { Messages.showMessageDialog(getField(), "set.existing.script.name.message", "cannot.browse.method.dialog.title", Messages.getInformationIcon()); return null; }/*from w w w . j ava2 s.c om*/ //check class name final String classQualifiedName = myForm.getTestQualifiedClassName(); if (classQualifiedName.trim().length() == 0) { Messages.showMessageDialog(getField(), RBundle.message("set.class.name.message"), RBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon()); return null; } final Ref<FileSymbol> fSWrapper = new Ref<FileSymbol>(); final RVirtualClass testClass = RCacheUtil.getClassByNameInScriptInRubyTestMode(classQualifiedName, getProject(), myScope, file, fSWrapper); if (testClass == null) { Messages.showMessageDialog(getField(), RBundle.message("class.does.not.exists.error.message", classQualifiedName), RBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon()); return null; } final TestMethodFilter methodFilter = new TestMethodFilter(testClass); final RMethodList.RMethodProvider methodProvider = new TestMethodProvider(testClass, fSWrapper); final RVirtualMethod psiMethod = RMethodList.showDialog(testClass, methodFilter, methodProvider, getField()); return psiMethod != null ? psiMethod.getName() : null; }
From source file:org.jetbrains.plugins.scala.error.ErrorMessageDialog.java
License:Apache License
public static boolean showInfoMessage(final String message, final String title, final Component parent) { final ErrorMessageDialog dialog = new ErrorMessageDialog(message, title, Messages.getInformationIcon()); dialog.pack();//w ww . j a v a 2s . co m dialog.setLocationRelativeTo(parent); dialog.setVisible(true); return dialog.myIsOk; }
From source file:org.sonarlint.intellij.actions.UpdateAction.java
License:Open Source License
void doUpdate(final Project p, final SonarLintStatus status, final SonarLintConsole console) { SonarQubeRunnerFacade runner = p.getComponent(SonarQubeRunnerFacade.class); try {/*from w ww . j av a2 s.c o m*/ runner.tryUpdate(); } catch (final Exception ex) { console.error("Unable to perform update", ex); showMessage(p, "Unable to update SonarLint: " + ex.getMessage(), Messages.getErrorIcon()); return; } finally { status.stopRun(); } String version = runner.getVersion(); if (version == null) { showMessage(p, "Unable to update SonarLint. Please check logs in SonarLint console.", Messages.getErrorIcon()); } else { showMessage(p, "SonarLint is up to date and running", Messages.getInformationIcon()); } }