private Text createValueText() {
   final Text t = new Text(this, SWT.BORDER);
   t.setMessage(Messages.argument);
   t.addKeyListener(
       new KeyAdapter() {
         @Override
         public void keyReleased(final KeyEvent e) {
           AssertionComposite.this.orCondition.updateFilter();
         }
       });
   final RowData rowData = new RowData();
   rowData.width = 132;
   t.setLayoutData(rowData);
   return t;
 }
 private Combo createAssertionCombo() {
   final Combo c = new Combo(this, SWT.NONE);
   for (final Assertion assertion : Assertion.values()) {
     c.add(assertion.toString());
   }
   c.select(0);
   c.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(final SelectionEvent e) {
           AssertionComposite.this.orCondition.updateFilter();
         }
       });
   final RowData rowData = new RowData();
   rowData.width = 75;
   c.setLayoutData(rowData);
   return c;
 }
Ejemplo n.º 3
0
  protected void manageResized() {

    try {

      final RowData layoutData = (RowData) compositeCharts.getLayoutData();
      int size = Math.min(form.getClientArea().width - 40, form.getClientArea().height - 40);
      // not working for this chart !
      //   Point prefered = chartComposites.computeSize(size, SWT.DEFAULT);
      layoutData.width = size;
      layoutData.height = size;

      form.reflow(true);

    } catch (RuntimeException e) {
      // ignore
      e.printStackTrace();
    }
  }
Ejemplo n.º 4
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.wrap = true;
    layout.fill = false;
    layout.justify = true;
    shell.setLayout(layout);

    Button b = new Button(shell, SWT.PUSH);
    b.setText("Button 1");
    b = new Button(shell, SWT.PUSH);

    b.setText("Button 2");

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 3");

    b = new Button(shell, SWT.PUSH);
    b.setText("Not shown");
    b.setVisible(false);
    RowData data = new RowData();
    data.exclude = true;
    b.setLayoutData(data);

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 200 high");
    data = new RowData();
    data.height = 200;
    b.setLayoutData(data);

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 200 wide");
    data = new RowData();
    data.width = 200;
    b.setLayoutData(data);

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
 private Text createAttributeText(final String attribute) {
   final Text t = new Text(this, SWT.BORDER);
   final Fields field = Fields.byField(attribute);
   if (field == null) {
     t.setEditable(true);
     t.setMessage(Messages.custom_field);
   } else {
     t.setEditable(false);
     t.setText(field.getName());
   }
   t.addKeyListener(
       new KeyAdapter() {
         @Override
         public void keyReleased(final KeyEvent e) {
           AssertionComposite.this.orCondition.updateFilter();
         };
       });
   final RowData rowData = new RowData();
   rowData.width = 132;
   t.setLayoutData(rowData);
   return t;
 }
Ejemplo n.º 6
0
  private void updatePreview() {
    Display display = mPreviewArea.getDisplay();

    for (Control c : mPreviewArea.getChildren()) {
      c.dispose();
    }

    if (!validatePage()) {
      return;
    }

    Map<String, Map<String, BufferedImage>> map = generateImages(true /*previewOnly*/);
    for (Entry<String, Map<String, BufferedImage>> categoryEntry : map.entrySet()) {
      String category = categoryEntry.getKey();
      if (category.length() > 0) {
        Label nameLabel = new Label(mPreviewArea, SWT.NONE);
        nameLabel.setText(String.format("%1$s:", category));
        RowData rowData = new RowData();
        nameLabel.setLayoutData(rowData);
        // Ensure these get their own rows
        rowData.width = PREVIEW_AREA_WIDTH;
      }

      Map<String, BufferedImage> images = categoryEntry.getValue();
      for (Entry<String, BufferedImage> entry : images.entrySet()) {
        BufferedImage image = entry.getValue();
        Image swtImage = SwtUtils.convertToSwt(display, image, true, -1);
        if (swtImage != null) {
          @SuppressWarnings("unused") // Has side effect
          ImageControl imageControl = new ImageControl(mPreviewArea, SWT.NONE, swtImage);
        }
      }
    }

    mPreviewArea.layout(true);
  }
Ejemplo n.º 7
0
 /**
  * When this view is resized, the StyledText SWT widget is resized accordingly. This method should
  * be called only as a response to the ControlListener.
  */
 public void controlResized(ControlEvent e) {
   Point parentSize = parentCompo.getSize();
   rowData.width = parentSize.x - 36;
   rowData.height = parentSize.y - 11;
   shellTextArea.setLayoutData(rowData);
 }
