List of usage examples for com.intellij.openapi.ui Messages showYesNoDialog
@YesNoResult public static int showYesNoDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
From source file:org.jetbrains.tfsIntegration.ui.ManageWorkspacesForm.java
License:Apache License
private void removeServer(final @NotNull ServerInfo server) { String warning = TFSBundle.message("remove.server.prompt", server.getPresentableUri()); if (Messages.showYesNoDialog(myContentPane, warning, TFSBundle.message("remove.server.title"), Messages.getWarningIcon()) == Messages.YES) { Workstation.getInstance().removeServer(server); updateControls(null);/* w w w .j av a 2 s . c om*/ } }
From source file:org.jetbrains.tfsIntegration.ui.ManageWorkspacesForm.java
License:Apache License
private void deleteWorkspace(@NotNull WorkspaceInfo workspace) { if (Messages.showYesNoDialog(myContentPane, TFSBundle.message("delete.workspace.prompt", workspace.getName()), TFSBundle.message("delete.workspace.title"), Messages.getWarningIcon()) != Messages.YES) { return;/*from w w w . j a v a2 s . com*/ } try { workspace.getServer().deleteWorkspace(workspace, myContentPane, true); updateControls(workspace); } catch (UserCancelledException e) { // ignore } catch (TfsException e) { Messages.showErrorDialog(myProject, e.getMessage(), TFSBundle.message("delete.workspace.title")); } }
From source file:org.jetbrains.tfsIntegration.ui.ProjectConfigurableForm.java
License:Apache License
public ProjectConfigurableForm(final Project project) { myProject = project;/*from w ww . j av a 2 s.com*/ myManageButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { ManageWorkspacesDialog d = new ManageWorkspacesDialog(myProject); d.show(); } }); myUseIdeaHttpProxyCheckBox.setSelected(TFSConfigurationManager.getInstance().useIdeaHttpProxy()); myResetPasswordsButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final String title = "Reset Stored Passwords"; if (Messages.showYesNoDialog(myProject, "Do you want to reset all stored passwords?", title, Messages.getQuestionIcon()) == Messages.YES) { TFSConfigurationManager.getInstance().resetStoredPasswords(); Messages.showInfoMessage(myProject, "Passwords reset successfully.", title); } } }); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent e) { updateNonInstalledCheckbox(); } }; myStatefulCheckBox.addActionListener(l); myTFSCheckBox.addActionListener(l); }
From source file:org.jetbrains.tfsIntegration.ui.TfsLoginDialog.java
License:Apache License
@Override protected void doOKAction() { if (shouldPromptForProxyPassword(false)) { HttpConfigurable hc = HttpConfigurable.getInstance(); hc.setPlainProxyPassword(myLoginForm.getProxyPassword()); }//ww w . j a va2s. c o m if (myLoginForm.getCredentials().getType() == Credentials.Type.Alternate && "http".equals(getUri().getScheme())) { if (Messages.showYesNoDialog(myLoginForm.getContentPane(), "You're about to send your credentials over unsecured HTTP connection. Continue?", getTitle(), null) != Messages.YES) { return; } } if (myOkActionCallback == null || myOkActionCallback.value(this)) { super.doOKAction(); } }
From source file:org.napile.idea.thermit.config.explorer.AntExplorer.java
License:Apache License
public void removeBuildFile() { final AntBuildFile buildFile = getCurrentBuildFile(); if (buildFile == null) { return;//w w w .j ava 2s . c om } final String fileName = buildFile.getPresentableUrl(); final int result = Messages.showYesNoDialog(myProject, ThermitBundle.message("remove.the.reference.to.file.confirmation.text", fileName), ThermitBundle.message("confirm.remove.dialog.title"), Messages.getQuestionIcon()); if (result != 0) { return; } myConfig.removeBuildFile(buildFile); }
From source file:org.sonar.ide.intellij.config.SonarQubeSettingsForm.java
License:Open Source License
public SonarQubeSettingsForm() { addButton.addActionListener(new ActionListener() { @Override//w w w .ja v a 2s . c o m public void actionPerformed(ActionEvent e) { SonarQubeServerDialog dialog = new SonarQubeServerDialog(formComponent, null, getServers()); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { serversList.addItem(dialog.getServer()); serversList.setSelectedItem(dialog.getServer()); modified = true; refreshButtons(); } } }); serversList.setRenderer(new ListCellRendererWrapper() { @Override public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) { setText(value != null ? ((SonarQubeServer) value).getId() : SonarQubeBundle.message("sonarqube.settings.server.no_server")); } }); editButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SonarQubeServerDialog dialog = new SonarQubeServerDialog(formComponent, (SonarQubeServer) serversList.getSelectedItem(), getServers()); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { DefaultComboBoxModel model = (DefaultComboBoxModel) serversList.getModel(); int selectedIndex = model.getIndexOf(model.getSelectedItem()); model.removeElementAt(selectedIndex); model.insertElementAt(dialog.getServer(), selectedIndex); model.setSelectedItem(dialog.getServer()); modified = true; refreshButtons(); } } }); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SonarQubeServer server = (SonarQubeServer) serversList.getSelectedItem(); if (server != null && Messages.showYesNoDialog(formComponent, SonarQubeBundle.message("sonarqube.settings.server.remove.msg", server.getId()), SonarQubeBundle.message("sonarqube.settings.server.remove.title"), Messages.getQuestionIcon()) == Messages.YES) { serversList.removeItem(serversList.getSelectedItem()); modified = true; refreshButtons(); } } }); }
From source file:org.trzcinka.intellitrac.view.toolwindow.tickets.reports_list.ReportsListForm.java
License:Apache License
public ReportsListForm() { editButton.addActionListener(new ActionListener() { /**//from w w w.j a va 2 s . c o m * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { Report selectedReport = (Report) reportsList.getSelectedValue(); if (selectedReport != null) { State stateInfo = State.REPORT_EDITOR; ticketsModel.getCurrentReportModel().setCurrentReport(selectedReport); ticketsModel.setCurrentState(stateInfo); } } }); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Report selectedReport = (Report) reportsList.getSelectedValue(); if (selectedReport != null) { String message = bundle.getString("tool_window.tickets.reports_list.confirm_report_removal"); int answer = Messages.showYesNoDialog(ApplicationModel.getProject(), message, bundle.getString("dialogs.warning"), Messages.getQuestionIcon()); if (answer == 0) { ticketsModel.getReportsListModel().removeReport(selectedReport); } } } }); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { State state = State.REPORT_EDITOR; ticketsModel.getCurrentReportModel().setCurrentReport(new Report()); ticketsModel.setCurrentState(state); } }); openButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openReport(); } }); reportsList.addComponentListener(new ComponentAdapter() { }); reportsList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openReport(); } } }); }
From source file:org.twodividedbyzero.idea.findbugs.actions.ImportBugCollection.java
License:Open Source License
@SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON") @Override/*from w w w .j av a 2 s .c om*/ void actionPerformedImpl(@NotNull final AnActionEvent e, @NotNull final Project project, @Nullable final Module module, @NotNull final FindBugsPlugin plugin, @NotNull final ToolWindow toolWindow, @NotNull final FindBugsState state, @NotNull final FindBugsPreferences preferences) { final DialogBuilder dialogBuilder = new DialogBuilder(project); dialogBuilder.addOkAction(); dialogBuilder.addCancelAction(); dialogBuilder.setTitle("Import previous saved bug collection xml"); final String exportDir = preferences.getProperty(FindBugsPreferences.EXPORT_BASE_DIR, FindBugsPluginConstants.DEFAULT_EXPORT_DIR) + File.separatorChar + project.getName(); final ImportFileDialog importFileDialog = new ImportFileDialog(exportDir, dialogBuilder); dialogBuilder.showModal(true); if (dialogBuilder.getDialogWrapper().getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) { return; } final String fileToImport = importFileDialog.getText(); if (fileToImport == null || fileToImport.trim().isEmpty()) { return; } final BugCollection bugCollection = plugin.getToolWindowPanel().getBugCollection(); if (bugCollection != null && !bugCollection.getCollection().isEmpty()) { //noinspection DialogTitleCapitalization final int result = Messages.showYesNoDialog(project, "Current result in the 'Found bugs view' will be deleted. Continue ?", "Delete found bugs?", Messages.getQuestionIcon()); if (result == 1) { return; } } final AtomicBoolean taskCanceled = new AtomicBoolean(); final TransferToEDTQueue<Runnable> transferToEDTQueue = new TransferToEDTQueue<Runnable>( "Add New Bug Instance", new Processor<Runnable>() { @Override public boolean process(Runnable runnable) { runnable.run(); return true; } }, new Condition<Object>() { @Override public boolean value(Object o) { return project.isDisposed() || taskCanceled.get(); } }, 500); //Create a task to import the bug collection from XML final BackgroundableTask task = new BackgroundableTask(project, "Importing Findbugs Result", true) { private ProgressIndicator _indicator; @SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" }) @Override public void run(@NotNull final ProgressIndicator indicator) { MessageBusManager.publishAnalysisStartedToEDT(project); setProgressIndicator(indicator); indicator.setFraction(0.0); indicator.setIndeterminate(false); indicator.setText(fileToImport); SortedBugCollection importBugCollection = null; try { final SortedBugCollection bugCollection = new SortedBugCollection(); final FindBugsPlugin pluginComponent = IdeaUtilImpl.getPluginComponent(project); importBugCollection = bugCollection.createEmptyCollectionWithMetadata(); final edu.umd.cs.findbugs.Project importProject = importBugCollection.getProject(); importProject.setGuiCallback(new PluginGuiCallback(pluginComponent)); importBugCollection.setDoNotUseCloud(true); for (final Plugin plugin : Plugin.getAllPlugins()) { importProject.setPluginStatusTrinary(plugin.getPluginId(), !preferences.isPluginDisabled(plugin.getPluginId())); } importBugCollection.readXML(fileToImport); final ProjectStats projectStats = importBugCollection.getProjectStats(); int bugCount = 0; for (final BugInstance bugInstance : importBugCollection) { if (indicator.isCanceled()) { taskCanceled.set(true); MessageBusManager.publishAnalysisAbortedToEDT(project); Thread.currentThread().interrupt(); return; } final Integer bugCounter = bugCount++; final double fraction = bugCounter.doubleValue() / projectStats.getTotalBugs(); indicator.setFraction(fraction); indicator.setText2("Importing bug '" + bugCount + "' of '" + projectStats.getTotalBugs() + "' - " + bugInstance.getMessageWithoutPrefix()); /** * Guarantee thread visibility *one* time. */ final AtomicReference<BugInstance> bugInstanceRef = New.atomicRef(bugInstance); final AtomicReference<ProjectStats> projectStatsRef = New.atomicRef(projectStats); transferToEDTQueue.offer(new Runnable() { /** * Invoked by EDT. */ @Override public void run() { MessageBusManager.publishNewBugInstance(project, bugInstanceRef.get(), projectStatsRef.get()); } }); } EventDispatchThreadHelper.invokeLater(new Runnable() { public void run() { transferToEDTQueue.drain(); FindBugsPluginImpl.showToolWindowNotifier(project, "Imported bug collection from '" + fileToImport + "'.", MessageType.INFO); } }); importBugCollection.setDoNotUseCloud(false); importBugCollection.setTimestamp(System.currentTimeMillis()); importBugCollection.reinitializeCloud(); } catch (final IOException e1) { MessageBusManager.publishAnalysisAbortedToEDT(project); final String message = "Import failed"; showToolWindowNotifier(project, message, MessageType.ERROR); LOGGER.error(message, e1); } catch (final DocumentException e1) { MessageBusManager.publishAnalysisAbortedToEDT(project); final String message = "Import failed"; showToolWindowNotifier(project, message, MessageType.ERROR); LOGGER.error(message, e1); } finally { MessageBusManager.publishAnalysisFinishedToEDT(project, importBugCollection, null, null); Thread.currentThread().interrupt(); } } @Override public void setProgressIndicator(@NotNull final ProgressIndicator indicator) { _indicator = indicator; } @Override public ProgressIndicator getProgressIndicator() { return _indicator; } }; task.setCancelText("Cancel"); task.asBackgroundable(); task.queue(); }
From source file:org.twodividedbyzero.idea.findbugs.gui.preferences.ConfigurationPanel.java
License:Open Source License
private boolean validatePreferences(@Nullable final PersistencePreferencesBean prefs) { if (prefs == null) { Messages.showErrorDialog(this, "The configuration is invalid.", "Invalid Configuration"); return false; } else if (prefs.isEmpty()) { final int answer = Messages.showYesNoDialog(this, "The configuration is empty. Do you want to proceed?", "Empty Configuration", Messages.getQuestionIcon()); if (answer != DialogWrapper.OK_EXIT_CODE) { return false; }//from w ww.ja va2 s . c o m } return true; }
From source file:org.twodividedbyzero.idea.findbugs.gui.preferences.PluginConfiguration.java
License:Open Source License
private void doAddPlugin(final File selectedFile) { try {// w w w .ja va 2s . co m // TODO CUSTOM_PLUGIN: check what happen when a plugin with same pluginId is already loaded ? final Plugin plugin = FindBugsCustomPluginUtil.loadTemporary(selectedFile); if (plugin == null) { Messages.showErrorDialog(_parent, "Can not load plugin " + selectedFile.getPath(), "Plugin Loading"); return; } try { final int answer = Messages.showYesNoDialog(_parent, "Add plugin '" + plugin.getPluginId() + "'?", "Add Plugin", null); if (answer == Messages.YES) { _preferences.addUserPlugin(FindBugsCustomPluginUtil.getAsString(plugin), plugin.getPluginId(), true); updatePreferences(); _preferences.setModified(true); } } finally { FindBugsCustomPluginUtil.unload(plugin); } } catch (final Throwable e) { //noinspection DialogTitleCapitalization Messages.showErrorDialog(_parent, "Error loading " + selectedFile.getPath() + ":\n\n" + e.getClass().getSimpleName() + ": " + e.getMessage(), "Error loading plugin"); } }