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:altn8.ui.AlternateFreeRegexItemDialog.java
License:Apache License
/** * // w ww . jav a 2 s. c o m */ public static void showDialog(@NotNull String title, @NotNull AlternateFreeRegexItem currentItem, @NotNull AbstractDataPanel.Runnable<AlternateFreeRegexItem> runnable) { AlternateFreeRegexItemDialog dialog = new AlternateFreeRegexItemDialog(title, currentItem); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { AlternateFreeRegexItem newItem = dialog.getItem(); if (!newItem.equals(currentItem) && !newItem.isEmpty()) { runnable.run(newItem); } } }
From source file:altn8.ui.AlternateGenericPrefixPostfixRegexItemDialog.java
License:Apache License
/** * /* ww w . jav a 2 s .c o m*/ */ public static void showDialog(@NotNull String title, @NotNull AlternateGenericPrefixPostfixRegexItem currentItem, @NotNull AbstractDataPanel.Runnable<AlternateGenericPrefixPostfixRegexItem> runnable) { AlternateGenericPrefixPostfixRegexItemDialog dialog = new AlternateGenericPrefixPostfixRegexItemDialog( title, currentItem); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { AlternateGenericPrefixPostfixRegexItem newItem = dialog.getItem(); if (!newItem.equals(currentItem) && !newItem.isEmpty()) { runnable.run(newItem); } } }
From source file:be.mavicon.intellij.ppimport.PPImportAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { VirtualFile[] virtualFiles = e.getData(LangDataKeys.VIRTUAL_FILE_ARRAY); if (isValidSelection(virtualFiles)) { if (target.isConfirm()) { ConfirmDialog confirmDialog = new ConfirmDialog(target.getProfile()); confirmDialog.show();//from ww w . j a va 2 s .co m int exitCode = confirmDialog.getExitCode(); if (DialogWrapper.OK_EXIT_CODE != exitCode) { PPImportPlugin.doNotify("Import cancelled upon confirmation.", NotificationType.INFORMATION); return; } } PPImporter.getInstance().doImport(virtualFiles, this.target, this.includeExtensions, this.uploadMultipleFilesAsJar); } }
From source file:com.android.tools.idea.avdmanager.AccelerationErrorSolution.java
License:Apache License
private void showQuickFix(@NotNull List<String> requested) { ModelWizardDialog sdkQuickfixWizard = SdkQuickfixUtils.createDialogForPaths(myProject, requested); if (sdkQuickfixWizard != null) { sdkQuickfixWizard.show();// ww w . j a v a 2 s . c om if (sdkQuickfixWizard.getExitCode() == DialogWrapper.OK_EXIT_CODE) { myChangesMade = true; } } }
From source file:com.android.tools.idea.gradle.structure.editors.ModuleDependenciesPanel.java
License:Apache License
private void addExternalDependency() { Module module = GradleUtil.findModuleByGradlePath(myProject, myModulePath); MavenDependencyLookupDialog dialog = new MavenDependencyLookupDialog(myProject, module); dialog.setTitle("Choose Library Dependency"); dialog.show();/*from ww w . j av a 2 s.c om*/ if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { String coordinateText = dialog.getSearchText(); coordinateText = installRepositoryIfNeeded(coordinateText); if (coordinateText != null) { myModel.addItem(new ModuleDependenciesTableItem( new Dependency(Dependency.Scope.COMPILE, Dependency.Type.EXTERNAL, coordinateText))); } } myModel.fireTableDataChanged(); }
From source file:com.android.tools.idea.rendering.HtmlLinkManager.java
License:Apache License
private static void handleNewClassUrl(@NotNull String url, @NotNull Module module) { assert url.startsWith(URL_CREATE_CLASS) : url; String s = url.substring(URL_CREATE_CLASS.length()); final Project project = module.getProject(); String title = "Create Custom View"; final String className; final String packageName; int index = s.lastIndexOf('.'); if (index == -1) { className = s;/*from www . j a v a2 s .co m*/ packageName = ManifestInfo.get(module).getPackage(); } else { packageName = s.substring(0, index); className = s.substring(index + 1); } CreateClassDialog dialog = new CreateClassDialog(project, title, className, packageName, CreateClassKind.CLASS, true, module) { @Override protected boolean reportBaseInSourceSelectionInTest() { return true; } }; dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { final PsiDirectory targetDirectory = dialog.getTargetDirectory(); if (targetDirectory != null) { PsiClass newClass = ApplicationManager.getApplication().runWriteAction(new Computable<PsiClass>() { @Override public PsiClass compute() { PsiClass targetClass = JavaDirectoryService.getInstance().createClass(targetDirectory, className); PsiManager manager = PsiManager.getInstance(project); final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); final PsiElementFactory factory = facade.getElementFactory(); // Extend android.view.View PsiJavaCodeReferenceElement superclassReference = factory .createReferenceElementByFQClassName(CLASS_VIEW, targetClass.getResolveScope()); PsiReferenceList extendsList = targetClass.getExtendsList(); if (extendsList != null) { extendsList.add(superclassReference); } // Add constructor GlobalSearchScope scope = GlobalSearchScope.allScope(project); PsiJavaFile javaFile = (PsiJavaFile) targetClass.getContainingFile(); PsiImportList importList = javaFile.getImportList(); if (importList != null) { PsiClass contextClass = JavaPsiFacade.getInstance(project) .findClass("android.content.Context", scope); if (contextClass != null) { importList.add(factory.createImportStatement(contextClass)); } PsiClass attributeSetClass = JavaPsiFacade.getInstance(project) .findClass("android.util.AttributeSet", scope); if (attributeSetClass != null) { importList.add(factory.createImportStatement(attributeSetClass)); } } PsiMethod constructor = factory.createMethodFromText( "public " + className + "(Context context, AttributeSet attrs, int defStyle) {\n" + " super(context, attrs, defStyle);\n" + "}\n", targetClass); targetClass.add(constructor); // Format class CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject()); PsiFile containingFile = targetClass.getContainingFile(); if (containingFile != null) { codeStyleManager.reformat(javaFile); } return targetClass; } }); if (newClass != null) { PsiFile file = newClass.getContainingFile(); if (file != null) { openEditor(project, file, newClass.getTextOffset()); } } } } }
From source file:com.android.tools.idea.run.DeviceSelectionUtils.java
License:Apache License
@NotNull private static IDevice[] chooseDevicesManually(@NotNull AndroidFacet facet, @NotNull Predicate<IDevice> filter, @NotNull DeviceCount deviceCount) { final Project project = facet.getModule().getProject(); String value = PropertiesComponent.getInstance(project).getValue(ANDROID_TARGET_DEVICES_PROPERTY); String[] selectedSerials = value != null ? deserialize(value) : null; AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform(); if (platform == null) { LOG.error("Android platform not set for module: " + facet.getModule().getName()); return DeviceChooser.EMPTY_DEVICE_ARRAY; }/*from w w w. j a v a 2 s . c o m*/ DeviceChooserDialog chooser = new DeviceChooserDialog(facet, platform.getTarget(), deviceCount.isMultiple(), selectedSerials, filter); chooser.show(); IDevice[] devices = chooser.getSelectedDevices(); if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE || devices.length == 0) { return DeviceChooser.EMPTY_DEVICE_ARRAY; } PropertiesComponent.getInstance(project).setValue(ANDROID_TARGET_DEVICES_PROPERTY, serialize(devices)); return devices; }
From source file:com.android.tools.idea.structure.ModuleDependenciesPanel.java
License:Apache License
private void addExternalDependency() { Module module = GradleUtil.findModuleByGradlePath(myProject, myModulePath); MavenDependencyLookupDialog dialog = new MavenDependencyLookupDialog(myProject, module); dialog.setTitle("Choose Library Dependency"); dialog.show();/*from w w w .j a v a2 s.com*/ if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { String coordinateText = dialog.getSearchText(); myModel.addItem(new ModuleDependenciesTableItem( new Dependency(Dependency.Scope.COMPILE, Dependency.Type.EXTERNAL, coordinateText))); } myModel.fireTableDataChanged(); }
From source file:com.android.tools.idea.ui.resourcechooser.ColorPicker.java
License:Apache License
@Nullable public static Color showDialog(Component parent, String caption, @Nullable Color preselectedColor, boolean enableOpacity, @Nullable ColorPickerListener[] listeners, boolean opacityInPercent) { final ColorPickerDialog dialog = new ColorPickerDialog(parent, caption, preselectedColor, enableOpacity, listeners, opacityInPercent); dialog.show();//from w w w. j a va 2 s . c om if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { return dialog.getColor(); } return null; }
From source file:com.android.tools.idea.uibuilder.property.NlIdPropertyItem.java
License:Apache License
@Override public void setValue(Object value) { String newId = value != null ? stripIdPrefix(value.toString()) : ""; String oldId = getValue();/*from w w w . ja v a 2 s.c o m*/ XmlTag tag = getTag(); if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty() && !oldId.equals(newId) && tag != null && tag.isValid()) { // Offer rename refactoring? XmlAttribute attribute = tag.getAttribute(SdkConstants.ATTR_ID, SdkConstants.ANDROID_URI); if (attribute != null) { Module module = getModel().getModule(); Project project = module.getProject(); XmlAttributeValue valueElement = attribute.getValueElement(); if (valueElement != null && valueElement.isValid()) { // Exact replace only, no comment/text occurrence changes since it is non-interactive ValueResourceElementWrapper wrapper = new ValueResourceElementWrapper(valueElement); RenameProcessor processor = new RenameProcessor(project, wrapper, NEW_ID_PREFIX + newId, false /*comments*/, false /*text*/); processor.setPreviewUsages(false); // Do a quick usage search to see if we need to ask about renaming UsageInfo[] usages = processor.findUsages(); if (usages.length > 0) { int choice = ourRefactoringChoice; if (choice == REFACTOR_ASK) { DialogBuilder builder = createDialogBuilder(project); builder.setTitle("Update Usages?"); JPanel panel = new JPanel(new BorderLayout()); // UGH! JLabel label = new JLabel("<html>" + "Update usages as well?<br>" + "This will update all XML references and Java R field references.<br>" + "<br>" + "</html>"); panel.add(label, BorderLayout.CENTER); JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session"); panel.add(checkBox, BorderLayout.SOUTH); builder.setCenterPanel(panel); builder.setDimensionServiceKey("idPropertyDimension"); builder.removeAllActions(); DialogBuilder.CustomizableAction yesAction = builder.addOkAction(); yesAction.setText(Messages.YES_BUTTON); builder.addActionDescriptor(dialogWrapper -> new AbstractAction(Messages.NO_BUTTON) { @Override public void actionPerformed(ActionEvent actionEvent) { dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE); } }); builder.addCancelAction(); int exitCode = builder.show(); choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO : ourRefactoringChoice; //noinspection AssignmentToStaticFieldFromInstanceMethod ourRefactoringChoice = checkBox.isSelected() ? choice : REFACTOR_ASK; if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) { return; } } if (choice == REFACTOR_YES) { processor.run(); return; } } } } } super.setValue(!StringUtil.isEmpty(newId) ? NEW_ID_PREFIX + newId : null); }