mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +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:
parent
4b43360130
commit
0a65f2925b
3 changed files with 142 additions and 159 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
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.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -125,13 +123,10 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
|
||||||
public ResourceLookupTree() {
|
public ResourceLookupTree() {
|
||||||
fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {};
|
fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {};
|
||||||
fFileExtensions= new HashMap<>();
|
fFileExtensions= new HashMap<>();
|
||||||
fUnrefJob= new Job("Timer") { //$NON-NLS-1$
|
fUnrefJob = Job.create("Timer", monitor -> {
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
unrefNodeMap();
|
unrefNodeMap();
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
});
|
||||||
};
|
|
||||||
fUnrefJob.setSystem(true);
|
fUnrefJob.setSystem(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,6 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
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.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -266,9 +264,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler {
|
||||||
// workspace root rule.
|
// workspace root rule.
|
||||||
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
|
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
|
||||||
Job backgroundJob = new Job(actionName) {
|
Job backgroundJob = Job.create(actionName, monitor -> {
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
try {
|
try {
|
||||||
ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> {
|
ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> {
|
||||||
try {
|
try {
|
||||||
|
@ -294,7 +290,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler {
|
||||||
consoleHeader[2] = project.getName();
|
consoleHeader[2] = project.getName();
|
||||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
String invokeMsg = InvokeMessages.getFormattedString("InvokeAction.console.message", //$NON-NLS-1$
|
String invokeMsg = InvokeMessages.getFormattedString("InvokeAction.console.message", //$NON-NLS-1$
|
||||||
new String[] { actionName, execDir.toString() }); //$NON-NLS-1$
|
new String[] { actionName, execDir.toString() }); // $NON-NLS-1$
|
||||||
buf.append(invokeMsg);
|
buf.append(invokeMsg);
|
||||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -378,8 +374,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler {
|
||||||
try {
|
try {
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
} catch (CoreException e2) {
|
} catch (CoreException e2) {
|
||||||
monitor1.subTask(
|
monitor1.subTask(AutotoolsUIPlugin.getResourceString("MakeGenerator.refresh.error")); //$NON-NLS-1$
|
||||||
AutotoolsUIPlugin.getResourceString("MakeGenerator.refresh.error")); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errMsg = launcher.getErrorMessage();
|
errMsg = launcher.getErrorMessage();
|
||||||
|
@ -396,8 +391,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
backgroundJob.setRule(rule);
|
backgroundJob.setRule(rule);
|
||||||
backgroundJob.schedule();
|
backgroundJob.schedule();
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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.Status;
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
@ -51,9 +49,7 @@ public class ReconfigureHandler extends AbstractAutotoolsHandler {
|
||||||
// workspace root rule.
|
// workspace root rule.
|
||||||
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
|
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
|
||||||
Job backgroundJob = new Job("Reconfigure Action") { //$NON-NLS-1$
|
Job backgroundJob = Job.create("Reconfigure Action", monitor -> {
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
try {
|
try {
|
||||||
ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> {
|
ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> {
|
||||||
IProject project = getSelectedContainer().getProject();
|
IProject project = getSelectedContainer().getProject();
|
||||||
|
@ -70,10 +66,8 @@ public class ReconfigureHandler extends AbstractAutotoolsHandler {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
}
|
}
|
||||||
IStatus returnStatus = Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
return returnStatus;
|
});
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
backgroundJob.setRule(rule);
|
backgroundJob.setRule(rule);
|
||||||
backgroundJob.schedule();
|
backgroundJob.schedule();
|
||||||
|
|
Loading…
Add table
Reference in a new issue