Skip to content

Commit 003bb2d

Browse files
committed
Issue #15: Refresh project on build completion
1 parent 7c06bc5 commit 003bb2d

File tree

8 files changed

+70
-7
lines changed

8 files changed

+70
-7
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018 IBM Corporation and others.
2+
* Copyright (c) 2018, 2019 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -290,5 +290,27 @@ public boolean supportsDebug() {
290290
}
291291
return false;
292292
}
293+
294+
@Override
295+
public void buildComplete() {
296+
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
297+
if (project != null && project.isAccessible()) {
298+
Job job = new Job(NLS.bind(Messages.RefreshResourceJobLabel, project.getName())) {
299+
@Override
300+
protected IStatus run(IProgressMonitor monitor) {
301+
try {
302+
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
303+
return Status.OK_STATUS;
304+
} catch (Exception e) {
305+
MCLogger.logError("An error occurred while refreshing the resource: " + project.getLocation()); //$NON-NLS-1$
306+
return new Status(IStatus.ERROR, MicroclimateCorePlugin.PLUGIN_ID,
307+
NLS.bind(Messages.RefreshResourceError, project.getLocation()), e);
308+
}
309+
}
310+
};
311+
job.setPriority(Job.LONG);
312+
job.schedule();
313+
}
314+
}
293315

294316
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018 IBM Corporation and others.
2+
* Copyright (c) 2018, 2019 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -96,12 +96,17 @@ public synchronized void setAppStatus(String appStatus) {
9696

9797
public synchronized void setBuildStatus(String buildStatus, String buildDetails) {
9898
if (buildStatus != null) {
99-
this.buildStatus = BuildStatus.get(buildStatus);
99+
BuildStatus newStatus = BuildStatus.get(buildStatus);
100+
boolean hasChanged = newStatus != this.buildStatus;
101+
this.buildStatus = newStatus;
100102
if (buildDetails != null && buildDetails.trim().isEmpty()) {
101103
this.buildDetails = null;
102104
} else {
103105
this.buildDetails = buildDetails;
104106
}
107+
if (hasChanged && newStatus.isComplete()) {
108+
buildComplete();
109+
}
105110
}
106111
}
107112

@@ -272,6 +277,10 @@ public boolean supportsDebug() {
272277
// Override as needed
273278
return false;
274279
}
280+
281+
public void buildComplete() {
282+
// Override to perform actions when a build has completed
283+
}
275284

276285
@Override
277286
public String toString() {

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/constants/BuildStatus.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018 IBM Corporation and others.
2+
* Copyright (c) 2018, 2019 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -48,6 +48,10 @@ public static BuildStatus get(String buildStatus) {
4848
return BuildStatus.UNKOWN;
4949
}
5050

51+
public boolean isComplete() {
52+
return this == SUCCESS || this == FAILED;
53+
}
54+
5155
public String getDisplayString() {
5256
return displayString;
5357
}

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/messages/Messages.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2018, 2019 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
112
package com.ibm.microclimate.core.internal.messages;
213

314
import org.eclipse.osgi.util.NLS;
@@ -47,6 +58,9 @@ public class Messages extends NLS {
4758

4859
public static String DebugLaunchError;
4960
public static String ReconnectDebugJob;
61+
62+
public static String RefreshResourceJobLabel;
63+
public static String RefreshResourceError;
5064

5165
static {
5266
// initialize resource bundle

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/messages/messages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ BuildStateUnknown=No build status information
5151

5252
DebugLaunchError=An error occurred trying to launch the debugger for the {0} project.
5353
ReconnectDebugJob=Reconnect debugger
54+
55+
RefreshResourceJobLabel=Refreshing resource: {0}
56+
RefreshResourceError=An error occurred while trying to refresh the {0} resource.

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/marker/MicroclimateMarkerResolution.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018 IBM Corporation and others.
2+
* Copyright (c) 2018, 2019 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -50,7 +50,7 @@ public void run(IMarker marker) {
5050
app.mcConnection.requestValidateGenerate(app);
5151
IResource resource = marker.getResource();
5252
if (resource != null) {
53-
Job job = new Job(Messages.refreshResourceJobLabel) {
53+
Job job = new Job(NLS.bind(Messages.refreshResourceJobLabel, resource.getName())) {
5454
@Override
5555
protected IStatus run(IProgressMonitor monitor) {
5656
try {

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/messages/Messages.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2018 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
112
package com.ibm.microclimate.ui.internal.messages;
213

314
import org.eclipse.osgi.util.NLS;

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/messages/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ActionNewConnection=&New Microclimate Connection
6262

6363
ValidateLabel=Validate
6464
AttachDebuggerLabel=A&ttach Debugger
65-
refreshResourceJobLabel=Refresh resource
65+
refreshResourceJobLabel=Refreshing resource: {0}
6666
RefreshResourceError=An error occurred while trying to refresh the {0} resource.
6767

6868
ImportProjectError=An error occurred while importing the {0} project.

0 commit comments

Comments
 (0)