FileDocCategorySizeDatePackage
ShareUtils.javaAPI DocAzureus 3.0.3.44994Thu Sep 23 08:05:00 BST 2004org.gudy.azureus2.ui.swt.sharing

ShareUtils

public class ShareUtils extends Object
author
parg

Fields Summary
Constructors Summary
Methods Summary
public static voidshareDir(AzureusCore azureus_core, Shell shell)

		shareDirSupport( azureus_core, shell, false, false );
	
public static voidshareDir(AzureusCore azureus_core, java.lang.String file_name)

		new AEThread("shareDir")
		{
			public void
			runSupport()
			{
				try{
					azureus_core.getPluginManager().getDefaultPluginInterface().getShareManager().addDir(new File(file_name));
					
				}catch( Throwable e ){
					
					Debug.printStackTrace( e );
				}
			}
		}.start();
	
public static voidshareDirContents(AzureusCore azureus_core, Shell shell, boolean recursive)

		shareDirSupport( azureus_core, shell, true, recursive );
	
public static voidshareDirContents(AzureusCore azureus_core, java.lang.String file_name, boolean recursive)

		new AEThread("shareDirCntents")
		{
			public void
			runSupport()
			{
				try{
					azureus_core.getPluginManager().getDefaultPluginInterface().getShareManager().addDirContents(new File(file_name), recursive);
			
				}catch( Throwable e ){
					
					Debug.printStackTrace( e );
				}
			}
		}.start();
	
protected static voidshareDirSupport(AzureusCore azureus_core, Shell shell, boolean contents, boolean recursive)

		new AEThread("shareDirSupport")
		{
			public void
			runSupport()
			{
				Display display = shell.getDisplay();
				final String[] path = { null };
				final AESemaphore	sem = new AESemaphore("ShareUtils:dir");
				
				display.asyncExec(new AERunnable() {
					public void runSupport()
					{
						try{
							DirectoryDialog dialog = new DirectoryDialog(shell, SWT.SYSTEM_MODAL);
							
							dialog.setFilterPath( TorrentOpener.getFilterPathData() );
							
							dialog.setText( 
										contents?
										MessageText.getString("MainWindow.dialog.share.sharedircontents") + 
												(recursive?"("+MessageText.getString("MainWindow.dialog.share.sharedircontents.recursive")+")":""):
										MessageText.getString("MainWindow.dialog.share.sharedir"));
							
							path[0] = TorrentOpener.setFilterPathData( dialog.open() );

						}finally{
							
							sem.release();
						}
					}
				});
				
				sem.reserve();
				
				if ( path[0] != null ){
					
					if ( contents ){
						
						shareDirContents( azureus_core, path[0], recursive );
						
					}else{
						
						shareDir( azureus_core, path[0] );
					}
				}
			}
		}.start();
	
public static voidshareFile(AzureusCore azureus_core, Shell shell)

		new AEThread("shareFile")
		{
			public void
			runSupport()
			{
				Display display = shell.getDisplay();
				final String[] path = { null };
				final AESemaphore	sem = new AESemaphore("ShareUtils:file");
        
					
				display.asyncExec(new AERunnable() {
					public void runSupport()
					{
						try{
							FileDialog dialog = new FileDialog(shell, SWT.SYSTEM_MODAL | SWT.OPEN);
							
							dialog.setFilterPath( TorrentOpener.getFilterPathData() );
													
							dialog.setText(MessageText.getString("MainWindow.dialog.share.sharefile"));
							
              path[0] = TorrentOpener.setFilterPathData( dialog.open() );

						}finally{
							
							sem.release();
						}
					}
				});
				
				sem.reserve();
				
				if ( path[0] != null ){
					
					shareFile( azureus_core, path[0] );
				}
			}
		}.start();
	
public static voidshareFile(AzureusCore azureus_core, java.lang.String file_name)

		new AEThread("shareFile")
		{
			public void
			runSupport()
			{
				try{
					azureus_core.getPluginManager().getDefaultPluginInterface().getShareManager().addFile(new File(file_name));
					
				}catch( Throwable e ){
					
					Debug.printStackTrace( e );
				}
			}
		}.start();