1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

autotools: Start using Job.create.

Making use of lambdas for the sake of showing new APIs and having better
code.

Change-Id: If03cde0b2ae58d965387b0b224bc5129af78dacc
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2016-06-17 11:33:54 +03:00
parent 4b43360130
commit 0a65f2925b
3 changed files with 142 additions and 159 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2015 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2016 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -40,8 +40,6 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
@ -125,13 +123,10 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
public ResourceLookupTree() {
fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {};
fFileExtensions= new HashMap<>();
fUnrefJob= new Job("Timer") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
fUnrefJob = Job.create("Timer", monitor -> {
unrefNodeMap();
return Status.OK_STATUS;
}
};
});
fUnrefJob.setSystem(true);
}

View file

@ -42,8 +42,6 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@ -266,9 +264,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler {
// workspace root rule.
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
Job backgroundJob = new Job(actionName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
Job backgroundJob = Job.create(actionName, monitor -> {
try {
ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> {
try {
@ -378,8 +374,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler {
try {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e2) {
monitor1.subTask(
AutotoolsUIPlugin.getResourceString("MakeGenerator.refresh.error")); //$NON-NLS-1$
monitor1.subTask(AutotoolsUIPlugin.getResourceString("MakeGenerator.refresh.error")); //$NON-NLS-1$
}
} else {
errMsg = launcher.getErrorMessage();
@ -396,8 +391,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler {
return e.getStatus();
}
return Status.OK_STATUS;
}
};
});
backgroundJob.setRule(rule);
backgroundJob.schedule();

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2015 Red Hat Inc..
* Copyright (c) 2009, 2016 Red Hat Inc..
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -21,8 +21,6 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
@ -51,9 +49,7 @@ public class ReconfigureHandler extends AbstractAutotoolsHandler {
// workspace root rule.
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
Job backgroundJob = new Job("Reconfigure Action") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
Job backgroundJob = Job.create("Reconfigure Action", monitor -> {
try {
ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> {
IProject project = getSelectedContainer().getProject();
@ -70,10 +66,8 @@ public class ReconfigureHandler extends AbstractAutotoolsHandler {
} catch (CoreException e) {
return e.getStatus();
}
IStatus returnStatus = Status.OK_STATUS;
return returnStatus;
}
};
return Status.OK_STATUS;
});
backgroundJob.setRule(rule);
backgroundJob.schedule();