Java Code Examples for com.intellij.openapi.ui.DialogBuilder#show()
The following examples show how to use
com.intellij.openapi.ui.DialogBuilder#show() .
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: PackagesNotificationPanel.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void doShowError(String title, String description, DialogBuilder builder) { builder.setTitle(title); final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setText(description); textArea.setWrapStyleWord(false); textArea.setLineWrap(true); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); final JPanel panel = new JPanel(new BorderLayout(10, 0)); panel.setPreferredSize(new Dimension(600, 400)); panel.add(scrollPane, BorderLayout.CENTER); panel.add(new JBLabel("Details:", Messages.getErrorIcon(), SwingConstants.LEFT), BorderLayout.NORTH); builder.setCenterPanel(panel); builder.setButtonsAlignment(SwingConstants.CENTER); builder.addOkAction(); builder.show(); }
Example 2
Source File: DateFilterPopupComponent.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(@Nonnull AnActionEvent e) { final DateFilterComponent dateComponent = new DateFilterComponent(false, DateFormatUtil.getDateFormat().getDelegate()); VcsLogDateFilter currentFilter = myFilterModel.getFilter(); if (currentFilter != null) { if (currentFilter.getBefore() != null) { dateComponent.setBefore(currentFilter.getBefore().getTime()); } if (currentFilter.getAfter() != null) { dateComponent.setAfter(currentFilter.getAfter().getTime()); } } DialogBuilder db = new DialogBuilder(DateFilterPopupComponent.this); db.addOkAction(); db.setCenterPanel(dateComponent.getPanel()); db.setPreferredFocusComponent(dateComponent.getPanel()); db.setTitle("Select Period"); if (DialogWrapper.OK_EXIT_CODE == db.show()) { long after = dateComponent.getAfter(); long before = dateComponent.getBefore(); VcsLogDateFilter filter = new VcsLogDateFilterImpl(after > 0 ? new Date(after) : null, before > 0 ? new Date(before) : null); myFilterModel.setFilter(filter); } }
Example 3
Source File: MergeTool.java From consulo with Apache License 2.0 | 6 votes |
private static void showDialog(MergeRequestImpl data) { DialogBuilder builder = new DialogBuilder(data.getProject()); builder.setDimensionServiceKey(data.getGroupKey()); builder.setTitle(data.getWindowTitle()); Disposable parent = Disposable.newDisposable(); builder.addDisposable(parent); MergePanel2 mergePanel = createMergeComponent(data, builder, parent); builder.setCenterPanel(mergePanel.getComponent()); builder.setPreferredFocusComponent(mergePanel.getPreferredFocusedComponent()); builder.setHelpId(data.getHelpId()); int result = builder.show(); MergeRequestImpl lastData = mergePanel.getMergeRequest(); if (lastData != null) { lastData.setResult(result); } }
Example 4
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 5
Source File: TemplateEditPane.java From CodeMaker with Apache License 2.0 | 5 votes |
private void testTemplate() { CodeTemplate template = new CodeTemplate(getTemplateName(), getClassName(), getTemplate(), getClassNumber(), getFileEncoding(), getTemplateLanguage(), getTargetLanguage()); final List<ClassEntry> classEntries = inputClassIndices() .map(i -> getSelectedTestInput().createInput("SomeClass" + i) ) .collect(Collectors.toList()); Object result; try { result = templateEngine.evaluate(template, classEntries, classEntries.get(0)); } catch (Throwable e) { result = e; } final DialogBuilder builder = new DialogBuilder(this.templateEdit); builder.addCloseButton().setText("Close"); if(result instanceof GeneratedSource) { builder.setTitle(((GeneratedSource) result).getClassName()); builder.setCenterPanel( Editors.createSourceEditor(null, getTargetLanguage(), ((GeneratedSource) result).getContent(), true).getComponent()); } else { Throwable error = (Throwable) result; builder.setTitle("Failed!"); builder.setCenterPanel( Editors.createSourceEditor(null, "txt", error.getMessage() + "\n\n" + ExceptionUtil.getThrowableText(error), true) .getComponent()); } builder.show(); }
Example 6
Source File: CodeMakerAction.java From CodeMaker with Apache License 2.0 | 5 votes |
private void showSource(Project project, String language, String className, String content) { final Editor editor = Editors.createSourceEditor(project, language, content, true); try { final DialogBuilder builder = new DialogBuilder(project); builder.addCloseButton().setText("Close"); builder.setCenterPanel(editor.getComponent()); builder.setTitle(className); builder.show(); } finally { Editors.release(editor); } }
Example 7
Source File: DialogUtil.java From freeline with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 创建普通对话框 * @param message * @param okText * @param cancelText * @return */ public static boolean createDialog(String message, String okText, String cancelText) { DialogBuilder builder = new DialogBuilder(); builder.setTitle("Dialog Message"); builder.resizable(false); builder.setCenterPanel(new JLabel(message, Messages.getInformationIcon(), SwingConstants.CENTER)); builder.addOkAction().setText(okText); builder.addCancelAction().setText(cancelText); builder.setButtonsAlignment(SwingConstants.CENTER); return builder.show() == 0; }
Example 8
Source File: UsingReportAction.java From freeline with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void actionPerformed(AnActionEvent event) { final Project project = event.getProject(); Module[] modules = ModuleManager.getInstance(project).getModules(); List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>(); for (Module module : modules) { GradleBuildFile file = GradleBuildFile.get(module); if (file != null && !GradleUtil.isLibrary(file)) { selectModulesList.add(Pair.create(module, file.getPsiFile())); } } if (selectModulesList.size() > 1) { final DialogBuilder builder = new DialogBuilder(); builder.setTitle("Freeline Reporter"); builder.resizable(false); builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the exact one.", Messages.getInformationIcon(), SwingConstants.CENTER)); builder.addOkAction().setText("Cancel"); for (final Pair<Module, PsiFile> pair : selectModulesList) { builder.addAction(new AbstractAction(":" + pair.first.getName()) { @Override public void actionPerformed(ActionEvent e) { builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE); report(project, pair.getSecond()); } }); } if (builder.show() > -1) { //return false; } } else if (selectModulesList.size() == 1) { report(project, selectModulesList.get(0).getSecond()); } }
Example 9
Source File: ExtractConceptInfoCollector.java From Intellij-Plugin with Apache License 2.0 | 5 votes |
private void showDialog(String steps, ExtractConceptDialog form) { final DialogBuilder builder = new DialogBuilder(editor.getProject()); form.setData(steps, getConceptFileNames(), builder); builder.setCenterPanel(form.getRootPane()); builder.setTitle("Extract Concept"); builder.removeAllActions(); builder.show(); }
Example 10
Source File: ExecutionErrorDialog.java From consulo with Apache License 2.0 | 5 votes |
public static void show(final ExecutionException e, final String title, final Project project) { if (e instanceof RunCanceledByUserException) { return; } if (ApplicationManager.getApplication().isUnitTestMode()) { throw new RuntimeException(e.getLocalizedMessage()); } final String message = e.getMessage(); if (message == null || message.length() < 100) { Messages.showErrorDialog(project, message == null ? "exception was thrown" : message, title); return; } final DialogBuilder builder = new DialogBuilder(project); builder.setTitle(title); final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setForeground(UIUtil.getLabelForeground()); textArea.setBackground(UIUtil.getLabelBackground()); textArea.setFont(UIUtil.getLabelFont()); textArea.setText(message); textArea.setWrapStyleWord(false); textArea.setLineWrap(true); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); final JPanel panel = new JPanel(new BorderLayout(10, 0)); panel.setPreferredSize(new Dimension(500, 200)); panel.add(scrollPane, BorderLayout.CENTER); panel.add(new JLabel(Messages.getErrorIcon()), BorderLayout.WEST); builder.setCenterPanel(panel); builder.setButtonsAlignment(SwingConstants.CENTER); builder.addOkAction(); builder.show(); }
Example 11
Source File: EnvironmentVariablesTextFieldWithBrowseButton.java From consulo with Apache License 2.0 | 5 votes |
public static void showParentEnvironmentDialog(@Nonnull Component parent) { EnvVariablesTable table = new EnvVariablesTable(); table.setValues(convertToVariables(new TreeMap<>(new GeneralCommandLine().getParentEnvironment()), true)); table.getActionsPanel().setVisible(false); DialogBuilder builder = new DialogBuilder(parent); builder.setTitle(ExecutionBundle.message("environment.variables.system.dialog.title")); builder.centerPanel(table.getComponent()); builder.addCloseButton(); builder.show(); }
Example 12
Source File: RenderingOptionsForm.java From markdown-doclet with GNU General Public License v3.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { DialogBuilder dialogBuilder = new DialogBuilder((Component)e.getSource()); dialogBuilder.setTitle("Markdown Javadoc Rendering Options"); dialogBuilder.addOkAction(); dialogBuilder.addCancelAction(); RenderingOptionsForm form = new RenderingOptionsForm(options.renderingOptions); dialogBuilder.setCenterPanel(form.getComponent()); int exitCode = dialogBuilder.show(); if (exitCode == DialogWrapper.OK_EXIT_CODE) { options.renderingOptions = form.get(); } }
Example 13
Source File: FreelineUtil.java From freeline with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * 检查是否需要载入Freeline * * @param project * @return */ public static boolean checkInstall(@NotNull final Project project) { final FreelineStatus status = getFreelineStatus(project); if (GradleUtil.isSyncInProgress(project)) { NotificationUtils.errorMsgDialog("Waiting for sync project to complete"); return false; } if (status.hasInitFreeline()) { return true; } if (status.getGradleBuildFiles().size() < 1) { NotificationUtils.errorMsgDialog("It's not an Android Gradle project Currently?"); return false; } if (status.isExistClasspath() && status.isExistPlugin() && !status.isExistFreelineCore()) { NotificationUtils.errorNotification("Execute task initFreeline and download freeline dependencies..."); initFreeline(project); return false; } if (DialogUtil.createDialog("Detected that you did not installFreeline Freeline, Whether installFreeline Automatically?", "Install Freeline Automatically", "Cancel")) { Module[] modules = ModuleManager.getInstance(project).getModules(); List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>(); for (Module module : modules) { GradleBuildFile file = GradleBuildFile.get(module); if (file != null && !GradleUtil.isLibrary(file)) { selectModulesList.add(Pair.create(module, file.getPsiFile())); } } // 多个app模块的情况 if (selectModulesList.size() > 1) { final DialogBuilder builder = new DialogBuilder(); builder.setTitle("Install Freeline"); builder.resizable(false); builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the module to be installed Freeline.", Messages.getInformationIcon(), SwingConstants.CENTER)); builder.addOkAction().setText("Cancel"); for (final Pair<Module, PsiFile> pair : selectModulesList) { builder.addAction(new AbstractAction(":" + pair.first.getName()) { @Override public void actionPerformed(ActionEvent e) { builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE); installFreeline(project, status, pair.getSecond()); } }); } if (builder.show() > -1) { return false; } } else if (selectModulesList.size() == 1) { installFreeline(project, status, selectModulesList.get(0).getSecond()); } else { NotificationUtils.errorMsgDialog("Can not found Application Module! Please Sync Project."); return false; } } return false; }
Example 14
Source File: MemoryDiskConflictResolver.java From consulo with Apache License 2.0 | 4 votes |
boolean askReloadFromDisk(VirtualFile file, Document document) { if (myConflictAppeared != null) { Throwable trace = myConflictAppeared; myConflictAppeared = null; throw new IllegalStateException("Unexpected memory-disk conflict in tests for " + file.getPath() + ", please use FileDocumentManager#reloadFromDisk or avoid VFS refresh", trace); } String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl()); DialogBuilder builder = new DialogBuilder(); builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER)); builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button")); builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button")); builder.addAction(new AbstractAction(UIBundle.message("file.cache.conflict.show.difference.button")) { @Override public void actionPerformed(ActionEvent e) { Project project = ProjectLocator.getInstance().guessProjectForFile(file); String fsContent = LoadTextUtil.loadText(file).toString(); DocumentContent content1 = DiffContentFactory.getInstance().create(project, fsContent, file.getFileType()); DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file); String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl()); String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content"); String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content"); DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2); request.putUserData(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, true); DialogBuilder diffBuilder = new DialogBuilder(project); DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, diffBuilder, diffBuilder.getWindow()); diffPanel.setRequest(request); diffBuilder.setCenterPanel(diffPanel.getComponent()); diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict"); diffBuilder.addOkAction().setText(UIBundle.message("file.cache.conflict.save.changes.button")); diffBuilder.addCancelAction(); diffBuilder.setTitle(title); if (diffBuilder.show() == DialogWrapper.OK_EXIT_CODE) { builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE); } } }); builder.setTitle(UIBundle.message("file.cache.conflict.dialog.title")); builder.setButtonsAlignment(SwingConstants.CENTER); builder.setHelpId("reference.dialogs.fileCacheConflict"); return builder.show() == 0; }