void setLayout() {
   String direction = getObjectAdapter().getDirection();
   if (direction != null && direction.equals(AttributeNames.HORIZONTAL))
     buttonsPanel.setLayout(new GridLayout(1, 0));
   else if (direction != null && direction.equals(AttributeNames.VERTICAL))
     buttonsPanel.setLayout(new GridLayout(0, 1));
   else {
     int numCols = getObjectAdapter().getUnboundButtonsRowSize();
     buttonsPanel.setLayout(new GridLayout(0, numCols));
   }
 }
Example #2
0
  public void addToParent(VirtualContainer theParent) {
    if (theParent == null) {
      throw new IllegalArgumentException("Argument cannot be null");
    } else {
      if (!(theParent instanceof SWTContainer)) {
        throw new IllegalArgumentException("Argument must be of SWT type");
      } else {
        if (theParent.getPhysicalComponent() == null) {
          throw new IllegalArgumentException("Cannot add to an uninitialized parent");
        }
      }
    }

    component = new Tree((Composite) theParent.getPhysicalComponent(), SWT.BORDER);

    init();

    if (model != null) {
      generateFromModel(model.getRoot(), getTree());
    }
    getComponent().setSize(width, height);
  }
  void rebuildButtons() {
    stringToObjects = new Hashtable();
    stringToButtons = new Hashtable();
    buttonsPanel.removeAll();
    // buttonGroup = new ButtonGroup();
    int newSize = getSize();
    //  	for (int i = 0; i < getSize(); i ++) {
    for (int i = 0; i < newSize; i++) {

      Object item = getElementAt(i);
      String itemString = item.toString();
      // AbstractButton button = new JRadioButton(itemString);
      VirtualButton button = createButton(itemString);
      setColors(button);
      // VirtualButton button = createButton (itemString);
      button.setActionCommand(itemString);
      stringToObjects.put(itemString, item);
      stringToButtons.put(itemString, button);
      button.addActionListener(this);
      // buttonGroup.add(radioButton);
      buttonsPanel.add(button);

      doAdditionalProcessing(button);
    }
    // force the first item to be selected
    lastSelectedItem = null;

    // int numCols = getObjectAdapter().getUnboundButtonsRowSize();
    setLayout();
    // not sure we need this as color is set before this
    // 	setColors(buttonsPanel);
    /*
    buttonsPanel.setLayout(new GridLayout (0, numCols));
    oldSize = getSize();
    */
    oldSize = newSize;
  }
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   return (Component) buttonsPanel.getPhysicalComponent();
 }