mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 01:06:01 +02:00
fixed syncing of binary runner and getBinaries()
This commit is contained in:
parent
b06853641e
commit
84c89baed2
2 changed files with 40 additions and 83 deletions
|
@ -1,3 +1,9 @@
|
|||
2004-04-06 David Inglis
|
||||
|
||||
Fixed up syncing of binary runner and ::getBinaries()
|
||||
|
||||
* model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
|
||||
|
||||
2004-04-04 Alain Magloire
|
||||
|
||||
More support for external headers.
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
||||
*/
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -19,76 +18,64 @@ 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.IJobChangeEvent;
|
||||
import org.eclipse.core.runtime.jobs.IJobChangeListener;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
public class BinaryRunner implements IJobChangeListener {
|
||||
IProject project;
|
||||
public class BinaryRunner {
|
||||
|
||||
ICProject cproject;
|
||||
Job runner;
|
||||
ArchiveContainer vlib;
|
||||
BinaryContainer vbin;
|
||||
boolean done = false;
|
||||
|
||||
public BinaryRunner(IProject prj) {
|
||||
project = prj;
|
||||
cproject = CModelManager.getDefault().create(project);
|
||||
cproject = CModelManager.getDefault().create(prj);
|
||||
}
|
||||
|
||||
|
||||
public void start() {
|
||||
String taskName = CCorePlugin.getResourceString("CoreModel.BinaryRunner.Binary_Search_Thread"); //$NON-NLS-1
|
||||
Job runner = new Job(taskName) {
|
||||
/* (non-Javadoc)
|
||||
String taskName = CCorePlugin.getResourceString("CoreModel.BinaryRunner.Binary_Search_Thread"); //$NON-NLS-1$
|
||||
runner = new Job(taskName) {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
if (cproject == null || Thread.currentThread().isInterrupted()) {
|
||||
if (cproject == null || monitor.isCanceled()) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||
vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||
BinaryContainer vbin = (BinaryContainer) cproject.getBinaryContainer();
|
||||
ArchiveContainer vlib = (ArchiveContainer) cproject.getArchiveContainer();
|
||||
vlib.removeChildren();
|
||||
vbin.removeChildren();
|
||||
try {
|
||||
project.accept(new Visitor(BinaryRunner.this));
|
||||
cproject.getProject().accept(new Visitor(BinaryRunner.this, monitor));
|
||||
} catch (CoreException e) {
|
||||
//e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// What is wrong ?
|
||||
e.printStackTrace();
|
||||
return e.getStatus();
|
||||
}
|
||||
if (!Thread.currentThread().isInterrupted()) {
|
||||
if (monitor.isCanceled()) {
|
||||
fireEvents(cproject, vbin);
|
||||
fireEvents(cproject, vlib);
|
||||
}
|
||||
// Tell the listeners we are done.
|
||||
synchronized(BinaryRunner.this) {
|
||||
BinaryRunner.this.notifyAll();
|
||||
BinaryRunner.this.runner = null;
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
runner.schedule();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* wrap the wait call and the interrupteException.
|
||||
*/
|
||||
public synchronized void waitIfRunning() {
|
||||
while (runner != null && !done) {
|
||||
public void waitIfRunning() {
|
||||
if (runner != null) {
|
||||
try {
|
||||
wait();
|
||||
runner.join();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void stop() {
|
||||
if ( runner != null && !done) {
|
||||
if (runner != null && runner.getState() == Job.RUNNING) {
|
||||
runner.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +85,7 @@ public class BinaryRunner implements IJobChangeListener {
|
|||
ICElement[] children = container.getChildren();
|
||||
if (children.length > 0) {
|
||||
CModelManager factory = CModelManager.getDefault();
|
||||
ICElement root = (ICModel)factory.getCModel();
|
||||
ICElement root = (ICModel) factory.getCModel();
|
||||
CElementDelta cdelta = new CElementDelta(root);
|
||||
cdelta.added(cproject);
|
||||
cdelta.added(container);
|
||||
|
@ -124,20 +111,23 @@ public class BinaryRunner implements IJobChangeListener {
|
|||
}
|
||||
|
||||
class Visitor implements IResourceVisitor {
|
||||
BinaryRunner runner;
|
||||
|
||||
public Visitor (BinaryRunner r) {
|
||||
runner = r;
|
||||
private BinaryRunner vRunner;
|
||||
private IProgressMonitor vMonitor;
|
||||
|
||||
public Visitor(BinaryRunner r, IProgressMonitor monitor) {
|
||||
vRunner = r;
|
||||
vMonitor = monitor;
|
||||
}
|
||||
|
||||
public boolean visit(IResource res) throws CoreException {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
if (vMonitor.isCanceled()) {
|
||||
return false;
|
||||
}
|
||||
if (cproject.isOnOutputEntry(res)) {
|
||||
if (res instanceof IFile) {
|
||||
if (runner != null) {
|
||||
runner.addChildIfBinary((IFile)res);
|
||||
if (vRunner != null) {
|
||||
vRunner.addChildIfBinary((IFile) res);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -145,43 +135,4 @@ public class BinaryRunner implements IJobChangeListener {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.IJobChangeListener#aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent)
|
||||
*/
|
||||
public void aboutToRun(IJobChangeEvent event) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.IJobChangeListener#awake(org.eclipse.core.runtime.jobs.IJobChangeEvent)
|
||||
*/
|
||||
public void awake(IJobChangeEvent event) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.IJobChangeListener#done(org.eclipse.core.runtime.jobs.IJobChangeEvent)
|
||||
*/
|
||||
public void done(IJobChangeEvent event) {
|
||||
done = true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.IJobChangeListener#running(org.eclipse.core.runtime.jobs.IJobChangeEvent)
|
||||
*/
|
||||
public void running(IJobChangeEvent event) {
|
||||
done = false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.IJobChangeListener#scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent)
|
||||
*/
|
||||
public void scheduled(IJobChangeEvent event) {
|
||||
done = false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.IJobChangeListener#sleeping(org.eclipse.core.runtime.jobs.IJobChangeEvent)
|
||||
*/
|
||||
public void sleeping(IJobChangeEvent event) {
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue