[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.technology] ProgressMonitorDialog issue ?

Hi,

Not sure if this is the right newsgroup to ask, but here it is ...
Could not find any reference in Bugzilla, maybe a kind soul around here cah
help.

I am working on a plugin with a long Action which is implemented as
following :
/////////////////////////////////
public class VerifIntegriteAction implements IObjectActionDelegate,
IRunnableWithProgress
{
 [...]
 public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException
 {
  try
  {
   Object sel = targetPart.getSite().getSelectionProvider();
   if (sel instanceof TreeViewer)
   {
    [...]
      if (obj instanceof IContainer)
      {
       maxFiles = CustomFileManagerSingleton.countFiles((IContainer) obj);
       monitor.beginTask("Vérification de cohérence", maxFiles);
      }

      if (obj instanceof IFolder)
      {
       IFolder folder = (IFolder) obj;
       folder.accept(new CustomVisitor(monitor, maxFiles));
      }
     }
    }
   }
  }
  catch [...]
 }

 public void run(IAction action)
 {
  try
  {
   new ProgressMonitorDialog(targetPart.getSite().getShell()).run(false,
true, this);
  }
  catch (Exception e)
  {
   e.printStackTrace();
  }
 }
}
///////////////////////////
the CustomVisitor being
//////////////////////////////
public class CustomVisitor implements IResourceVisitor
{
 private IProgressMonitor monitor;
 private int maxFiles = 1;
 private int crtFile = 0;
 /**
  * @param monitor
  */
 public CustomVisitor(IProgressMonitor monitor, int maxFiles)
 {
  super();
  this.monitor = monitor;
  this.maxFiles = maxFiles;
  this.crtFile = 0;
 }

 /**
  * blocked
  */
 private CustomVisitor()
 {
 }

 public boolean visit(IResource resource) throws CoreException
 {
  if (!monitor.isCanceled())
  {
   [set up stuff]
  }
  if (resource instanceof IFile)
  {
   IFile ifile = (IFile) resource;
   if (!monitor.isCanceled())
   {
    [do long processing with the content of the ifile]
   }
   crtFile++;
   monitor.setTaskName("[" + crtFile + "/" + maxFiles + "] " +
ifile.getName());
   monitor.worked(1);
   return false;
  }
  else
  {
   return true;
  }
 }
}
//////////////////////////////////////
I am obtaining a progress dialog with the cancel button activated.
I am unable to click the button and isCanceled() is false all the time.
However, the dialog and its title does refresh.
What's funnier is that if I simply move the mouse around or change the focus
on another application
then switch back, Eclipse does not refresh any more (neither the progress
dialog nor the
whole platform window). But processing still continues "in the background".
Maybe i'm using the progressmonitor the wrong way ?
Any ideas ?
Thanks,
Adrian