Ejemplo n.º 1
0
 /**
  * Update ProgressBar widget.<br>
  * Try to reuse the old ProgressBar if possible, otherwise dispose it and create a new one.
  *
  * @param parent
  * @param indeterminate
  * @param visible
  */
 void eswtUpdateProgressbar(Composite parent, boolean indeterminate, boolean visible) {
   // Only dispose old ProgressBar if it has wrong style
   if (eswtProgressBar != null) {
     boolean isIndeterminate = (eswtProgressBar.getStyle() & SWT.INDETERMINATE) != 0;
     if (indeterminate != isIndeterminate) {
       eswtProgressBar.setLayoutData(null);
       eswtProgressBar.dispose();
       eswtProgressBar = null;
     }
   }
   // create new ProgressBar
   if (eswtProgressBar == null) {
     int newStyle = indeterminate ? SWT.INDETERMINATE : SWT.NONE;
     eswtProgressBar = new ProgressBar(parent, newStyle);
     eswtProgressBar.setLayoutData(eswtProgbarLD);
     // update ScrolledText's layoutdata
     FormData imageLD = (FormData) eswtImgLabel.getLayoutData();
     imageLD.bottom = new FormAttachment(eswtProgressBar);
   }
   // set Progressbar visibility
   if (eswtProgressBar != null) {
     eswtProgbarLD.top = (visible ? null : new FormAttachment(100));
     eswtProgressBar.setVisible(visible);
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.internal.progress.AnimationItem#animationStart()
  */
 @Override
 void animationStart() {
   super.animationStart();
   animationRunning = true;
   if (bar.isDisposed()) {
     return;
   }
   bar.setVisible(true);
   refresh();
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.internal.progress.AnimationItem#animationDone()
  */
 @Override
 void animationDone() {
   super.animationDone();
   animationRunning = false;
   if (bar.isDisposed()) {
     return;
   }
   bar.setVisible(false);
   refresh();
 }
Ejemplo n.º 4
0
 /** Create contents of the shell. */
 protected void createContents() {
   setText("Working");
   setSize(300, 150);
   setCursor(waitingIndicator);
   setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
   ProgressBar progressBar = new ProgressBar(this, SWT.SMOOTH | SWT.INDETERMINATE);
   progressBar.setBounds(10, 71, 274, 25);
   progressBar.setEnabled(true);
   progressBar.setVisible(true);
   txtPleaseWaitUntil = new Text(this, SWT.WRAP | SWT.MULTI);
   txtPleaseWaitUntil.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
   txtPleaseWaitUntil.setText("Please wait until the application closes all open files.");
   txtPleaseWaitUntil.setBounds(12, 24, 272, 41);
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.ui.internal.progress.AnimationItem#createAnimationItem(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createAnimationItem(Composite parent) {

    if (okImage == null) {
      Display display = parent.getDisplay();
      noneImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_none.png")
              .createImage(display); // $NON-NLS-1$
      okImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_ok.png")
              .createImage(display); // $NON-NLS-1$
      errorImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_error.png")
              .createImage(display); // $NON-NLS-1$
    }

    top = new Composite(parent, SWT.NULL);
    top.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            FinishedJobs.getInstance().removeListener(ProgressAnimationItem.this);
            noneImage.dispose();
            okImage.dispose();
            errorImage.dispose();
          }
        });

    boolean isCarbon = Util.isMac();

    GridLayout gl = new GridLayout();
    if (isHorizontal()) gl.numColumns = isCarbon ? 3 : 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    if (isHorizontal()) {
      gl.horizontalSpacing = 2;
    } else {
      gl.verticalSpacing = 2;
    }
    top.setLayout(gl);

    bar = new ProgressBar(top, flags | SWT.INDETERMINATE);
    bar.setVisible(false);
    bar.addMouseListener(mouseListener);

    GridData gd;
    int hh = 12;
    if (isHorizontal()) {
      gd = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
      gd.heightHint = hh;
    } else {
      gd = new GridData(SWT.CENTER, SWT.BEGINNING, false, true);
      gd.widthHint = hh;
    }

    bar.setLayoutData(gd);

    toolbar = new ToolBar(top, SWT.FLAT);
    toolbar.setVisible(false);

    toolButton = new ToolItem(toolbar, SWT.NONE);
    toolButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            doAction();
          }
        });

    if (isCarbon) {
      new Label(top, SWT.NONE).setLayoutData(new GridData(4, 4));
    }

    refresh();

    return top;
  }
Ejemplo n.º 6
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public IOSNavBarComposite(Composite parent, BrowserSimImageList imageList) {
    super(parent, SWT.NONE);

    this.setLayout(new FormLayout());

    pageTitleStyledText = new IOSPageTitleStyledText(this, imageList);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(0, 26);
    formData.height = 27;
    pageTitleStyledText.setLayoutData(formData);

    urlText = new AdressBarText(this, SWT.SINGLE);
    formData = new FormData();
    formData.left = new FormAttachment(0, 12);
    formData.right = new FormAttachment(100, -58);
    formData.top = new FormAttachment(0, 33 - AdressBarText.adressBarUrlOffset);
    formData.height = 16;
    urlText.setLayoutData(formData);

    refreshButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh-selected.png"));
    formData = new FormData();
    Rectangle refreshImageBounds = imageList.getImage(BD + "refresh.png").getBounds();
    formData.right = new FormAttachment(100, -8);
    formData.bottom = new FormAttachment(100, -7);
    formData.width = refreshImageBounds.width;
    formData.height = refreshImageBounds.height;
    refreshButtonComposite.setLayoutData(formData);

    stopButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop-selected.png"));
    formData = new FormData();
    Rectangle stopImageBounds = imageList.getImage(BD + "stop.png").getBounds();
    formData.right = new FormAttachment(100, -42);
    formData.bottom = new FormAttachment(100, -12);
    formData.width = stopImageBounds.width;
    formData.height = stopImageBounds.height;
    stopButtonComposite.setLayoutData(formData);

    progressBar = new ProgressBar(this, SWT.NONE);
    progressBar.setVisible(false);
    formData = new FormData();
    formData.left = new FormAttachment(0, 7);
    formData.right = new FormAttachment(100, -36);
    formData.bottom = new FormAttachment(100, -1);
    formData.height = 5;
    progressBar.setLayoutData(formData);

    Composite imagesComposite = new Composite(this, SWT.NONE);
    formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.top = new FormAttachment(0);
    formData.bottom = new FormAttachment(100);
    imagesComposite.setLayoutData(formData);

    GridLayout gridLayout = new GridLayout(5, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;

    imagesComposite.setLayout(gridLayout);

    for (ImageDescriptor descriptor : BODY_DESCRIPTOR) {
      descriptor.createWidget(imagesComposite, imageList);
    }
  }