Methods Summary |
---|
public void | detach()
|
public boolean | eventOccurred(org.gudy.azureus2.plugins.ui.UIManagerEvent event)
Object data = event.getData();
switch( event.getType()){
case UIManagerEvent.ET_SHOW_TEXT_MESSAGE: // data is String[] - title, message, text
{
String[] bits = (String[])data;
for (int i=0;i<bits.length;i++){
console.out.println( bits[i] );
}
break;
}
case UIManagerEvent.ET_OPEN_TORRENT_VIA_FILE: // data is File
{
openTorrent(((File)data).toString());
break;
}
case UIManagerEvent.ET_OPEN_TORRENT_VIA_URL: // data is Object[]{URL,URL,Boolean} - { torrent_url, referrer url, auto_download}
{
openRemoteTorrent(((URL)((Object[])data)[0]).toExternalForm());
break;
}
case UIManagerEvent.ET_PLUGIN_VIEW_MODEL_CREATED: // data is PluginViewModel (or subtype)
{
break;
}
case UIManagerEvent.ET_PLUGIN_CONFIG_MODEL_CREATED: // data is PluginConfigModel (or subtype)
{
break;
}
case UIManagerEvent.ET_COPY_TO_CLIPBOARD: // data is String
{
break;
}
case UIManagerEvent.ET_PLUGIN_VIEW_MODEL_DESTROYED: // data is PluginViewModel (or subtype)
{
break;
}
case UIManagerEvent.ET_PLUGIN_CONFIG_MODEL_DESTROYED: // data is PluginConfigModel (or subtype)
{
break;
}
case UIManagerEvent.ET_OPEN_URL: // data is URL
{
break;
}
case UIManagerEvent.ET_CREATE_TABLE_COLUMN: // data is String[] - table_id, cell_id: result is TableColumn
{
// need to return a dummy TableColumn as a result?
return( false );
}
case UIManagerEvent.ET_ADD_TABLE_COLUMN: // data is TableColumn previously created
{
break;
}
case UIManagerEvent.ET_ADD_TABLE_CONTEXT_MENU_ITEM: // data is TableContextMenuItem
{
break;
}
case UIManagerEvent.ET_SHOW_CONFIG_SECTION: // data is String - section id
{
event.setResult(new Boolean(false));
break;
}
default:
{
console.out.println( "Unrecognised UI event '" + event.getType() + "'" );
}
}
return( true );
|
public org.gudy.azureus2.plugins.ui.UIInputReceiver | getInputReceiver()Not yet supported.
return null;
|
public org.gudy.azureus2.plugins.ui.UIInstance | getInstance(org.gudy.azureus2.plugins.PluginInterface plugin_interface)
return( this );
|
public void | init(boolean first, boolean others)Creates a new instance of Main
/*public UI() {
}*/
super.init(first,others);
System.setProperty("java.awt.headless", "true");
|
public void | openRemoteTorrent(java.lang.String url)
if (console != null) {
console.downloadRemoteTorrent(url);
return;
}
System.out.println( "Downloading torrent from url: " + url );
TorrentDownloaderFactory.downloadManaged(url);
return;
|
public void | openTorrent(java.lang.String fileName)
if( console != null )
{
// System.out.println("NOT NULL CONSOLE. CAN PASS STRAIGHT TO IT!");
console.downloadTorrent(fileName);
return;
}
else
{
// System.out.println("NULL CONSOLE");
}
if( fileName.toUpperCase().startsWith( "HTTP://" ) ) {
System.out.println( "Downloading torrent from url: " + fileName );
TorrentDownloaderFactory.downloadManaged( fileName );
return;
}
try {
if (!TorrentUtils.isTorrentFile(fileName)) {//$NON-NLS-1$
Logger.getLogger("azureus2.ui.console").error(fileName+" doesn't seem to be a torrent file. Not added.");
return;
}
} catch (Exception e) {
Logger.getLogger("azureus2.ui.console").error("Something is wrong with "+fileName+". Not added. (Reason: "+e.getMessage()+")");
return;
}
if (UIConst.getGlobalManager()!=null) {
try {
String downloadDir = COConfigurationManager.getDirectoryParameter("Default save path");
System.out.println( "Adding torrent: " + fileName + " and saving to " + downloadDir);
UIConst.getGlobalManager().addDownloadManager(fileName, downloadDir);
} catch (Exception e) {
Logger.getLogger("azureus2.ui.console").error("The torrent "+fileName+" could not be added.", e);
}
}
|
public java.lang.String[] | processArgs(java.lang.String[] args)
return args;
|
public int | promptUser(java.lang.String title, java.lang.String text, java.lang.String[] options, int defaultOption)
console.out.println("Prompt: " + title);
console.out.println(text);
String sOptions = "Options: ";
for (int i = 0; i < options.length; i++) {
if (i != 0) {
sOptions += ", ";
}
sOptions += "[" + i + "]" + options[i];
}
console.out.println(sOptions);
console.out.println("WARNING: Option [" + defaultOption +
"] automatically selected. " +
"Console UI devs need to implement this function!");
return defaultOption;
|
public void | startUI()
super.startUI();
PluginInterface pi = UIConst.getAzureusCore().getPluginManager().getDefaultPluginInterface();
UIManager ui_manager = pi.getUIManager();
ui_manager.addUIEventListener( this );
try{
ui_manager.attachUI( this );
}catch( UIException e ){
e.printStackTrace();
}
TorrentDownloaderFactory.initManager(UIConst.getGlobalManager(), true, true, COConfigurationManager.getStringParameter("Default save path") );
if ((!isStarted()) || (console == null) || (!console.isAlive())) {
// ConsoleInput.printconsolehelp(System.out);
System.out.println();
console = new ConsoleInput("Main", UIConst.getAzureusCore(), System.in, System.out, Boolean.TRUE);
if( System.getProperty("azureus.console.multiuser") != null)
{
UserManager manager = UserManager.getInstance(pi);
console.registerCommand(new UserCommand(manager));
}
console.printconsolehelp();
}
|