Java Code Examples for com.intellij.openapi.ui.DialogBuilder#addAction()
The following examples show how to use
com.intellij.openapi.ui.DialogBuilder#addAction() .
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: 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 2
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 3
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; }