Package com.aelitis.azureus.ui.common.table

Examples of com.aelitis.azureus.ui.common.table.TableColumnCore


     
      TableColumnCore[]  cols = cols_sets[i];
     
      for (int j=0;j<cols.length;j++){
       
        TableColumnCore  col = cols[j];
       
        String id = col.getName();
     
        if (usable_cols.containsKey(id)) {
         
          continue;
        }
       
        FakeTableCell fakeTableCell = null;
        try {
          fakeTableCell = new FakeTableCell(col);
          fakeTableCell.setOrentation(SWT.LEFT);
          fakeTableCell.setWrapText(false);
          fakeTableCell.setDataSource(download_manager);
          col.invokeCellAddedListeners(fakeTableCell);
          // One refresh to see if it throws up
          fakeTableCell.refresh();
          usable_cols.put(id, fakeTableCell);
        } catch (Throwable t) {
          //System.out.println("not usable col: " + id + " - " + Debug.getCompressedStackTrace());
          try {
            if (fakeTableCell != null) {
              fakeTableCell.dispose();
            }
          } catch (Throwable t2) {
            //ignore;
          }
        }
      }
    }
   
    Collection<FakeTableCell> values = usable_cols.values();
   
    cells = new FakeTableCell[values.size()];
   
    values.toArray( cells );
   
    Arrays.sort(
        cells,
        new Comparator<FakeTableCell>()
        {
          public int compare(FakeTableCell o1, FakeTableCell o2) {
            TableColumnCore  c1 = (TableColumnCore) o1.getTableColumn();
            TableColumnCore  c2 = (TableColumnCore) o2.getTableColumn();

            String key1 = MessageText.getString(c1.getTitleLanguageKey());
            String key2 = MessageText.getString(c2.getTitleLanguageKey());
           
            return key1.compareToIgnoreCase(key2);
          }
        });
           
View Full Code Here


      DownloadManager[] dms, int iNewPos) {
    if (dms == null || dms.length == 0) {
      return;
    }
   
    TableColumnCore sortColumn = tv == null ? null : tv.getSortColumn();
    boolean isSortAscending = sortColumn == null ? true
        : sortColumn.isSortAscending();

    for (int i = 0; i < dms.length; i++) {
      DownloadManager dm = dms[i];
      int iOldPos = dm.getPosition();
     
      dm.getGlobalManager().moveTo(dm, iNewPos);
      if (isSortAscending) {
        if (iOldPos > iNewPos)
          iNewPos++;
      } else {
        if (iOldPos < iNewPos)
          iNewPos--;
      }
    }

    if (tv != null) {
      boolean bForceSort = sortColumn.getName().equals("#");
      tv.columnInvalidate("#");
      tv.refreshTable(bForceSort);
    }
  }
View Full Code Here

    return noneVisible;
  }

  private static void setVisibility(Map mapTCs, String[] defaultVisibleOrder) {
    for (Iterator iter = mapTCs.values().iterator(); iter.hasNext();) {
      TableColumnCore tc = (TableColumnCore) iter.next();
      Long force_visible = (Long)tc.getUserData( TableColumn.UD_FORCE_VISIBLE );
      if ( force_visible == null || force_visible==0 ){
     
        tc.setVisible(false);
      }
    }

    for (int i = 0; i < defaultVisibleOrder.length; i++) {
      String id = defaultVisibleOrder[i];
      TableColumnCore tc = (TableColumnCore) mapTCs.get(id);
      if (tc != null) {
        tc.setVisible(true);
        tc.setPositionNoShift(i);
      }
    }
  }
View Full Code Here

        try {
          Constructor constructor = info.cla.getDeclaredConstructor(new Class[] {
            String.class
          });
          TableColumnCore column = (TableColumnCore) constructor.newInstance(new Object[] {
            tableID
          });
          return column;
        } catch (Exception e) {
          Debug.out(e);
View Full Code Here

    initialize(ALIGN_LEAD | ALIGN_TOP, POSITION_INVISIBLE, 175, INTERVAL_INVALID_ONLY);
  }

  // @see org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell)
  public void refresh(TableCell cell) {
    TableColumnCore column = (TableColumnCore) cell.getDataSource();
    String key = column.getTitleLanguageKey();
    if (!cell.setSortValue(column.getPosition()) && cell.isValid()) {
      return;
    }
    String s = "";
    try {
      s = (((TableCellCore) cell).getTableRowCore().getIndex() + 1) + ". ";
    } catch (Throwable e) {
    }
    s += MessageText.getString(key, column.getName());
    //s = column.getPosition() + "] " + s;
    cell.setText(s);
  }
