FileDocCategorySizeDatePackage
StatsView.javaAPI DocAzureus 3.0.3.47579Thu Jun 28 16:08:24 BST 2007org.gudy.azureus2.ui.swt.views.stats

StatsView

public class StatsView extends org.gudy.azureus2.ui.swt.views.AbstractIView

Fields Summary
org.gudy.azureus2.core3.global.GlobalManager
manager
com.aelitis.azureus.core.AzureusCore
core
org.eclipse.swt.widgets.TabFolder
folder
org.eclipse.swt.widgets.TabItem
itemActivity
org.eclipse.swt.widgets.TabItem
itemStats
org.eclipse.swt.widgets.TabItem
itemCache
org.eclipse.swt.widgets.TabItem[]
itemDHTs
org.eclipse.swt.widgets.TabItem
itemVivaldi
ActivityView
viewActivity
TransferStatsView
viewStats
CacheView
viewCache
DHTView[]
viewDHTs
org.gudy.azureus2.ui.swt.views.IView
viewVivaldi
UpdateThread
updateThread
Constructors Summary
public StatsView(org.gudy.azureus2.core3.global.GlobalManager manager, com.aelitis.azureus.core.AzureusCore core)

   this.manager = manager;
   this.core = core;
  
Methods Summary
public voiddelete()

    updateThread.stopIt();

    //Don't ask me why, but without this an exception is thrown further
    // (in folder.dispose() )
    //TODO : Investigate to see if it's a platform (OSX-Carbon) BUG, and report to SWT team.
    if(Constants.isOSX) {
      if(folder != null && !folder.isDisposed()) {
        TabItem[] items = folder.getItems();
        for(int i=0 ; i < items.length ; i++) {
          if (!items[i].isDisposed())
            items[i].dispose();
        }
      }
    }
    
    viewActivity.delete();
    viewStats.delete();
    viewCache.delete();
    
    for (int i=0;i<viewDHTs.length;i++){
    	viewDHTs[i].delete();
    }

    if(! folder.isDisposed()) {
      Utils.disposeComposite(folder);
    }
  
public org.eclipse.swt.widgets.CompositegetComposite()

    return folder;
  
public java.lang.StringgetFullTitle()

    return MessageText.getString("Stats.title.full"); //$NON-NLS-1$
  
public voidinitialize(org.eclipse.swt.widgets.Composite composite)

    folder = new TabFolder(composite, SWT.LEFT);
    folder.setBackground(Colors.background);
    
    List	dhts = new ArrayList();

    dhts.add( new DHTView( DHTView.DHT_TYPE_MAIN ));  

    if ( NetworkAdmin.getSingleton().hasIPV6Potential()){
  
    	dhts.add(  new DHTView( DHTView.DHT_TYPE_MAIN_V6 ));
    }
    
    if( Constants.isCVSVersion()){
    	
       	dhts.add(  new DHTView( DHTView.DHT_TYPE_CVS ));
    }
    
    viewDHTs = new DHTView[dhts.size()];
    
    dhts.toArray( viewDHTs );
    
    itemActivity = new TabItem(folder, SWT.NULL);
    itemStats = new TabItem(folder, SWT.NULL);
    itemCache  = new TabItem(folder, SWT.NULL);
    
    itemDHTs = new TabItem[viewDHTs.length];
    
    for (int i=0;i<itemDHTs.length;i++){
    	itemDHTs[i] = new TabItem(folder, SWT.NULL);
    }
  
    itemVivaldi = new TabItem(folder,SWT.NULL);

    viewActivity = new ActivityView(manager);
    viewStats = new TransferStatsView(manager,core);
    viewCache = new CacheView();
    
 
    
    
    viewVivaldi = new VivaldiView();
    
    Messages.setLanguageText(itemActivity, viewActivity.getData());
    Messages.setLanguageText(itemStats, viewStats.getData());
    Messages.setLanguageText(itemCache, viewCache.getData());
    
    for (int i=0;i<viewDHTs.length;i++){
    	Messages.setLanguageText(itemDHTs[i], viewDHTs[i].getData());
    }
       
    Messages.setLanguageText(itemVivaldi, viewVivaldi.getData());
    
    TabItem items[] = {itemActivity};
    folder.setSelection(items);
    
    viewActivity.initialize(folder);
    itemActivity.setControl(viewActivity.getComposite());
    
    viewStats.initialize(folder);
    itemStats.setControl(viewStats.getComposite());
    
    viewCache.initialize(folder);
    itemCache.setControl(viewCache.getComposite());
    
    for (int i=0;i<viewDHTs.length;i++){
    	viewDHTs[i].initialize(folder);
    	itemDHTs[i].setControl(viewDHTs[i].getComposite());
    }
    
    viewVivaldi.initialize(folder);
    itemVivaldi.setControl(viewVivaldi.getComposite());
    
    folder.addSelectionListener(new SelectionListener() {
      public void widgetSelected(SelectionEvent e) {
        refresh();
      }
      public void widgetDefaultSelected(SelectionEvent e) {
      }
    });
    
    
    refresh();
    viewActivity.getComposite().layout(true);
    viewVivaldi.getComposite().layout(true);
    
    updateThread = new UpdateThread(); 
    updateThread.setDaemon(true);
    updateThread.start();
  
public voidrefresh()

    if(getComposite() == null || getComposite().isDisposed())
      return;

    try {
      int index = folder.getSelectionIndex();
      
      if( index == 0 ) {
        if (viewActivity != null && !itemActivity.isDisposed())   viewActivity.refresh();
        return;
      }
      
      if( index == 1 ) {
        if (viewStats != null && !itemStats.isDisposed())  viewStats.refresh();
        return;
      }
      
      if( index == 2 ) {
        if (viewCache != null && !itemCache.isDisposed())  viewCache.refresh();
        return;
      }
      
      if ( index-3 < viewDHTs.length ){
    	  if ( !itemDHTs[index-3].isDisposed()){
    		  viewDHTs[index-3].refresh();
    	  }
    	  return;
      }
      
      if (viewVivaldi != null && !itemVivaldi.isDisposed())  viewVivaldi.refresh();
  
    } catch (Exception e) {
    	Debug.printStackTrace( e );
    }
  
public voidshowDHT()

	  folder.setSelection( new TabItem[]{ itemDHTs[0] });
  
public voidshowTransfers()

	  folder.setSelection( new TabItem[]{ itemStats });