Skip to content

Commit d424ec7

Browse files
authored
Merge pull request #123 from eharris369/113-useJobForDelete
Issue #113: Use job for project delete
2 parents 9f39909 + be79b73 commit d424ec7

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
import org.eclipse.core.resources.IProject;
1515
import org.eclipse.core.resources.ResourcesPlugin;
16-
import org.eclipse.core.runtime.NullProgressMonitor;
16+
import org.eclipse.core.runtime.IProgressMonitor;
17+
import org.eclipse.core.runtime.IStatus;
18+
import org.eclipse.core.runtime.Status;
19+
import org.eclipse.core.runtime.jobs.Job;
1720
import org.eclipse.jface.viewers.ISelectionProvider;
1821
import org.eclipse.jface.viewers.IStructuredSelection;
1922
import org.eclipse.osgi.util.NLS;
@@ -24,6 +27,7 @@
2427
import com.ibm.microclimate.core.internal.MCEclipseApplication;
2528
import com.ibm.microclimate.core.internal.MCLogger;
2629
import com.ibm.microclimate.core.internal.MCUtil;
30+
import com.ibm.microclimate.ui.MicroclimateUIPlugin;
2731
import com.ibm.microclimate.ui.internal.messages.Messages;
2832

2933
/**
@@ -63,17 +67,24 @@ public void run() {
6367
}
6468

6569
if (MCUtil.openConfirmDialog(Messages.DeleteProjectTitle, NLS.bind(Messages.DeleteProjectMessage, app.name))) {
66-
try {
67-
app.mcConnection.requestProjectDelete(app.projectID);
68-
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(app.name);
69-
if (project != null && project.exists() && project.getLocation().toFile().equals(app.fullLocalPath.toFile())) {
70-
project.delete(false, true, new NullProgressMonitor());
71-
}
72-
} catch (Exception e) {
73-
MCLogger.logError("An error occurred deleting the project: " + app.name + ", with id: " + app.projectID, e);
74-
MCUtil.openDialog(true, Messages.DeleteProjectErrorTitle,
75-
NLS.bind(Messages.DeleteProjectErrorMsg, new String[] {app.name, e.getMessage()}));
76-
}
70+
Job job = new Job(NLS.bind(Messages.DeleteProjectJobTitle, app.name)) {
71+
@Override
72+
protected IStatus run(IProgressMonitor monitor) {
73+
try {
74+
app.mcConnection.requestProjectDelete(app.projectID);
75+
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(app.name);
76+
if (project != null && project.exists() && project.getLocation().toFile().equals(app.fullLocalPath.toFile())) {
77+
project.delete(false, true, monitor);
78+
}
79+
return Status.OK_STATUS;
80+
} catch (Exception e) {
81+
MCLogger.logError("An error occurred deleting the project: " + app.name + ", with id: " + app.projectID, e);
82+
return new Status(IStatus.ERROR, MicroclimateUIPlugin.PLUGIN_ID, NLS.bind(Messages.DeleteProjectErrorMsg, app.name), e);
83+
}
84+
}
85+
};
86+
job.schedule();
87+
7788
}
7889
}
7990
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class Messages extends NLS {
8383
public static String DeleteProjectLabel;
8484
public static String DeleteProjectTitle;
8585
public static String DeleteProjectMessage;
86-
public static String DeleteProjectErrorTitle;
86+
public static String DeleteProjectJobTitle;
8787
public static String DeleteProjectErrorMsg;
8888
public static String refreshResourceJobLabel;
8989
public static String RefreshResourceError;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ LaunchDebugSessionLabel=&Launch Debug Session
7676
DeleteProjectLabel=D&elete
7777
DeleteProjectTitle=Project Delete
7878
DeleteProjectMessage=Are you sure you want to delete project {0} in Microclimate and from your filesystem?
79-
DeleteProjectErrorTitle=Project Delete Error
80-
DeleteProjectErrorMsg=An error occurred trying to delete Microclimate project {0}: {1}
79+
DeleteProjectJobTitle=Deleting project: {0}
80+
DeleteProjectErrorMsg=An error occurred trying to delete Microclimate project: {0}
8181
refreshResourceJobLabel=Refreshing resource: {0}
8282
RefreshResourceError=An error occurred while trying to refresh the {0} resource.
8383
RefreshConnectionJobLabel=Refreshing connection: {0}

0 commit comments

Comments
 (0)