Skip to content

Instantly share code, notes, and snippets.

@vexus2
Created July 5, 2013 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vexus2/5931909 to your computer and use it in GitHub Desktop.
Save vexus2/5931909 to your computer and use it in GitHub Desktop.
Show Dialog and catch handlers
public void syncWithSonar(Project project) {
Collection<Rule> sonarRules = this.sonarRulesByRuleKey.values();
int oldSize = sonarRules.size();
clearState();
Collection<SonarSettingsBean> allSonarSettingsBeans = SonarSettingsComponent.getSonarSettingsBeans(project);
SonarService sonarService = ServiceManager.getService(SonarService.class);
if (null != allSonarSettingsBeans) {
for (Rule rule : sonarService.getAllRules(allSonarSettingsBeans)) {
this.sonarRulesByRuleKey.put(rule.getKey(), rule);
}
int newSize = sonarRulesByRuleKey.values().size();
if (oldSize != newSize) {
// show restart ide dialog
final int ret = Messages.showOkCancelDialog("Detected new sonar rules. You have to restart IDE to reload the settings. Restart?",
IdeBundle.message("title.restart.needed"), Messages.getQuestionIcon());
if (ret == 0) {
if (ApplicationManager.getApplication().isRestartCapable()) {
ApplicationManager.getApplication().restart();
} else {
ApplicationManager.getApplication().exit();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment