List of usage examples for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE
int OK_EXIT_CODE
To view the source code for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE.
Click Source Link
From source file:com.jetbrains.lang.dart.ide.refactoring.ServerRefactoringDialog.java
License:Apache License
@Override protected void doAction() { // Validate final status. {// w w w . j ava 2 s . c o m final RefactoringStatus finalStatus = myRefactoring.checkFinalConditions(); if (finalStatus == null) { return; } if (finalStatus.hasError()) { Messages.showErrorDialog(myProject, finalStatus.getMessage(), CommonBundle.getErrorTitle()); return; } } if (hasPreviewButton() && isPreviewUsages() || isForcePreview()) { previewRefactoring(); } else { doRefactoring(myRefactoring.getPotentialEdits()); } close(DialogWrapper.OK_EXIT_CODE); }
From source file:com.jetbrains.lang.dart.ide.refactoring.ServerRefactoringDialog.java
License:Apache License
protected final void doRefactoring(@NotNull final Set<String> excludedIds) { // Apply the change. final String error = ApplicationManager.getApplication().runWriteAction(new Computable<String>() { @Override//w ww. j a v a 2s.c om public String compute() { final SourceChange change = myRefactoring.getChange(); assert change != null; try { AssistUtils.applySourceChange(myProject, change, false, excludedIds); } catch (DartSourceEditException e) { return e.getMessage(); } return null; } }); if (error == null) { close(DialogWrapper.OK_EXIT_CODE); } else { Messages.showErrorDialog(myProject, error, CommonBundle.getErrorTitle()); } }
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 ww w . j av 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);//from w w w . ja v a2s .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 . j ava 2 s .c om*/ 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.maddyhome.idea.copyright.actions.GenerateCopyrightAction.java
License:Apache License
public void actionPerformed(AnActionEvent event) { DataContext context = event.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(context); assert project != null; Module module = LangDataKeys.MODULE.getData(context); PsiDocumentManager.getInstance(project).commitAllDocuments(); PsiFile file = getFile(context, project); assert file != null; if (CopyrightManager.getInstance(project).getCopyrightOptions(file) == null) { if (Messages.showOkCancelDialog(project, "No copyright configured for current file. Would you like to edit copyright settings?", "No Copyright Available", Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) { ShowSettingsUtil.getInstance().showSettingsDialog(project, new CopyrightProjectConfigurable(project).getDisplayName()); } else {//from w w w . j a v a 2s. c o m return; } } new UpdateCopyrightProcessor(project, module, file).run(); }
From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.PluginHeaderPanel.java
License:Apache License
private void createUIComponents() { myInstallButton = new JButton() { {/*from w w w .j a v a 2 s .c o m*/ setOpaque(false); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } @Override public Dimension getPreferredSize() { final FontMetrics metrics = getFontMetrics(getFont()); final int textWidth = metrics.stringWidth(getText()); final int width = 8 + 16 + 4 + textWidth + 8; final int height = 2 + Math.max(16, metrics.getHeight()) + 2; return new Dimension(width, height); } @Override public void paint(Graphics g2) { final Graphics2D g = (Graphics2D) g2; final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); final int w = g.getClipBounds().width; final int h = g.getClipBounds().height; g.setPaint(getBackgroundBorderPaint()); g.fillRoundRect(0, 0, w, h, 7, 7); g.setPaint(getBackgroundPaint()); g.fillRoundRect(1, 1, w - 2, h - 2, 6, 6); g.setColor(getButtonForeground()); int offset = 8; g.drawString(getText(), offset + 16 + 4, getBaseline(w, h)); getIcon().paintIcon(this, g, offset, (getHeight() - getIcon().getIconHeight()) / 2); config.restore(); } private Color getButtonForeground() { switch (myActionId) { case UPDATE: return new JBColor(Gray._240, Gray._210); case INSTALL: return new JBColor(Gray._240, Gray._210); case RESTART: case UNINSTALL: return new JBColor(Gray._0, Gray._210); } return new JBColor(Gray._80, Gray._60); } private Paint getBackgroundPaint() { switch (myActionId) { case UPDATE: return new JBGradientPaint(this, new JBColor(new Color(98, 158, 225), new Color(98, 158, 225)), new JBColor(new Color(58, 91, 181), new Color(58, 91, 181))); case INSTALL: return new JBGradientPaint(this, new JBColor(new Color(96, 204, 105), new Color(81, 149, 87)), new JBColor(new Color(50, 101, 41), new Color(40, 70, 47))); case RESTART: case UNINSTALL: return UIUtil.isUnderDarcula() ? new JBGradientPaint(this, UIManager.getColor("Button.darcula.color1"), UIManager.getColor("Button.darcula.color2")) : Gray._240; } return Gray._238; } private Paint getBackgroundBorderPaint() { switch (myActionId) { case UPDATE: return new JBColor(new Color(166, 180, 205), Gray._85); case INSTALL: return new JBColor(new Color(201, 223, 201), Gray._70); case RESTART: case UNINSTALL: return new JBColor(Gray._220, Gray._100.withAlpha(180)); } return Gray._208; } @Override public String getText() { switch (myActionId) { case UPDATE: return "Update"; case INSTALL: return "Install"; case UNINSTALL: return "Uninstall"; case RESTART: return "Restart " + ApplicationNamesInfo.getInstance().getFullProductName(); } return super.getText(); } @Override public Icon getIcon() { switch (myActionId) { case UPDATE: return AllIcons.General.DownloadPlugin; case INSTALL: return AllIcons.General.DownloadPlugin; case UNINSTALL: return AllIcons.Actions.Delete; case RESTART: return AllIcons.Actions.Restart; } return super.getIcon(); } }; myInstallButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { switch (myActionId) { case UPDATE: case INSTALL: new InstallPluginAction(myManager.getAvailable(), myManager.getInstalled()) .install(new Runnable() { @Override public void run() { setPlugin(myPlugin); } }, true); break; case UNINSTALL: UninstallPluginAction.uninstall(myManager.getInstalled(), true, myPlugin); break; case RESTART: if (myManager != null) { myManager.apply(); } final DialogWrapper dialog = DialogWrapper .findInstance(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); if (dialog != null && dialog.isModal()) { dialog.close(DialogWrapper.OK_EXIT_CODE); } //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final DialogWrapper settings = DialogWrapper .findInstance(IdeFocusManager.findInstance().getFocusOwner()); if (settings instanceof SettingsDialog) { ((SettingsDialog) settings).doOKAction(); ApplicationManager.getApplication().restart(); } else { ApplicationManager.getApplication().restart(); } } }); break; } setPlugin(myPlugin); } }); }
From source file:com.microsoft.alm.plugin.idea.tfvc.core.tfs.conflicts.DialogContentMerger.java
License:Open Source License
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 {/*from w w w . j a v a 2 s . c o m*/ 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; } }
From source file:com.microsoft.azure.hdinsight.common.ErrorMessageForm.java
License:Open Source License
public ErrorMessageForm(String title) { super((Project) null, true); setModal(true);//from w w w. j a v a 2 s .com setTitle(title); getRootPane().setDefaultButton(buttonOK); buttonOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { close(DialogWrapper.OK_EXIT_CODE, true); } }); showAdvancedInfoCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { setDetailsVisible(showAdvancedInfoCheckBox.isSelected()); } }); showAdvancedInfoCheckBox.setText(advancedInfoText); init(); }
From source file:com.microsoft.azure.hdinsight.serverexplore.ui.AddNewClusterFrom.java
License:Open Source License
private void addActionListener() { Okbutton.addActionListener(new ActionListener() { @Override// w ww.j a va2 s . c o m public void actionPerformed(ActionEvent e) { synchronized (AddNewClusterFrom.class) { isCarryOnNextStep = true; errorMessage = null; errorMessageField.setVisible(false); String clusterNameOrUrl = clusterNameFiled.getText().trim(); userName = userNameField.getText().trim(); storageName = storageNameField.getText().trim(); storageKey = storageKeyTextField.getText().trim(); password = String.valueOf(passwordField.getPassword()); if (StringHelper.isNullOrWhiteSpace(clusterNameOrUrl) || StringHelper.isNullOrWhiteSpace(storageName) || StringHelper.isNullOrWhiteSpace(storageKey) || StringHelper.isNullOrWhiteSpace(userName) || StringHelper.isNullOrWhiteSpace(password)) { errorMessage = "Cluster Name, Storage Key, User Name, or Password shouldn't be empty"; isCarryOnNextStep = false; } else { clusterName = getClusterName(clusterNameOrUrl); if (clusterName == null) { errorMessage = "Wrong cluster name or endpoint"; isCarryOnNextStep = false; } else { int status = ClusterManagerEx.getInstance() .isHDInsightAdditionalStorageExist(clusterName, storageName); if (status == 1) { errorMessage = "Cluster already exist in current list"; isCarryOnNextStep = false; } else if (status == 2) { errorMessage = "Default storage account is required"; isCarryOnNextStep = false; } } } if (isCarryOnNextStep) { getStorageAccount(); } if (isCarryOnNextStep) { if (storageAccount != null) { HDInsightAdditionalClusterDetail hdInsightAdditionalClusterDetail = new HDInsightAdditionalClusterDetail( clusterName, userName, password, storageAccount); ClusterManagerEx.getInstance() .addHDInsightAdditionalCluster(hdInsightAdditionalClusterDetail); hdInsightModule.refreshWithoutAsync(); } close(DialogWrapper.OK_EXIT_CODE, true); } else { errorMessageField.setText(errorMessage); errorMessageField.setVisible(true); } } } }); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { close(DialogWrapper.CANCEL_EXIT_CODE, true); } }); }