List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon
@NotNull public static Icon getQuestionIcon()
From source file:org.coding.git.util.CodingNetNotifications.java
License:Apache License
@Messages.YesNoResult public static boolean showYesNoDialog(@Nullable Project project, @NotNull String title, @NotNull String message, @NotNull DialogWrapper.DoNotAskOption doNotAskOption) { return Messages.YES == Messages.showYesNoDialog(project, message, title, Messages.getQuestionIcon(), doNotAskOption);//w w w . j a v a2s. com }
From source file:org.codinjutsu.tools.nosql.redis.view.action.SetSeparatorAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent event) { String[] strings = ArrayUtil.toStringArray(myPredefinedSeparators); String current = redisPanel.getGroupSeparator(); String separator = Messages.showEditableChooseDialog("Redis Keys Separator", "Select Separator", Messages.getQuestionIcon(), strings, current, null); if (separator == null) { return;/*from w ww . ja v a 2 s . c o m*/ } if (StringUtils.equals(redisPanel.getGroupSeparator(), separator)) { return; } redisPanel.setGroupSeparator(separator); myPredefinedSeparators.add(separator); update(event); }
From source file:org.community.intellij.plugins.communitycase.actions.Init.java
License:Apache License
/** * {@inheritDoc}//from ww w .j a v a2 s .c om */ public void actionPerformed(final AnActionEvent e) { final Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) { return; } FileChooserDescriptor fcd = new FileChooserDescriptor(false, true, false, false, false, false); fcd.setShowFileSystemRoots(true); fcd.setTitle(Bundle.getString("init.destination.directory.title")); fcd.setDescription(Bundle.getString("init.destination.directory.description")); fcd.setHideIgnored(false); final VirtualFile baseDir = project.getBaseDir(); final VirtualFile[] files = FileChooser.chooseFiles(project, fcd, baseDir); if (files.length == 0) { return; } final VirtualFile root = files[0]; if (Util.isUnder(root)) { final int v = Messages.showYesNoDialog(project, Bundle.message("init.warning.already.under.git", StringUtil.escapeXml(root.getPresentableUrl())), Bundle.getString("init.warning.title"), Messages.getWarningIcon()); if (v != 0) { return; } } LineHandler h = new LineHandler(project, root, Command.INIT); h.setRemote(true); HandlerUtil.doSynchronously(h, Bundle.getString("initializing.title"), h.printableCommandLine()); if (!h.errors().isEmpty()) { UiUtil.showOperationErrors(project, h.errors(), " init"); return; } int rc = Messages.showYesNoDialog(project, Bundle.getString("init.add.root.message"), Bundle.getString("init.add.root.title"), Messages.getQuestionIcon()); if (rc != 0) { return; } final String path = root.equals(baseDir) ? "" : root.getPath(); Vcs.getInstance(project) .runInBackground(new Task.Backgroundable(project, Bundle.getString("common.refreshing")) { public void run(@NotNull ProgressIndicator indicator) { refreshAndConfigureVcsMappings(project, root, path); } }); }
From source file:org.cordovastudio.utils.CordovaStudioUtils.java
License:Apache License
public static void addRunConfiguration(@NotNull final CordovaFacet facet, @Nullable final String activityClass, final boolean ask, @Nullable final TargetSelectionMode targetSelectionMode, @Nullable final String preferredAvdName) { final Module module = facet.getModule(); final Project project = module.getProject(); final Runnable r = new Runnable() { @Override//from w ww . j a v a 2 s . com public void run() { final RunManagerEx runManager = RunManagerEx.getInstanceEx(project); final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(module.getName(), CordovaRunConfigurationType.getInstance().getFactory()); final CordovaRunConfiguration configuration = (CordovaRunConfiguration) settings.getConfiguration(); configuration.setModule(module); if (activityClass != null) { configuration.MODE = CordovaRunConfiguration.LAUNCH_SPECIFIC_ACTIVITY; configuration.ACTIVITY_CLASS = activityClass; } else { configuration.MODE = CordovaRunConfiguration.LAUNCH_DEFAULT_ACTIVITY; } if (targetSelectionMode != null) { configuration.setTargetSelectionMode(targetSelectionMode); } if (preferredAvdName != null) { configuration.PREFERRED_AVD = preferredAvdName; } runManager.addConfiguration(settings, false); runManager.setActiveConfiguration(settings); } }; if (!ask) { r.run(); } else { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { final String moduleName = facet.getModule().getName(); final int result = Messages.showYesNoDialog(project, "Do you want to create run configuration for module " + moduleName + "?", "Create Run Configuration", Messages.getQuestionIcon()); if (result == Messages.YES) { r.run(); } } }); } }
From source file:org.f3.ideaplugin.NewF3ClassAction.java
License:Open Source License
@NotNull protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) { Module module = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project); if (module == null) return PsiElement.EMPTY_ARRAY; MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, "Enter a new class name", "New F3 Class", Messages.getQuestionIcon(), "", validator);/*from www . ja va 2s . c o m*/ return validator.getCreatedElements(); }
From source file:org.intellij.erlang.rebar.importWizard.RebarProjectImportBuilder.java
License:Apache License
@SuppressWarnings("DialogTitleCapitalization") @Override/*from ww w . j a va2 s .c o m*/ public boolean validate(Project current, Project dest) { if (!findIdeaModuleFiles(mySelectedOtpApps)) { return true; } final int resultCode = Messages.showYesNoCancelDialog( ApplicationInfoEx.getInstanceEx().getFullApplicationName() + " module files found:\n\n" + StringUtil.join(mySelectedOtpApps, new Function<ImportedOtpApp, String>() { public String fun(ImportedOtpApp importedOtpApp) { final VirtualFile ideaModuleFile = importedOtpApp.getIdeaModuleFile(); return ideaModuleFile != null ? " " + ideaModuleFile.getPath() + "\n" : ""; } }, "") + "\nWould you like to reuse them?", "Module files found", Messages.getQuestionIcon()); if (resultCode == DialogWrapper.OK_EXIT_CODE) { return true; } else if (resultCode == DialogWrapper.CANCEL_EXIT_CODE) { try { deleteIdeaModuleFiles(mySelectedOtpApps); return true; } catch (IOException e) { LOG.error(e); return false; } } else { return false; } }
From source file:org.intellij.lang.xpath.xslt.refactoring.extractTemplate.XsltExtractTemplateAction.java
License:Apache License
private boolean extractFrom(final @NotNull PsiElement start, final PsiElement end, String newName) { final XmlTag outerTemplate = XsltCodeInsightUtil.getTemplateTag(start, false); if (outerTemplate == null) { return false; }/* w w w . jav a 2 s. com*/ final XmlTag parentScope = PsiTreeUtil.getParentOfType(start, XmlTag.class, true); if (parentScope == null) { return false; } final StringBuilder sb = new StringBuilder("\n"); final Set<String> vars = new LinkedHashSet<String>(); final int startOffset = start.getTextRange().getStartOffset(); final int endOffset = end.getTextRange().getEndOffset(); PsiElement e = start; while (e != null) { if (e instanceof XmlTag) { final XmlTag tag = (XmlTag) e; if (XsltSupport.isVariable(tag)) { final XsltVariable variable = XsltElementFactory.getInstance().wrapElement(tag, XsltVariable.class); final LocalSearchScope searchScope = new LocalSearchScope(parentScope); final Query<PsiReference> query = ReferencesSearch.search(variable, searchScope); for (PsiReference reference : query) { final XmlElement context = PsiTreeUtil.getContextOfType(reference.getElement(), XmlElement.class, true); if (context == null || context.getTextRange().getStartOffset() > endOffset) { return false; } } } } sb.append(e.getText()); final List<XPathVariableReference> references = RefactoringUtil.collectVariableReferences(e); for (XPathVariableReference reference : references) { final XPathVariable variable = reference.resolve(); if (variable instanceof XsltVariable) { final XmlTag var = ((XsltVariable) variable).getTag(); if (var.getTextRange().getStartOffset() < startOffset) { // don't pass through global parameters and variables if (XsltCodeInsightUtil.getTemplateTag(variable, false) != null) { vars.add(variable.getName()); } } } else if (variable == null) { // TODO just copy unresolved refs or fail? vars.add(reference.getReferencedName()); } } if (e == end) { break; } e = e.getNextSibling(); } sb.append("\n"); final String s = newName == null ? Messages.showInputDialog(start.getProject(), "Template Name: ", getRefactoringName(), Messages.getQuestionIcon()) : newName; if (s != null) { new WriteCommandAction(start.getProject()) { protected void run(Result result) throws Throwable { final PsiFile containingFile = start.getContainingFile(); XmlTag templateTag = parentScope.createChildTag("template", XsltSupport.XSLT_NS, sb.toString(), false); templateTag.setAttribute("name", s); final PsiElement dummy = XmlElementFactory.getInstance(start.getProject()) .createDisplayText(" "); final PsiElement outerParent = outerTemplate.getParent(); final PsiElement element = outerParent.addAfter(dummy, outerTemplate); templateTag = (XmlTag) outerParent.addAfter(templateTag, element); final TextRange adjust = templateTag.getTextRange(); final PsiDocumentManager psiDocumentManager = PsiDocumentManager .getInstance(start.getProject()); final Document doc = psiDocumentManager.getDocument(containingFile); assert doc != null; psiDocumentManager.doPostponedOperationsAndUnblockDocument(doc); CodeStyleManager.getInstance(start.getManager().getProject()).adjustLineIndent(containingFile, adjust); final PsiElement parent = start.getParent(); XmlTag callTag = parentScope.createChildTag("call-template", XsltSupport.XSLT_NS, null, false); callTag.setAttribute("name", s); if (start instanceof XmlToken && ((XmlToken) start).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) { assert start == end; callTag = (XmlTag) start.replace(callTag); } else { callTag = (XmlTag) parent.addBefore(callTag, start); parent.deleteChildRange(start, end); } for (String var : vars) { final XmlTag param = templateTag.createChildTag("param", XsltSupport.XSLT_NS, null, false); param.setAttribute("name", var); RefactoringUtil.addParameter(templateTag, param); final XmlTag arg = RefactoringUtil.addWithParam(callTag); arg.setAttribute("name", var); arg.setAttribute("select", "$" + var); } } }.execute().logException(Logger.getInstance(getClass().getName())); } return true; }
From source file:org.intellij.lang.xpath.xslt.refactoring.VariableInlineHandler.java
License:Apache License
public static void invoke(@NotNull final XPathVariable variable, Editor editor) { final String type = LanguageFindUsages.INSTANCE.forLanguage(variable.getLanguage()).getType(variable); final Project project = variable.getProject(); final XmlTag tag = ((XsltElement) variable).getTag(); final String expression = tag.getAttributeValue("select"); if (expression == null) { CommonRefactoringUtil.showErrorHint(project, editor, MessageFormat.format("{0} ''{1}'' has no value.", StringUtil.capitalize(type), variable.getName()), TITLE, null); return;/*w w w. ja va2s . c o m*/ } final Collection<PsiReference> references = ReferencesSearch .search(variable, new LocalSearchScope(tag.getParentTag()), false).findAll(); if (references.size() == 0) { CommonRefactoringUtil.showErrorHint(project, editor, MessageFormat.format("{0} ''{1}'' is never used.", variable.getName()), TITLE, null); return; } boolean hasExternalRefs = false; if (XsltSupport.isTopLevelElement(tag)) { final Query<PsiReference> query = ReferencesSearch.search(variable, GlobalSearchScope.allScope(project), false); hasExternalRefs = !query.forEach(new Processor<PsiReference>() { int allRefs = 0; public boolean process(PsiReference psiReference) { if (++allRefs > references.size()) { return false; } else if (!references.contains(psiReference)) { return false; } return true; } }); } final HighlightManager highlighter = HighlightManager.getInstance(project); final ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>(); final PsiReference[] psiReferences = references.toArray(new PsiReference[references.size()]); TextRange[] ranges = ContainerUtil.map2Array(psiReferences, TextRange.class, new Function<PsiReference, TextRange>() { public TextRange fun(PsiReference s) { final PsiElement psiElement = s.getElement(); final XmlAttributeValue context = PsiTreeUtil.getContextOfType(psiElement, XmlAttributeValue.class, true); if (psiElement instanceof XPathElement && context != null) { return XsltCodeInsightUtil.getRangeInsideHostingFile((XPathElement) psiElement) .cutOut(s.getRangeInElement()); } return psiElement.getTextRange().cutOut(s.getRangeInElement()); } }); final Editor e = editor instanceof EditorWindow ? ((EditorWindow) editor).getDelegate() : editor; for (TextRange range : ranges) { final TextAttributes textAttributes = EditorColors.SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes(); final Color color = getScrollmarkColor(textAttributes); highlighter.addOccurrenceHighlight(e, range.getStartOffset(), range.getEndOffset(), textAttributes, HighlightManagerImpl.HIDE_BY_ESCAPE, highlighters, color); } highlighter.addOccurrenceHighlights(e, new PsiElement[] { ((XsltVariable) variable).getNameIdentifier() }, EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes(), false, highlighters); if (!hasExternalRefs) { if (!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog( MessageFormat.format("Inline {0} ''{1}''? ({2} occurrence{3})", type, variable.getName(), String.valueOf(references.size()), references.size() > 1 ? "s" : ""), TITLE, Messages.getQuestionIcon()) != 0) { return; } } else { if (!ApplicationManager.getApplication().isUnitTestMode() && Messages .showYesNoDialog(MessageFormat.format("Inline {0} ''{1}''? ({2} local occurrence{3})\n" + "\nWarning: It is being used in external files. Its declaration will not be removed.", type, variable.getName(), String.valueOf(references.size()), references.size() > 1 ? "s" : ""), TITLE, Messages.getWarningIcon()) != 0) { return; } } final boolean hasRefs = hasExternalRefs; new WriteCommandAction.Simple(project, "XSLT.Inline", tag.getContainingFile()) { @Override protected void run() throws Throwable { try { for (PsiReference psiReference : references) { final PsiElement element = psiReference.getElement(); if (element instanceof XPathElement) { final XPathElement newExpr = XPathChangeUtil.createExpression(element, expression); element.replace(newExpr); } else { assert false; } } if (!hasRefs) { tag.delete(); } } catch (IncorrectOperationException e) { Logger.getInstance(VariableInlineHandler.class.getName()).error(e); } } }.execute(); }
From source file:org.intellij.lang.xpath.xslt.refactoring.XsltExtractFunctionAction.java
License:Apache License
protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) { final String name = Messages.showInputDialog(expression.getProject(), "Function Name: ", getRefactoringName(), Messages.getQuestionIcon()); final boolean[] b = new boolean[] { false }; if (name != null) { final String[] parts = name.split(":", 2); if (parts.length < 2) { Messages.showMessageDialog(expression.getProject(), "Custom functions require a prefixed name", "Error", Messages.getErrorIcon()); b[0] = true;/*from w w w . jav a 2 s .c om*/ } final XmlElement context = PsiTreeUtil.getContextOfType(expression, XmlElement.class); final NamespaceContext namespaceContext = expression.getXPathContext().getNamespaceContext(); if (namespaceContext != null && context != null && namespaceContext.resolve(parts[0], context) == null) { Messages.showMessageDialog(expression.getProject(), "Prefix '" + parts[0] + "' is not defined", "Error", Messages.getErrorIcon()); b[0] = true; } } return new RefactoringOptions() { @Override public boolean isCanceled() { return b[0]; } @Override public String getName() { return name; } }; }
From source file:org.intellij.plugins.xpathView.ui.AddNamespaceDialog.java
License:Apache License
public AddNamespaceDialog(Project project, Set<String> unresolvedPrefixes, Collection<String> uriList, Mode mode) {//from w w w .ja v a 2 s . c om super(project, false); myIcon.setText(null); myIcon.setIcon(Messages.getQuestionIcon()); myURI.setModel(new DefaultComboBoxModel(ArrayUtil.toStringArray(uriList))); myURI.setSelectedItem(""); myURI.setEditable(mode == Mode.EDITABLE || mode == Mode.URI_EDITABLE); addUpdateListener(myURI); myPrefix.setModel(new DefaultComboBoxModel(ArrayUtil.toStringArray(unresolvedPrefixes))); myPrefix.setEditable(mode == Mode.EDITABLE || mode == Mode.PREFIX_EDITABLE); if (unresolvedPrefixes.size() == 1) { myPrefix.setSelectedItem(unresolvedPrefixes.iterator().next()); } addUpdateListener(myPrefix); updateOkAction(); init(); }