use of com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger.Debuggees in project google-cloud-intellij by GoogleCloudPlatform.
the class ProjectDebuggeeBinding method refreshDebugTargetList.
/**
* Refreshes the list of attachable debug targets based on the project selection.
*/
@SuppressWarnings("FutureReturnValueIgnored")
private void refreshDebugTargetList(CloudProject cloudProject) {
targetSelector.removeAllItems();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
String projectNumber = Optional.ofNullable(cloudProject.projectNumber()).map(Object::toString).orElse(null);
if (projectNumber != null && getCloudDebuggerClient() != null) {
final ListDebuggeesResponse debuggees = getCloudDebuggerClient().debuggees().list().setProject(projectNumber).setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger()).execute();
isCdbQueried = true;
SwingUtilities.invokeLater(() -> {
DebugTarget targetSelection = null;
if (debuggees == null || debuggees.getDebuggees() == null || debuggees.getDebuggees().isEmpty()) {
disableTargetSelector(GctBundle.getString("clouddebug.nomodulesfound"));
} else {
targetSelector.setEnabled(true);
Map<String, DebugTarget> perModuleCache = new HashMap<>();
for (Debuggee debuggee : debuggees.getDebuggees()) {
DebugTarget item = new DebugTarget(debuggee, cloudProject.projectId());
if (!Strings.isNullOrEmpty(item.getModule()) && !Strings.isNullOrEmpty(item.getVersion())) {
// If we already have an existing item for that module+version,
// compare the minor versions and only use the latest minor version.
String key = String.format("%s:%s", item.getModule(), item.getVersion());
DebugTarget existing = perModuleCache.get(key);
if (existing != null && existing.getMinorVersion() > item.getMinorVersion()) {
continue;
}
if (existing != null) {
targetSelector.removeItem(existing);
}
perModuleCache.put(key, item);
}
if (inputState != null && !Strings.isNullOrEmpty(inputState.getDebuggeeId())) {
if (inputState.getDebuggeeId().equals(item.getId())) {
targetSelection = item;
}
}
targetSelector.addItem(item);
okAction.setEnabled(true);
}
}
if (targetSelection != null) {
targetSelector.setSelectedItem(targetSelection);
}
});
}
} catch (final IOException ex) {
SwingUtilities.invokeLater(() -> disableTargetSelector(ex));
LOG.warn("Error listing debuggees from Cloud Debugger API", ex);
}
});
}
Aggregations