Java Code Examples for com.intellij.openapi.ui.DialogWrapper#OK_EXIT_CODE
The following examples show how to use
com.intellij.openapi.ui.DialogWrapper#OK_EXIT_CODE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewStoryboardAction.java From robovm-idea with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(AnActionEvent e) { if(module == null) { return; } VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); final NewStoryboardDialog dialog = new NewStoryboardDialog(e.getProject(), new File(file.getCanonicalPath())); dialog.show(); if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { IBIntegratorProxy proxy = IBIntegratorManager.getInstance().getProxy(module); if(proxy == null) { RoboVmPlugin.logError(e.getProject(), "Couldn't get interface builder integrator for module %s", module.getName()); } else { File resourceDir = new File(file.getCanonicalPath()); proxy.newIOSStoryboard(dialog.getStoryboardName(), resourceDir); VirtualFile vsfFile = VfsUtil.findFileByIoFile(resourceDir, true); vsfFile.refresh(false, true); } } }
Example 2
Source File: TodoConfigurable.java From consulo with Apache License 2.0 | 6 votes |
private void editSelectedFilter() { stopEditing(); int selectedIndex = myFiltersTable.getSelectedRow(); if (selectedIndex < 0 || selectedIndex >= myFiltersModel.getRowCount()) { return; } TodoFilter sourceFilter = myFilters.get(selectedIndex); TodoFilter filter = sourceFilter.clone(); FilterDialog dialog = new FilterDialog(myPanel, filter, selectedIndex, myFilters, myPatterns); dialog.setTitle(IdeBundle.message("title.edit.todo.filter")); dialog.show(); int exitCode = dialog.getExitCode(); if (DialogWrapper.OK_EXIT_CODE == exitCode) { myFilters.set(selectedIndex, filter); myFiltersModel.fireTableRowsUpdated(selectedIndex, selectedIndex); myFiltersTable.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
Example 3
Source File: AddChangeListAction.java From consulo with Apache License 2.0 | 6 votes |
public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); NewChangelistDialog dlg = new NewChangelistDialog(project); dlg.show(); if (dlg.getExitCode() == DialogWrapper.OK_EXIT_CODE) { String name = dlg.getName(); if (name.length() == 0) { name = getUniqueName(project); } final LocalChangeList list = ChangeListManager.getInstance(project).addChangeList(name, dlg.getDescription()); if (dlg.isNewChangelistActive()) { ChangeListManager.getInstance(project).setDefaultChangeList(list); } dlg.getPanel().changelistCreatedOrChanged(list); } }
Example 4
Source File: BuildCppAction.java From CppTools with Apache License 2.0 | 6 votes |
private void doRun(final VirtualFile file, final Project project) { final BuildPropertiesDialog dialog = new BuildPropertiesDialog(file, project); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { final CppSupportLoader loader = CppSupportLoader.getInstance(project); final String configuration = dialog.getSelectedBuildConfiguration(); if (configuration != null) loader.setActiveConfiguration(configuration); final String buildAction = dialog.getSelectedBuildAction(); if (buildAction != null) loader.setLastBuildAction(buildAction); String commandLineBuildParameters = dialog.getAdditionalCommandLineBuildParameters(); loader.setAdditionalCommandLineBuildParameters(commandLineBuildParameters); dialog.getBuildHandler().doBuild( new BuildTarget(configuration, buildAction, commandLineBuildParameters), new Runnable() { public void run() { doRun(dialog.getBuildHandler().getFile(), project); } } ); } }
Example 5
Source File: CreateIpaAction.java From robovm-idea with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(final AnActionEvent e) { final CreateIpaDialog dialog = new CreateIpaDialog(e.getProject()); dialog.show(); if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { // create IPA IpaConfig ipaConfig = dialog.getIpaConfig(); CompileScope scope = CompilerManager.getInstance(e.getProject()).createModuleCompileScope(ipaConfig.module, true); scope.putUserData(IPA_CONFIG_KEY, ipaConfig); CompilerManager.getInstance(e.getProject()).compile(scope, new CompileStatusNotification() { @Override public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { RoboVmPlugin.logInfo(e.getProject(), "IPA creation complete, %d errors, %d warnings", errors, warnings); } }); } }
Example 6
Source File: BaseDialog.java From PackageTemplates with Apache License 2.0 | 5 votes |
@Override public void show() { preShow(); super.show(); switch (getExitCode()) { case DialogWrapper.OK_EXIT_CODE: onOKAction(); break; case DialogWrapper.CANCEL_EXIT_CODE: onCancelAction(); break; } }
Example 7
Source File: SelectPackageTemplateDialog.java From PackageTemplates with Apache License 2.0 | 5 votes |
@Override public void show() { super.show(); switch (getExitCode()) { case DialogWrapper.OK_EXIT_CODE: presenter.onSuccess(PackageTemplateHelper.getPackageTemplate(getSelectedPath())); break; case DialogWrapper.CANCEL_EXIT_CODE: presenter.onCancel(); break; } }
Example 8
Source File: DialogContentMerger.java From azure-devops-intellij with MIT License | 5 votes |
public boolean mergeContent(final ContentTriplet contentTriplet, final Project project, final VirtualFile localFile, final VcsRevisionNumber serverVersion) { ArgumentHelper.checkIfFileWriteable(new File(localFile.getPath())); final MergeDialogCustomizer c = new MergeDialogCustomizer(); final MergeRequest request = DiffRequestFactory.getInstance().createMergeRequest(StreamUtil.convertSeparators(contentTriplet.localContent), StreamUtil.convertSeparators(contentTriplet.serverContent), StreamUtil.convertSeparators(contentTriplet.baseContent), localFile, project, ActionButtonPresentation.APPLY, ActionButtonPresentation.CANCEL_WITH_PROMPT); request.setWindowTitle(c.getMergeWindowTitle(localFile)); request.setVersionTitles(new String[]{ c.getLeftPanelTitle(localFile), c.getCenterPanelTitle(localFile), c.getRightPanelTitle(localFile, serverVersion) }); // TODO (JetBrains) call canShow() first DiffManager.getInstance().getDiffTool().show(request); if (request.getResult() == DialogWrapper.OK_EXIT_CODE) { return true; } else { request.restoreOriginalContent(); // TODO (JetBrains) maybe MergeVersion.MergeDocumentVersion.restoreOriginalContent() should save document itself? ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { final Document document = FileDocumentManager.getInstance().getDocument(localFile); if (document != null) { FileDocumentManager.getInstance().saveDocument(document); } } }); return false; } }
Example 9
Source File: CreateCommitAction.java From commit-template-idea-plugin with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent actionEvent) { final CommitMessageI commitPanel = getCommitPanel(actionEvent); if (commitPanel == null) return; CommitDialog dialog = new CommitDialog(actionEvent.getProject()); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { commitPanel.setCommitMessage(dialog.getCommitMessage().toString()); } }
Example 10
Source File: EncryptPropertyAction.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent anActionEvent) { final Project project = (Project)anActionEvent.getData(CommonDataKeys.PROJECT); PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext()); if (selectedProperty == null) return; final EncryptDialog form = new EncryptDialog(); form.setTitle("Encrypt Property: " + selectedProperty.getKey()); form.show(); boolean isOk = form.getExitCode() == DialogWrapper.OK_EXIT_CODE; // System.out.println("******** IS OK " + isOk); logger.debug("**** ALGORITHM " + form.getAlgorithm().getSelectedItem()); logger.debug("**** MODE " + form.getMode().getSelectedItem()); if (isOk) { new WriteCommandAction.Simple(project, psiFile) { @Override protected void run() throws Throwable { EncryptionAlgorithm algorithm = (EncryptionAlgorithm) form.getAlgorithm().getSelectedItem(); EncryptionMode mode = (EncryptionMode) form.getMode().getSelectedItem(); byte[] encryptedBytes = algorithm.getBuilder().forKey(form.getEncryptionKey().getText()).using(mode) .build().encrypt(selectedProperty.getValue().getBytes()); StringBuilder result = new StringBuilder(); result.append(ENCRYPT_PREFIX); result.append(new String(Base64.encode(encryptedBytes))); result.append(ENCRYPT_SUFFIX); selectedProperty.setValue(result.toString()); } }.execute(); } }
Example 11
Source File: AdbWifiConnect.java From ADBWIFI with Apache License 2.0 | 5 votes |
private static DeviceResult askUserForDevice(AndroidFacet facet, String packageName) { final DeviceChooserDialog chooser = new DeviceChooserDialog(facet); chooser.show(); if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) { return null; } IDevice[] selectedDevices = chooser.getSelectedDevices(); if (selectedDevices.length == 0) { return null; } return new DeviceResult(selectedDevices, facet, packageName); }
Example 12
Source File: DecryptPropertyAction.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent anActionEvent) { final Project project = (Project) anActionEvent.getData(CommonDataKeys.PROJECT); PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext()); final EncryptDialog form = new EncryptDialog(); form.setTitle("Decrypt Property: " + selectedProperty.getKey()); form.show(); boolean isOk = form.getExitCode() == DialogWrapper.OK_EXIT_CODE; logger.debug("**** ALGORITHM " + form.getAlgorithm().getSelectedItem()); logger.debug("**** MODE " + form.getMode().getSelectedItem()); if (isOk) { new WriteCommandAction.Simple(project, psiFile) { @Override protected void run() throws Throwable { EncryptionAlgorithm algorithm = (EncryptionAlgorithm) form.getAlgorithm().getSelectedItem(); EncryptionMode mode = (EncryptionMode) form.getMode().getSelectedItem(); try { String originalValue = selectedProperty.getValue(); String encryptedProperty = originalValue.substring(2, originalValue.length() - 1); byte[] decryptedBytes = algorithm.getBuilder().forKey(form.getEncryptionKey().getText()).using(mode) .build().decrypt(Base64.decode(encryptedProperty)); selectedProperty.setValue(new String(decryptedBytes)); } catch (Exception e) { Notification notification = MuleUIUtils.MULE_NOTIFICATION_GROUP.createNotification("Unable to decrypt property", "Property '" + selectedProperty.getKey() + "' cannot be decrypted : " + e, NotificationType.ERROR, null); Notifications.Bus.notify(notification, project); } } }.execute(); } }
Example 13
Source File: LombokLoggerHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean checkLoggerField(@NotNull PsiField psiField, @NotNull String lombokLoggerName, boolean lombokLoggerIsStatic) { if (!isValidLoggerField(psiField, lombokLoggerName, lombokLoggerIsStatic)) { final String messageText = String.format("Logger field: \"%s\" Is not private %sfinal field named \"%s\". Refactor anyway?", psiField.getName(), lombokLoggerIsStatic ? "static " : "", lombokLoggerName); int result = Messages.showOkCancelDialog(messageText, "Attention!", Messages.getOkButton(), Messages.getCancelButton(), Messages.getQuestionIcon()); return DialogWrapper.OK_EXIT_CODE == result; } return true; }
Example 14
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 5 votes |
private static void navigateToStarted(final Document oldDocument, final Project project, final int exitCode) { final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(oldDocument); if (file != null) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { final FileEditor[] editors = FileEditorManager.getInstance(project).getEditors(virtualFile); for (FileEditor editor : editors) { if (editor instanceof TextEditor) { final Editor textEditor = ((TextEditor)editor).getEditor(); final TemplateState templateState = TemplateManagerImpl.getTemplateState(textEditor); if (templateState != null) { if (exitCode == DialogWrapper.OK_EXIT_CODE) { final TextRange range = templateState.getVariableRange(PRIMARY_VARIABLE_NAME); if (range != null) { new OpenFileDescriptor(project, virtualFile, range.getStartOffset()).navigate(true); return; } } else if (exitCode > 0){ templateState.gotoEnd(); return; } } } } } } }
Example 15
Source File: OpenPanelAction.java From GitCommitMessage with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent actionEvent) { final CommitMessageI commitPanel = getCommitPanel(actionEvent); if (commitPanel == null) return; PanelDialog dialog = new PanelDialog(actionEvent.getProject()); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { commitPanel.setCommitMessage(dialog.getCommitMessage(actionEvent.getProject())); } }
Example 16
Source File: Panel.java From GitCommitMessage with Apache License 2.0 | 5 votes |
public DialogWrapper createTemplateDialog(Project project) { Template template = new Template(project); DialogBuilder builder = new DialogBuilder(project); builder.setTitle("Git / Hg Mercurial Commit Message Template."); builder.setCenterPanel(template.getMainPanel()); builder.removeAllActions(); builder.addOkAction(); builder.addCancelAction(); boolean isOk = builder.show() == DialogWrapper.OK_EXIT_CODE; if (isOk) { TemplateFileHandler.storeFile(project, template.getTemplateContent()); } return builder.getDialogWrapper(); }
Example 17
Source File: SOAPKitScaffoldingAction.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
@Override public void actionPerformed(AnActionEvent anActionEvent) { final VirtualFile selectedWsdlFile = CommonDataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext()); final Project project = anActionEvent.getProject(); PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); final VirtualFile moduleContentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(selectedWsdlFile); final VirtualFile appsRoot = moduleContentRoot.findFileByRelativePath(MuleConfigUtils.CONFIG_RELATIVE_PATH); String appPath = appsRoot.getPath(); String wsdlPath = selectedWsdlFile.getPath(); logger.debug("*** WSDL PATH IS " + wsdlPath); logger.debug("*** APP PATH IS " + appPath); Definition wsdlDefinition = WsdlUtils.parseWSDL(wsdlPath); List<String> configFiles = MuleDeployProperties.getConfigFileNames(appPath); final SoapKitDialog form = new SoapKitDialog(wsdlDefinition, configFiles); form.show(); boolean isOk = form.getExitCode() == DialogWrapper.OK_EXIT_CODE; if (!isOk) return; final String service = form.getService().getSelectedItem().toString(); final String port = form.getPort().getSelectedItem().toString(); String muleXml = form.getConfigFile().getSelectedItem().toString(); logger.debug("*** SERVICE " + service); logger.debug("*** PORT " + port); logger.debug("*** muleXml " + muleXml); logger.debug("*** wsdlPath " + wsdlPath); if (SoapKitDialog.NEW_FILE.equals(muleXml)) { File muleXmlFile = null; int i = 0; do { muleXml = selectedWsdlFile.getNameWithoutExtension() + (i > 0 ? "-" + i : "") + ".xml"; muleXmlFile = new File(appPath, muleXml); i++; } while (muleXmlFile.exists()); } final String muleXmlConfigFileName = muleXml; try { new WriteCommandAction.Simple(project, psiFile) { @Override protected void run() throws Throwable { VirtualFile vMuleXmlFile = appsRoot.findOrCreateChildData(this, muleXmlConfigFileName); Element resultElement = SCAFFOLDER.scaffold(wsdlPath, wsdlPath, service, port, ""); writeMuleXmlFile(resultElement, vMuleXmlFile); } }.execute(); } catch (Exception e) { Notification notification = MuleUIUtils.MULE_NOTIFICATION_GROUP.createNotification("Unable to generate flows from WSDL File", "Error Message : " + e, NotificationType.ERROR, null); Notifications.Bus.notify(notification, project); } moduleContentRoot.refresh(false, true); }
Example 18
Source File: CompileCppAction.java From CppTools with Apache License 2.0 | 4 votes |
private void invoke(final Project project, final VirtualFile file, CompileCppOptions _options) { CompileHandler handler = getCompileHandler(CompileCppDialog.getCurrentCompilerOption(project)); final CompileCppDialog dialog = new CompileCppDialog(project, handler, _options); dialog.show(); if(dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) return; _options = new CompileCppOptions() { public String getCompilerOptions() { return dialog.getCompilerOptions(); } public String getProjectCompilerOptions() { return dialog.getProjectCompilerOptions(); } public boolean doRun() { return dialog.doRun(); } public String getOutputFileName() { final String fileName = dialog.getOutputFileName(); return fileName.length() > 0? fileName:null; } public Project getProject() { return project; } public boolean isCppFile() { return "cpp".endsWith(file.getExtension()); } }; final CompileCppOptions options = _options; handler = getCompileHandler(CompileCppDialog.getCurrentCompilerOption(project)); List<String> runCommand = handler.buildCommand( file, options ); if (runCommand == null) throw new RuntimeException("Cannot invoke compilation"); final Map<String, String> commandLineProperties = handler.getCommandLineProperties(); final String baseForExecutableFile = file.getParent().getPath() + File.separatorChar; final String fileToExecute = baseForExecutableFile + handler.getOutputFileName(file, options); new File(fileToExecute).delete(); final ConsoleBuilder consoleBuilderRef[] = new ConsoleBuilder[1]; Runnable action = new Runnable() { public void run() { if (options.doRun() && new File(fileToExecute).exists()) { new ConsoleBuilder( "Run " + file.getName(), new BuildState(Arrays.asList(fileToExecute),new File(file.getParent().getPath()),commandLineProperties), project, null, new Runnable() { public void run() { invoke(project, file, options); } }, new Runnable() { public void run() { consoleBuilderRef[0].start(); } }, null ).start(); } } }; final ConsoleBuilder consoleBuilder = new ConsoleBuilder( "Compile File " + file.getName(), new BuildState(runCommand,new File(file.getParent().getPath()), commandLineProperties), project, handler.getCompileLogFilter(file, options), new Runnable() { public void run() { invoke(project, file, options); } }, null, action ); consoleBuilderRef[0] = consoleBuilder; consoleBuilder.start(); }
Example 19
Source File: PluginErrorReportSubmitter.java From BashSupport with Apache License 2.0 | 4 votes |
@Override public boolean submit(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo, @NotNull final Component parentComponent, @NotNull final Consumer<SubmittedReportInfo> consumer) { final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent); final Project project = CommonDataKeys.PROJECT.getData(dataContext); StringBuilder stacktrace = new StringBuilder(); for (IdeaLoggingEvent event : events) { stacktrace.append(event.getMessage()).append("\n"); stacktrace.append(event.getThrowableText()).append("\n"); } Properties properties = new Properties(); queryPluginDescriptor(getPluginDescriptor(), properties); StringBuilder versionId = new StringBuilder(); versionId.append(properties.getProperty(PLUGIN_ID_PROPERTY_KEY)).append(" ").append(properties.getProperty(PLUGIN_VERSION_PROPERTY_KEY)); versionId.append(", ").append(ApplicationInfo.getInstance().getBuild().asString()); // show modal error submission dialog PluginErrorSubmitDialog dialog = new PluginErrorSubmitDialog(parentComponent); dialog.prepare(additionalInfo, stacktrace.toString(), versionId.toString()); dialog.show(); // submit error to server if user pressed SEND int code = dialog.getExitCode(); if (code == DialogWrapper.OK_EXIT_CODE) { dialog.persist(); String description = dialog.getDescription(); String user = dialog.getUser(); String editedStacktrace = dialog.getStackTrace(); submitToServer(project, editedStacktrace, description, user, new Consumer<SubmittedReportInfo>() { @Override public void consume(SubmittedReportInfo submittedReportInfo) { consumer.consume(submittedReportInfo); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Messages.showInfoMessage(parentComponent, "The error report has been submitted successfully. Thank you for your feedback!", "BashSupport Error Submission"); } }); } }, new Consumer<Throwable>() { @Override public void consume(Throwable throwable) { LOGGER.info("Error submission failed", throwable); consumer.consume(new SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.FAILED)); } } ); return true; } return false; }
Example 20
Source File: MergeRequestImpl.java From consulo with Apache License 2.0 | 4 votes |
public void setResult(int result) { if (result == DialogWrapper.OK_EXIT_CODE) applyChanges(); myResult = result; }