Ejemplo n.º 8
0
  public LoginPanel(Shell page, Composite parent) {
    super(parent, SWT.NONE);
    this.shell = page;

    setLayout(new GridLayout());
    // ´´½¨µÇ¼ÇøÓòµÄÓû§±êÇ© Óû§ÃûÊäÈë¿ò ÃÜÂë±êÇ© ÃÜÂëÊäÈë¿ò µÇ¼°´Å¥
    Composite panelTop = new Composite(this, SWT.NONE);
    panelTop.setBackgroundMode(SWT.INHERIT_DEFAULT);

    RowLayout layout = new RowLayout();
    layout.spacing = 40;
    layout.marginBottom = 0;
    layout.marginRight = 10;
    layout.marginTop = 0;
    layout.wrap = false;
    layout.pack = true;
    layout.center = true;

    panelTop.setLayout(layout);

    userText = new Text(panelTop, SWT.BORDER);
    RowData rd = new RowData();
    rd.width = 240;
    userText.setMessage("Õʺš¢Óû§Ãû»òÕßemail");
    userText.setLayoutData(rd);
    userText.setData(RWT.CUSTOM_VARIANT, "loginInput");
    userText.setFocus();

    passwordText = new Text(panelTop, SWT.BORDER | SWT.PASSWORD);
    rd = new RowData();
    rd.width = 220;
    passwordText.setMessage("ÊäÈëµÇ¼ÃÜÂë");
    passwordText.setLayoutData(rd);
    passwordText.setData(RWT.CUSTOM_VARIANT, "loginInput");

    okButton = new Button(panelTop, SWT.PUSH);
    okButton.setData(RWT.CUSTOM_VARIANT, "loginInput");
    rd = new RowData();
    rd.width = 50;
    rd.height = 50;
    okButton.setLayoutData(rd);
    page.setDefaultButton(okButton);
    okButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            buttonPressed();
          }
        });

    // ´´½¨±£´æÃÜÂë¹´Ñ¡¿òºÍ±£´æÓû§Ãû¹´Ñ¡¿ò
    Composite panelBottom = new Composite(this, SWT.NONE);

    layout = new RowLayout();
    layout.spacing = 4;
    layout.marginBottom = 0;
    layout.marginRight = 10;
    layout.marginTop = 0;
    layout.wrap = false;
    layout.pack = true;

    panelBottom.setLayout(layout);

    saveIdButton = new Button(panelBottom, SWT.CHECK);
    saveIdButton.setText("±£´æµÇ¼ÕʺÅ");
    saveIdButton.setData(RWT.CUSTOM_VARIANT, "loginCheck");

    savePassButton = new Button(panelBottom, SWT.CHECK);
    savePassButton.setText("±£´æµÇ¼ÃÜÂë");
    savePassButton.setData(RWT.CUSTOM_VARIANT, "loginCheck");

    // cookie save
    String uid = RWT.getSettingStore().getAttribute(COOKIE_UI_USERID);
    if (uid != null && uid.length() > 0) {
      userText.setText(uid);
      saveIdButton.setSelection(true);
    }
    // cookie save
    String psd = RWT.getSettingStore().getAttribute(COOKIE_UI_PASSWORD);
    if (psd != null && psd.length() > 0) {
      passwordText.setText(psd);
      savePassButton.setSelection(true);
    }

    panelTop.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
    panelBottom.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));

    createTooltips();
  }
Ejemplo n.º 9
0
  @Override
  public void testAddClickListener() {
    final ITableRidget ridget = getRidget();
    ridget.updateFromModel();
    final Grid control = getWidget();
    final RowData rowData = new RowData();
    rowData.width = 300;
    rowData.height = 300;
    control.setLayoutData(rowData);
    control.getColumn(0).setWidth(100);
    control.getColumn(1).setWidth(100);
    control.getShell().pack();
    control.getParent().update();

    try {
      ridget.addClickListener(null);
      fail();
    } catch (final RuntimeException npe) {
      ok();
    }

    final FTClickListener listener1 = new FTClickListener();
    ridget.addClickListener(listener1);

    final FTClickListener listener2 = new FTClickListener();
    ridget.addClickListener(listener2);
    ridget.addClickListener(listener2);

    final Event mdEvent = new Event();
    mdEvent.widget = control;
    mdEvent.type = SWT.MouseDown;
    mdEvent.button = 2;
    final GridItem row2 = control.getItem(2);
    mdEvent.item = row2;
    mdEvent.x = row2.getBounds(0).x + 1;
    mdEvent.y = row2.getBounds(0).y + 1;
    control.notifyListeners(SWT.MouseDown, mdEvent);

    assertEquals(0, listener1.getCount());
    assertEquals(0, listener2.getCount());

    mdEvent.type = SWT.MouseUp;
    control.notifyListeners(SWT.MouseUp, mdEvent);

    assertEquals(1, listener1.getCount());
    assertEquals(1, listener2.getCount());

    final ClickEvent event = listener2.getEvent();
    assertEquals(ridget, event.getSource());
    assertEquals(2, event.getButton());
    assertEquals(0, event.getColumnIndex());
    assertEquals(row2.getData(), event.getRow());

    ridget.removeClickListener(listener1);

    mdEvent.type = SWT.MouseDown;
    control.notifyListeners(SWT.MouseDown, mdEvent);
    mdEvent.type = SWT.MouseUp;
    control.notifyListeners(SWT.MouseUp, mdEvent);

    assertEquals(1, listener1.getCount());
  }