FileDocCategorySizeDatePackage
MyTorrentsSuperView.javaAPI DocAzureus 3.0.3.413952Tue Aug 14 22:27:10 BST 2007org.gudy.azureus2.ui.swt.views

MyTorrentsSuperView

public class MyTorrentsSuperView extends AbstractIView implements org.gudy.azureus2.ui.swt.debug.ObfusticateImage, IViewExtension
author
MjrTom 2005/Dec/08: Avg Avail Item

Fields Summary
private static int
SASH_WIDTH
private com.aelitis.azureus.core.AzureusCore
azureus_core
private MyTorrentsView
torrentview
private MyTorrentsView
seedingview
private Composite
form
static final com.aelitis.azureus.ui.common.table.TableColumnCore[]
tableIncompleteItems
static final com.aelitis.azureus.ui.common.table.TableColumnCore[]
tableCompleteItems
Constructors Summary
public MyTorrentsSuperView(com.aelitis.azureus.core.AzureusCore _azureus_core)


   	 
  	azureus_core		= _azureus_core;

    TableColumnManager tcExtensions = TableColumnManager.getInstance();
    for (int i = 0; i < tableCompleteItems.length; i++) {
      tcExtensions.addColumn(tableCompleteItems[i]);
    }
    for (int i = 0; i < tableIncompleteItems.length; i++) {
      tcExtensions.addColumn(tableIncompleteItems[i]);
    }
  
Methods Summary
public voiddelete()

    if (torrentview != null)
      torrentview.delete();
    if (seedingview != null)
      seedingview.delete();
    super.delete();
  
public voidgenerateDiagnostics(org.gudy.azureus2.core3.util.IndentWriter writer)

	  super.generateDiagnostics( writer );

	  try{
		  writer.indent();
	  
		  writer.println( "Downloading" );
		  
		  writer.indent();

		  torrentview.generateDiagnostics( writer );
	  
	  }finally{
		  
		  writer.exdent();
		  
		  writer.exdent();
	  }
	  
	  try{
		  writer.indent();
	  
		  writer.println( "Seeding" );
		  
		  writer.indent();

		  seedingview.generateDiagnostics( writer );
	  
	  }finally{
		  
		  writer.exdent();

		  writer.exdent();
	  }
  
public CompositegetComposite()

    return form;
  
private MyTorrentsViewgetCurrentView()

    // wrap in a try, since the controls may be disposed
    try {
      if (torrentview.isTableFocus())
        return torrentview;
      else if (seedingview.isTableFocus())
        return seedingview;
    } catch (Exception ignore) {/*ignore*/}

    return null;
  
public java.lang.StringgetFullTitle()

    return MessageText.getString("MyTorrentsView.mytorrents");
  
public MenugetPrivateMenu()

		return null;
	
public org.gudy.azureus2.core3.download.DownloadManager[]getSelectedDownloads()

	  MyTorrentsView currentView = getCurrentView();
	  if (currentView == null) {return null;}
	  return currentView.getSelectedDownloads();
  
public voidinitialize(Composite parent)

    if (form != null) {
      return;
    }
    
    form = new Composite(parent, SWT.NONE);
		FormLayout flayout = new FormLayout();
		flayout.marginHeight = 0;
		flayout.marginWidth = 0;
		form.setLayout(flayout);
		GridData gridData;
		gridData = new GridData(GridData.FILL_BOTH);
		form.setLayoutData(gridData);
    
		GridLayout layout;

    
    final Composite child1 = new Composite(form,SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    child1.setLayout(layout);
    torrentview = new MyTorrentsView(azureus_core, false, tableIncompleteItems);
    torrentview.initialize(child1);

    final Sash sash = new Sash(form, SWT.HORIZONTAL);

    final Composite child2 = new Composite(form,SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    child2.setLayout(layout);
    seedingview = new MyTorrentsView(azureus_core, true, tableCompleteItems);
    seedingview.initialize(child2);

    FormData formData;

		// FormData for table child1
		formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.top = new FormAttachment(0, 0);
		child1.setLayoutData(formData);
		final FormData child1Data = formData;
    
		// sash
		formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.top = new FormAttachment(child1);
		formData.height = SASH_WIDTH;
		sash.setLayoutData(formData);

    // child2
		formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.bottom = new FormAttachment(100, 0);
		formData.top = new FormAttachment(sash);
    // More precision, times by 100
    int weight = (int) (COConfigurationManager.getFloatParameter("MyTorrents.SplitAt"));
		if (weight > 10000) {
			weight = 10000;
		} else if (weight < 100) {
			weight *= 100;
		}
		// Min/max of 5%/95%
		if (weight < 500) {
			weight = 500;
		} else if (weight > 9000) {
			weight = 9000;
		}
		
		// height will be set on first resize call
		sash.setData("PCT", new Double((float)weight / 10000));
		child2.setLayoutData(formData);

		
		// Listeners to size the folder
		sash.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				final boolean FASTDRAG = true;

				if (FASTDRAG && e.detail == SWT.DRAG)
					return;

				child1Data.height = e.y + e.height - SASH_WIDTH;
				form.layout();

				Double l = new Double((double) child1.getBounds().height
						/ form.getBounds().height);
				sash.setData("PCT", l);
				if (e.detail != SWT.DRAG)
					COConfigurationManager.setParameter("MyTorrents.SplitAt", (int) (l
							.doubleValue() * 10000));
			}
		});

		form.addListener(SWT.Resize, new Listener() {
			public void handleEvent(Event e) {
				Double l = (Double) sash.getData("PCT");
				if (l != null) {
					child1Data.height = (int) (form.getBounds().height * l
							.doubleValue());
					form.layout();
				}
			}
		});
  
public booleanisEnabled(java.lang.String itemKey)

    IView currentView = getCurrentView();
    if (currentView != null)
      return currentView.isEnabled(itemKey);
    else
      return false;
  
public voiditemActivated(java.lang.String itemKey)

    IView currentView = getCurrentView();
    if (currentView != null)
      currentView.itemActivated(itemKey);    
  
public org.eclipse.swt.graphics.ImageobfusticatedImage(org.eclipse.swt.graphics.Image image, org.eclipse.swt.graphics.Point shellOffset)

		if (torrentview != null) {
			torrentview.obfusticatedImage(image, shellOffset);
		}
		if (seedingview != null) {
			seedingview.obfusticatedImage(image, shellOffset);
		}
		return image;
	
public voidrefresh()

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

    seedingview.refresh();
    torrentview.refresh();
  
public voidupdateLanguage()

  	// no super call, the views will do their own
  	
    if (getComposite() == null || getComposite().isDisposed())
      return;

    seedingview.updateLanguage();
    torrentview.updateLanguage();
	
public voidviewActivated()

    IView currentView = getCurrentView();
    if (currentView instanceof IViewExtension) {
    	((IViewExtension)currentView).viewActivated();
    }
	
public voidviewDeactivated()

    IView currentView = getCurrentView();
    if (currentView instanceof IViewExtension) {
    	((IViewExtension)currentView).viewDeactivated();
    }