List of usage examples for com.intellij.openapi.ui DialogBuilder getDialogWrapper
public DialogWrapper getDialogWrapper()
From source file:com.machak.idea.plugins.actions.CopyHippoSharedFiles.java
License:Apache License
private void showProjectRootPopup(final String basePath, final File tomcatDirectory) { final DialogBuilder dialogBuilder = new DialogBuilder(project); dialogBuilder.setTitle("Create project file:"); final JPanel simplePanel = new JPanel(); simplePanel.add(new JLabel("Following path will be used as project base:\n" + basePath)); dialogBuilder.setCenterPanel(simplePanel); final Action acceptAction = new AbstractAction() { private static final long serialVersionUID = 1L; @Override//from w w w. j a v a 2s. c o m public void actionPerformed(final ActionEvent e) { // check if file exists and overwrite: final String filePath = tomcatDirectory.getAbsolutePath() + File.separator + "bin" + File.separator + PROJECT_FILE; createAndWriteFile(filePath, basePath); dialogBuilder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE); } }; acceptAction.putValue(Action.NAME, "OK"); dialogBuilder.addAction(acceptAction); dialogBuilder.addCancelAction(); dialogBuilder.showModal(true); }
From source file:com.machak.idea.plugins.actions.CopyHippoSharedFiles.java
License:Apache License
private void processJars(final ApplicationComponent component, final String tomcatSharedDirectory, final File sharedDirectory, final Map<String, String> depMap) { final FilenameFilter fileFilter = createJarsFilter(component, depMap); final File[] jars = sharedDirectory.listFiles(fileFilter); if (!component.isShowDialog()) { for (File jar : jars) { deleteFile(jar);/*w ww . ja v a 2 s. c om*/ } copyJars(tomcatSharedDirectory, depMap); return; } final int length = jars.length; myFiles = new String[length]; myCheckedMarks = new boolean[length]; for (int i = 0; i < length; i++) { final File file = jars[i]; myFiles[i] = file.getAbsolutePath(); myCheckedMarks[i] = true; } final TableModel model = new MyTableModel(); final JBTable myTable = new JBTable(); myTable.setPreferredSize(new Dimension(700, 400)); myTable.setModel(model); final TableColumnModel columnModel = myTable.getColumnModel(); columnModel.getColumn(CHECKED_COLUMN).setCellRenderer(new BooleanTableCellRenderer()); columnModel.getColumn(CHECKED_COLUMN).setPreferredWidth(40); columnModel.getColumn(FILE_COLUMN).setPreferredWidth(660); final DialogBuilder dialogBuilder = new DialogBuilder(project); dialogBuilder.setTitle("Files to delete"); dialogBuilder.setCenterPanel(myTable); final Action deleteAction = new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(final ActionEvent e) { final int length = model.getRowCount(); for (int i = 0; i < length; i++) { final Boolean checked = (Boolean) model.getValueAt(i, CHECKED_COLUMN); if (checked) { final File jar = jars[i]; deleteFile(jar); } } // do copy: copyJars(tomcatSharedDirectory, depMap); dialogBuilder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE); } }; deleteAction.putValue(Action.NAME, "OK"); dialogBuilder.addAction(deleteAction); dialogBuilder.addCancelAction(); dialogBuilder.showModal(true); }
From source file:com.machak.idea.plugins.tomcat.actions.DeleteTomcatWebapps.java
License:Apache License
private void showDeletePopup(final String webappsDirectory, final File webappDir) { final String absolutePath = webappDir.getAbsolutePath(); final DialogBuilder dialogBuilder = new DialogBuilder(project); dialogBuilder.setTitle("Create project file:"); final JPanel simplePanel = new JPanel(); simplePanel.add(new JLabel("All directories within: " + absolutePath + " will be deleted")); dialogBuilder.setCenterPanel(simplePanel); final Action acceptAction = new AbstractAction() { private static final long serialVersionUID = 1L; @Override/*from w w w . ja v a2s.com*/ public void actionPerformed(final ActionEvent e) { deleteFiles(webappsDirectory, webappDir); dialogBuilder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE); } }; acceptAction.putValue(Action.NAME, "OK"); dialogBuilder.addAction(acceptAction); dialogBuilder.addCancelAction(); dialogBuilder.showModal(true); }
From source file:com.urswolfer.intellij.plugin.gerrit.ui.diff.CustomizableFrameDiffTool.java
License:Apache License
public void show(DiffRequest request) { Collection hints = request.getHints(); boolean shouldOpenDialog = shouldOpenDialog(hints); if (shouldOpenDialog) { final DialogBuilder builder = new DialogBuilder(request.getProject()); DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true); if (diffPanel == null) { Disposer.dispose(builder);/*from w ww . ja v a2s . c o m*/ return; } if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) { diffPanel.setPatchAppliedApproximately(); // todo read only and not variants } final Runnable onOkRunnable = request.getOnOkRunnable(); if (onOkRunnable != null) { builder.setOkOperation(new Runnable() { @Override public void run() { builder.getDialogWrapper().close(0); onOkRunnable.run(); } }); } else { builder.removeAllActions(); } builder.setCenterPanel(diffPanel.getComponent()); builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent()); builder.setTitle(request.getWindowTitle()); builder.setDimensionServiceKey(request.getGroupKey()); new AnAction() { public void actionPerformed(final AnActionEvent e) { builder.getDialogWrapper().close(0); } }.registerCustomShortcutSet( new CustomShortcutSet( KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent()); showDiffDialog(builder, hints); } else { final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey()); DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper, true); if (diffPanel == null) { Disposer.dispose(frameWrapper); return; } if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) { diffPanel.setPatchAppliedApproximately(); } frameWrapper.setTitle(request.getWindowTitle()); DiffUtil.initDiffFrame(diffPanel.getProject(), frameWrapper, diffPanel, diffPanel.getComponent()); new AnAction() { public void actionPerformed(final AnActionEvent e) { frameWrapper.getFrame().dispose(); } }.registerCustomShortcutSet( new CustomShortcutSet( KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent()); frameWrapper.show(); } }
From source file:org.intellij.plugins.intelliLang.inject.AbstractLanguageInjectionSupport.java
License:Apache License
@Nullable protected static BaseInjection showDefaultInjectionUI(final Project project, BaseInjection injection) { final BaseInjectionPanel panel = new BaseInjectionPanel(injection, project); panel.reset();/*from w w w.jav a 2 s . com*/ final DialogBuilder builder = new DialogBuilder(project); LanguageInjectionSupport support = InjectorUtils.findInjectionSupport(injection.getSupportId()); if (support != null && support instanceof AbstractLanguageInjectionSupport) { builder.setHelpId(((AbstractLanguageInjectionSupport) support).getHelpId()); } builder.addOkAction(); builder.addCancelAction(); builder.setDimensionServiceKey("#org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionDialog"); builder.setCenterPanel(panel.getComponent()); builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE); builder.setOkOperation(new Runnable() { public void run() { try { panel.apply(); builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE); } catch (Exception e) { final Throwable cause = e.getCause(); final String message = e.getMessage() + (cause != null ? "\n " + cause.getMessage() : ""); Messages.showErrorDialog(project, message, "Unable to Save"); } } }); if (builder.show() == DialogWrapper.OK_EXIT_CODE) { return injection; } return null; }
From source file:org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport.java
License:Apache License
private static BaseInjection showInjectionUI(final Project project, final MethodParameterInjection methodParameterInjection) { final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project); panel.reset();/* w ww .ja v a2 s.c o m*/ final DialogBuilder builder = new DialogBuilder(project); builder.setHelpId("reference.settings.injection.language.injection.settings.java.parameter"); builder.addOkAction(); builder.addCancelAction(); builder.setCenterPanel(panel.getComponent()); builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE); builder.setOkOperation(new Runnable() { public void run() { panel.apply(); builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE); } }); if (builder.show() == DialogWrapper.OK_EXIT_CODE) { return new BaseInjection(methodParameterInjection.getSupportId()).copyFrom(methodParameterInjection); } return null; }
From source file:org.intellij.plugins.intelliLang.inject.xml.XmlLanguageInjectionSupport.java
License:Apache License
@Nullable private static BaseInjection showInjectionUI(final Project project, final BaseInjection xmlInjection) { final DialogBuilder builder = new DialogBuilder(project); final AbstractInjectionPanel panel; if (xmlInjection instanceof XmlTagInjection) { panel = new XmlTagPanel((XmlTagInjection) xmlInjection, project); builder.setHelpId("reference.settings.injection.language.injection.settings.xml.tag"); } else if (xmlInjection instanceof XmlAttributeInjection) { panel = new XmlAttributePanel((XmlAttributeInjection) xmlInjection, project); builder.setHelpId("reference.settings.injection.language.injection.settings.xml.attribute"); } else/*from w w w.j a va2 s . c om*/ throw new AssertionError(); panel.reset(); builder.addOkAction(); builder.addCancelAction(); builder.setCenterPanel(panel.getComponent()); builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE); builder.setOkOperation(new Runnable() { public void run() { panel.apply(); builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE); } }); if (builder.show() == DialogWrapper.OK_EXIT_CODE) { return new AbstractTagInjection().copyFrom(xmlInjection); } return null; }
From source file:org.jetbrains.idea.svn.integrate.QuickMergeInteractionImpl.java
License:Apache License
@Override public QuickMergeContentsVariants selectMergeVariant() { final QuickMergeWayOptionsPanel panel = new QuickMergeWayOptionsPanel(); final DialogBuilder builder = new DialogBuilder(myProject); builder.removeAllActions();/*from ww w.j a v a2s.c om*/ builder.setTitle("Select Merge Variant"); builder.setCenterPanel(panel.getMainPanel()); panel.setWrapper(builder.getDialogWrapper()); builder.show(); return panel.getVariant(); }
From source file:org.mvnsearch.snippet.plugin.actions.CreateSnippetFileAction.java
License:Apache License
public void actionPerformed(AnActionEvent event) { final Project project = event.getData(PlatformDataKeys.PROJECT); final PsiElement psiElement = event.getData(LangDataKeys.PSI_ELEMENT); if (psiElement instanceof PsiDirectory) { final SnippetFileCreationForm form = new SnippetFileCreationForm(); final DialogBuilder builder = new DialogBuilder(project); builder.setTitle("Create file from snippet"); builder.setCenterPanel(form.getRootPanel()); builder.setOkOperation(new Runnable() { public void run() { String result = generateFile((PsiDirectory) psiElement, form.getMnemonic(), form.getFileName(), project);// w w w .j a va2s .co m if (StringUtil.isEmpty(result)) { //create successfully builder.getDialogWrapper().close(1); } else { //failed builder.setTitle(result); } } }); builder.showModal(true); } }
From source file:org.mvnsearch.snippet.plugin.actions.EditSnippetAction.java
License:Apache License
/** * create or save snippet//w w w . jav a 2s . c o m * * @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); }