View Full Code Here

    initialize(ALIGN_LEAD | ALIGN_TOP, POSITION_INVISIBLE, 150, INTERVAL_INVALID_ONLY);
  }

  // @see org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell)
  public void refresh(TableCell cell) {
    TableColumnCore column = (TableColumnCore) cell.getDataSource();
    String key = column.getTitleLanguageKey();
    if (!cell.setSortValue(key) && cell.isValid()) {
      return;
    }
    cell.setText(MessageText.getString(key + ".info", ""));
  }
View Full Code Here

    setType(TYPE_GRAPHIC);
  }

  // @see org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell)
  public void refresh(TableCell cell) {
    TableColumnCore column = (TableColumnCore) cell.getDataSource();
    String key = column.getTitleLanguageKey();
    cell.setSortValue(MessageText.getString(key, column.getName()));
  }
View Full Code Here

    cell.setSortValue(MessageText.getString(key, column.getName()));
  }

  // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, org.gudy.azureus2.ui.swt.views.table.TableCellSWT)
  public void cellPaint(GC gc, TableCellSWT cell) {
    TableColumnCore column = (TableColumnCore) cell.getDataSource();
    String key = column.getTitleLanguageKey();
    Rectangle bounds = cell.getBounds();
    if (bounds == null || bounds.isEmpty()) {
      return;
    }
   
    Font fontDefault = gc.getFont();
    if (fontHeader == null) {
      FontData[] fontData = gc.getFont().getFontData();
      fontData[0].setStyle(SWT.BOLD);
      fontData[0].setHeight(fontData[0].getHeight() + 1);
      fontHeader = new Font(gc.getDevice(), fontData);
    }

    gc.setFont(fontHeader);

    bounds.y += 3;
    bounds.x += 7;
    bounds.width -= 14;
    String name = MessageText.getString(key, column.getName());
    GCStringPrinter sp = new GCStringPrinter(gc, name, bounds, GCStringPrinter.FLAG_SKIPCLIP, SWT.TOP);
    sp.printString();

    Point titleSize = sp.getCalculatedSize();

    gc.setFont(fontDefault);
    String info = MessageText.getString(key + ".info", "");
    Rectangle infoBounds = new Rectangle(bounds.x + 10, bounds.y + titleSize.y
        + 5, bounds.width - 15, bounds.height - 20);
    GCStringPrinter.printString(gc, info, infoBounds, true, false);

    TableColumnInfo columnInfo = (TableColumnInfo) cell.getTableRow().getData(
        "columninfo");
    if (columnInfo == null) {
      final TableColumnManager tcm = TableColumnManager.getInstance();
      columnInfo = tcm.getColumnInfo(column.getForDataSourceType(),
          column.getTableID(), column.getName());
      cell.getTableRowCore().setData("columninfo", columnInfo);
    }
    Rectangle profBounds = new Rectangle(bounds.width - 100, bounds.y - 2, 100, 20);
    byte proficiency = columnInfo.getProficiency();
    if (proficiency > 0 && proficiency < profText.length) {
View Full Code Here

        Rectangle hitArea = (Rectangle) data;
        if (hitArea.contains(event.x, event.y)) {
          TableViewColumnSetup tv = (TableViewColumnSetup) ((TableCellCore) event.cell).getTableRowCore().getView();
          Object dataSource = event.cell.getDataSource();
          if (dataSource instanceof TableColumnCore) {
            TableColumnCore column = (TableColumnCore) dataSource;
            tv.chooseColumn(column);
          }
        }
      }
    } else if (event.eventType == TableRowMouseEvent.EVENT_MOUSEMOVE) {
View Full Code Here

   */
  public void addColumns(TableColumnCore[] itemsToAdd) {
    try {
      items_mon.enter();
      for (int i = 0; i < itemsToAdd.length; i++) {
        TableColumnCore item = itemsToAdd[i];
        if ( item.isRemoved()){
          continue;
        }
        String name = item.getName();
        String sTableID = item.getTableID();
        Map mTypes = (Map) items.get(sTableID);
        if (mTypes == null) {
          // LinkedHashMap to preserve order
          mTypes = new LinkedHashMap();
          items.put(sTableID, mTypes);
        }
        if (!mTypes.containsKey(name)) {
          mTypes.put(name, item);
          Map mapColumnConfig = getTableConfigMap(sTableID);
          item.loadSettings(mapColumnConfig);
        }
      }
      for (int i = 0; i < itemsToAdd.length; i++) {
        TableColumnCore item = itemsToAdd[i];
       
        if (!item.isRemoved() && !item.getColumnAdded()) {
          item.setColumnAdded();
        }
      }
    } catch (Exception e) {
      System.out.println("Error while adding Table Column Extension");
      Debug.printStackTrace(e);
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.ui.common.table.TableColumnCore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.