List of usage examples for com.intellij.openapi.ui Messages getInformationIcon
@NotNull public static Icon getInformationIcon()
From source file:com.intellij.application.options.ExportSchemeAction.java
License:Apache License
public static <T extends Named, E extends ExternalizableScheme> void doExport(final E scheme, SchemesManager<T, E> manager) { if (scheme != null) { try {/*from www . j a v a2 s . c om*/ ShareSchemeDialog dialog = new ShareSchemeDialog(); dialog.init(scheme); dialog.show(); if (dialog.isOK()) { try { manager.exportScheme(scheme, dialog.getName(), dialog.getDescription()); Messages.showMessageDialog("Scheme '" + scheme.getName() + "' was shared successfully as '" + dialog.getName() + " '", "Share Scheme", Messages.getInformationIcon()); } catch (IOException e) { Messages.showErrorDialog( "Cannot share scheme '" + scheme.getName() + "': " + e.getLocalizedMessage(), "Share Shceme"); } } } catch (WriteExternalException e1) { Messages.showErrorDialog("Cannot share scheme: " + e1.getLocalizedMessage(), "Share Scheme"); } } }
From source file:com.intellij.codeInsight.daemon.impl.analysis.AddSchemaPrefixIntention.java
License:Apache License
@Override public void invoke(@Nonnull Project project, Editor editor, @Nonnull PsiElement element) throws IncorrectOperationException { final XmlAttribute xmlns = getXmlnsDeclaration(element); if (xmlns == null) { return;/* w w w. j a va2s . co m*/ } final String namespace = xmlns.getValue(); final XmlTag tag = xmlns.getParent(); if (tag != null) { final Set<String> ns = tag.getLocalNamespaceDeclarations().keySet(); final String nsPrefix = Messages.showInputDialog(project, "Namespace Prefix:", NAME, Messages.getInformationIcon(), "", new InputValidator() { @RequiredDispatchThread @Override public boolean checkInput(String inputString) { return !ns.contains(inputString); } @RequiredDispatchThread @Override public boolean canClose(String inputString) { return checkInput(inputString); } }); if (nsPrefix == null) { return; } final List<XmlTag> tags = new ArrayList<XmlTag>(); final List<XmlAttributeValue> values = new ArrayList<XmlAttributeValue>(); new WriteCommandAction(project, NAME, tag.getContainingFile()) { @Override protected void run(Result result) throws Throwable { tag.accept(new XmlRecursiveElementVisitor() { @Override public void visitXmlTag(XmlTag tag) { if (tag.getNamespace().equals(namespace) && tag.getNamespacePrefix().length() == 0) { tags.add(tag); } super.visitXmlTag(tag); } @Override public void visitXmlAttributeValue(XmlAttributeValue value) { PsiReference ref = null; boolean skip = false; for (PsiReference reference : value.getReferences()) { if (reference instanceof TypeOrElementOrAttributeReference) { ref = reference; } else if (reference instanceof SchemaPrefixReference) { skip = true; break; } } if (!skip && ref != null) { final PsiElement xmlElement = ref.resolve(); if (xmlElement instanceof XmlElement) { final XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false); if (tag != null) { if (tag.getNamespace().equals(namespace)) { if (ref.getRangeInElement().getLength() == value.getValue().length()) { //no ns prefix values.add(value); } } } } } } }); for (XmlAttributeValue value : values) { ((XmlAttribute) value.getParent()).setValue(nsPrefix + ":" + value.getValue()); } for (XmlTag xmlTag : tags) { xmlTag.setName(nsPrefix + ":" + xmlTag.getLocalName()); } xmlns.setName("xmlns:" + nsPrefix); } }.execute(); } }
From source file:com.intellij.codeInsight.intention.impl.ImplementAbstractMethodHandler.java
License:Apache License
public void invoke() { PsiDocumentManager.getInstance(myProject).commitAllDocuments(); final PsiElement[][] result = new PsiElement[1][]; ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override//w w w .j av a2s . c o m public void run() { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { final PsiClass psiClass = myMethod.getContainingClass(); if (!psiClass.isValid()) return; if (!psiClass.isEnum()) { result[0] = getClassImplementations(psiClass); } else { final List<PsiElement> enumConstants = new ArrayList<PsiElement>(); for (PsiField field : psiClass.getFields()) { if (field instanceof PsiEnumConstant) { final PsiEnumConstantInitializer initializingClass = ((PsiEnumConstant) field) .getInitializingClass(); if (initializingClass != null) { PsiMethod method = initializingClass.findMethodBySignature(myMethod, true); if (method == null || !method.getContainingClass().equals(initializingClass)) { enumConstants.add(initializingClass); } } else { enumConstants.add(field); } } } result[0] = PsiUtilCore.toPsiElementArray(enumConstants); } } }); } }, CodeInsightBundle.message("intention.implement.abstract.method.searching.for.descendants.progress"), true, myProject); if (result[0] == null) return; if (result[0].length == 0) { Messages.showMessageDialog(myProject, CodeInsightBundle.message("intention.implement.abstract.method.error.no.classes.message"), CodeInsightBundle.message("intention.implement.abstract.method.error.no.classes.title"), Messages.getInformationIcon()); return; } if (result[0].length == 1) { implementInClass(new Object[] { result[0][0] }); return; } final MyPsiElementListCellRenderer elementListCellRenderer = new MyPsiElementListCellRenderer(); elementListCellRenderer.sort(result[0]); myList = new JBList(result[0]); myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); final Runnable runnable = new Runnable() { @Override public void run() { int index = myList.getSelectedIndex(); if (index < 0) return; implementInClass(myList.getSelectedValues()); } }; myList.setCellRenderer(elementListCellRenderer); final PopupChooserBuilder builder = new PopupChooserBuilder(myList); elementListCellRenderer.installSpeedSearch(builder); builder.setTitle(CodeInsightBundle.message("intention.implement.abstract.method.class.chooser.title")) .setItemChoosenCallback(runnable).createPopup().showInBestPositionFor(myEditor); }
From source file:com.intellij.debugger.actions.InspectAction.java
License:Apache License
private boolean canInspect(ValueDescriptorImpl descriptor, DebuggerContextImpl context) { DebuggerSession session = context.getDebuggerSession(); if (session == null || !session.isPaused()) return false; boolean isField = descriptor instanceof FieldDescriptorImpl; if (descriptor instanceof WatchItemDescriptor) { Modifier modifier = ((WatchItemDescriptor) descriptor).getModifier(); if (modifier == null || !modifier.canInspect()) return false; isField = modifier instanceof Field; }/* ww w . j a v a 2 s .co m*/ if (isField) { // check if possible if (!context.getDebugProcess().canWatchFieldModification()) { Messages.showMessageDialog(context.getProject(), DebuggerBundle.message("error.modification.watchpoints.not.supported"), ActionsBundle.actionText(DebuggerActions.INSPECT), Messages.getInformationIcon()); return false; } } return true; }
From source file:com.intellij.execution.MethodBrowser.java
License:Apache License
protected String showDialog() { final String className = getClassName(); if (className.trim().length() == 0) { Messages.showMessageDialog(getField(), ExecutionBundle.message("set.class.name.message"), ExecutionBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon()); return null; }//w w w . j a v a 2 s. c om final PsiClass testClass = getModuleSelector().findClass(className); if (testClass == null) { Messages.showMessageDialog(getField(), ExecutionBundle.message("class.does.not.exists.error.message", className), ExecutionBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon()); return null; } final MethodListDlg dlg = new MethodListDlg(testClass, getFilter(testClass), getField()); if (dlg.showAndGet()) { final PsiMethod method = dlg.getSelected(); if (method != null) { return method.getName(); } } return null; }
From source file:com.intellij.find.findUsages.FindUsagesManager.java
License:Apache License
private boolean findUsageInFile(@NotNull FileEditor editor, @NotNull FileSearchScope direction) { ApplicationManager.getApplication().assertIsDispatchThread(); if (myLastSearchInFileData == null) return false; PsiElement[] primaryElements = myLastSearchInFileData.getPrimaryElements(); PsiElement[] secondaryElements = myLastSearchInFileData.getSecondaryElements(); if (primaryElements.length == 0) {//all elements have been invalidated Messages.showMessageDialog(myProject, FindBundle.message("find.searched.elements.have.been.changed.error"), FindBundle.message("cannot.search.for.usages.title"), Messages.getInformationIcon()); // SCR #10022 //clearFindingNextUsageInFile(); return false; }/*from ww w. j a v a 2s .c o m*/ //todo TextEditor textEditor = (TextEditor) editor; Document document = textEditor.getEditor().getDocument(); PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document); if (psiFile == null) return false; final FindUsagesHandler handler = getFindUsagesHandler(primaryElements[0], false); if (handler == null) return false; findUsagesInEditor(primaryElements, secondaryElements, handler, psiFile, direction, myLastSearchInFileData.myOptions, textEditor); return true; }
From source file:com.intellij.ide.actions.ShowFilePathAction.java
License:Apache License
public static void showDialog(Project project, String message, String title, File file, DialogWrapper.DoNotAskOption option) { if (Messages.showOkCancelDialog(project, message, title, RevealFileAction.getActionName(), IdeBundle.message("action.close"), Messages.getInformationIcon(), option) == Messages.OK) { openFile(file);//from ww w . ja va 2 s . c o m } }
From source file:com.intellij.ide.favoritesTreeView.actions.AddNewFavoritesListAction.java
License:Apache License
public static String doAddNewFavoritesList(final Project project) { final FavoritesManager favoritesManager = FavoritesManager.getInstance(project); final String name = Messages.showInputDialog(project, IdeBundle.message("prompt.input.new.favorites.list.name"), IdeBundle.message("title.add.new.favorites.list"), Messages.getInformationIcon(), getUniqueName(project), new InputValidator() { @Override/*from w w w . ja va 2 s . c o m*/ public boolean checkInput(String inputString) { return inputString != null && inputString.trim().length() > 0; } @Override public boolean canClose(String inputString) { inputString = inputString.trim(); if (favoritesManager.getAvailableFavoritesListNames().contains(inputString)) { Messages.showErrorDialog(project, IdeBundle.message("error.favorites.list.already.exists", inputString.trim()), IdeBundle.message("title.unable.to.add.favorites.list")); return false; } return inputString.length() > 0; } }); if (name == null || name.length() == 0) return null; favoritesManager.createNewList(name); return name; }
From source file:com.intellij.ide.favoritesTreeView.FavoritesManager.java
License:Apache License
public void renameList(final Project project, @NotNull String listName) { final String newName = Messages.showInputDialog(project, IdeBundle.message("prompt.input.favorites.list.new.name", listName), IdeBundle.message("title.rename.favorites.list"), Messages.getInformationIcon(), listName, new InputValidator() { @Override// ww w .ja v a 2 s . c o m public boolean checkInput(String inputString) { return inputString != null && inputString.trim().length() > 0; } @Override public boolean canClose(String inputString) { inputString = inputString.trim(); if (myName2FavoritesRoots.keySet().contains(inputString) || myProviders.keySet().contains(inputString)) { Messages.showErrorDialog(project, IdeBundle.message("error.favorites.list.already.exists", inputString.trim()), IdeBundle.message("title.unable.to.add.favorites.list")); return false; } return !inputString.isEmpty(); } }); if (newName != null && renameFavoritesList(listName, newName)) { rootsChanged(); } }
From source file:com.intellij.ide.ui.customization.CustomizableActionsPanel.java
License:Apache License
private void editToolbarIcon(String actionId, DefaultMutableTreeNode node) { final AnAction anAction = ActionManager.getInstance().getAction(actionId); if (isToolbarAction(node) && anAction.getTemplatePresentation() != null && anAction.getTemplatePresentation().getIcon() == null) { final int exitCode = Messages.showOkCancelDialog( IdeBundle.message("error.adding.action.without.icon.to.toolbar"), IdeBundle.message("title.unable.to.add.action.without.icon.to.toolbar"), Messages.getInformationIcon()); if (exitCode == Messages.OK) { mySelectedSchema.addIconCustomization(actionId, null); anAction.getTemplatePresentation().setIcon(AllIcons.Toolbar.Unknown); anAction.setDefaultIcon(false); node.setUserObject(Pair.create(actionId, AllIcons.Toolbar.Unknown)); myActionsTree.repaint();/* w w w .ja va 2s . c o m*/ setCustomizationSchemaForCurrentProjects(); } } }