~motu-torrent/azureus/upstream-stable

« back to all changes in this revision

Viewing changes to org/gudy/azureus2/ui/swt/views/tableitems/files/PieceCountItem.java

  • Committer: John Dong
  • Date: 2007-10-22 04:54:13 UTC
  • Revision ID: john.dong@gmail.com-20071022045413-3ovb11u82rrcokxx
Commit 3.0.3.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2004, 2005, 2006 Aelitis SAS, All rights Reserved
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details ( see the LICENSE file ).
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program; if not, write to the Free Software
15
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
 *
17
 
 * AELITIS, SAS au capital de 46,603.30 euros,
18
 
 * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
19
 
 */
20
 
 
21
 
package org.gudy.azureus2.ui.swt.views.tableitems.files;
22
 
 
23
 
import org.gudy.azureus2.core3.disk.DiskManagerFileInfo;
24
 
import org.gudy.azureus2.plugins.ui.tables.*;
25
 
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;
26
 
 
27
 
/**
28
 
 *
29
 
 * @author TuxPaper
30
 
 * @since 2.0.8.5
31
 
 */
32
 
public class PieceCountItem
33
 
       extends CoreTableColumn 
34
 
       implements TableCellRefreshListener
35
 
{
36
 
  /** Default Constructor */
37
 
  public PieceCountItem() {
38
 
    super("numberofpieces", ALIGN_TRAIL, POSITION_LAST, 75, TableManager.TABLE_TORRENT_FILES);
39
 
  }
40
 
 
41
 
  public void refresh(TableCell cell) {
42
 
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo)cell.getDataSource();
43
 
    long value = (fileInfo == null) ? 0 : fileInfo.getNbPieces();
44
 
 
45
 
    if( !cell.setSortValue( value ) && cell.isValid() ) {
46
 
      return;
47
 
    }
48
 
    
49
 
        // < 0 -> unknown skeleton value 
50
 
 
51
 
    cell.setText( value<0?"":(""+value));
52
 
  }
53
 
}
 
1
/*
 
2
 * Copyright (C) 2004, 2005, 2006 Aelitis SAS, All rights Reserved
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details ( see the LICENSE file ).
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program; if not, write to the Free Software
 
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 *
 
17
 * AELITIS, SAS au capital de 46,603.30 euros,
 
18
 * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
 
19
 */
 
20
 
 
21
package org.gudy.azureus2.ui.swt.views.tableitems.files;
 
22
 
 
23
import org.gudy.azureus2.core3.disk.DiskManagerFileInfo;
 
24
import org.gudy.azureus2.plugins.ui.tables.*;
 
25
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;
 
26
 
 
27
/**
 
28
 *
 
29
 * @author TuxPaper
 
30
 * @since 2.0.8.5
 
31
 */
 
32
public class PieceCountItem
 
33
       extends CoreTableColumn 
 
34
       implements TableCellRefreshListener
 
35
{
 
36
  /** Default Constructor */
 
37
  public PieceCountItem() {
 
38
    super("numberofpieces", ALIGN_TRAIL, POSITION_LAST, 75, TableManager.TABLE_TORRENT_FILES);
 
39
    setMinWidthAuto(true);
 
40
  }
 
41
 
 
42
  public void refresh(TableCell cell) {
 
43
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo)cell.getDataSource();
 
44
    long value = (fileInfo == null) ? 0 : fileInfo.getNbPieces();
 
45
 
 
46
    if( !cell.setSortValue( value ) && cell.isValid() ) {
 
47
      return;
 
48
    }
 
49
    
 
50
        // < 0 -> unknown skeleton value 
 
51
 
 
52
    cell.setText( value<0?"":(""+value));
 
53
  }
 
54
}