Topic
4 replies Latest Post - ‏2007-06-26T08:46:42Z by SystemAdmin
SystemAdmin
SystemAdmin
1479 Posts
ACCEPTED ANSWER

Pinned topic Using progress monitors

‏2003-03-20T20:56:10Z |
Hi Folks,

I'm trying to use a progress monitor for a plugin that generates a file
in the workspace. The plugin extends the org.eclipse.ui.viewActions
extension point. My implementation class's run method invokes another
class which implements IProgressMonitor to do the work. Here is a
snipet from my ViewActionDelegate implementation. HeadlessAntGenerator
is the helper class that implements IProgressMonitor.

================== Snipet Start =========================
1 HeadlessAntGenerator antGenerator = new HeadlessAntGenerator();
2 Composite parent = view.getViewSite().getShell();
3 ProgressMonitorPart monitor = new ProgressMonitorPart(parent, null);
4 monitor.setVisible(true);
5 antGenerator.generate(earProject, monitor);
6 monitor.setVisible(false);
7 monitor.dispose();
================== Snipet End ===========================

I don't see a progress monitor during the execution of the plugin. I'm
reasonably sure it's executing because I can see the print statements
from the generate method. Some things I wasn't sure about are

1. What to use as the parent? Line 2 was my best guess.
2. Are lines 4 and 6 necessary?
3. Is this whole approach wrong for using progress monitors?

  • Paul
Updated on 2007-06-26T08:46:42Z at 2007-06-26T08:46:42Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1479 Posts
    ACCEPTED ANSWER

    Re: Using progress monitors

    ‏2003-03-20T21:10:06Z  in response to SystemAdmin
    The code only makes the shell the parent. It doesn't size or position
    it. You can't just take a shell and make a child window on it.

    I would suggest that you use ProgressMonitorDialog instead. This will
    be a dialog that contains a progress monitor.

    ProgressMonitorPart is when you have your window that you can control
    and using a layout, position and size the ProgressMonitorPart.

    Paul Glezen wrote:
    > Hi Folks,
    >
    > I'm trying to use a progress monitor for a plugin that generates a file
    > in the workspace. The plugin extends the org.eclipse.ui.viewActions
    > extension point. My implementation class's run method invokes another
    > class which implements IProgressMonitor to do the work. Here is a
    > snipet from my ViewActionDelegate implementation. HeadlessAntGenerator
    > is the helper class that implements IProgressMonitor.
    >
    > ================== Snipet Start =========================
    > 1 HeadlessAntGenerator antGenerator = new HeadlessAntGenerator();
    > 2 Composite parent = view.getViewSite().getShell();
    > 3 ProgressMonitorPart monitor = new ProgressMonitorPart(parent, null);
    > 4 monitor.setVisible(true);
    > 5 antGenerator.generate(earProject, monitor);
    > 6 monitor.setVisible(false);
    > 7 monitor.dispose();
    > ================== Snipet End ===========================
    >
    > I don't see a progress monitor during the execution of the plugin. I'm
    > reasonably sure it's executing because I can see the print statements
    > from the generate method. Some things I wasn't sure about are
    >
    > 1. What to use as the parent? Line 2 was my best guess.
    > 2. Are lines 4 and 6 necessary?
    > 3. Is this whole approach wrong for using progress monitors?
    >
    > - Paul
    >

    Thanks, Rich Kulp

    • SystemAdmin
      SystemAdmin
      1479 Posts
      ACCEPTED ANSWER

      Re: Using progress monitors

      ‏2003-03-22T16:26:48Z  in response to SystemAdmin
      That worked. Thanks, Rich, for straightening me out again (probably
      won't be the last time).

      • Paul
      • SystemAdmin
        SystemAdmin
        1479 Posts
        ACCEPTED ANSWER

        Re: Using progress monitors

        ‏2003-03-22T18:37:09Z  in response to SystemAdmin
        You're welcome.
        It's my job to help customers (besides also developing new code ;-) ).

        Rich
        • SystemAdmin
          SystemAdmin
          1479 Posts
          ACCEPTED ANSWER

          Re: Using progress monitors

          ‏2007-06-26T08:46:42Z  in response to SystemAdmin
          Hello,
          I have also some problems with the ProgressMonitorPart - ProgressMonitorDialog. If I use ProgressMonitorDialog it works fine but the thing is that my task is so fast that I can't see its output in the ProgressMonitorDialog.

          Therefore, I'd like to know if it's possible to attach a ProgressMonitorDialog or a ProgressMonitorPart to a console so that it writes to the console.

          Thanks.