From: <dam...@us...> - 2006-03-31 10:24:03
|
Revision: 72 Author: damokles Date: 2006-03-31 02:23:54 -0800 (Fri, 31 Mar 2006) ViewCVS: http://svn.sourceforge.net/azsmrc/?rev=72&view=rev Log Message: ----------- fix the move bug, evil marc, I had to bother paul with it until we found out you was the evildoer Modified Paths: -------------- trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/DownloadManagerShell.java Modified: trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/DownloadManagerShell.java =================================================================== --- trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/DownloadManagerShell.java 2006-03-31 09:20:45 UTC (rev 71) +++ trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/DownloadManagerShell.java 2006-03-31 10:23:54 UTC (rev 72) @@ -97,1331 +97,1331 @@ public class DownloadManagerShell { - private Shell DOWNLOAD_MANAGER_SHELL; - private Table downloadsTable, seedsTable; - private Semaphore semaphore = new Semaphore(1); - private SashForm sash; - private CTabFolder tabFolder; - private CTabItem myTorrents; + private Shell DOWNLOAD_MANAGER_SHELL; + private Table downloadsTable, seedsTable; + private Semaphore semaphore = new Semaphore(1); + private SashForm sash; + private CTabFolder tabFolder; + private CTabItem myTorrents; - private DownloadListener dlL = new DownloadListener(){ + private DownloadListener dlL = new DownloadListener(){ - public void stateChanged(Download download, int old_state, int new_state) { - try { - semaphore.acquire(); - //Changing from Downloading to Seeding - if (new_state == Download.ST_SEEDING && downloadsMap.containsKey(download.getHash())) { - downloadsMap.get(download.getHash()).removeFromTable(); - downloadsMap.remove(download.getHash()); - SeedContainer sc = new SeedContainer(download,seedsTable,SWT.NULL); - seedsMap.put(download.getHash(), sc); - } - } catch (InterruptedException e) { + public void stateChanged(Download download, int old_state, int new_state) { + try { + semaphore.acquire(); + //Changing from Downloading to Seeding + if (new_state == Download.ST_SEEDING && downloadsMap.containsKey(download.getHash())) { + downloadsMap.get(download.getHash()).removeFromTable(); + downloadsMap.remove(download.getHash()); + SeedContainer sc = new SeedContainer(download,seedsTable,SWT.NULL); + seedsMap.put(download.getHash(), sc); + } + } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - semaphore.release(); - } - //Other changes go here - } + e.printStackTrace(); + } finally { + semaphore.release(); + } + //Other changes go here + } - public void positionChanged(Download download, int oldPosition, int newPosition) { - debugLogger.finer("Position changed "+download+" "+oldPosition+" -> "+newPosition); - if(downloadsMap.containsKey(download.getHash())) - resortDownloads = true; - else - resortSeeds = true; - } + public void positionChanged(Download download, int oldPosition, int newPosition) { + debugLogger.finer("Position changed "+download+" "+oldPosition+" -> "+newPosition); + if(downloadsMap.containsKey(download.getHash())) + resortDownloads = true; + else + resortSeeds = true; + } - }; + }; - private boolean COLLAPSED; - private boolean bSingleUserMode; - private String TITLE; + private boolean COLLAPSED; + private boolean bSingleUserMode; + private String TITLE; - private SortedMap<String,DownloadContainer> downloadsMap = new TreeMap<String,DownloadContainer>(); - private SortedMap<String,SeedContainer> seedsMap = new TreeMap<String,SeedContainer>(); + private SortedMap<String,DownloadContainer> downloadsMap = new TreeMap<String,DownloadContainer>(); + private SortedMap<String,SeedContainer> seedsMap = new TreeMap<String,SeedContainer>(); - private ToolItem top,up,bottom,down,login,logout,quickconnect; - private ToolItem refresh,manage_users, preferences, console; - private ToolItem addTorrent_by_file,addTorrent_by_url, pauseAll, resumeAll ; - private ToolItem stopTorrent, queueTorrent, removeTorrent; - private MenuItem menuLogin,menuLogout,menuQuickconnect; - public ConsoleTab consoleTab; + private ToolItem top,up,bottom,down,login,logout,quickconnect; + private ToolItem refresh,manage_users, preferences, console; + private ToolItem addTorrent_by_file,addTorrent_by_url, pauseAll, resumeAll ; + private ToolItem stopTorrent, queueTorrent, removeTorrent; + private MenuItem menuLogin,menuLogout,menuQuickconnect; + public ConsoleTab consoleTab; - //status bar labels - private CLabel statusBarText; - private Composite statusbarComp; - private CLabelPadding statusDown, statusUp, /*statusBarText,*/ connectionStatusIcon, sslStatusIcon; + //status bar labels + private CLabel statusBarText; + private Composite statusbarComp; + private CLabelPadding statusDown, statusUp, /*statusBarText,*/ connectionStatusIcon, sslStatusIcon; - private String azureusDownload = "N/S"; - private String azureusUpload = "N/S"; - private int upSpeed = 0; - private int downSpeed = 0; + private String azureusDownload = "N/S"; + private String azureusUpload = "N/S"; + private int upSpeed = 0; + private int downSpeed = 0; - private boolean resortDownloads = false; - private boolean resortSeeds = false; - private Logger debugLogger; + private boolean resortDownloads = false; + private boolean resortSeeds = false; + private Logger debugLogger; - private int drag_drop_line_start = -1; + private int drag_drop_line_start = -1; - public void open(){ - debugLogger = RCMain.getRCMain().getDebugLogger(); - if(DOWNLOAD_MANAGER_SHELL != null && !DOWNLOAD_MANAGER_SHELL.isDisposed()){ - DOWNLOAD_MANAGER_SHELL.setVisible(true); - DOWNLOAD_MANAGER_SHELL.forceFocus(); - DOWNLOAD_MANAGER_SHELL.forceActive(); - return; - } + public void open(){ + debugLogger = RCMain.getRCMain().getDebugLogger(); + if(DOWNLOAD_MANAGER_SHELL != null && !DOWNLOAD_MANAGER_SHELL.isDisposed()){ + DOWNLOAD_MANAGER_SHELL.setVisible(true); + DOWNLOAD_MANAGER_SHELL.forceFocus(); + DOWNLOAD_MANAGER_SHELL.forceActive(); + return; + } - if(TITLE == null) TITLE = "AzSMRC"; + if(TITLE == null) TITLE = "AzSMRC"; - DOWNLOAD_MANAGER_SHELL = new Shell(RCMain.getRCMain().getDisplay()); + DOWNLOAD_MANAGER_SHELL = new Shell(RCMain.getRCMain().getDisplay()); - DOWNLOAD_MANAGER_SHELL.setImage(ImageRepository.getImage("TrayIcon_Blue")); + DOWNLOAD_MANAGER_SHELL.setImage(ImageRepository.getImage("TrayIcon_Blue")); - //Grid Layout - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - gridLayout.marginHeight = 0; - gridLayout.verticalSpacing=0; - gridLayout.horizontalSpacing=0; - gridLayout.marginWidth = 0; - DOWNLOAD_MANAGER_SHELL.setLayout(gridLayout); - DOWNLOAD_MANAGER_SHELL.setMinimumSize(400,250); + //Grid Layout + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + gridLayout.marginHeight = 0; + gridLayout.verticalSpacing=0; + gridLayout.horizontalSpacing=0; + gridLayout.marginWidth = 0; + DOWNLOAD_MANAGER_SHELL.setLayout(gridLayout); + DOWNLOAD_MANAGER_SHELL.setMinimumSize(400,250); - //-----------------------MAIN TOP MENU----------------------------\\ - Menu menuBar = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.BAR); - DOWNLOAD_MANAGER_SHELL.setMenuBar (menuBar); + //-----------------------MAIN TOP MENU----------------------------\\ + Menu menuBar = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.BAR); + DOWNLOAD_MANAGER_SHELL.setMenuBar (menuBar); - MenuItem fileItem = new MenuItem(menuBar,SWT.CASCADE); - fileItem.setText("&File"); + MenuItem fileItem = new MenuItem(menuBar,SWT.CASCADE); + fileItem.setText("&File"); - Menu fileSubmenu = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.DROP_DOWN); - fileItem.setMenu (fileSubmenu); + Menu fileSubmenu = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.DROP_DOWN); + fileItem.setMenu (fileSubmenu); - MenuItem toolItem = new MenuItem(menuBar,SWT.CASCADE); - toolItem.setText("&Tools"); + MenuItem toolItem = new MenuItem(menuBar,SWT.CASCADE); + toolItem.setText("&Tools"); - Menu toolSubmenu = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.DROP_DOWN); - toolItem.setMenu (toolSubmenu); + Menu toolSubmenu = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.DROP_DOWN); + toolItem.setMenu (toolSubmenu); - MenuItem helpItem = new MenuItem(menuBar,SWT.CASCADE); - helpItem.setText("&Help"); + MenuItem helpItem = new MenuItem(menuBar,SWT.CASCADE); + helpItem.setText("&Help"); - Menu helpSubmenu = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.DROP_DOWN); - helpItem.setMenu (helpSubmenu); + Menu helpSubmenu = new Menu (DOWNLOAD_MANAGER_SHELL, SWT.DROP_DOWN); + helpItem.setMenu (helpSubmenu); - //----File submenu + //----File submenu - //Login - menuLogin = new MenuItem(fileSubmenu,SWT.PUSH); - menuLogin.setText("&Connect to Server"); - menuLogin.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - new ConnectionDialog(RCMain.getRCMain().getDisplay()); - } - }); + //Login + menuLogin = new MenuItem(fileSubmenu,SWT.PUSH); + menuLogin.setText("&Connect to Server"); + menuLogin.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + new ConnectionDialog(RCMain.getRCMain().getDisplay()); + } + }); - //QuickConnect - menuQuickconnect = new MenuItem(fileSubmenu,SWT.PUSH); - menuQuickconnect.setText("&Quickconnect"); - menuQuickconnect.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - Properties properties = RCMain.getRCMain().getProperties(); - if ( - properties.getProperty("connection_lastURL",null) != null && - properties.getProperty("connection_username",null) != null && - properties.getProperty("connection_password",null) != null) { - RCMain.getRCMain().connect(true); - RCMain.getRCMain().getClient().sendListTransfers(RemoteConstants.ST_ALL); - } else - new ConnectionDialog(RCMain.getRCMain().getDisplay()); - } - }); + //QuickConnect + menuQuickconnect = new MenuItem(fileSubmenu,SWT.PUSH); + menuQuickconnect.setText("&Quickconnect"); + menuQuickconnect.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + Properties properties = RCMain.getRCMain().getProperties(); + if ( + properties.getProperty("connection_lastURL",null) != null && + properties.getProperty("connection_username",null) != null && + properties.getProperty("connection_password",null) != null) { + RCMain.getRCMain().connect(true); + RCMain.getRCMain().getClient().sendListTransfers(RemoteConstants.ST_ALL); + } else + new ConnectionDialog(RCMain.getRCMain().getDisplay()); + } + }); - //Logout - menuLogout = new MenuItem(fileSubmenu,SWT.PUSH); - menuLogout.setText("&Disconnect from Server"); - menuLogout.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - RCMain.getRCMain().disconnect(); - setLogInOutButtons(false); - DOWNLOAD_MANAGER_SHELL.setText(TITLE); - RCMain.getRCMain().setTrayIcon(0); - downloadsMap.clear(); - seedsMap.clear(); - downloadsTable.removeAll(); - seedsTable.removeAll(); - Control[] children_downloads = downloadsTable.getChildren(); - for(Control child:children_downloads) child.dispose(); - Control[] children_seeds = seedsTable.getChildren(); - for(Control child:children_seeds) child.dispose(); - } - }); + //Logout + menuLogout = new MenuItem(fileSubmenu,SWT.PUSH); + menuLogout.setText("&Disconnect from Server"); + menuLogout.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + RCMain.getRCMain().disconnect(); + setLogInOutButtons(false); + DOWNLOAD_MANAGER_SHELL.setText(TITLE); + RCMain.getRCMain().setTrayIcon(0); + downloadsMap.clear(); + seedsMap.clear(); + downloadsTable.removeAll(); + seedsTable.removeAll(); + Control[] children_downloads = downloadsTable.getChildren(); + for(Control child:children_downloads) child.dispose(); + Control[] children_seeds = seedsTable.getChildren(); + for(Control child:children_seeds) child.dispose(); + } + }); - //Separator - new MenuItem(fileSubmenu,SWT.SEPARATOR); + //Separator + new MenuItem(fileSubmenu,SWT.SEPARATOR); - //Exit - MenuItem exitItem = new MenuItem (fileSubmenu, SWT.PUSH); - exitItem.setText ("E&xit\tCtrl+Q"); - exitItem.setAccelerator (SWT.CTRL + 'Q'); - exitItem.addListener (SWT.Selection, new Listener () { - public void handleEvent (Event e) { - MessageBox messageBox = new MessageBox(DOWNLOAD_MANAGER_SHELL, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); - messageBox.setText("Confirm Exit"); - messageBox.setMessage("Are you sure you wish to exit AzSMRC entirely?"); - int response = messageBox.open(); - switch (response){ - case SWT.OK: - RCMain.getRCMain().close(); - break; - case SWT.CANCEL: - break; - } - } - }); + //Exit + MenuItem exitItem = new MenuItem (fileSubmenu, SWT.PUSH); + exitItem.setText ("E&xit\tCtrl+Q"); + exitItem.setAccelerator (SWT.CTRL + 'Q'); + exitItem.addListener (SWT.Selection, new Listener () { + public void handleEvent (Event e) { + MessageBox messageBox = new MessageBox(DOWNLOAD_MANAGER_SHELL, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); + messageBox.setText("Confirm Exit"); + messageBox.setMessage("Are you sure you wish to exit AzSMRC entirely?"); + int response = messageBox.open(); + switch (response){ + case SWT.OK: + RCMain.getRCMain().close(); + break; + case SWT.CANCEL: + break; + } + } + }); - //-----Tools Submenu + //-----Tools Submenu - MenuItem menuConsole = new MenuItem(toolSubmenu,SWT.PUSH); - menuConsole.setText("&Console\tCtrl+C"); - menuConsole.setAccelerator(SWT.CTRL + 'C'); - menuConsole.addListener(SWT.Selection, new Listener(){ - public void handleEvent(Event e){ - CTabItem[] tabs = tabFolder.getItems(); - for(CTabItem tab:tabs){ - if(tab.getText().equalsIgnoreCase("Console")){ - tabFolder.setSelection(tab); - return; - } - } - consoleTab = new ConsoleTab(tabFolder); - } - }); + MenuItem menuConsole = new MenuItem(toolSubmenu,SWT.PUSH); + menuConsole.setText("&Console\tCtrl+C"); + menuConsole.setAccelerator(SWT.CTRL + 'C'); + menuConsole.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event e){ + CTabItem[] tabs = tabFolder.getItems(); + for(CTabItem tab:tabs){ + if(tab.getText().equalsIgnoreCase("Console")){ + tabFolder.setSelection(tab); + return; + } + } + consoleTab = new ConsoleTab(tabFolder); + } + }); - MenuItem menuPrefs = new MenuItem(toolSubmenu,SWT.PUSH); - menuPrefs.setText("&Preferences"); - menuPrefs.addListener(SWT.Selection, new Listener(){ - public void handleEvent(Event e) { + MenuItem menuPrefs = new MenuItem(toolSubmenu,SWT.PUSH); + menuPrefs.setText("&Preferences"); + menuPrefs.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event e) { - CTabItem[] tabs = tabFolder.getItems(); - for(CTabItem tab:tabs){ - if(tab.getText().equalsIgnoreCase("Preferences")){ - tabFolder.setSelection(tab); - return; - } - } - new PreferencesTab(tabFolder); - } - }); + CTabItem[] tabs = tabFolder.getItems(); + for(CTabItem tab:tabs){ + if(tab.getText().equalsIgnoreCase("Preferences")){ + tabFolder.setSelection(tab); + return; + } + } + new PreferencesTab(tabFolder); + } + }); - //-----Help Submenu + //-----Help Submenu - MenuItem menuAbout = new MenuItem(helpSubmenu,SWT.PUSH); - menuAbout.setText("&User Guide"); - menuAbout.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - //open readme shell here - CTabItem[] tabs = tabFolder.getItems(); - for(CTabItem tab:tabs){ - if(tab.getText().equalsIgnoreCase("Information")){ - tabFolder.setSelection(tab); - return; - } - } - new ReadmeTab(tabFolder); - } - }); + MenuItem menuAbout = new MenuItem(helpSubmenu,SWT.PUSH); + menuAbout.setText("&User Guide"); + menuAbout.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + //open readme shell here + CTabItem[] tabs = tabFolder.getItems(); + for(CTabItem tab:tabs){ + if(tab.getText().equalsIgnoreCase("Information")){ + tabFolder.setSelection(tab); + return; + } + } + new ReadmeTab(tabFolder); + } + }); - //--------------------------TOOLBAR--------------------------------\\ + //--------------------------TOOLBAR--------------------------------\\ - //Toolbar for torrent adding and other features - ToolBar bar = new ToolBar(DOWNLOAD_MANAGER_SHELL,SWT.HORIZONTAL | SWT.FLAT); - GridData gridData = new GridData(); - gridData.horizontalSpan = 2; - bar.setLayoutData(gridData); + //Toolbar for torrent adding and other features + ToolBar bar = new ToolBar(DOWNLOAD_MANAGER_SHELL,SWT.HORIZONTAL | SWT.FLAT); + GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + bar.setLayoutData(gridData); - login = new ToolItem(bar,SWT.PUSH); - login.setImage(ImageRepository.getImage("connect")); - login.setToolTipText("Connect to server"); - login.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - new ConnectionDialog(RCMain.getRCMain().getDisplay()); - } - }); + login = new ToolItem(bar,SWT.PUSH); + login.setImage(ImageRepository.getImage("connect")); + login.setToolTipText("Connect to server"); + login.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + new ConnectionDialog(RCMain.getRCMain().getDisplay()); + } + }); - quickconnect = new ToolItem(bar,SWT.PUSH); - quickconnect.setImage(ImageRepository.getImage("connect_quick")); - quickconnect.setToolTipText("Quickconnect using last saved settings"); - quickconnect.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - Properties properties = RCMain.getRCMain().getProperties(); - if ( - properties.getProperty("connection_lastURL",null) != null && - properties.getProperty("connection_username",null) != null && - properties.getProperty("connection_password",null) != null) { - RCMain.getRCMain().connect(true); - RCMain.getRCMain().getClient().sendListTransfers(RemoteConstants.ST_ALL); - } else - new ConnectionDialog(RCMain.getRCMain().getDisplay()); - } - }); + quickconnect = new ToolItem(bar,SWT.PUSH); + quickconnect.setImage(ImageRepository.getImage("connect_quick")); + quickconnect.setToolTipText("Quickconnect using last saved settings"); + quickconnect.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + Properties properties = RCMain.getRCMain().getProperties(); + if ( + properties.getProperty("connection_lastURL",null) != null && + properties.getProperty("connection_username",null) != null && + properties.getProperty("connection_password",null) != null) { + RCMain.getRCMain().connect(true); + RCMain.getRCMain().getClient().sendListTransfers(RemoteConstants.ST_ALL); + } else + new ConnectionDialog(RCMain.getRCMain().getDisplay()); + } + }); - logout = new ToolItem(bar,SWT.PUSH); - logout.setImage(ImageRepository.getImage("logout")); - logout.setToolTipText("Disconnect from server"); - logout.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - RCMain.getRCMain().disconnect(); - setLogInOutButtons(false); - DOWNLOAD_MANAGER_SHELL.setText(TITLE); - RCMain.getRCMain().setTrayIcon(0); - downloadsMap.clear(); - seedsMap.clear(); - downloadsTable.removeAll(); - seedsTable.removeAll(); - Control[] children_downloads = downloadsTable.getChildren(); - for(Control child:children_downloads) child.dispose(); - Control[] children_seeds = seedsTable.getChildren(); - for(Control child:children_seeds) child.dispose(); - } - }); + logout = new ToolItem(bar,SWT.PUSH); + logout.setImage(ImageRepository.getImage("logout")); + logout.setToolTipText("Disconnect from server"); + logout.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + RCMain.getRCMain().disconnect(); + setLogInOutButtons(false); + DOWNLOAD_MANAGER_SHELL.setText(TITLE); + RCMain.getRCMain().setTrayIcon(0); + downloadsMap.clear(); + seedsMap.clear(); + downloadsTable.removeAll(); + seedsTable.removeAll(); + Control[] children_downloads = downloadsTable.getChildren(); + for(Control child:children_downloads) child.dispose(); + Control[] children_seeds = seedsTable.getChildren(); + for(Control child:children_seeds) child.dispose(); + } + }); - refresh = new ToolItem(bar,SWT.PUSH); - refresh.setImage(ImageRepository.getImage("refresh")); - refresh.setToolTipText("Refresh"); - refresh.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(RCMain.getRCMain().connected()) - RCMain.getRCMain().getClient().sendListTransfers(RemoteConstants.ST_ALL); + refresh = new ToolItem(bar,SWT.PUSH); + refresh.setImage(ImageRepository.getImage("refresh")); + refresh.setToolTipText("Refresh"); + refresh.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(RCMain.getRCMain().connected()) + RCMain.getRCMain().getClient().sendListTransfers(RemoteConstants.ST_ALL); - //new UpdateDialog(DOWNLOAD_MANAGER_SHELL,SWT.NULL).open(); - } - }); + //new UpdateDialog(DOWNLOAD_MANAGER_SHELL,SWT.NULL).open(); + } + }); - //separator - new ToolItem(bar,SWT.SEPARATOR); + //separator + new ToolItem(bar,SWT.SEPARATOR); - addTorrent_by_file = new ToolItem(bar,SWT.PUSH); - addTorrent_by_file.setImage(ImageRepository.getImage("open_by_file")); - addTorrent_by_file.setToolTipText("Add a torrent from a local file"); - addTorrent_by_file.addListener(SWT.Selection, new Listener(){ - public void handleEvent(Event e) { - Shell[] shells = RCMain.getRCMain().getDisplay().getShells(); - for(int i = 0; i < shells.length; i++){ - if(shells[i].getText().equalsIgnoreCase("Send Torrent File to Server")){ - shells[i].setActive(); - shells[i].setFocus(); - return; - } - } - new OpenByFileDialog(RCMain.getRCMain().getDisplay()); - } - }); + addTorrent_by_file = new ToolItem(bar,SWT.PUSH); + addTorrent_by_file.setImage(ImageRepository.getImage("open_by_file")); + addTorrent_by_file.setToolTipText("Add a torrent from a local file"); + addTorrent_by_file.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event e) { + Shell[] shells = RCMain.getRCMain().getDisplay().getShells(); + for(int i = 0; i < shells.length; i++){ + if(shells[i].getText().equalsIgnoreCase("Send Torrent File to Server")){ + shells[i].setActive(); + shells[i].setFocus(); + return; + } + } + new OpenByFileDialog(RCMain.getRCMain().getDisplay()); + } + }); - addTorrent_by_url = new ToolItem(bar,SWT.PUSH); - addTorrent_by_url.setImage(ImageRepository.getImage("open_by_url")); - addTorrent_by_url.setToolTipText("Add a torrent from a URL"); - addTorrent_by_url.addListener(SWT.Selection, new Listener(){ - public void handleEvent(Event e) { - Shell[] shells = RCMain.getRCMain().getDisplay().getShells(); - for(int i = 0; i < shells.length; i++){ - if(shells[i].getText().equalsIgnoreCase("Add a Torrent by URL")){ - shells[i].setActive(); - shells[i].setFocus(); - return; - } - } - new OpenByURLDialog(RCMain.getRCMain().getDisplay()); - } - }); + addTorrent_by_url = new ToolItem(bar,SWT.PUSH); + addTorrent_by_url.setImage(ImageRepository.getImage("open_by_url")); + addTorrent_by_url.setToolTipText("Add a torrent from a URL"); + addTorrent_by_url.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event e) { + Shell[] shells = RCMain.getRCMain().getDisplay().getShells(); + for(int i = 0; i < shells.length; i++){ + if(shells[i].getText().equalsIgnoreCase("Add a Torrent by URL")){ + shells[i].setActive(); + shells[i].setFocus(); + return; + } + } + new OpenByURLDialog(RCMain.getRCMain().getDisplay()); + } + }); - //separator - new ToolItem(bar,SWT.SEPARATOR); + //separator + new ToolItem(bar,SWT.SEPARATOR); - top = new ToolItem(bar, SWT.PUSH); - top.setImage(ImageRepository.getImage("top")); - top.setToolTipText("Move selected torrent to top of list"); - top.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(downloadsTable.isFocusControl()){ - TableItem[] items = downloadsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if((current_position -1) > 0){ - container.getDownload().moveTo(1); - } - }else{ - TableItem[] items = seedsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if((current_position -1) > 0){ - container.getDownload().moveTo(1); - } - } - } - }); + top = new ToolItem(bar, SWT.PUSH); + top.setImage(ImageRepository.getImage("top")); + top.setToolTipText("Move selected torrent to top of list"); + top.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(downloadsTable.isFocusControl()){ + TableItem[] items = downloadsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if((current_position -1) > 0){ + container.getDownload().moveTo(1); + } + }else{ + TableItem[] items = seedsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if((current_position -1) > 0){ + container.getDownload().moveTo(1); + } + } + } + }); - up = new ToolItem(bar, SWT.PUSH); - up.setImage(ImageRepository.getImage("up")); - up.setToolTipText("Move selected torrent up one position"); - up.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(downloadsTable.isFocusControl()){ - TableItem[] items = downloadsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if((current_position -1) > 0){ - container.getDownload().setPosition(current_position-1); - } - }else{ - TableItem[] items = seedsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if((current_position -1) > 0){ - container.getDownload().setPosition(current_position-1); - } - } - } - }); + up = new ToolItem(bar, SWT.PUSH); + up.setImage(ImageRepository.getImage("up")); + up.setToolTipText("Move selected torrent up one position"); + up.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(downloadsTable.isFocusControl()){ + TableItem[] items = downloadsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if((current_position -1) > 0){ + container.getDownload().moveUp(); + } + }else{ + TableItem[] items = seedsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if((current_position -1) > 0){ + container.getDownload().moveUp(); + } + } + } + }); - down = new ToolItem(bar, SWT.PUSH); - down.setImage(ImageRepository.getImage("down")); - down.setToolTipText("Move selected torrent down one position"); - down.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(downloadsTable.isFocusControl()){ - TableItem[] items = downloadsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if((current_position + 1) != (downloadsMap.size() + 1)){ - container.getDownload().setPosition(current_position+1); - } - }else{ - TableItem[] items = seedsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if((current_position + 1) != (seedsMap.size() + 1)){ - container.getDownload().setPosition(current_position+1); - } - } - } - }); + down = new ToolItem(bar, SWT.PUSH); + down.setImage(ImageRepository.getImage("down")); + down.setToolTipText("Move selected torrent down one position"); + down.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(downloadsTable.isFocusControl()){ + TableItem[] items = downloadsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if((current_position + 1) != (downloadsMap.size() + 1)){ + container.getDownload().moveDown(); + } + }else{ + TableItem[] items = seedsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if((current_position + 1) != (seedsMap.size() + 1)){ + container.getDownload().moveDown(); + } + } + } + }); - bottom = new ToolItem(bar, SWT.PUSH); - bottom.setImage(ImageRepository.getImage("bottom")); - bottom.setToolTipText("Move selected torrent to bottom of list"); - bottom.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(downloadsTable.isFocusControl()){ - TableItem[] items = downloadsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if(current_position != downloadsMap.size()){ - container.getDownload().setPosition(downloadsMap.size()); - } - }else{ - TableItem[] items = seedsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - int current_position = container.getDownload().getPosition(); - if(current_position != seedsMap.size()){ - container.getDownload().setPosition(seedsMap.size()); - } - } - } - }); + bottom = new ToolItem(bar, SWT.PUSH); + bottom.setImage(ImageRepository.getImage("bottom")); + bottom.setToolTipText("Move selected torrent to bottom of list"); + bottom.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(downloadsTable.isFocusControl()){ + TableItem[] items = downloadsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if(current_position != downloadsMap.size()){ + container.getDownload().setPosition(downloadsMap.size()); + } + }else{ + TableItem[] items = seedsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + int current_position = container.getDownload().getPosition(); + if(current_position != seedsMap.size()){ + container.getDownload().setPosition(seedsMap.size()); + } + } + } + }); - //Set all torrent move buttons disabled - setTorrentMoveButtons(false,false,false,false); + //Set all torrent move buttons disabled + setTorrentMoveButtons(false,false,false,false); - //separator - new ToolItem(bar,SWT.SEPARATOR); + //separator + new ToolItem(bar,SWT.SEPARATOR); - queueTorrent = new ToolItem(bar, SWT.PUSH); - queueTorrent.setImage(ImageRepository.getImage("toolbar_queue")); - queueTorrent.setToolTipText("Queue Torrent"); - queueTorrent.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(downloadsTable.isFocusControl()){ - TableItem[] items = downloadsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - container.getDownload().stopAndQueue(); - RCMain.getRCMain().getClient().transactionCommit(); - setToolBarTorrentIcons(false,true,true); - }else{ - TableItem[] items = seedsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - container.getDownload().stopAndQueue(); - RCMain.getRCMain().getClient().transactionCommit(); - setToolBarTorrentIcons(false,true,true); - } - } - }); + queueTorrent = new ToolItem(bar, SWT.PUSH); + queueTorrent.setImage(ImageRepository.getImage("toolbar_queue")); + queueTorrent.setToolTipText("Queue Torrent"); + queueTorrent.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(downloadsTable.isFocusControl()){ + TableItem[] items = downloadsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + container.getDownload().stopAndQueue(); + RCMain.getRCMain().getClient().transactionCommit(); + setToolBarTorrentIcons(false,true,true); + }else{ + TableItem[] items = seedsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + container.getDownload().stopAndQueue(); + RCMain.getRCMain().getClient().transactionCommit(); + setToolBarTorrentIcons(false,true,true); + } + } + }); - stopTorrent = new ToolItem(bar, SWT.PUSH); - stopTorrent.setImage(ImageRepository.getImage("toolbar_stop")); - stopTorrent.setToolTipText("Stop Torrent"); - stopTorrent.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(downloadsTable.isFocusControl()){ - TableItem[] items = downloadsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - container.getDownload().stop(); - RCMain.getRCMain().getClient().transactionCommit(); - setToolBarTorrentIcons(true,false,true); - }else{ - TableItem[] items = seedsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - container.getDownload().stop(); - RCMain.getRCMain().getClient().transactionCommit(); - setToolBarTorrentIcons(true,false,true); - } - } - }); + stopTorrent = new ToolItem(bar, SWT.PUSH); + stopTorrent.setImage(ImageRepository.getImage("toolbar_stop")); + stopTorrent.setToolTipText("Stop Torrent"); + stopTorrent.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(downloadsTable.isFocusControl()){ + TableItem[] items = downloadsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + container.getDownload().stop(); + RCMain.getRCMain().getClient().transactionCommit(); + setToolBarTorrentIcons(true,false,true); + }else{ + TableItem[] items = seedsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + container.getDownload().stop(); + RCMain.getRCMain().getClient().transactionCommit(); + setToolBarTorrentIcons(true,false,true); + } + } + }); - removeTorrent = new ToolItem(bar, SWT.PUSH); - removeTorrent.setImage(ImageRepository.getImage("toolbar_remove")); - removeTorrent.setToolTipText("Remove Torrents"); - removeTorrent.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - if(downloadsTable.isFocusControl()){ - TableItem[] items = downloadsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - container.getDownload().remove(); - container.removeFromTable(); - if(seedsMap.containsKey(container.getDownload().getHash())){ - seedsMap.remove(container.getDownload().getHash()); - }else if(downloadsMap.containsKey(container.getDownload().getHash())){ - downloadsMap.remove(container.getDownload().getHash()); - } - RCMain.getRCMain().getClient().transactionCommit(); - }else{ - TableItem[] items = seedsTable.getSelection(); - if(items.length == 0 || items.length > 1) return; - Container container = (Container)items[0].getData(); - container.getDownload().remove(); - container.removeFromTable(); - if(seedsMap.containsKey(container.getDownload().getHash())){ - seedsMap.remove(container.getDownload().getHash()); - }else if(downloadsMap.containsKey(container.getDownload().getHash())){ - downloadsMap.remove(container.getDownload().getHash()); - } - RCMain.getRCMain().getClient().transactionCommit(); + removeTorrent = new ToolItem(bar, SWT.PUSH); + removeTorrent.setImage(ImageRepository.getImage("toolbar_remove")); + removeTorrent.setToolTipText("Remove Torrents"); + removeTorrent.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + if(downloadsTable.isFocusControl()){ + TableItem[] items = downloadsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + container.getDownload().remove(); + container.removeFromTable(); + if(seedsMap.containsKey(container.getDownload().getHash())){ + seedsMap.remove(container.getDownload().getHash()); + }else if(downloadsMap.containsKey(container.getDownload().getHash())){ + downloadsMap.remove(container.getDownload().getHash()); + } + RCMain.getRCMain().getClient().transactionCommit(); + }else{ + TableItem[] items = seedsTable.getSelection(); + if(items.length == 0 || items.length > 1) return; + Container container = (Container)items[0].getData(); + container.getDownload().remove(); + container.removeFromTable(); + if(seedsMap.containsKey(container.getDownload().getHash())){ + seedsMap.remove(container.getDownload().getHash()); + }else if(downloadsMap.containsKey(container.getDownload().getHash())){ + downloadsMap.remove(container.getDownload().getHash()); + } + RCMain.getRCMain().getClient().transactionCommit(); - } - } - }); + } + } + }); - setToolBarTorrentIcons(false,false,false); + setToolBarTorrentIcons(false,false,false); - //separator - new ToolItem(bar,SWT.SEPARATOR); + //separator + new ToolItem(bar,SWT.SEPARATOR); - pauseAll = new ToolItem(bar, SWT.PUSH); - pauseAll.setImage(ImageRepository.getImage("pause")); - pauseAll.setToolTipText("Pause all torrents"); - pauseAll.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - RCMain.getRCMain().getClient().sendStopAll(); - } - }); + pauseAll = new ToolItem(bar, SWT.PUSH); + pauseAll.setImage(ImageRepository.getImage("pause")); + pauseAll.setToolTipText("Pause all torrents"); + pauseAll.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + RCMain.getRCMain().getClient().sendStopAll(); + } + }); - resumeAll = new ToolItem(bar, SWT.PUSH); - resumeAll.setImage(ImageRepository.getImage("resume")); - resumeAll.setToolTipText("Resume all paused torrents"); - resumeAll.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - RCMain.getRCMain().getClient().sendStartAll(); - } - }); + resumeAll = new ToolItem(bar, SWT.PUSH); + resumeAll.setImage(ImageRepository.getImage("resume")); + resumeAll.setToolTipText("Resume all paused torrents"); + resumeAll.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + RCMain.getRCMain().getClient().sendStartAll(); + } + }); - //separator - new ToolItem(bar,SWT.SEPARATOR); + //separator + new ToolItem(bar,SWT.SEPARATOR); - preferences = new ToolItem(bar,SWT.PUSH); - preferences.setImage(ImageRepository.getImage("preferences")); - preferences.setToolTipText("Open Preferences"); - preferences.addListener(SWT.Selection, new Listener(){ - public void handleEvent(Event e) { + preferences = new ToolItem(bar,SWT.PUSH); + preferences.setImage(ImageRepository.getImage("preferences")); + preferences.setToolTipText("Open Preferences"); + preferences.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event e) { - CTabItem[] tabs = tabFolder.getItems(); - for(CTabItem tab:tabs){ - if(tab.getText().equalsIgnoreCase("Preferences")){ - tabFolder.setSelection(tab); - return; - } - } - new PreferencesTab(tabFolder); - } - }); + CTabItem[] tabs = tabFolder.getItems(); + for(CTabItem tab:tabs){ + if(tab.getText().equalsIgnoreCase("Preferences")){ + tabFolder.setSelection(tab); + return; + } + } + new PreferencesTab(tabFolder); + } + }); - manage_users = new ToolItem(bar,SWT.PUSH); - manage_users.setImage(ImageRepository.getImage("manager_users")); - manage_users.setToolTipText("Manage Users"); - manage_users.addListener(SWT.Selection, new Listener(){ - public void handleEvent(Event e) { + manage_users = new ToolItem(bar,SWT.PUSH); + manage_users.setImage(ImageRepository.getImage("manager_users")); + manage_users.setToolTipText("Manage Users"); + manage_users.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event e) { - CTabItem[] tabs = tabFolder.getItems(); - for(CTabItem tab:tabs){ - if(tab.getText().equalsIgnoreCase("Manage Users")){ - tabFolder.setSelection(tab); - return; - } - } - new ManageUsersTab(tabFolder); - } - }); + CTabItem[] tabs = tabFolder.getItems(); + for(CTabItem tab:tabs){ + if(tab.getText().equalsIgnoreCase("Manage Users")){ + tabFolder.setSelection(tab); + return; + } + } + new ManageUsersTab(tabFolder); + } + }); - console = new ToolItem(bar,SWT.PUSH); - console.setImage(ImageRepository.getImage("console")); - console.setToolTipText("Open Console"); - console.addListener(SWT.Selection, new Listener(){ - public void handleEvent(Event e){ - CTabItem[] tabs = tabFolder.getItems(); - for(CTabItem tab:tabs){ - if(tab.getText().equalsIgnoreCase("Console")){ - tabFolder.setSelection(tab); - return; - } - } - consoleTab = new ConsoleTab(tabFolder); - } - }); + console = new ToolItem(bar,SWT.PUSH); + console.setImage(ImageRepository.getImage("console")); + console.setToolTipText("Open Console"); + console.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event e){ + CTabItem[] tabs = tabFolder.getItems(); + for(CTabItem tab:tabs){ + if(tab.getText().equalsIgnoreCase("Console")){ + tabFolder.setSelection(tab); + return; + } + } + consoleTab = new ConsoleTab(tabFolder); + } + }); - ToolItem information = new ToolItem(bar,SWT.PUSH); - information.setImage(ImageRepository.getImage("information")); - information.setToolTipText("View AzMultiUser Guide and Information"); - information.addListener(SWT.Selection, new Listener(){ - public void handleEvent (Event e){ - //open readme shell here - CTabItem[] tabs = tabFolder.getItems(); - for(CTabItem tab:tabs){ - if(tab.getText().equalsIgnoreCase("Information")){ - tabFolder.setSelection(tab); - return; - } - } - new ReadmeTab(tabFolder); - } - }); + ToolItem information = new ToolItem(bar,SWT.PUSH); + information.setImage(ImageRepository.getImage("information")); + information.setToolTipText("View AzMultiUser Guide and Information"); + information.addListener(SWT.Selection, new Listener(){ + public void handleEvent (Event e){ + //open readme shell here + CTabItem[] tabs = tabFolder.getItems(); + for(CTabItem tab:tabs){ + if(tab.getText().equalsIgnoreCase("Information")){ + tabFolder.setSelection(tab); + return; + } + } + new ReadmeTab(tabFolder); + } + }); - setLogInOutButtons(false); + setLogInOutButtons(false); - //shell title - DOWNLOAD_MANAGER_SHELL.setText(TITLE); + //shell title + DOWNLOAD_MANAGER_SHELL.setText(TITLE); - //------------------- Listeners for the shell ---------------------\\ + //------------------- Listeners for the shell ---------------------\\ - final SpeedUpdateListener sul = new SpeedUpdateListener() { - public void setSpeed(final int d, final int u) { - upSpeed = u; - downSpeed = d; - refreshStatusBar(); - } - }; + final SpeedUpdateListener sul = new SpeedUpdateListener() { + public void setSpeed(final int d, final int u) { + upSpeed = u; + downSpeed = d; + refreshStatusBar(); + } + }; - RCMain.getRCMain().getClient().addSpeedUpdateListener(sul); + RCMain.getRCMain().getClient().addSpeedUpdateListener(sul); - final ConnectionListener cl = new ConnectionListener() { + final ConnectionListener cl = new ConnectionListener() { - public void connectionState(final int state) { - setConnectionStatusBar(state); - if(state > 0){ - if (RCMain.getRCMain().getClient().isSSLEncrypted()) { - setSSLStatusBar(true,true); - } else { - setSSLStatusBar(true,false); - } - } + public void connectionState(final int state) { + setConnectionStatusBar(state); + if(state > 0){ + if (RCMain.getRCMain().getClient().isSSLEncrypted()) { + setSSLStatusBar(true,true); + } else { + setSSLStatusBar(true,false); + } + } - //set the toolbar buttons - if(state > 0){ - setLogInOutButtons(true); - //reset the title of MyTorrents once Logged in - RCMain.getRCMain().getDisplay().asyncExec(new Runnable(){ + //set the toolbar buttons + if(state > 0){ + setLogInOutButtons(true); + //reset the title of MyTorrents once Logged in + RCMain.getRCMain().getDisplay().asyncExec(new Runnable(){ - public void run() { - String userLoggedIn = RCMain.getRCMain().getClient().getUsername(); - if(myTorrents != null || !myTorrents.isDisposed()){ - if(bSingleUserMode){ - myTorrents.setText("ALL Torrents"); - }else if(userLoggedIn != null) - myTorrents.setText(userLoggedIn + "'s Torrents"); - else - myTorrents.setText("My Torrents"); - } + public void run() { + String userLoggedIn = RCMain.getRCMain().getClient().getUsername(); + if(myTorrents != null || !myTorrents.isDisposed()){ + if(bSingleUserMode){ + myTorrents.setText("ALL Torrents"); + }else if(userLoggedIn != null) + myTorrents.setText(userLoggedIn + "'s Torrents"); + else + myTorrents.setText("My Torrents"); + } - } + } - }); - }else{ - setLogInOutButtons(false); - } - } - }; + }); + }else{ + setLogInOutButtons(false); + } + } + }; - RCMain.getRCMain().getClient().addConnectionListener(cl); + RCMain.getRCMain().getClient().addConnectionListener(cl); - final DownloadManagerListener dml = new DownloadManagerListener(){ + final DownloadManagerListener dml = new DownloadManagerListener(){ - public void downloadAdded(final Download download) { - try { - if (DOWNLOAD_MANAGER_SHELL.isDisposed()) { - RCMain.getRCMain().getClient().getDownloadManager().removeListener(this); - return; - } + public void downloadAdded(final Download download) { + try { + if (DOWNLOAD_MANAGER_SHELL.isDisposed()) { + RCMain.getRCMain().getClient().getDownloadManager().removeListener(this); + return; + } - semaphore.acquire(); - RCMain.getRCMain().getDisplay().syncExec(new Runnable() { - public void run() { - if(download.getState() == Download.ST_SEEDING || download.getStats().getCompleted() == 1000){ - if (!seedsMap.containsKey(download.getHash())) { - SeedContainer sc = new SeedContainer(download); - int pos = findInsertionPosition(sc, seedsTable); - sc.addToTable(seedsTable, SWT.NONE, pos); - seedsMap.put(download.getHash(), sc); - resortSeeds = true; //just to make sure sometimes findInsertionPosition screws up - } - }else{ - if (!downloadsMap.containsKey(download.getHash())) { - DownloadContainer dc = new DownloadContainer(download); - int pos = findInsertionPosition(dc, downloadsTable); - dc.addToTable(downloadsTable, SWT.NONE, pos); - downloadsMap.put(download.getHash(), dc); - resortDownloads = true; - } - } - }; - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - semaphore.release(); - } - download.addDownloadListener(dlL); - } + semaphore.acquire(); + RCMain.getRCMain().getDisplay().syncExec(new Runnable() { + public void run() { + if(download.getState() == Download.ST_SEEDING || download.getStats().getCompleted() == 1000){ + if (!seedsMap.containsKey(download.getHash())) { + SeedContainer sc = new SeedContainer(download); + int pos = findInsertionPosition(sc, seedsTable); + sc.addToTable(seedsTable, SWT.NONE, pos); + seedsMap.put(download.getHash(), sc); + resortSeeds = true; //just to make sure sometimes findInsertionPosition screws up + } + }else{ + if (!downloadsMap.containsKey(download.getHash())) { + DownloadContainer dc = new DownloadContainer(download); + int pos = findInsertionPosition(dc, downloadsTable); + dc.addToTable(downloadsTable, SWT.NONE, pos); + downloadsMap.put(download.getHash(), dc); + resortDownloads = true; + } + } + }; + }); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + semaphore.release(); + } + download.addDownloadListener(dlL); + } - public void downloadRemoved(Download download) { - if(downloadsMap.containsKey(download.getHash())){ - downloadsMap.get(download.getHash()).removeFromTable(); - downloadsMap.remove(download.getHash()); - resortDownloads = true; - }else if(seedsMap.containsKey(download.getHash())){ - seedsMap.get(download.getHash()).removeFromTable(); - seedsMap.remove(download.getHash()); - resortSeeds = true; - } - } - }; + public void downloadRemoved(Download download) { + if(downloadsMap.containsKey(download.getHash())){ + downloadsMap.get(download.getHash()).removeFromTable(); + downloadsMap.remove(download.getHash()); + resortDownloads = true; + }else if(seedsMap.containsKey(download.getHash())){ + seedsMap.get(download.getHash()).removeFromTable(); + seedsMap.remove(download.getHash()); + resortSeeds = true; + } + } + }; - RCMain.getRCMain().getClient().getDownloadManager().addListener(dml); + RCMain.getRCMain().getClient().getDownloadManager().addListener(dml); - final ClientUpdateListener cul = new ClientUpdateListener(){ + final ClientUpdateListener cul = new ClientUpdateListener(){ - public void update(long updateSwitches) { - if ((updateSwitches & Constants.UPDATE_LIST_TRANSFERS) != 0){ - Download[] downloads = RCMain.getRCMain().getClient().getDownloadManager().getSortedDownloads(); - for (int i = 0; i < downloads.length; i++){ - if(!downloadsMap.containsKey(downloads[i].getHash()) && !seedsMap.containsKey(downloads[i].getHash())){ - if(downloads[i].getState() == Download.ST_SEEDING || downloads[i].getStats().getCompleted() == 1000){ - SeedContainer sc = new SeedContainer(downloads[i],seedsTable,SWT.NULL); - seedsMap.put(downloads[i].getHash(), sc); - resortSeeds = true; - }else{ - DownloadContainer dc = new DownloadContainer(downloads[i],downloadsTable,SWT.BORDER); - downl... [truncated message content] |