List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon
@NotNull public static Icon getQuestionIcon()
From source file:org.jetbrains.plugins.groovy.actions.generate.equals.GroovyGenerateEqualsHandler.java
License:Apache License
@Nullable protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) { myEqualsFields = null;//from w w w. ja v a 2 s . c om myHashCodeFields = null; myNonNullFields = PsiField.EMPTY_ARRAY; GlobalSearchScope scope = aClass.getResolveScope(); final PsiMethod equalsMethod = GroovyGenerateEqualsHelper.findMethod(aClass, GroovyGenerateEqualsHelper.getEqualsSignature(project, scope)); final PsiMethod hashCodeMethod = GroovyGenerateEqualsHelper.findMethod(aClass, GroovyGenerateEqualsHelper.getHashCodeSignature()); boolean needEquals = equalsMethod == null; boolean needHashCode = hashCodeMethod == null; if (!needEquals && !needHashCode) { String text = aClass instanceof PsiAnonymousClass ? GroovyCodeInsightBundle .message("generate.equals.and.hashcode.already.defined.warning.anonymous") : GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName()); if (Messages.showYesNoDialog(project, text, GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"), Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) { if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() { public Boolean compute() { try { equalsMethod.delete(); hashCodeMethod.delete(); return Boolean.TRUE; } catch (IncorrectOperationException e) { LOG.error(e); return Boolean.FALSE; } } }).booleanValue()) { return null; } else { needEquals = needHashCode = true; } } else { return null; } } GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode); wizard.show(); if (!wizard.isOK()) return null; myEqualsFields = wizard.getEqualsFields(); myHashCodeFields = wizard.getHashCodeFields(); myNonNullFields = wizard.getNonNullFields(); return DUMMY_RESULT; }
From source file:org.jetbrains.plugins.groovy.actions.generate.missing.GroovyGenerateMethodMissingHandler.java
License:Apache License
@Nullable @Override//from w w w .j av a 2 s . co m protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) { final PsiMethod[] missings = aClass.findMethodsByName("methodMissing", true); PsiMethod method = null; for (PsiMethod missing : missings) { final PsiParameter[] parameters = missing.getParameterList().getParameters(); if (parameters.length == 2) { if (isNameParam(parameters[0])) { method = missing; } } } if (method != null) { String text = GroovyCodeInsightBundle.message("generate.method.missing.already.defined.warning"); if (Messages.showYesNoDialog(project, text, GroovyCodeInsightBundle.message("generate.method.missing.already.defined.title"), Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) { final PsiMethod finalMethod = method; if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() { public Boolean compute() { try { finalMethod.delete(); return Boolean.TRUE; } catch (IncorrectOperationException e) { LOG.error(e); return Boolean.FALSE; } } }).booleanValue()) { return null; } } else { return null; } } return new ClassMember[1]; }
From source file:org.jetbrains.plugins.groovy.actions.generate.missing.GroovyGeneratePropertyMissingHandler.java
License:Apache License
@Nullable @Override/* w w w. j ava 2 s. com*/ protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) { final PsiMethod[] missings = aClass.findMethodsByName("propertyMissing", true); PsiMethod getter = null; PsiMethod setter = null; for (PsiMethod missing : missings) { final PsiParameter[] parameters = missing.getParameterList().getParameters(); if (parameters.length == 1) { if (isNameParam(parameters[0])) { getter = missing; } } else if (parameters.length == 2) { if (isNameParam(parameters[0])) { setter = missing; } } } if (setter != null && getter != null) { String text = GroovyCodeInsightBundle.message("generate.property.missing.already.defined.warning"); if (Messages.showYesNoDialog(project, text, GroovyCodeInsightBundle.message("generate.property.missing.already.defined.title"), Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) { final PsiMethod finalGetter = getter; final PsiMethod finalSetter = setter; if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() { public Boolean compute() { try { finalSetter.delete(); finalGetter.delete(); return Boolean.TRUE; } catch (IncorrectOperationException e) { LOG.error(e); return Boolean.FALSE; } } }).booleanValue()) { return null; } } else { return null; } } return new ClassMember[1]; }
From source file:org.jetbrains.plugins.groovy.annotator.intentions.dynamic.DynamicToolWindowWrapper.java
License:Apache License
private boolean removeDynamicElement(DefaultMutableTreeNode child, boolean isShowDialog, int rowsCount) { Object namedElement = child.getUserObject(); if (!(namedElement instanceof DNamedElement)) return false; if (isShowDialog) { int result; if (rowsCount > 1) { result = Messages.showOkCancelDialog(myBigPanel, GroovyBundle.message("are.you.sure.to.delete.elements", String.valueOf(rowsCount)), GroovyBundle.message("dynamic.element.deletion"), Messages.getQuestionIcon()); } else {/*from ww w. ja v a 2s. c o m*/ result = Messages.showOkCancelDialog(myBigPanel, GroovyBundle.message("are.you.sure.to.delete.dynamic.property", ((DNamedElement) namedElement).getName()), GroovyBundle.message("dynamic.property.deletion"), Messages.getQuestionIcon()); } if (result != DialogWrapper.OK_EXIT_CODE) return false; } removeNamedElement(((DNamedElement) namedElement)); return true; }
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 w w . ja va 2 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.groovy.intentions.conversions.ConvertMapToClassIntention.java
License:Apache License
public static boolean checkForReturnFromMethod(GrExpression replacedNewExpression) { final PsiElement parent = PsiUtil.skipParentheses(replacedNewExpression.getParent(), true); final GrMethod method = PsiTreeUtil.getParentOfType(replacedNewExpression, GrMethod.class, true, GrClosableBlock.class); if (method == null) return false; if (!(parent instanceof GrReturnStatement)) { //check for return expression final List<GrStatement> returns = ControlFlowUtils.collectReturns(method.getBlock()); final PsiElement expr = PsiUtil.skipParentheses(replacedNewExpression, true); if (!(returns.contains(expr))) return false; }// ww w. j a v a 2 s . c om return !(!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog(replacedNewExpression.getProject(), GroovyIntentionsBundle.message("do.you.want.to.change.method.return.type", method.getName()), GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) != 0); }
From source file:org.jetbrains.plugins.groovy.intentions.conversions.ConvertMapToClassIntention.java
License:Apache License
public static boolean checkForVariableDeclaration(GrExpression replacedNewExpression) { final PsiElement parent = PsiUtil.skipParentheses(replacedNewExpression.getParent(), true); if (parent instanceof GrVariable && !(parent instanceof GrField) && !(parent instanceof GrParameter) && ((GrVariable) parent).getDeclaredType() != null && replacedNewExpression.getType() != null) { if (ApplicationManager.getApplication().isUnitTestMode() || Messages.showYesNoDialog(replacedNewExpression.getProject(), GroovyIntentionsBundle.message("do.you.want.to.change.variable.type", ((GrVariable) parent).getName()), GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) == 0) { return true; }/*from ww w. ja va2s. c om*/ } return false; }
From source file:org.jetbrains.plugins.groovy.intentions.conversions.ConvertMapToClassIntention.java
License:Apache License
@Nullable public static GrParameter checkForMethodParameter(GrExpression map) { final GrParameter parameter = getParameterByArgument(map); if (parameter == null) return null; final PsiElement parent = parameter.getParent().getParent(); if (!(parent instanceof PsiMethod)) return null; final PsiMethod method = (PsiMethod) parent; if (ApplicationManager.getApplication().isUnitTestMode() || Messages.showYesNoDialog(map.getProject(), GroovyIntentionsBundle.message("do.you.want.to.change.type.of.parameter.in.method", parameter.getName(), method.getName()), GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) == 0) { return parameter; }//from w w w .j ava2 s .c o m return null; }
From source file:org.jetbrains.plugins.ruby.rails.actions.generators.actions.special.GenerateControllerPanel.java
License:Apache License
public GenerateControllerPanel(@NotNull final String controllersRootPath, @Nullable final String path) { myControllerDir.setText(path == null ? "" : path); myRootPath = controllersRootPath;/*from w w w. j a va 2s. c o m*/ myListModel = new DefaultListModel(); myActionsList.setModel(myListModel); myActionsList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { final Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setIcon(RubyIcons.RUBY_METHOD_NODE); return comp; } }); final MyActionInputValidator validator = new MyActionInputValidator(); myAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String text = Messages.showInputDialog( RBundle.message("dialog.generate.controller.actions.promt"), RBundle.message("dialog.generate.controller.actions.promt.title"), Messages.getQuestionIcon(), TextUtil.EMPTY_STRING, validator); if (!TextUtil.isEmpty(text)) { myListModel.addElement(NamingConventions.toUnderscoreCase(text)); if (myListModel.size() == 1) { myActionsList.setSelectedIndex(0); } } myActionsList.requestFocus(); } }); myRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final Object[] selection = myActionsList.getSelectedValues(); int selectedIndex = -2; for (Object obj : selection) { if (selectedIndex == -2) { selectedIndex = myListModel.indexOf(obj); } myListModel.removeElement(obj); } if (myListModel.size() > 0) { if (selectedIndex < myListModel.size()) { myActionsList.setSelectedIndex(selectedIndex); } else { myActionsList.setSelectedIndex(myListModel.size() - 1); } } myActionsList.requestFocus(); } }); myControllerName.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { updateLocation(); } }); myControllerDir.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { updateLocation(); } }); myControllerName.setText(DOTS); myControllerName.setText(TextUtil.EMPTY_STRING); myContentPanel.doLayout(); }
From source file:org.jetbrains.plugins.ruby.rails.facet.BaseRailsFacetBuilder.java
License:Apache License
private static void generateRailsApplication(final Module module, @NotNull final Sdk sdk, final RunContentDescriptorFactory descriptorFactory, @NotNull final RailsWizardSettingsHolder settings, @NotNull final String applicationHomePath, @Nullable final Runnable onDone) { if (settings.getAppGenerateWay() == RailsWizardSettingsHolder.Generate.NEW) { final String preconfigureForDBName = settings.getDBNameToPreconfigure(); // if directory for rails application home already exists // then try to find Rails Application in it final VirtualFile appHomeDir = VirtualFileUtil.findFileByLocalPath(applicationHomePath); // If rails application already exists ask user overwrite existing files or not? final boolean toOverwrite; if (appHomeDir != null && appHomeDir.isDirectory() && RailsUtil.containsRailsApp(applicationHomePath)) { final int dialogResult = Messages.showYesNoDialog(module.getProject(), RBundle.message("module.rails.generateapp.rails.new.overwrite.message", applicationHomePath), RBundle.message("module.rails.generateapp.rails.new.overwrite.title"), Messages.getQuestionIcon()); toOverwrite = dialogResult == DialogWrapper.OK_EXIT_CODE; } else {// ww w .ja va 2 s. c o m toOverwrite = false; } RailsUtil.generateRailsApp(module, sdk, applicationHomePath, toOverwrite, preconfigureForDBName, descriptorFactory, onDone); } }