mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
run target build in progress service dialog
This commit is contained in:
parent
0abb812267
commit
7ed4f67c41
1 changed files with 30 additions and 71 deletions
|
@ -4,13 +4,11 @@ package org.eclipse.cdt.make.ui;
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.IMakeTarget;
|
import org.eclipse.cdt.make.core.IMakeTarget;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.make.internal.ui.dialogs.GoToBackProgressMonitorDialog;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.preferences.MakeTargetsPreferencePage;
|
import org.eclipse.cdt.make.internal.ui.preferences.MakeTargetsPreferencePage;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
|
@ -21,8 +19,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.jface.operation.IRunnableContext;
|
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
@ -32,6 +28,7 @@ import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.actions.BuildAction;
|
import org.eclipse.ui.actions.BuildAction;
|
||||||
|
import org.eclipse.ui.progress.IProgressService;
|
||||||
|
|
||||||
public class TargetBuild {
|
public class TargetBuild {
|
||||||
|
|
||||||
|
@ -71,22 +68,14 @@ public class TargetBuild {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void runWithProgressDialog(Shell shell, IMakeTarget[] targets) {
|
static private void runWithProgressDialog(Shell shell, Job job) {
|
||||||
GoToBackProgressMonitorDialog pd = new GoToBackProgressMonitorDialog(shell,
|
IProgressService service = PlatformUI.getWorkbench().getProgressService();
|
||||||
MakeUIPlugin.getResourceString("TargetBuild.backgroundTask.name")); //$NON-NLS-1$
|
service.showInDialog(shell,job);
|
||||||
try {
|
|
||||||
TargetBuild.run(true, pd, targets);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
MakeUIPlugin.errorDialog(shell, MakeUIPlugin.getResourceString("TargetBuild.execption.message"), //$NON-NLS-1$
|
|
||||||
e.getTargetException().toString(), e.getTargetException());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void buildTargets(Shell shell, final IMakeTarget[] targets) {
|
static public void buildTargets(Shell shell, final IMakeTarget[] targets) {
|
||||||
saveAllResources(targets);
|
saveAllResources(targets);
|
||||||
if (MakeTargetsPreferencePage.isBuildTargetInBackground()) {
|
Job targetJob = new Job(MakeUIPlugin.getResourceString("TargetBuild.backgroundTask.name")) { //$NON-NLS-1$
|
||||||
new Job(MakeUIPlugin.getResourceString("TargetBuild.backgroundTask.name")) { //$NON-NLS-1$
|
|
||||||
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
monitor.beginTask(MakeUIPlugin.getResourceString("TargetBuild.monitor.beginTask"), targets.length); //$NON-NLS-1$
|
monitor.beginTask(MakeUIPlugin.getResourceString("TargetBuild.monitor.beginTask"), targets.length); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
|
@ -108,42 +97,12 @@ public class TargetBuild {
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
}.schedule();
|
|
||||||
} else {
|
|
||||||
runWithProgressDialog(shell, targets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static public void run(boolean fork, IRunnableContext context, final IMakeTarget[] targets) throws InvocationTargetException {
|
|
||||||
try {
|
|
||||||
saveAllResources(targets);
|
|
||||||
|
|
||||||
context.run(fork, true, new IRunnableWithProgress() {
|
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
|
||||||
monitor.beginTask(MakeUIPlugin.getResourceString("TargetBuild.monitor.beginTask"), targets.length); //$NON-NLS-1$
|
|
||||||
try {
|
|
||||||
for (int i = 0; i < targets.length; i++) {
|
|
||||||
final IMakeTarget target = targets[i];
|
|
||||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
|
||||||
target.build(new SubProgressMonitor(monitor, 1));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
MakeUIPlugin.getWorkspace().run(runnable, monitor);
|
|
||||||
}
|
if (MakeTargetsPreferencePage.isBuildTargetInBackground()) {
|
||||||
} catch (CoreException e) {
|
targetJob.schedule();
|
||||||
throw new InvocationTargetException(e);
|
} else {
|
||||||
} catch (OperationCanceledException e) {
|
runWithProgressDialog(shell, targetJob);
|
||||||
throw new InterruptedException(e.getMessage());
|
|
||||||
} finally {
|
|
||||||
monitor.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue