Example #1
0
 /** {@inheritDoc} */
 @Override
 public void setBackground(int columnIndex, Color color) {
   if (columnIndex == Integer.MAX_VALUE) {
     item.setHeaderBackground(color);
   } else {
     item.setBackground(columnIndex, color);
   }
 }
  /** Updates this cell - delayed. */
  protected void updateCellValuesDelayed() {
    /*
     * Check if the cell has been disposed
     */
    if (getColumn() == null) return;
    // LogUtils.debug(GridBindingCellInformationImpl.this, "");
    final IGridBinding grid = getGrid();
    final GridColumn gridColumn = getColumn().getGridColumn();
    final GridItem gridItem = getRow().getGridItem();

    /*
     * Update the cell
     */
    final IUIAttribute attr = getLabelUIAttribute();
    final IObservableValue currentValue = attr.getCurrentValue();
    if (currentValue.isDisposed()) return;
    final IObservableValue v = getObjectValue();

    final String text = (String) currentValue.getValue();
    final Color foreground = attr.getForeground();
    final Color background = attr.getBackground();
    final Image image = attr.getImage();
    final Font font = attr.getFont();
    final String tooltip = attr.getTooltip();
    // TODO: the rest: cursor, enabled, style range
    if (gridItem == null) {
      /*
       * Column header:
       */
      gridColumn.setText(text == null ? "" : text);
      gridColumn.setImage(image);
      // TODO gridColumn.set
      /*
       * The changes in the column name and image only take effect when the table is redrawn
       */
      grid.getGrid().redraw();
    } else if (gridColumn == null) {
      /*
       * Row Header
       */
      gridItem.setHeaderText(text == null ? "" : text);
      gridItem.setHeaderImage(image);
      gridItem.setHeaderForeground(foreground);
      gridItem.setHeaderBackground(background);
    } else {
      /*
       * Normal cell
       */
      final int index = grid.getGrid().indexOf(gridColumn);
      Assert.isTrue(index != -1);

      // gridItem.setChecked(index, v.getValue() == Boolean.TRUE);
      // gridItem.setText(index, null);
      // gridItem.setImage(index, null);
      // gridItem.setFont(index, null);

      gridItem.setText(index, text == null ? "" : text);
      gridItem.setImage(index, image);
      gridItem.setFont(index, font);
      gridItem.setForeground(index, foreground);
      gridItem.setBackground(index, background);
      gridItem.setToolTipText(index, tooltip);
    }
  }