use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class ServerIssueUpdater method fetchAndMatchServerIssues.
public void fetchAndMatchServerIssues(Collection<VirtualFile> virtualFiles, ProgressIndicator indicator, boolean waitForCompletion) {
if (!projectSettings.isBindingEnabled()) {
// not in connected mode
return;
}
try {
SonarQubeServer server = projectBindingManager.getSonarQubeServer();
ConnectedSonarLintEngine engine = projectBindingManager.getConnectedEngine();
String moduleKey = projectSettings.getProjectKey();
boolean downloadAll = virtualFiles.size() >= FETCH_ALL_ISSUES_THRESHOLD;
String msg;
if (downloadAll) {
msg = "Fetching all server issues";
} else {
msg = "Fetching server issues";
}
if (waitForCompletion) {
msg += " (waiting for results)";
}
console.debug(msg);
indicator.setText(msg);
// submit tasks
List<Future<Void>> updateTasks = fetchAndMatchServerIssues(virtualFiles, server, engine, moduleKey, downloadAll);
if (waitForCompletion) {
waitForTasks(updateTasks);
}
} catch (InvalidBindingException e) {
// ignore, do nothing
}
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class SonarQubeEventNotifications method register.
private void register(SonarLintProjectSettings settings) {
unregister();
if (settings.isBindingEnabled()) {
SonarQubeServer server;
try {
server = bindingManager.getSonarQubeServer();
} catch (InvalidBindingException e) {
// do nothing
return;
}
if (server.enableNotifications()) {
NotificationConfiguration config = createConfiguration(settings, server);
SonarQubeNotifications.get().register(config);
}
}
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class SonarLintProjectBindPanel method setServerList.
/**
* Sets new servers in the combo box, or disable it if there aren't any.
* Will also enable or disable other components.
*/
private void setServerList(Collection<SonarQubeServer> servers, @Nullable String previousSelectedStorageId) {
DefaultComboBoxModel<SonarQubeServer> model = (DefaultComboBoxModel<SonarQubeServer>) serverComboBox.getModel();
if (servers.isEmpty()) {
serverComboBox.setEnabled(false);
SonarQubeServer s = SonarQubeServer.newBuilder().setName(SERVER_EMPTY_TEXT).build();
serverComboBox.setPrototypeDisplayValue(s);
// ensure this is called, even when nothing is selected
} else {
serverComboBox.setEnabled(bindEnable.isSelected());
int i = 0;
int selectedIndex = -1;
for (SonarQubeServer s : servers) {
if (previousSelectedStorageId != null && s.getName() != null && previousSelectedStorageId.equals(s.getName())) {
selectedIndex = i;
}
serverComboBox.setPrototypeDisplayValue(null);
// this won't call the change listener
model.insertElementAt(s, i);
i++;
}
// can be -1 (nothing selected)
serverComboBox.setSelectedIndex(selectedIndex);
}
// ensure this is called, even when nothing is selected
onServerSelected();
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class SonarLintProjectBindPanel method downloadProjectList.
/**
* Assumes that it's bound and a server is selected
*/
@CheckForNull
private Map<String, RemoteModule> downloadProjectList() {
ApplicationManager.getApplication().assertIsDispatchThread();
SonarQubeServer selectedServer = getSelectedServer();
String storageId = getSelectedStorageId();
if (selectedServer == null || storageId == null) {
return null;
}
SonarLintEngineManager core = SonarLintUtils.get(SonarLintEngineManager.class);
ConnectedSonarLintEngine engine = core.getConnectedEngine(storageId);
ServerDownloadProjectTask downloadTask = new ServerDownloadProjectTask(project, engine, selectedServer);
try {
ProgressManager.getInstance().run(downloadTask);
return downloadTask.getResult();
} catch (Exception e) {
String msg = e.getMessage() != null ? e.getMessage() : "Failed to download list of projects";
Messages.showErrorDialog(rootPanel, msg, "Error Downloading Project List");
return null;
}
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class SonarLintProjectConfigurable method onSave.
/**
* When we save the binding, we need to:
* - Send a message for listeners interested in it
* - If we are bound to a module, update it (even if we detected no changes)
* - Clear all issues and submit an analysis on all open files
*/
private void onSave() {
SonarLintProjectNotifications.get(project).reset();
ProjectConfigurationListener projectListener = project.getMessageBus().syncPublisher(ProjectConfigurationListener.TOPIC);
if (projectSettings.isBindingEnabled() && projectSettings.getProjectKey() != null && projectSettings.getServerId() != null) {
ProjectBindingManager bindingManager = SonarLintUtils.get(project, ProjectBindingManager.class);
try {
SonarQubeServer server = bindingManager.getSonarQubeServer();
ConnectedSonarLintEngine engine = bindingManager.getConnectedEngineSkipChecks();
String moduleKey = projectSettings.getProjectKey();
ServerUpdateTask task = new ServerUpdateTask(engine, server, Collections.singletonMap(moduleKey, Collections.singletonList(project)), true);
ProgressManager.getInstance().run(task.asModal());
} catch (InvalidBindingException e) {
// nothing to do, SonarLintEngineManager should have already shown a warning
}
}
projectListener.changed(projectSettings);
}
Aggregations