private List<ChangeInfo> getChanges(Project project, boolean requestSettingsIfNonExistent) { final GerritSettings settings = GerritSettings.getInstance(); String apiUrl = GerritApiUtil.getApiUrl(); if (Strings.isNullOrEmpty(apiUrl)) { if (requestSettingsIfNonExistent) { final LoginDialog dialog = new LoginDialog(project); dialog.show(); if (!dialog.isOK()) { return Collections.emptyList(); } apiUrl = GerritApiUtil.getApiUrl(); } else { return Collections.emptyList(); } } return GerritUtil.getChanges(apiUrl, settings.getLogin(), settings.getPassword()); }
private void changeSelected(ChangeInfo changeInfo, final Project project) { final GerritSettings settings = GerritSettings.getInstance(); final ChangeInfo changeDetails = GerritUtil.getChangeDetails( GerritApiUtil.getApiUrl(), settings.getLogin(), settings.getPassword(), changeInfo.getNumber()); myDetailsPanel.setData(changeDetails); updateChangesBrowser(changeDetails, project); }
private void handleNotification(Project project) { final GerritSettings settings = GerritSettings.getInstance(); if (!settings.getReviewNotifications()) { return; } String apiUrl = GerritApiUtil.getApiUrl(); List<ChangeInfo> changes = GerritUtil.getChangesToReview(apiUrl, settings.getLogin(), settings.getPassword()); boolean newChange = false; for (ChangeInfo change : changes) { if (!myNotifiedChanges.contains(change.getChangeId())) { newChange = true; break; } } if (newChange) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("<ul>"); for (ChangeInfo change : changes) { stringBuilder .append("<li>") .append( !myNotifiedChanges.contains(change.getChangeId()) ? "<strong>NEW: </strong>" : "") .append(change.getSubject()) .append(" (Owner: ") .append(change.getOwner().getName()) .append(')') .append("</li>"); myNotifiedChanges.add(change.getChangeId()); } stringBuilder.append("</ul>"); GerritUtil.notifyInformation( project, "Gerrit Changes waiting for my review", stringBuilder.toString()); } }