コード例 #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);
   }
 }
コード例 #2
0
  /** Creates content Composite. */
  Composite eswtConstructContent(int style) {
    Composite comp = super.eswtConstructContent(SWT.VERTICAL);

    FormLayout layout = new FormLayout();
    layout.marginBottom = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTBOTTOMMARGIN);
    layout.marginTop = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTTOPMARGIN);
    layout.marginLeft = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTLEFTMARGIN);
    layout.marginRight = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTRIGHTMARGIN);
    layout.spacing = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTVERTICALSPACING);
    comp.setLayout(layout);

    eswtScrolledText = new ScrolledTextComposite(comp, comp.getVerticalBar());
    eswtImgLabel = new LabelExtension(comp, SWT.NONE);

    FormData imageLD = new FormData();
    imageLD.right = new FormAttachment(100);
    imageLD.top = new FormAttachment(0);
    eswtImgLabel.setLayoutData(imageLD);

    FormData scrolledTextLD = new FormData();
    scrolledTextLD.left = new FormAttachment(0);
    scrolledTextLD.top = new FormAttachment(0);
    scrolledTextLD.right = new FormAttachment(eswtImgLabel);
    eswtScrolledText.setLayoutData(scrolledTextLD);

    eswtProgbarLD = new FormData();
    eswtProgbarLD.left = new FormAttachment(0);
    eswtProgbarLD.right = new FormAttachment(100);
    eswtProgbarLD.bottom = new FormAttachment(100);

    eswtUpdateProgressbar(comp, false, false);

    return comp;
  }