Esempio n. 1
0
  // @see
  // org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, org.gudy.azureus2.plugins.ui.tables.TableCell)
  public void cellPaint(GC gc, TableCellSWT cell) {
    VuzeActivitiesEntry entry = (VuzeActivitiesEntry) cell.getDataSource();

    if (entry instanceof VuzeActivitiesEntryBuddy) {

      VuzeActivitiesEntryBuddy entryBuddy = (VuzeActivitiesEntryBuddy) entry;
      VuzeBuddy buddy = entryBuddy.getBuddy();
      if (buddy instanceof VuzeBuddySWT) {
        VuzeBuddySWT buddySWT = (VuzeBuddySWT) buddy;
        Image imgAvatar = buddySWT.getAvatarImage();

        if (imgAvatar != null) {
          Rectangle cellBounds = cell.getBounds();
          Rectangle imgBounds = imgAvatar.getBounds();
          int dstWidth = cellBounds.width - 4;
          int dstHeight = dstWidth;

          gc.drawImage(
              imgAvatar,
              0,
              0,
              imgBounds.width,
              imgBounds.height,
              cellBounds.x + ((cellBounds.width - dstWidth) / 2),
              cellBounds.y + ((cellBounds.height - dstWidth) / 2),
              dstWidth,
              dstHeight);
        }
      }
    }
  }
Esempio n. 2
0
  public void select(VuzeBuddySWT buddy, boolean value, boolean appendSelection) {

    if (null != buddy) {
      for (Iterator iterator = avatarWidgets.iterator(); iterator.hasNext(); ) {
        AvatarWidget widget = (AvatarWidget) iterator.next();
        if (true == buddy.equals(widget.getVuzeBuddy())) {
          widget.setSelected(value);
          if (true == appendSelection) {
            break;
          }
        } else if (false == appendSelection) {
          if (true == value) {
            if (widget.isSelected() != false) {
              widget.setSelected(false);
              widget.refreshVisual();
            }
          } else {
            widget.setSelected(false);
            widget.refreshVisual();
          }
        }
      }
    }
    /*
     * De-select all buddies if the given 'buddy' is null
     */
    else {
      for (Iterator iterator = avatarWidgets.iterator(); iterator.hasNext(); ) {
        AvatarWidget widget = (AvatarWidget) iterator.next();
        if (true == widget.isSelected()) {
          widget.setSelected(false);
          widget.refreshVisual();
        }
      }
    }
  }