Пример #1
0
 /**
  * Adds eSWT Command to this command.
  *
  * @param control The Control where eSWT Command is added. For example Shell.
  * @param isDefault If true, created eSWT command is set to be default one.
  */
 void addESWTCommand(Control control, final boolean isDefault) {
   final Control finalControl = control;
   ESWTUIThreadRunner.syncExec(
       new Runnable() {
         public void run() {
           eswtAddESWTCommand(finalControl, isDefault);
         }
       });
 }
Пример #2
0
 /**
  * Removes eSWT Command from this command.
  *
  * @param control The Control where eSWT Command is located.
  */
 void removeESWTCommand(Control control) {
   final Control finalControl = control;
   ESWTUIThreadRunner.syncExec(
       new Runnable() {
         public void run() {
           eswtRemoveESWTCommand(finalControl);
         }
       });
 }
Пример #3
0
 /** Dispose Alert. */
 void dispose() {
   super.dispose();
   ESWTUIThreadRunner.syncExec(
       new Runnable() {
         public void run() {
           topShell.dispose();
         }
       });
 }
Пример #4
0
 /**
  * Checks if the text label's scrollbar is visible.
  *
  * @return true if the scrollbar is visible.
  */
 private boolean isTextScrolling() {
   ESWTUIThreadRunner.syncExec(
       new Runnable() {
         public void run() {
           textScrolling = eswtScrolledText.isTextScrolling();
         }
       });
   return textScrolling;
 }
Пример #5
0
 /**
  * Sets the text used in the Alert.
  *
  * @param newText the Alert's text string, or null if there is no text
  */
 public void setString(String newText) {
   text = newText;
   ESWTUIThreadRunner.syncExec(
       new Runnable() {
         public void run() {
           String temp = (text != null) ? text : getDefaultText(type);
           eswtScrolledText.setText(temp);
           eswtSetPreferredContentSize(-1, eswtGetPreferredContentHeight());
           getContentComp().layout();
         }
       });
   setCommandsVisibility(isModal());
 }
Пример #6
0
 /** Update indicator if it changed. */
 void updateIndicator() {
   ESWTUIThreadRunner.syncExec(
       new Runnable() {
         public void run() {
           if (indicator != null) {
             // show ProgressBar
             if (indicator.isIndefinite()) {
               // indefinite ProgressBar
               switch (indicator.getValue()) {
                 case Gauge.CONTINUOUS_IDLE:
                 case Gauge.INCREMENTAL_IDLE:
                   // currently these are mapped to full progress bar
                   // TODO: eSWT support required
                   eswtUpdateProgressbar(getContentComp(), false, true);
                   eswtSetProgressbarValues(0, 1, 1);
                   break;
                 case Gauge.CONTINUOUS_RUNNING:
                   eswtUpdateProgressbar(getContentComp(), true, true);
                   break;
                 case Gauge.INCREMENTAL_UPDATING:
                   // currently this are mapped to blinking
                   // empty and full progress bar
                   // TODO: eSWT support required
                   eswtUpdateProgressbar(getContentComp(), false, true);
                   if (eswtProgressBar.getSelection() > 0) {
                     eswtSetProgressbarValues(0, 1, 0);
                   } else {
                     eswtSetProgressbarValues(0, 1, 1);
                   }
                   break;
                 default:
                   break;
               }
             } else {
               // definite ProgressBar
               eswtUpdateProgressbar(getContentComp(), false, true);
               eswtSetProgressbarValues(0, indicator.getMaxValue(), indicator.getValue());
             }
           } else {
             // hide ProgressBar
             eswtUpdateProgressbar(getContentComp(), false, false);
           }
           eswtSetPreferredContentSize(-1, eswtGetPreferredContentHeight());
           getContentComp().layout();
         }
       });
 }
Пример #7
0
  /**
   * Sets the image of this Alert.
   *
   * @param newImage an Image, or null if there is no image
   */
  public void setImage(Image newImage) {
    image = newImage;
    ESWTUIThreadRunner.syncExec(
        new Runnable() {
          public void run() {
            Image temp = (image != null) ? image : null;
            // Get the image size from QT Style for scaling
            int scaleToSize = Style.pixelMetric(Style.QSTYLE_PM_MESSAGEBOXICONSIZE);

            if (temp != null) {

              // calculate the aspect ratio
              float aspectRatio = (float) temp.getHeight() / temp.getWidth();

              // check the image size
              if ((temp.getWidth() > scaleToSize) || (temp.getHeight() > scaleToSize)) {
                // we need to scale down the image
                if (temp.getWidth() > scaleToSize) {
                  // Width is greater
                  Image wScaled =
                      Image.createImage(temp, scaleToSize, (int) (scaleToSize * aspectRatio));

                  // now check the new dimension against height
                  if (wScaled.getHeight() > scaleToSize) {
                    // scale the image again
                    Image whScaled = Image.createImage(temp, scaleToSize, scaleToSize);
                    eswtImgLabel.setImage(Image.getESWTImage(whScaled));
                  } else {
                    // height was ok after scaling on width
                    eswtImgLabel.setImage(Image.getESWTImage(wScaled));
                  }
                } else if (temp.getHeight() > scaleToSize) {
                  // Height is greater
                  Image hScaled =
                      Image.createImage(temp, (int) (scaleToSize / aspectRatio), scaleToSize);

                  // now check the new dimension against width
                  if (hScaled.getWidth() > scaleToSize) {
                    // scale the image again
                    Image hwScaled = Image.createImage(temp, scaleToSize, scaleToSize);
                    eswtImgLabel.setImage(Image.getESWTImage(hwScaled));
                  } else {
                    // widh was ok after scaling using height
                    eswtImgLabel.setImage(Image.getESWTImage(hScaled));
                  }
                }

              } else {
                // image is right size
                eswtImgLabel.setImage(Image.getESWTImage(temp));
              }
            } else {
              // no image
              if (type != null) {
                // display the default image
                eswtImgLabel.setStandardIcon(getDefaultImageType(type), scaleToSize, scaleToSize);
                eswtImgLabel.pack();
              }
            }
            eswtSetPreferredContentSize(-1, eswtGetPreferredContentHeight());
            getContentComp().layout();
          }
        });
  }