~motu-torrent/azureus/upstream-stable

« back to all changes in this revision

Viewing changes to org/gudy/azureus2/ui/swt/views/tableitems/mytorrents/UpItem.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
 
 * File    : UpItem.java
3
 
 * Created : 24 nov. 2003
4
 
 * By      : Olivier
5
 
 *
6
 
 * Copyright (C) 2004, 2005, 2006 Aelitis SAS, All rights Reserved
7
 
 *
8
 
 * This program is free software; you can redistribute it and/or modify
9
 
 * it under the terms of the GNU General Public License as published by
10
 
 * the Free Software Foundation; either version 2 of the License.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details ( see the LICENSE file ).
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 
 *
21
 
 * AELITIS, SAS au capital de 46,603.30 euros,
22
 
 * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
23
 
 */
24
 
 
25
 
package org.gudy.azureus2.ui.swt.views.tableitems.mytorrents;
26
 
 
27
 
import org.gudy.azureus2.core3.util.DisplayFormatters;
28
 
import org.gudy.azureus2.core3.download.DownloadManager;
29
 
import org.gudy.azureus2.plugins.ui.tables.*;
30
 
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;
31
 
 
32
 
 
33
 
/** bytes uploaded column
34
 
 *
35
 
 * @author Olivier
36
 
 * @author TuxPaper (2004/Apr/17: modified to TableCellAdapter)
37
 
 */
38
 
public class UpItem
39
 
       extends CoreTableColumn 
40
 
       implements TableCellRefreshListener
41
 
{
42
 
  /** Default Constructor */
43
 
  public UpItem(String sTableID) {
44
 
    super("up", ALIGN_TRAIL, POSITION_INVISIBLE, 70, sTableID);
45
 
    setRefreshInterval(INTERVAL_LIVE);
46
 
 
47
 
    if (sTableID.equals(TableManager.TABLE_MYTORRENTS_COMPLETE))
48
 
      setPosition(POSITION_LAST);
49
 
    else
50
 
      setPosition(POSITION_INVISIBLE);
51
 
  }
52
 
 
53
 
  public void refresh(TableCell cell) {
54
 
    DownloadManager dm = (DownloadManager)cell.getDataSource();
55
 
    long value = (dm == null) ? 0 : dm.getStats().getTotalDataBytesSent();
56
 
 
57
 
    if (!cell.setSortValue(value) && cell.isValid())
58
 
      return;
59
 
 
60
 
    cell.setText(DisplayFormatters.formatByteCountToKiBEtc(value));
61
 
  }
62
 
}
 
1
/*
 
2
 * File    : UpItem.java
 
3
 * Created : 24 nov. 2003
 
4
 * By      : Olivier
 
5
 *
 
6
 * Copyright (C) 2004, 2005, 2006 Aelitis SAS, All rights Reserved
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details ( see the LICENSE file ).
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
 *
 
21
 * AELITIS, SAS au capital de 46,603.30 euros,
 
22
 * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
 
23
 */
 
24
 
 
25
package org.gudy.azureus2.ui.swt.views.tableitems.mytorrents;
 
26
 
 
27
import org.gudy.azureus2.core3.util.DisplayFormatters;
 
28
import org.gudy.azureus2.core3.download.DownloadManager;
 
29
import org.gudy.azureus2.plugins.ui.tables.*;
 
30
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;
 
31
 
 
32
 
 
33
/** bytes uploaded column
 
34
 *
 
35
 * @author Olivier
 
36
 * @author TuxPaper (2004/Apr/17: modified to TableCellAdapter)
 
37
 */
 
38
public class UpItem
 
39
       extends CoreTableColumn 
 
40
       implements TableCellRefreshListener
 
41
{
 
42
  /** Default Constructor */
 
43
  public UpItem(String sTableID) {
 
44
    super("up", ALIGN_TRAIL, POSITION_INVISIBLE, 70, sTableID);
 
45
    setRefreshInterval(INTERVAL_LIVE);
 
46
    setMinWidthAuto(true);
 
47
 
 
48
    if (sTableID.equals(TableManager.TABLE_MYTORRENTS_COMPLETE))
 
49
      setPosition(POSITION_LAST);
 
50
    else
 
51
      setPosition(POSITION_INVISIBLE);
 
52
  }
 
53
 
 
54
  public void refresh(TableCell cell) {
 
55
    DownloadManager dm = (DownloadManager)cell.getDataSource();
 
56
    long value = (dm == null) ? 0 : dm.getStats().getTotalDataBytesSent();
 
57
 
 
58
    if (!cell.setSortValue(value) && cell.isValid())
 
59
      return;
 
60
 
 
61
    cell.setText(DisplayFormatters.formatByteCountToKiBEtc(value));
 
62
  }
 
63
}