Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to handle changes to workspace outside Eclipse with a Job
How to handle changes to workspace outside Eclipse with a Job [message #334957] Wed, 11 March 2009 19:14
Mikael Petterson is currently offline Mikael PettersonFriend
Messages: 153
Registered: July 2009
Senior Member
Hi,

We have a StateCacheJobQueue that extends Job. I looked at:
http://www.eclipse.org/articles/Article-Concurrency/jobs-api .html

I create it with the following snippet:

public void schedule(int jobPriority) {
priority = jobPriority;
StateCacheJobQueue queue = StateCacheFactory.getInstance()
.getJobQueue();
queue.schedule(this);
}

In the StateCacheJobQueue the run is executed ( see below). It then calls
executePendingJobs(). Is it within this method that I should call my
refreshLocal() on the resource to take into account changes in the
workspace that are not made from within Eclipse.

I don't know where to find the information. If this is not the correct
forum please point me in the right direction.

I am really stuck in this matter so all pointers are greatly appreciated.


cheers,

//Mike

StateCacheJobQueue
==================
/*
* (non-Javadoc)
*
* @see
org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.c ore.runtime.IProgressMonitor)
*/
protected IStatus run(IProgressMonitor monitor) {
//synchronized in case build starts during checkCancel
synchronized (this) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
// if the system is shutting down, don't update
if (systemBundle.getState() == Bundle.STOPPING)
return Status.OK_STATUS;
}
try {
executePendingJobs(monitor);
// if the update was successful then it should not be recorded
as
// interrupted
interrupted = false;
return Status.OK_STATUS;
} catch (OperationCanceledException e) {
return Status.CANCEL_STATUS;
} catch (CoreException sig) {
return sig.getStatus();
}
}

/**
* Executes all pending jobs
*
* @param monitor
* @throws CoreException
* @throws OperationCanceledException
*/
private void executePendingJobs(IProgressMonitor monitor)
throws CoreException, OperationCanceledException {

try {
monitor.beginTask(MESSAGE_QUEUE_NAME, priorityQueue.size());

while (!priorityQueue.isEmpty()) {

checkCanceled(monitor);

StateCacheJob job = null;

// synchronize on the buffer but execute job outside lock
synchronized (priorityQueue) {
if (!priorityQueue.isEmpty())
job = (StateCacheJob) priorityQueue.remove();
}

// check if buffer was empty
if (null == job) break;

// execute job
if (null != job.getStateCache().getResource()) {
monitor.subTask(Messages
.getString("StateCacheJobQueue.task.refresh")
//$NON-NLS-1$
+
job.getStateCache().getResource().getFullPath());
job.execute(new SubProgressMonitor(monitor, 1));
}
}
} finally {
monitor.done();
}
}
Previous Topic:Trying to figure out how I was supposed to figure this out
Next Topic:XML and Content Types
Goto Forum:
  


Current Time: Thu Nov 27 23:21:26 GMT 2014

Powered by FUDForum. Page generated in 0.01578 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software