Skip to content

Commit 9c98ab5

Browse files
committed
Issue #99: Fix post project creation issues
1 parent cd4dd7a commit 9c98ab5

File tree

5 files changed

+33
-18
lines changed

5 files changed

+33
-18
lines changed

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/MicroclimateApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.net.MalformedURLException;
1515
import java.net.URL;
16+
import java.util.Collections;
1617
import java.util.List;
1718

1819
import org.eclipse.core.runtime.IPath;
@@ -47,7 +48,7 @@ public class MicroclimateApplication {
4748
private String containerId;
4849
private ProjectCapabilities projectCapabilities;
4950
private String action;
50-
private List<ProjectLogInfo> logInfos;
51+
private List<ProjectLogInfo> logInfos = Collections.emptyList();
5152
private boolean metricsAvailable = false;
5253

5354
// Must be updated whenever httpPort changes. Can be null

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/connection/MicroclimateSocket.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,11 @@ private void onProjectCreation(JSONObject event) throws JSONException {
280280
String projectID = event.getString(MCConstants.KEY_PROJECT_ID);
281281
mcConnection.refreshApps(projectID);
282282
MicroclimateApplication app = mcConnection.getAppByID(projectID);
283-
if (app == null) {
283+
if (app != null) {
284+
app.setEnabled(true);
285+
} else {
284286
MCLogger.logError("No application found matching the project id for the project creation event: " + projectID); //$NON-NLS-1$
285-
return;
286287
}
287-
app.setEnabled(true);
288288
MCUtil.updateConnection(mcConnection);
289289
}
290290

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/actions/HideAllLogsAction.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,30 @@ public void setApp(MCEclipseApplication app) {
3838

3939
// Only enable if there is at least one log file that has a console
4040
boolean enabled = false;
41-
for (ProjectLogInfo logInfo : app.getLogInfos()) {
42-
if (app.getConsole(logInfo) != null) {
43-
enabled = true;
44-
break;
45-
}
46-
}
41+
if (app.getLogInfos() != null && !app.getLogInfos().isEmpty()) {
42+
for (ProjectLogInfo logInfo : app.getLogInfos()) {
43+
if (app.getConsole(logInfo) != null) {
44+
enabled = true;
45+
break;
46+
}
47+
}
48+
}
4749
setEnabled(enabled);
4850
}
4951

5052
@Override
5153
public void run() {
5254
if (app == null) {
5355
// should not be possible
54-
MCLogger.logError("ToggleConsolesAction ran but no Microclimate application was selected");
56+
MCLogger.logError("HideAllLogsAction ran but no Microclimate application was selected");
5557
return;
5658
}
5759

60+
if (app.getLogInfos() == null || app.getLogInfos().isEmpty()) {
61+
MCLogger.logError("HideAllLogsAction ran but there are no logs for the selected application: " + app.name);
62+
return;
63+
}
64+
5865
// Remove any existing consoles for this app
5966
for (ProjectLogInfo logInfo : app.getLogInfos()) {
6067
SocketConsole console = app.getConsole(logInfo);

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/actions/LogFileActionProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void fillContextMenu(IMenuManager menu) {
6060
if (obj instanceof MCEclipseApplication) {
6161
final MCEclipseApplication app = (MCEclipseApplication)obj;
6262
if (app.mcConnection.checkVersion(1905, "2019_M5_E")) {
63-
if (app.isAvailable() && app.getLogInfos().size() > 0) {
63+
if (app.isAvailable() && app.getLogInfos() != null && !app.getLogInfos().isEmpty()) {
6464
MenuManager menuMgr = new MenuManager(Messages.ShowLogFilesMenu, "ShowLogFiles");
6565
showAllLogsAction.setApp(app);
6666
menuMgr.add(showAllLogsAction);

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/actions/ShowAllLogsAction.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ public void setApp(MCEclipseApplication app) {
3737

3838
// Only enable if there is a log file that does not currently have a console
3939
boolean enabled = false;
40-
for (ProjectLogInfo logInfo : app.getLogInfos()) {
41-
if (app.getConsole(logInfo) == null) {
42-
enabled = true;
43-
break;
44-
}
40+
if (app.getLogInfos() != null && !app.getLogInfos().isEmpty()) {
41+
for (ProjectLogInfo logInfo : app.getLogInfos()) {
42+
if (app.getConsole(logInfo) == null) {
43+
enabled = true;
44+
break;
45+
}
46+
}
4547
}
4648
setEnabled(enabled);
4749
}
@@ -50,10 +52,15 @@ public void setApp(MCEclipseApplication app) {
5052
public void run() {
5153
if (app == null) {
5254
// should not be possible
53-
MCLogger.logError("ToggleConsolesAction ran but no Microclimate application was selected");
55+
MCLogger.logError("ShowAllLogsAction ran but no Microclimate application was selected");
5456
return;
5557
}
5658

59+
if (app.getLogInfos() == null || app.getLogInfos().isEmpty()) {
60+
MCLogger.logError("ShowAllLogsAction ran but there are no logs for the selected application: " + app.name);
61+
return;
62+
}
63+
5764
// Create consoles for any log files that don't have one yet
5865
for (ProjectLogInfo logInfo : app.getLogInfos()) {
5966
if (app.getConsole(logInfo) == null) {

0 commit comments

Comments
 (0)