List of usage examples for com.intellij.openapi.ui DialogBuilder setOkActionEnabled
public void setOkActionEnabled(final boolean isEnabled)
From source file:com.intellij.history.integration.ui.views.HistoryDialog.java
License:Apache License
private boolean showAsDialog(CreatePatchConfigurationPanel p) { final DialogBuilder b = new DialogBuilder(myProject); JComponent createPatchPanel = p.getPanel(); b.setPreferredFocusComponent(IdeFocusTraversalPolicy.getPreferredFocusedComponent(createPatchPanel)); b.setTitle(message("create.patch.dialog.title")); b.setCenterPanel(createPatchPanel);//from w w w. j a v a 2s .c o m p.installOkEnabledListener(new Consumer<Boolean>() { public void consume(final Boolean aBoolean) { b.setOkActionEnabled(aBoolean); } }); return b.show() == DialogWrapper.OK_EXIT_CODE; }
From source file:net.stevechaloner.intellijad.environment.EnvironmentValidator.java
License:Apache License
/** * Shows the error dialog, allowing the user to cancel the decompilation or open the config. * * @param config the configuration/*from ww w .j a v a2 s. c o m*/ * @param envContext the environment context * @param consoleContext the console's logging context * @param message the error message * @return the result of the dialog-based operation */ private static ValidationResult showErrorDialog(@NotNull Config config, @NotNull EnvironmentContext envContext, @NotNull ConsoleContext consoleContext, @NotNull String message) { DialogBuilder builder = new DialogBuilder(envContext.getProject()); builder.setTitle(IntelliJadResourceBundle.message("plugin.IntelliJad.name")); builder.addOkAction().setText(IntelliJadResourceBundle.message("option.open-config")); builder.addCancelAction().setText(IntelliJadResourceBundle.message("option.cancel-decompilation")); JLabel label = new JLabel(message); label.setUI(new MultiLineLabelUI()); builder.setCenterPanel(label); builder.setOkActionEnabled(true); ValidationResult result; switch (builder.show()) { case DialogWrapper.OK_EXIT_CODE: // this will cause recursive correction unless cancel is selected Project project = envContext.getProject(); ConfigAccessor configAccessor = config.isUseProjectSpecificSettings() ? new ProjectConfigComponent(project) : new ApplicationConfigComponent(); // design point - if this dialog is cancelled, should we assume the decompilation is cancelled? ShowSettingsUtil.getInstance().editConfigurable(project, configAccessor); config.copyFrom(configAccessor.getConfig()); result = validateEnvironment(config, envContext, consoleContext); break; case DialogWrapper.CANCEL_EXIT_CODE: default: result = new ValidationResult(false, true); break; } return result; }
From source file:org.mvnsearch.snippet.plugin.actions.EditSnippetAction.java
License:Apache License
/** * create or save snippet/*from w w w .j ava2 s. com*/ * * @param event event */ public void actionPerformed(final AnActionEvent event) { Project project = event.getData(PlatformDataKeys.PROJECT); final SearchPanelForm searchPanelForm = getSearchPanelForm(event); final Snippet currentSnippet = searchPanelForm.getCurrentSnippet(); editForm.fillInfo(searchPanelForm.getSelectedAgent(), currentSnippet); //new snippet for edit final Snippet newSnippet = currentSnippet == null ? searchPanelForm.getSelectedAgent().constructNewSnippet() : currentSnippet; final DialogBuilder builder = new DialogBuilder(project); builder.setTitle("Snippet Edit(All Field Required)"); builder.setCenterPanel(editForm.getRootPanel()); builder.setOkActionEnabled(true); builder.setOkOperation(new Runnable() { public void run() { if (editForm.isInvalid()) { builder.setTitle("Please fill requried fields!"); return; } builder.getDialogWrapper().close(1); editForm.fillSnippet(newSnippet); searchPanelForm.getSelectedAgent().updateSnippet(newSnippet); getSearchPanelForm(event).refreshSnippetInfo(); } }); builder.showModal(true); }