@Override public void run(AnActionButton button) { String packageName = Messages.showInputDialog("Enter the import path to exclude from auto-import and completion:", "Exclude Import Path", Messages.getWarningIcon()); addExcludedPackage(packageName); }
public MiscGUI() { resetCustomAssociationsButton.addActionListener((e) -> { if (Messages.showYesNoCancelDialog(rootPanel, "This will remove all manually added associations. Proceed?", "Remove all associations", Messages.getWarningIcon()) == Messages.YES) { PluginMain$.MODULE$.resetAssociations(); } }); }
@Override public void run(AnActionButton anActionButton) { SonarQubeServer server = getSelectedServer(); int selectedIndex = serverList.getSelectedIndex(); if (server == null) { return; } Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); List<String> projectsUsingNames = getOpenProjectNames(openProjects, server); if (!projectsUsingNames.isEmpty()) { String projects = projectsUsingNames.stream().collect(Collectors.joining("<br>")); int response = Messages.showYesNoDialog(serversPanel, "<html>The following opened projects are bound to this server configuration:<br><b>" + projects + "</b><br>Delete the server?</html>", "Server Configuration In Use", Messages.getWarningIcon()); if (response == Messages.NO) { return; } } CollectionListModel model = (CollectionListModel) serverList.getModel(); // it's not removed from serverIds and editorList model.remove(server); servers.remove(server); serverChangeListener.changed(servers); if (model.getSize() > 0) { int newIndex = Math.min(model.getSize() - 1, Math.max(selectedIndex - 1, 0)); serverList.setSelectedValue(model.getElementAt(newIndex), true); } }
static boolean showWarning() { if (!ApplicationManager.getApplication().isUnitTestMode() && !PropertiesComponent.getInstance().getBoolean(HIDE_WARNING_PROPERTY, false)) { int result = Messages.showYesNoDialog("Analysing all files may take a considerable amount of time to complete.\n" + "To get the best from SonarLint, you should preferably use the automatic analysis of the file you're working on.", "SonarLint - Analyze All Files", "Proceed", "Cancel", Messages.getWarningIcon(), new DoNotShowAgain()); return result == Messages.OK; } return true; }
@Test public void testDeleteWorkspaceWithProgress_UserCancel() throws Exception { final MockObserver observer = new MockObserver(manageWorkspacesModel); when(Messages.showYesNoDialog(mockProject, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_CONFIRM_MSG, workspace1.getName()), TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_CONFIRM_TITLE), Messages.getWarningIcon())).thenReturn(Messages.NO); manageWorkspacesModel.deleteWorkspaceWithProgress(workspace1); observer.assertUpdateNeverOccurred(ManageWorkspacesModel.REFRESH_WORKSPACE); verifyStatic(never()); VcsUtil.runVcsProcessWithProgress(any(VcsRunnable.class), any(String.class), any(Boolean.class), any(Project.class)); Messages.showErrorDialog(any(Project.class), any(String.class), any(String.class)); }
@Test public void testDeleteWorkspaceWithProgress_Happy() throws Exception { final MockObserver observer = new MockObserver(manageWorkspacesModel); when(Messages.showYesNoDialog(mockProject, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_CONFIRM_MSG, workspace1.getName()), TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_CONFIRM_TITLE), Messages.getWarningIcon())).thenReturn(Messages.YES); manageWorkspacesModel.deleteWorkspaceWithProgress(workspace1); observer.assertAndClearLastUpdate(manageWorkspacesModel, ManageWorkspacesModel.REFRESH_WORKSPACE); verifyStatic(never()); Messages.showErrorDialog(any(Project.class), any(String.class), any(String.class)); }
@Override public boolean ensureLoggedIn(String username) { Optional<CredentialedUser> projectUser = getLoggedInUser(username); while (!projectUser.isPresent()) { int addUserResult = Messages.showOkCancelDialog( AccountMessageBundle.message("login.credentials.missing.message", username), AccountMessageBundle.message("login.credentials.missing.dialog.title"), AccountMessageBundle.message("login.credentials.missing.dialog.addaccount.button"), AccountMessageBundle.message("login.credentials.missing.dialog.cancel.button"), Messages.getWarningIcon()); if (addUserResult == Messages.OK) { logIn(); projectUser = getLoggedInUser(username); } else { return false; } } return true; }
@Test public void testDeleteWorkspaceWithProgress_Exception() throws Exception { final MockObserver observer = new MockObserver(manageWorkspacesModel); when(Messages.showYesNoDialog(mockProject, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_CONFIRM_MSG, workspace1.getName()), TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_CONFIRM_TITLE), Messages.getWarningIcon())).thenReturn(Messages.YES); when(VcsUtil.runVcsProcessWithProgress(any(VcsRunnable.class), eq(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_MSG, workspace1.getName())), eq(true), eq(mockProject))) .thenThrow(new VcsException(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_ERROR_MSG, workspace1.getName()))); manageWorkspacesModel.deleteWorkspaceWithProgress(workspace1); observer.assertAndClearLastUpdate(manageWorkspacesModel, ManageWorkspacesModel.REFRESH_WORKSPACE); verifyStatic(times(1)); Messages.showErrorDialog(eq(mockProject), eq(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_ERROR_MSG, workspace1.getName())), eq(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_MANAGE_WORKSPACES_DELETE_ERROR_TITLE))); }