public void refreshUI() {
logError(null);
resizeTableColumns();
canUpdate = false;
CloudFoundryApplicationModule appModule = null;
try {
appModule = getUpdatedApplication();
}
catch (CoreException ce) {
logApplicationModuleFailureError(Messages.ApplicationDetailsPart_ERROR_UNABLE_REFRESH_EDITOR_STATE);
}
// Refresh the state of the editor regardless of whether there is a
// module or not
refreshPublishState(appModule);
if (appModule == null) {
return;
}
if (saveManifest != null) {
ManifestParser parser = new ManifestParser(appModule, cloudServer);
if (!parser.canWriteToManifest()) {
saveManifest.setEnabled(false);
saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_SAVE_CREATE_TOOLTIP);
}
else {
saveManifest.setEnabled(true);
saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_UPDATE);
}
}
// The rest of the refresh requires appModule to be non-null
updateServerNameDisplay(appModule);
int state = appModule.getState();
setCurrentStartDebugApplicationAction();
instanceSpinner.setSelection(appModule.getInstanceCount());
refreshAndReenableDeploymentButtons(appModule);
// refreshApplicationDeploymentButtons(appModule);
mappedURIsLink.setEnabled(state == IServer.STATE_STARTED);
CloudApplication cloudApplication = appModule.getApplication();
instanceSpinner.setEnabled(cloudApplication != null);
instancesViewer.getTable().setEnabled(cloudApplication != null);
instancesViewer.setInput(null);
memoryText.setEnabled(cloudApplication != null);
if (cloudApplication != null) {
int appMemory = appModule.getApplication().getMemory();
if (appMemory > 0) {
memoryText.setText(appMemory + ""); //$NON-NLS-1$
}
}
List<String> currentURIs = null;
if (cloudApplication != null) {
currentURIs = cloudApplication.getUris();
ApplicationStats applicationStats = appModule.getApplicationStats();
InstancesInfo instancesInfo = appModule.getInstancesInfo();
if (applicationStats != null) {
List<InstanceStats> statss = applicationStats.getRecords();
List<InstanceInfo> infos = instancesInfo != null ? instancesInfo.getInstances() : null;
InstanceStatsAndInfo[] statsAndInfos = new InstanceStatsAndInfo[statss.size()];
for (int i = 0; i < statss.size(); i++) {
InstanceStats stats = statss.get(i);
InstanceInfo info = null;
if (infos != null && infos.size() > i) {
info = infos.get(i);
}
statsAndInfos[i] = new InstanceStatsAndInfo(stats, info);
}
instancesViewer.setInput(statsAndInfos);
}
}
if (currentURIs == null && !isPublished) {
// At this stage, the app may not have deployed due to errors, but
// there may already
// be set URIs in an existing info
currentURIs = appModule.getDeploymentInfo() != null ? appModule.getDeploymentInfo().getUris() : null;
}
if (currentURIs == null) {
currentURIs = Collections.emptyList();
}
if (!currentURIs.equals(this.appUrls)) {
updateAppUrls(currentURIs);
}
refreshServices(appModule);
instancesViewer.refresh(true);
canUpdate = true;
if (appModule.getErrorMessage() != null) {
editorPage.setMessage(appModule.getErrorMessage(), IMessageProvider.ERROR);
}
else {
editorPage.setMessage(null, IMessageProvider.ERROR);
}
}