Esempio n. 1
0
 /**
  * Implements <code>IProgressMonitor.done</code>.
  *
  * @see IProgressMonitor#done()
  */
 public void done() {
   fLabel.setText(""); // $NON-NLS-1$
   fSubTaskName = ""; // $NON-NLS-1$
   fProgressIndicator.sendRemainingWork();
   fProgressIndicator.done();
   if (fToolBar != null && !fToolBar.isDisposed()) fToolBar.setVisible(false);
 }
Esempio n. 2
0
 /**
  * Implements <code>IProgressMonitor.beginTask</code>.
  *
  * @see IProgressMonitor#beginTask(java.lang.String, int)
  */
 public void beginTask(String name, int totalWork) {
   fTaskName = name;
   fSubTaskName = ""; // $NON-NLS-1$
   updateLabel();
   if (totalWork == IProgressMonitor.UNKNOWN || totalWork == 0) {
     fProgressIndicator.beginAnimatedTask();
   } else {
     fProgressIndicator.beginTask(totalWork);
   }
   if (fToolBar != null && !fToolBar.isDisposed()) {
     fToolBar.setVisible(true);
     fToolBar.setFocus();
   }
 }
Esempio n. 3
0
 /** Sets the progress monitor part's font. */
 public void setFont(Font font) {
   super.setFont(font);
   fLabel.setFont(font);
   fProgressIndicator.setFont(font);
 }
Esempio n. 4
0
 /**
  * Implements <code>IProgressMonitor.internalWorked</code>.
  *
  * @see IProgressMonitor#internalWorked(double)
  */
 public void internalWorked(double work) {
   fProgressIndicator.worked(work);
 }
Esempio n. 5
0
  /**
   * Creates the progress monitor's UI parts and layouts them according to the given layout. If the
   * layout is <code>null</code> the part's default layout is used.
   *
   * @param layout The layout for the receiver.
   * @param progressIndicatorHeight The suggested height of the indicator
   */
  protected void initialize(Layout layout, int progressIndicatorHeight) {
    if (layout == null) {
      GridLayout l = new GridLayout();
      l.marginWidth = 0;
      l.marginHeight = 0;
      layout = l;
    }
    int numColumns = 1;
    if (fHasStopButton) numColumns++;
    setLayout(layout);

    if (layout instanceof GridLayout) ((GridLayout) layout).numColumns = numColumns;

    fLabel = new Label(this, SWT.LEFT);
    fLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 1));

    if (progressIndicatorHeight == SWT.DEFAULT) {
      GC gc = new GC(fLabel);
      FontMetrics fm = gc.getFontMetrics();
      gc.dispose();
      progressIndicatorHeight = fm.getHeight();
    }

    fProgressIndicator = new ProgressIndicator(this);
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = false;
    gd.verticalAlignment = GridData.CENTER;
    gd.heightHint = progressIndicatorHeight;
    fProgressIndicator.setLayoutData(gd);

    if (fHasStopButton) {
      fToolBar = new ToolBar(this, SWT.FLAT);

      gd = new GridData();
      gd.grabExcessHorizontalSpace = false;
      gd.grabExcessVerticalSpace = false;
      gd.verticalAlignment = GridData.CENTER;
      fToolBar.setLayoutData(gd);
      fStopButton = new ToolItem(fToolBar, SWT.PUSH);
      // It would have been nice to use the fCancelListener, but that
      // listener operates on the fCancelComponent which must be a control.
      fStopButton.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              setCanceled(true);
              if (fStopButton != null) {
                fStopButton.setEnabled(false);
              }
            }
          });
      final Image stopImage =
          ImageDescriptor.createFromFile(ProgressMonitorPart.class, "images/stop.gif")
              .createImage(getDisplay()); // $NON-NLS-1$
      final Cursor arrowCursor = new Cursor(this.getDisplay(), SWT.CURSOR_ARROW);
      fToolBar.setCursor(arrowCursor);
      fStopButton.setImage(stopImage);
      fStopButton.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
              // RAP [rh] images don't support dispose
              //        			stopImage.dispose();
              arrowCursor.dispose();
            }
          });
      fStopButton.setToolTipText(
          JFaceResources.getString("ProgressMonitorPart.cancelToolTip")); // $NON-NLS-1$
    }
  }