Ejemplo n.º 1
0
  /**
   * Constructs a new instance of this class given its parent and a style value describing its
   * behavior and appearance.
   *
   * <p>The style value is either one of the style constants defined in class <code>SWT</code> which
   * is applicable to instances of this class, or must be built by <em>bitwise OR</em>'ing together
   * (that is, using the <code>int</code> "|" operator) two or more of those <code>SWT</code> style
   * constants. The class description lists the style constants that are applicable to the class.
   * Style bits are also inherited from superclasses.
   *
   * <p>To ensure that the color of corners is equal to one of the underlying control invoke the
   * parent composites {@link Composite#setBackgroundMode(int)} with {@link SWT#INHERIT_DEFAULT} or
   * {@link SWT#INHERIT_DEFAULT}
   *
   * @param parent a composite control which will be the parent of the new instance (cannot be null)
   * @param style the style of control to construct
   * @exception IllegalArgumentException
   *     <ul>
   *       <li>ERROR_NULL_ARGUMENT - if the parent is null
   *     </ul>
   *
   * @exception SWTException
   *     <ul>
   *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
   *       <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
   *     </ul>
   *
   * @see SWT
   * @see Widget#checkSubclass
   * @see Widget#getStyle
   */
  public PGroup(Composite parent, int style) {
    super(parent, checkStyle(style));
    setStrategy(new RectangleGroupStrategy());
    setToggleRenderer(new ChevronsToggleRenderer());
    setToolItemRenderer(new SimpleToolItemRenderer());

    initialFont =
        new Font(
            getDisplay(),
            getFont().getFontData()[0].getName(),
            getFont().getFontData()[0].getHeight(),
            SWT.BOLD);
    super.setFont(initialFont);

    strategy.initialize(this);

    initListeners();
  }
Ejemplo n.º 2
0
  /** Create contents of the shell. */
  protected void createContents() {
    setText("List of values");
    setSize(500, 401);

    CTabFolder tabFolder = new CTabFolder(this, SWT.BORDER);
    tabFolder.setSimple(false);
    tabFolder.setSingle(true);
    tabFolder.setBounds(10, 10, 472, 351);
    tabFolder.setSelectionBackground(
        Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));

    CTabItem tbtmPatient = new CTabItem(tabFolder, SWT.NONE);
    tbtmPatient.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.BOLD));
    tbtmPatient.setText("Medicine");

    Composite composite = new Composite(tabFolder, SWT.NONE);
    tbtmPatient.setControl(composite);

    PGroup grpSearch = new PGroup(composite, SWT.SMOOTH);
    grpSearch.setBounds(10, 10, 446, 46);
    grpSearch.setStrategy(new RectangleGroupStrategy());
    grpSearch.setToggleRenderer(new ChevronsToggleRenderer());
    grpSearch.setText("Search");

    txtID = new Text(grpSearch, SWT.BORDER);
    txtID.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
              search();
            }
          }
        });
    txtID.setBounds(27, 24, 117, 19);

    txtName = new Text(grpSearch, SWT.BORDER);
    txtName.setBounds(194, 24, 168, 19);
    txtName.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
              search();
            }
          }
        });

    Label lblId = new Label(grpSearch, SWT.NONE);
    lblId.setAlignment(SWT.RIGHT);
    lblId.setBounds(10, 27, 11, 13);
    lblId.setText("ID");

    Label lblName = new Label(grpSearch, SWT.NONE);
    lblName.setText("Name");
    lblName.setAlignment(SWT.RIGHT);
    lblName.setBounds(161, 27, 27, 13);

    Button btnSearch = new Button(grpSearch, SWT.NONE);
    btnSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            search();
          }
        });
    btnSearch.setBounds(368, 23, 68, 21);
    btnSearch.setText("Search");

    tblMedicine = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    tblMedicine.setBounds(10, 62, 446, 226);
    tblMedicine.setHeaderVisible(true);
    tblMedicine.setLinesVisible(true);

    TableColumn tblcolId = new TableColumn(tblMedicine, SWT.NONE);
    tblcolId.setWidth(160);
    tblcolId.setText("ID");

    TableColumn tblcolName = new TableColumn(tblMedicine, SWT.NONE);
    tblcolName.setWidth(280);
    tblcolName.setText("Name");

    Button btnCancel = new Button(composite, SWT.NONE);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });
    btnCancel.setBounds(388, 294, 68, 23);
    btnCancel.setText("Cancel");

    Button btnOk = new Button(composite, SWT.NONE);
    btnOk.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });
    btnOk.setBounds(314, 294, 68, 23);
    btnOk.setText("OK");
  }