private void initialize() {
    List<Control> children = new ArrayList<>(Arrays.asList(shlMyanmarTyping.getChildren()));
    while (!children.isEmpty()) {
      Control c = children.remove(0);
      if (c instanceof Composite) {
        children.addAll(Arrays.asList(((Composite) c).getChildren()));
      } else if (c instanceof Button) {
        Button b = (Button) c;
        MMKey key = MMKey.ALL_MM_KEY_MAP.get(b.getText().charAt(0));
        if (key != null) {
          b.setData(key);
          b.setText(key.toString());
          b.addSelectionListener(listener);
        }
      }
    }

    text.addModifyListener(modifyListener);
    text_5.addModifyListener(modifyTextListener);

    text_1.setEditable(false);
    text_2.setEditable(false);
    text_3.setEditable(false);
    text_4.setEditable(false);
    text.setFocus();
    text.setText(defaultText);
    text_5.setText("100F");
  }
  private void doEventLoop() {
    Shell splash = getSplash();
    while (fAuthenticated == false) {
      if (splash.getDisplay().readAndDispatch() == false) {
        splash.getDisplay().sleep();
      }
    }

    for (Control control : splash.getChildren()) {
      control.dispose();
    }

    String progressRectString = null;
    String messageRectString = null;
    String foregroundColorString = null;
    IProduct product = Platform.getProduct();
    if (product != null) {
      progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
      messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
      foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    }

    Rectangle progressRect =
        StringConverter.asRectangle(progressRectString, new Rectangle(5, 275, 445, 15));
    setProgressRect(progressRect);

    Rectangle messageRect =
        StringConverter.asRectangle(messageRectString, new Rectangle(0, 0, 0, 0));
    // new Rectangle(7, 252, 445, 20));
    setMessageRect(messageRect);

    getContent();
  }
Esempio n. 3
0
  public Image captureImage(Control control) {
    Rectangle rectangle = control.getBounds();
    Display display = control.getDisplay();
    Image image = null;
    if (control instanceof Shell) {
      Shell shell = (Shell) control;
      shell.layout();
      Point parentLocation = control.toDisplay(0, 0);
      image = getImage(control, rectangle.width, rectangle.height, false);

      rectangle.x = parentLocation.x;
      rectangle.y = parentLocation.y;

      GC myImageGC = new GC(image);
      try {
        for (Control child : shell.getChildren()) {
          Rectangle childBounds = child.getBounds();
          // bug of SWT on Win32, child bounds is not correct in the Window is not in the ToolBar
          int x = (rectangle.width - childBounds.width) / 2;
          int y = (rectangle.height - childBounds.height) - x;
          childBounds.x = rectangle.x + x;
          childBounds.y = rectangle.y + y;
          if (!rectangle.intersects(childBounds)) continue; // Child is completely outside parent.

          Image childImage = new Image(display, child.getBounds());
          GC gc = new GC(childImage);
          child.print(gc);
          DisposeUtil.dispose(gc);
          try {
            myImageGC.drawImage(childImage, x, y);
          } finally {
            childImage.dispose();
          }
        }
      } finally {
        myImageGC.dispose();
      }
    } else {
      image = defaultCapture(control);
    }
    return image;
  }
  public void testCreateView() {
    final MWindow window = createWindowWithOneView();
    wb = new E4Workbench(window, appContext);

    Widget topWidget = (Widget) window.getWidget();
    assertTrue(topWidget instanceof Shell);
    Shell shell = (Shell) topWidget;
    assertEquals("MyWindow", shell.getText());
    Control[] controls = shell.getChildren();
    assertEquals(1, controls.length);
    SashForm sash = (SashForm) controls[0];
    Control[] sashChildren = sash.getChildren();
    assertEquals(1, sashChildren.length);

    CTabFolder folder = (CTabFolder) sashChildren[0];
    assertEquals(1, folder.getItemCount());
    Control c = folder.getItem(0).getControl();
    assertTrue(c instanceof Composite);
    Control[] viewPart = ((Composite) c).getChildren();
    assertEquals(1, viewPart.length);
    assertTrue(viewPart[0] instanceof Tree);
  }
  /** @see org.eclipse.gef.tools.DirectEditManager#commit() */
  protected void commit() {
    Shell activeShell = Display.getCurrent().getActiveShell();
    if (activeShell != null
        && getCellEditor().getControl().getShell().equals(activeShell.getParent())) {
      Control[] children = activeShell.getChildren();
      if (children.length == 1 && children[0] instanceof Table) {
        /*
         * CONTENT ASSIST: focus is lost to the content assist pop up -
         * stay in focus
         */
        getCellEditor().getControl().setVisible(true);
        ((XtextStyledTextCellEditorEx) getCellEditor()).setDeactivationLock(true);
        return;
      }
    }

    // content assist hacks
    if (committed) {
      bringDown();
      return;
    }
    committed = true;
    super.commit();
  }
Esempio n. 6
0
  /**
   * Create a shell but do not display it
   *
   * @return Returns <code>true</code> when shell is created.
   */
  private void createUI() {

    final boolean isRecreateContent = _toolTipStyle == TOOLTIP_STYLE_RECREATE_CONTENT;
    boolean isShellCreated = false;
    boolean isCreateContent = false;

    if (_shell == null || _shell.isDisposed()) {

      /*
       * create shell
       */
      _shell =
          new Shell(
              _ownerControl.getShell(), //
              SWT.ON_TOP //
                  /*
                   * SWT.TOOL must be disabled that NO_FOCUS is working !!!
                   */
                  //							| SWT.TOOL
                  | SWT.NO_FOCUS);

      _shell.setLayout(new FillLayout());

      addTTShellListener(_shell);

      isShellCreated = true;

    } else {

      if (isRecreateContent) {

        // hide previous tooltip content

        _shell.setRedraw(false);

        final Control[] shellChildren = _shell.getChildren();
        for (final Control control : shellChildren) {
          control.dispose();
        }

        isCreateContent = true;
      }
    }

    final boolean isNewContent = isShellCreated || isCreateContent;

    if (isNewContent) {

      // create content
      createToolTipContentArea(_shell);
    }

    if (isShellCreated) {
      _shell.pack(true);
    } else {
      _shell.layout();
      _shell.pack(true);
    }

    _shell.setRedraw(true);

    if (isNewContent) {
      addTTAllControlsListener(_shell);
    }
  }