List of usage examples for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE
int OK_EXIT_CODE
To view the source code for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE.
Click Source Link
From source file:com.atlassian.theplugin.idea.jira.controls.FieldDueDate.java
License:Apache License
public FieldDueDate(final String date, final JIRAActionField field, final FreezeListener freezeListener) { super();/*from ww w . j a v a 2 s . c om*/ setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); textField = new FieldTextField(date, field); add(textField); add(Box.createRigidArea(new Dimension(BOX_WIDTH, 0))); final JButton button = new JButton("Select a Date"); add(button); textField.getDocument().addDocumentListener( new LocalDateTextFieldListener(textField, freezeListener, getFieldName(), true)); button.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { SimpleDateFormat dateFormatter = new SimpleDateFormat(DUE_DATE_FORMAT, Locale.US); Date dueDate; try { dueDate = dateFormatter.parse(textField.getText()); } catch (ParseException e) { PluginUtil.getLogger().info("Wrong date format [" + textField.getText() + "]. Using TODAY", e); dueDate = new Date(); } DatePicker datePicker = new DatePicker("Select Due Date", dueDate, true); datePicker.show(); if (datePicker.getExitCode() == DialogWrapper.OK_EXIT_CODE) { Date selectedDate = datePicker.getSelectedDate(); String text = ""; if (selectedDate != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(DUE_DATE_FORMAT, Locale.US); text = dateFormat.format(selectedDate); selectedDate = null; } textField.setText(text); } } }); }
From source file:com.atlassian.theplugin.idea.ThePluginProjectComponent.java
License:Apache License
private void askForUserStatistics() { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (pluginConfiguration.getGeneralConfigurationData() .getAnonymousEnhancedFeedbackEnabled() == null) { UsageStatsDialog dlg = new UsageStatsDialog(); dlg.show();//from w w w . ja v a 2s. com int answer = dlg.getExitCode(); boolean feedbackEnabled = answer == DialogWrapper.OK_EXIT_CODE; pluginConfiguration.getGeneralConfigurationData() .setAnonymousEnhancedFeedbackEnabled(feedbackEnabled); InfoServer.reportOptInOptOut(pluginConfiguration.getGeneralConfigurationData().getUid(), feedbackEnabled); } } }, ModalityState.defaultModalityState()); }
From source file:com.cfsoft.ofbiz.facet.ui.ComponentFileSetConfigurationTab.java
License:Apache License
public ComponentFileSetConfigurationTab(@NotNull final OfbizFacetConfiguration strutsFacetConfiguration, @NotNull final FacetEditorContext facetEditorContext) { originalConfiguration = strutsFacetConfiguration; module = facetEditorContext.getModule(); myConfigsSercher = new OfbizComponentConfigsSearcher(module); // init tree/*from ww w. j a v a 2s.co m*/ final SimpleTreeStructure structure = new SimpleTreeStructure() { public Object getRootElement() { return myRootNode; } }; myTree.setRootVisible(false); myTree.setShowsRootHandles(true); // show expand/collapse handles myBuilder = new SimpleTreeBuilder(myTree, (DefaultTreeModel) myTree.getModel(), structure, null); myBuilder.initRoot(); final DumbService dumbService = DumbService.getInstance(facetEditorContext.getProject()); myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(final TreeSelectionEvent e) { final OfbizFileSet fileSet = getCurrentFileSet(); myEditButton.setEnabled(fileSet != null && !dumbService.isDumb()); myRemoveButton.setEnabled(fileSet != null); } }); myAddSetButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final OfbizFileSet fileSet = new OfbizFileSet(OfbizFileSet.getUniqueId(myBuffer), OfbizFileSet.getUniqueName("My Component Fileset", myBuffer), originalConfiguration) { public boolean isNew() { return true; } }; final FileSetEditor editor = new FileSetEditor(myPanel, fileSet, facetEditorContext, myConfigsSercher); editor.show(); if (editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) { final OfbizFileSet editedFileSet = editor.getEditedFileSet(); Disposer.register(strutsFacetConfiguration, editedFileSet); myBuffer.add(editedFileSet); myModified = true; myBuilder.updateFromRoot(); selectFileSet(fileSet); } myTree.requestFocus(); } }); myEditButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final OfbizFileSet fileSet = getCurrentFileSet(); if (fileSet != null) { final FileSetEditor editor = new FileSetEditor(myPanel, fileSet, facetEditorContext, myConfigsSercher); editor.show(); if (editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) { myModified = true; myBuffer.remove(fileSet); final OfbizFileSet edited = editor.getEditedFileSet(); Disposer.register(strutsFacetConfiguration, edited); myBuffer.add(edited); edited.setAutodetected(false); myBuilder.updateFromRoot(); selectFileSet(edited); } myTree.requestFocus(); } } }); myRemoveButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { remove(); myModified = true; myBuilder.updateFromRoot(); myTree.requestFocus(); } }); dumbService.makeDumbAware(myAddSetButton, this); dumbService.makeDumbAware(myEditButton, this); }
From source file:com.cfsoft.ofbiz.facet.ui.ComponentFileSetConfigurationTab.java
License:Apache License
private void remove() { final SimpleNode[] nodes = myTree.getSelectedNodesIfUniform(); for (final SimpleNode node : nodes) { if (node instanceof FileSetNode) { final OfbizFileSet fileSet = ((FileSetNode) node).mySet; if (fileSet.getFiles().isEmpty()) { myBuffer.remove(fileSet); return; }/*from w ww . ja v a2s. co m*/ final int result = Messages.showYesNoDialog(myPanel, String.format("Remove File Set '%s' ?", fileSet.getName()), "Confirm removal", Messages.getQuestionIcon()); if (result == DialogWrapper.OK_EXIT_CODE) { if (fileSet.isAutodetected()) { fileSet.setRemoved(true); myBuffer.add(fileSet); } else { myBuffer.remove(fileSet); } } } else if (node instanceof ConfigFileNode) { final VirtualFilePointer filePointer = ((ConfigFileNode) node).myFilePointer; final OfbizFileSet fileSet = ((FileSetNode) node.getParent()).mySet; fileSet.removeFile(filePointer); } } }
From source file:com.cfsoft.ofbiz.facet.ui.ControllerFileSetConfigurationTab.java
License:Apache License
public ControllerFileSetConfigurationTab(@NotNull final OfbizFacetConfiguration strutsFacetConfiguration, @NotNull final FacetEditorContext facetEditorContext) { originalConfiguration = strutsFacetConfiguration; module = facetEditorContext.getModule(); myConfigsSercher = new OfbizControllerConfigsSearcher(module); // init tree/*from www. ja va2s. c om*/ final SimpleTreeStructure structure = new SimpleTreeStructure() { public Object getRootElement() { return myRootNode; } }; myTree.setRootVisible(false); myTree.setShowsRootHandles(true); // show expand/collapse handles myBuilder = new SimpleTreeBuilder(myTree, (DefaultTreeModel) myTree.getModel(), structure, null); myBuilder.initRoot(); final DumbService dumbService = DumbService.getInstance(facetEditorContext.getProject()); myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(final TreeSelectionEvent e) { final OfbizFileSet fileSet = getCurrentFileSet(); myEditButton.setEnabled(fileSet != null && !dumbService.isDumb()); myRemoveButton.setEnabled(fileSet != null); } }); myAddSetButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final OfbizFileSet fileSet = new OfbizFileSet(OfbizFileSet.getUniqueId(myBuffer), OfbizFileSet.getUniqueName("My Controller Fileset", myBuffer), originalConfiguration) { public boolean isNew() { return true; } }; final FileSetEditor editor = new FileSetEditor(myPanel, fileSet, facetEditorContext, myConfigsSercher); editor.show(); if (editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) { final OfbizFileSet editedFileSet = editor.getEditedFileSet(); Disposer.register(strutsFacetConfiguration, editedFileSet); myBuffer.add(editedFileSet); myModified = true; myBuilder.updateFromRoot(); selectFileSet(fileSet); } myTree.requestFocus(); } }); myEditButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final OfbizFileSet fileSet = getCurrentFileSet(); if (fileSet != null) { final FileSetEditor editor = new FileSetEditor(myPanel, fileSet, facetEditorContext, myConfigsSercher); editor.show(); if (editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) { myModified = true; myBuffer.remove(fileSet); final OfbizFileSet edited = editor.getEditedFileSet(); Disposer.register(strutsFacetConfiguration, edited); myBuffer.add(edited); edited.setAutodetected(false); myBuilder.updateFromRoot(); selectFileSet(edited); } myTree.requestFocus(); } } }); myRemoveButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { remove(); myModified = true; myBuilder.updateFromRoot(); myTree.requestFocus(); } }); dumbService.makeDumbAware(myAddSetButton, this); dumbService.makeDumbAware(myEditButton, this); }
From source file:com.cfsoft.ofbiz.facet.ui.ServiceFileSetConfigurationTab.java
License:Apache License
public ServiceFileSetConfigurationTab(@NotNull final OfbizFacetConfiguration ofbizFacetConfiguration, @NotNull final FacetEditorContext facetEditorContext) { originalConfiguration = ofbizFacetConfiguration; module = facetEditorContext.getModule(); myConfigsSercher = new OfbizServiceConfigsSearcher(module); // init tree//from w w w . j a v a 2 s.co m final SimpleTreeStructure structure = new SimpleTreeStructure() { public Object getRootElement() { return myRootNode; } }; myTree.setRootVisible(false); myTree.setShowsRootHandles(true); // show expand/collapse handles myBuilder = new SimpleTreeBuilder(myTree, (DefaultTreeModel) myTree.getModel(), structure, null); myBuilder.initRoot(); final DumbService dumbService = DumbService.getInstance(facetEditorContext.getProject()); myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(final TreeSelectionEvent e) { final OfbizFileSet fileSet = getCurrentFileSet(); myEditButton.setEnabled(fileSet != null && !dumbService.isDumb()); myRemoveButton.setEnabled(fileSet != null); } }); myAddSetButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final OfbizFileSet fileSet = new OfbizFileSet(OfbizFileSet.getUniqueId(myBuffer), OfbizFileSet.getUniqueName("My Services Fileset", myBuffer), originalConfiguration) { public boolean isNew() { return true; } }; final FileSetEditor editor = new FileSetEditor(myPanel, fileSet, facetEditorContext, myConfigsSercher); editor.show(); if (editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) { final OfbizFileSet editedFileSet = editor.getEditedFileSet(); Disposer.register(ofbizFacetConfiguration, editedFileSet); myBuffer.add(editedFileSet); myModified = true; myBuilder.updateFromRoot(); selectFileSet(fileSet); } myTree.requestFocus(); } }); myEditButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final OfbizFileSet fileSet = getCurrentFileSet(); if (fileSet != null) { final FileSetEditor editor = new FileSetEditor(myPanel, fileSet, facetEditorContext, myConfigsSercher); editor.show(); if (editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) { myModified = true; myBuffer.remove(fileSet); final OfbizFileSet edited = editor.getEditedFileSet(); Disposer.register(ofbizFacetConfiguration, edited); myBuffer.add(edited); edited.setAutodetected(false); myBuilder.updateFromRoot(); selectFileSet(edited); } myTree.requestFocus(); } } }); myRemoveButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { remove(); myModified = true; myBuilder.updateFromRoot(); myTree.requestFocus(); } }); dumbService.makeDumbAware(myAddSetButton, this); dumbService.makeDumbAware(myEditButton, this); }
From source file:com.dci.intellij.dbn.debugger.execution.action.OpenMethodBrowserAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { final Project project = ActionUtil.getProject(e); BackgroundTask backgroundTask = new BackgroundTask(project, "Loading executable elements", false) { @Override/*from w ww .java 2 s .com*/ public void execute(@NotNull ProgressIndicator progressIndicator) { initProgressIndicator(progressIndicator, true); final MethodBrowserSettings settings = MethodExecutionManager.getInstance(project) .getBrowserSettings(); DBMethod currentMethod = getConfiguration().getExecutionInput() == null ? null : getConfiguration().getExecutionInput().getMethod(); if (currentMethod != null) { settings.setConnectionHandler(currentMethod.getConnectionHandler()); settings.setSchema(currentMethod.getSchema()); settings.setMethod(currentMethod); } final ObjectTreeModel objectTreeModel = new ObjectTreeModel(settings.getSchema(), settings.getVisibleObjectTypes(), settings.getMethod()); new SimpleLaterInvocator() { public void run() { final MethodExecutionBrowserDialog browserDialog = new MethodExecutionBrowserDialog(project, settings, objectTreeModel); browserDialog.show(); if (browserDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { DBMethod method = browserDialog.getSelectedMethod(); MethodExecutionManager methodExecutionManager = MethodExecutionManager .getInstance(project); MethodExecutionInput methodExecutionInput = methodExecutionManager .getExecutionInput(method); if (methodExecutionInput != null) { getConfiguration().setExecutionInput(methodExecutionInput); } } } }.start(); } }; backgroundTask.start(); }
From source file:com.intellij.android.designer.model.RadIncludeLayout.java
License:Apache License
@Override public void configure(RadComponent rootComponent) throws Exception { ModuleProvider moduleProvider = rootComponent.getClientProperty(ModelParser.MODULE_KEY); ResourceDialog dialog = new ResourceDialog(moduleProvider.getModule(), IncludeLayoutProperty.TYPES, null, null) {/*from www . ja va 2 s . c om*/ @NotNull @Override protected Action[] createLeftSideActions() { return new Action[0]; } }; dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { setClientProperty(IncludeLayoutProperty.NAME, dialog.getResourceName()); } else { throw new Exception(); } }
From source file:com.intellij.codeInsight.daemon.impl.quickfix.CreateConstructorMatchingSuperFix.java
License:Apache License
public static void chooseConstructor2Delegate(final Project project, final Editor editor, PsiSubstitutor substitutor, List<PsiMethodMember> baseConstructors, PsiMethod[] baseConstrs, final PsiClass targetClass) { PsiMethodMember[] constructors = baseConstructors.toArray(new PsiMethodMember[baseConstructors.size()]); if (constructors.length == 0) { constructors = new PsiMethodMember[baseConstrs.length]; for (int i = 0; i < baseConstrs.length; i++) { constructors[i] = new PsiMethodMember(baseConstrs[i], substitutor); }//from www .j a v a 2s. c om } LOG.assertTrue(constructors.length >= 1); // Otherwise we won't have been messing with all this stuff boolean isCopyJavadoc = true; if (constructors.length > 1 && !ApplicationManager.getApplication().isUnitTestMode()) { MemberChooser<PsiMethodMember> chooser = new MemberChooser<PsiMethodMember>(constructors, false, true, project); chooser.setTitle(QuickFixBundle.message("super.class.constructors.chooser.title")); chooser.show(); if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return; constructors = chooser.getSelectedElements(new PsiMethodMember[0]); isCopyJavadoc = chooser.isCopyJavadoc(); } final PsiMethodMember[] constructors1 = constructors; final boolean isCopyJavadoc1 = isCopyJavadoc; ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { try { if (targetClass.getLBrace() == null) { PsiClass psiClass = JavaPsiFacade.getInstance(targetClass.getProject()).getElementFactory() .createClass("X"); targetClass.addRangeAfter(psiClass.getLBrace(), psiClass.getRBrace(), targetClass.getLastChild()); } JVMElementFactory factory = JVMElementFactories.getFactory(targetClass.getLanguage(), project); CodeStyleManager formatter = CodeStyleManager.getInstance(project); PsiMethod derived = null; for (PsiMethodMember candidate : constructors1) { PsiMethod base = candidate.getElement(); derived = GenerateMembersUtil.substituteGenericMethod(base, candidate.getSubstitutor(), targetClass); if (!isCopyJavadoc1) { final PsiDocComment docComment = derived.getDocComment(); if (docComment != null) { docComment.delete(); } } final String targetClassName = targetClass.getName(); LOG.assertTrue(targetClassName != null, targetClass); derived.setName(targetClassName); ConstructorBodyGenerator generator = ConstructorBodyGenerator.INSTANCE .forLanguage(derived.getLanguage()); if (generator != null) { StringBuilder buffer = new StringBuilder(); generator.start(buffer, derived.getName(), PsiParameter.EMPTY_ARRAY); generator.generateSuperCallIfNeeded(buffer, derived.getParameterList().getParameters()); generator.finish(buffer); PsiMethod stub = factory.createMethodFromText(buffer.toString(), targetClass); derived.getBody().replace(stub.getBody()); } derived = (PsiMethod) formatter.reformat(derived); derived = (PsiMethod) JavaCodeStyleManager.getInstance(project) .shortenClassReferences(derived); PsiGenerationInfo<PsiMethod> info = OverrideImplementUtil.createGenerationInfo(derived); info.insert(targetClass, null, true); derived = info.getPsiMember(); } if (derived != null) { editor.getCaretModel().moveToOffset(derived.getTextRange().getStartOffset()); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } } catch (IncorrectOperationException e) { LOG.error(e); } UndoUtil.markPsiFileForUndo(targetClass.getContainingFile()); } }); }
From source file:com.intellij.codeInsight.daemon.impl.quickfix.CreateConstructorParameterFromFieldFix.java
License:Apache License
@Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;/* w w w . j a v a 2 s .c o m*/ PsiMethod[] constructors = myClass.getConstructors(); if (constructors.length == 0) { final AddDefaultConstructorFix defaultConstructorFix = new AddDefaultConstructorFix(myClass); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { defaultConstructorFix.invoke(project, editor, file); } }); constructors = myClass.getConstructors(); } Arrays.sort(constructors, new Comparator<PsiMethod>() { @Override public int compare(PsiMethod c1, PsiMethod c2) { final PsiMethod cc1 = RefactoringUtil.getChainedConstructor(c1); final PsiMethod cc2 = RefactoringUtil.getChainedConstructor(c2); if (cc1 == c2) return 1; if (cc2 == c1) return -1; if (cc1 == null) { return cc2 == null ? 0 : compare(c1, cc2); } else { return cc2 == null ? compare(cc1, c2) : compare(cc1, cc2); } } }); final ArrayList<PsiMethod> constrs = filterConstructorsIfFieldAlreadyAssigned(constructors, getField()); if (constrs.size() > 1) { final PsiMethodMember[] members = new PsiMethodMember[constrs.size()]; int i = 0; for (PsiMethod constructor : constrs) { members[i++] = new PsiMethodMember(constructor); } final List<PsiMethodMember> elements; if (ApplicationManager.getApplication().isUnitTestMode()) { elements = Arrays.asList(members); } else { final MemberChooser<PsiMethodMember> chooser = new MemberChooser<PsiMethodMember>(members, false, true, project); chooser.setTitle("Choose constructors to add parameter to"); chooser.show(); elements = chooser.getSelectedElements(); if (elements == null) return; } for (PsiMethodMember member : elements) { if (!addParameterToConstructor(project, file, editor, member.getElement(), new PsiField[] { getField() })) break; } } else if (!constrs.isEmpty()) { final Collection<SmartPsiElementPointer<PsiField>> fieldsToFix = getFieldsToFix(); try { final PsiMethod constructor = constrs.get(0); final LinkedHashSet<PsiField> fields = new LinkedHashSet<PsiField>(); getFieldsToFix().add(myField); for (SmartPsiElementPointer<PsiField> elementPointer : fieldsToFix) { final PsiField field = elementPointer.getElement(); if (field != null && isAvailable(field) && filterConstructorsIfFieldAlreadyAssigned(new PsiMethod[] { constructor }, field) .contains(constructor)) { fields.add(field); } } if (constrs.size() == constructors.length && fields.size() > 1 && !ApplicationManager.getApplication().isUnitTestMode()) { PsiFieldMember[] members = new PsiFieldMember[fields.size()]; int i = 0; for (PsiField field : fields) { members[i++] = new PsiFieldMember(field); } MemberChooser<PsiElementClassMember> chooser = new MemberChooser<PsiElementClassMember>(members, false, true, project); chooser.setTitle("Choose Fields to Generate Constructor Parameters for"); chooser.show(); if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return; final List<PsiElementClassMember> selectedElements = chooser.getSelectedElements(); if (selectedElements == null) return; fields.clear(); for (PsiElementClassMember member : selectedElements) { fields.add((PsiField) member.getElement()); } } addParameterToConstructor(project, file, editor, constructor, constrs.size() == constructors.length ? fields.toArray(new PsiField[fields.size()]) : new PsiField[] { getField() }); } finally { fieldsToFix.clear(); } } }