List of usage examples for com.intellij.openapi.ui Messages showYesNoDialog
@YesNoResult public static int showYesNoDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
From source file:jetbrains.communicator.jabber.JabberConnectionCommand.java
License:Apache License
public void execute() { if (isConnected()) { if (Messages.YES == Messages.showYesNoDialog(StringUtil.getMsg("disconnect.from.jabber.account"), StringUtil.getMsg("disconnect.confirmation"), Messages.getQuestionIcon())) { myJabberFacade.disconnect(); myJabberFacade.getMyAccount().setLoginAllowed(false); myJabberFacade.saveSettings(); }//from w w w . ja va2 s . c om } else { myJabberUi.login(myParentComponent); } }
From source file:net.sf.logsupport.ui.util.Dialogs.java
License:Apache License
public static boolean confirmDelete(String what, String name) { if (name == null) { return Messages.showYesNoDialog( L10N.message("Dialogs.confirmDelete.confirmationTemplate.unnamed", what), L10N.message("Dialogs.confirmDelete.titleTemplate.unnamed", what), Messages.getWarningIcon()) == JOptionPane.YES_OPTION; } else {//from ww w. ja v a 2s .c o m return Messages.showYesNoDialog(L10N.message("Dialogs.confirmDelete.confirmationTemplate", what, name), L10N.message("Dialogs.confirmDelete.titleTemplate", what, name), Messages.getWarningIcon()) == JOptionPane.YES_OPTION; } }
From source file:net.sf.logsupport.ui.util.Dialogs.java
License:Apache License
public static boolean confirmOverwrite(String what) { return Messages.showYesNoDialog(L10N.message("Dialogs.confirmOverwrite.confirmationTemplate", what), L10N.message("Dialogs.confirmOverwrite.titleTemplate", what), Messages.getWarningIcon()) == JOptionPane.YES_OPTION; }
From source file:net.sourceforge.transparent.actions.CheckoutDialog.java
License:Open Source License
protected void doOKAction() { if (myConfiguration.FORCE_NON_EMPTY_COMMENT && getComment().length() == 0) { int requestForCheckin = Messages.showYesNoDialog("Check out with empty comment?", "Comment Is Empty", Messages.getWarningIcon()); if (requestForCheckin != OK_EXIT_CODE) { return; }// w w w .j a v a 2 s .c o m } // myConfiguration.LAST_COMMIT_MESSAGE = (getComment()); try { saveState(); super.doOKAction(); } catch (InputException ex) { ex.show(); } }
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;//from ww w .ja va2 s. co 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.jboss.forge.plugin.idea.runtime.UIPromptImpl.java
License:Open Source License
@Override public boolean promptBoolean(final String message) { ApplicationManager.getApplication().invokeAndWait(new Runnable() { @Override//from w ww . j a v a2 s . com public void run() { booleanValue = Messages.showYesNoDialog(message, "", Messages.getQuestionIcon()) == Messages.YES; } }, ModalityState.any()); return booleanValue; }
From source file:org.jetbrains.jet.plugin.framework.FrameworksCompatibilityUtils.java
License:Apache License
private static void removeWithConfirm(ModifiableRootModel rootModel, List<OrderEntry> orderEntries, String message, String title) { if (!orderEntries.isEmpty()) { int result = Messages.showYesNoDialog(message, title, Messages.getWarningIcon()); if (result == 0) { for (OrderEntry entry : orderEntries) { rootModel.removeOrderEntry(entry); }/*from w w w . ja va 2s . c om*/ } } }
From source file:org.jetbrains.plugins.groovy.findUsages.GroovyFieldFindUsagesHandlerFactory.java
License:Apache License
@Override public FindUsagesHandler createFindUsagesHandler(@NotNull PsiElement element, boolean forHighlightUsages) { return new JavaFindUsagesHandler(element, this) { @NotNull/*from w ww .j a v a2 s.c o m*/ @Override public PsiElement[] getSecondaryElements() { PsiElement element = getPsiElement(); final PsiField field = (PsiField) element; PsiClass containingClass = field.getContainingClass(); if (containingClass != null) { PsiMethod[] getters = GroovyPropertyUtils.getAllGettersByField(field); PsiMethod[] setters = GroovyPropertyUtils.getAllSettersByField(field); if (getters.length + setters.length > 0) { final boolean doSearch; if (arePhysical(getters) || arePhysical(setters)) { if (ApplicationManager.getApplication().isUnitTestMode()) return PsiElement.EMPTY_ARRAY; doSearch = Messages.showYesNoDialog( FindBundle.message("find.field.accessors.prompt", field.getName()), FindBundle.message("find.field.accessors.title"), Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE; } else { doSearch = true; } if (doSearch) { final List<PsiElement> elements = new ArrayList<PsiElement>(); for (PsiMethod getter : getters) { ContainerUtil.addAll(elements, SuperMethodWarningUtil.checkSuperMethods(getter, ACTION_STRING)); } for (PsiMethod setter : setters) { ContainerUtil.addAll(elements, SuperMethodWarningUtil.checkSuperMethods(setter, ACTION_STRING)); } for (Iterator<PsiElement> iterator = elements.iterator(); iterator.hasNext();) { if (iterator.next() instanceof GrAccessorMethod) iterator.remove(); } return PsiUtilCore.toPsiElementArray(elements); } else { return PsiElement.EMPTY_ARRAY; } } } return super.getSecondaryElements(); } }; }
From source file:org.jetbrains.plugins.ruby.ruby.module.wizard.ui.RubySdkSelectStep.java
License:Apache License
@Override public boolean validate() { Sdk jdk = myPanel.getChosenJdk();// w w w . j a v a 2s.c om if (jdk == null) { int result = Messages.showYesNoDialog( RBundle.message("sdk.error.no.sdk.prompt.messge.confirm.without.sdk"), RBundle.message("sdk.select.prompt.title"), Messages.getWarningIcon()); return result == DialogWrapper.OK_EXIT_CODE; } if (!RubySdkUtil.isKindOfRubySDK(jdk)) { Messages.showErrorDialog(RBundle.message("sdk.error.prompt.message.sdk.not.valid"), RBundle.message("sdk.select.prompt.title")); return false; } /* try to set selected SDK as Project default SDK final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject); if (!jdk.equals(projectRootManager.getSdk())) { int result = Messages.showYesNoDialog( RBundle.message("prompt.confirm.default.sdk.change"), RBundle.message("title.default.sdk.change"), Messages.getQuestionIcon() ); if (result == 1) { projectRootManager.setSdk(jdk); } }*/ return true; }
From source file:org.jetbrains.tfsIntegration.core.tfs.operations.ApplyGetOperations.java
License:Apache License
private boolean canOverrideLocalConflictingItem(final GetOperation operation, boolean sourceNotTarget) throws TfsException { if (myDownloadMode == DownloadMode.FORCE || myDownloadMode == DownloadMode.MERGE) { return true; }/*from w w w. jav a2s . co m*/ LocalConflictHandlingType conflictHandlingType = getLocalConflictHandlingType(); if (conflictHandlingType == LocalConflictHandlingType.ERROR) { throw new OperationFailedException( "Local conflict detected for " + VersionControlPath.localPathFromTfsRepresentation( sourceNotTarget ? operation.getSlocal() : operation.getTlocal())); } else if (conflictHandlingType == LocalConflictHandlingType.SHOW_MESSAGE) { String path = VersionControlPath.localPathFromTfsRepresentation( sourceNotTarget ? operation.getSlocal() : operation.getTlocal()); final String message = MessageFormat.format("Local conflict detected. Override local item?\n {0}", path); // TODO: more detailed message needed final String title = "Modify Files"; final Ref<Integer> result = new Ref<Integer>(); WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(new Runnable() { public void run() { result.set(Messages.showYesNoDialog(message, title, Messages.getQuestionIcon())); } }); if (result.get() == Messages.YES) { return true; } else { reportLocalConflict(operation, sourceNotTarget); return false; } } else { throw new IllegalArgumentException("Unknown conflict handling type: " + conflictHandlingType); } }