Skip to content

623: Prevent duplicate Verify or Upload Jobs from running #624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions io.sloeber.ui/src/io/sloeber/ui/actions/BuildHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@
/**
* This id a handler to connect the plugin.xml to the code for building the code
* This method forces a save all before building
*
*
* @author jan
*
*
*/
class BuildJobHandler extends Job {
IProject myBuildProject = null;

public BuildJobHandler(String name) {
super(name);
}
IProject myBuildProject = null;

public BuildJobHandler(IProject buildProject) {
super(Messages.BuildHandler_Build_Code_of_project + buildProject.getName());
Expand All @@ -39,6 +35,12 @@ protected IStatus run(IProgressMonitor monitor) {
Sketch.verify(this.myBuildProject, monitor);
return Status.OK_STATUS;
}

@Override
public boolean belongsTo(Object family) {
return myBuildProject.equals(family);
}

}

public class BuildHandler extends AbstractHandler {
Expand All @@ -57,8 +59,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
break;
default:
PlatformUI.getWorkbench().saveAllEditors(false);
for (int curProject = 0; curProject < SelectedProjects.length; curProject++) {
this.mBuildJob = new BuildJobHandler(SelectedProjects[curProject]);
for (IProject selectedProject : SelectedProjects) {
Job.getJobManager().cancel(selectedProject);
this.mBuildJob = new BuildJobHandler(selectedProject);
this.mBuildJob.setPriority(Job.INTERACTIVE);
this.mBuildJob.schedule();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ public void run() {
Sketch.upload(UploadJobHandler.this.myBuildProject);
return Status.OK_STATUS;
}

@Override
public boolean belongsTo(Object family) {
return myBuildProject.equals(family);
}
}

/**
* This is a handler to connect the plugin.xml to the code for uploading code to
* arduino teensy ..
*
*
* @author jan
*
*
*/
public class UploadProjectHandler extends AbstractHandler {

Expand Down Expand Up @@ -90,6 +95,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {

public static void uploadProject(IProject project) {
PlatformUI.getWorkbench().saveAllEditors(false);
Job.getJobManager().cancel(project);
Job mBuildJob = new UploadJobHandler(project);
mBuildJob.setPriority(Job.INTERACTIVE);
mBuildJob.schedule();
Expand Down