From: <dam...@us...> - 2008-11-16 21:40:31
|
Revision: 1699 http://azsmrc.svn.sourceforge.net/azsmrc/?rev=1699&view=rev Author: damokles Date: 2008-11-16 21:40:23 +0000 (Sun, 16 Nov 2008) Log Message: ----------- commit all pending changes for new Version Modified Paths: -------------- trunk/azsmrc/launch.properties trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/PluginLoader.java trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/ipc/IPCInterfaceImpl.java trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/RCMain.java trunk/azsmrc/lbms/tools/launcher/Launcher.java trunk/azsmrc/plugin.properties Added Paths: ----------- trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/resources/edit_columns_16.png trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/resources/force_start_16.png trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/resources/move_16.png Modified: trunk/azsmrc/launch.properties =================================================================== --- trunk/azsmrc/launch.properties 2008-11-16 19:48:49 UTC (rev 1698) +++ trunk/azsmrc/launch.properties 2008-11-16 21:40:23 UTC (rev 1699) @@ -1 +1,2 @@ -launch.class=lbms.azsmrc.remote.client.swtgui.Starter \ No newline at end of file +launch.class=lbms.azsmrc.remote.client.swtgui.Starter +swt.class=org.eclipse.swt.SWT \ No newline at end of file Modified: trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/PluginLoader.java =================================================================== --- trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/PluginLoader.java 2008-11-16 19:48:49 UTC (rev 1698) +++ trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/PluginLoader.java 2008-11-16 21:40:23 UTC (rev 1699) @@ -19,49 +19,50 @@ /** * @author Damokles - * + * */ public class PluginLoader { - public static void findAndLoadPlugins(PluginManagerImpl manager, ExtendedProperties azsmrcProps) { + public static void findAndLoadPlugins (PluginManagerImpl manager, + ExtendedProperties azsmrcProps) { - File app_dir = getApplicationFile("plugins"); + File app_dir = getApplicationFile("plugins"); - if ( !( app_dir.exists()) && app_dir.isDirectory()){ + if (!(app_dir.exists()) && app_dir.isDirectory()) { - System.out.println( "Plugin dir '" + app_dir + "' not found" ); + System.out.println("Plugin dir '" + app_dir + "' not found"); return; } else { - System.out.println( "Checking " + app_dir ); + System.out.println("Checking " + app_dir); } File[] plugins = app_dir.listFiles(); - if ( plugins == null || plugins.length == 0 ){ + if (plugins == null || plugins.length == 0) { - System.out.println( "Plugin dir '" + app_dir + "' empty" ); + System.out.println("Plugin dir '" + app_dir + "' empty"); return; } - for ( int i=0;i<plugins.length;i++ ) { + for (int i = 0; i < plugins.length; i++) { - File plugin_dir = plugins[i]; + File plugin_dir = plugins[i]; - if( !plugin_dir.isDirectory()){ + if (!plugin_dir.isDirectory()) { continue; } File[] pluginContents = plugin_dir.listFiles(); - boolean looks_like_plugin = false; + boolean looks_like_plugin = false; - for (int j=0;j<pluginContents.length;j++){ + for (int j = 0; j < pluginContents.length; j++) { - String name = pluginContents[j].getName().toLowerCase(); + String name = pluginContents[j].getName().toLowerCase(); - if ( name.endsWith( ".jar") || name.equals( "plugin.properties" )){ + if (name.endsWith(".jar") || name.equals("plugin.properties")) { looks_like_plugin = true; @@ -69,112 +70,120 @@ } } - if (!looks_like_plugin) continue; + if (!looks_like_plugin) { + continue; + } try { - System.out.println("Checking dir for Plugins: "+plugin_dir.getCanonicalPath()); + System.out.println("Checking dir for Plugins: " + + plugin_dir.getCanonicalPath()); - ClassLoader root_cl = getRootClassLoader(new File(".")); + ClassLoader root_cl = getRootClassLoader(new File(".")); ClassLoader classLoader = root_cl; - File[] pluginjars = getHighestJarVersions( plugins[i].listFiles()); + File[] pluginjars = getHighestJarVersions(plugins[i] + .listFiles()); - for( int j = 0 ; j < pluginjars.length ; j++){ - classLoader = addFileToClassPath(root_cl,classLoader, pluginjars[j]); + for (int j = 0; j < pluginjars.length; j++) { + classLoader = addFileToClassPath(root_cl, classLoader, + pluginjars[j]); } Properties props = new Properties(); - File properties_file = new File( plugin_dir, "plugin.properties"); + File properties_file = new File(plugin_dir, "plugin.properties"); // if properties file exists on its own then override any properties file // potentially held within a jar - if ( properties_file.exists()) { + if (properties_file.exists()) { - FileInputStream fis = null; + FileInputStream fis = null; - try{ - fis = new FileInputStream( properties_file ); + try { + fis = new FileInputStream(properties_file); - props.load( fis ); + props.load(fis); } finally { - if ( fis != null ){ + if (fis != null) { fis.close(); } } } else { - if ( classLoader instanceof URLClassLoader ){ + if (classLoader instanceof URLClassLoader) { - URLClassLoader current = (URLClassLoader)classLoader; + URLClassLoader current = (URLClassLoader) classLoader; URL url = current.findResource("plugin.properties"); - if ( url != null ){ + if (url != null) { props.load(url.openStream()); } else { - System.out.println("Failed to load Properties from jar."); + System.out + .println("Failed to load Properties from jar."); } } } String pluginID = props.getProperty("plugin.id"); - if (azsmrcProps.propertyExists("plugins."+pluginID+".load")) { + if (azsmrcProps.propertyExists("plugins." + pluginID + ".load")) { //if we don't want to load this plugin continue - if (!azsmrcProps.getPropertyAsBoolean("plugins."+pluginID+".load")) { - System.out.println( "Skipping load of "+pluginID); - manager.addDisabledPlugin(props, plugin_dir.getCanonicalPath()); + if (!azsmrcProps.getPropertyAsBoolean("plugins." + pluginID + + ".load")) { + System.out.println("Skipping load of " + pluginID); + manager.addDisabledPlugin(props, plugin_dir + .getCanonicalPath()); continue; } } else { //add the plugin to the load list - azsmrcProps.setProperty("plugins."+pluginID+".load", true); + azsmrcProps.setProperty("plugins." + pluginID + ".load", + true); } - String plugin_class = props.getProperty( "azsmrc.plugin.class"); + String plugin_class = props.getProperty("azsmrc.plugin.class"); -// if (plugin_class == null) continue; + // if (plugin_class == null) continue; // don't support multiple Launchables - Class c = classLoader.loadClass(plugin_class); + Class<?> c = classLoader.loadClass(plugin_class); - Plugin plugin = (Plugin) c.newInstance(); + Plugin plugin = (Plugin) c.newInstance(); - if ( plugin instanceof Plugin ) { + if (plugin instanceof Plugin) { - manager.addPlugin(plugin, props, plugin_dir.getCanonicalPath()); + manager.addPlugin(plugin, props, plugin_dir + .getCanonicalPath()); } - }catch( Throwable e ) { + } catch (Throwable e) { - System.out.println( "Load of Plugin in '" + plugin_dir + "' fails"); + System.out.println("Load of Plugin in '" + plugin_dir + + "' fails"); e.printStackTrace(); } } } - private static ClassLoader - getRootClassLoader( - File dir ) - { + private static ClassLoader getRootClassLoader (File dir) { ClassLoader root_class_loader = PluginLoader.class.getClassLoader(); - dir = new File( dir, "shared" ); - if ( dir.exists() && dir.isDirectory()){ + dir = new File(dir, "shared"); + if (dir.exists() && dir.isDirectory()) { - File[] files = dir.listFiles(); + File[] files = dir.listFiles(); - if ( files != null ) { + if (files != null) { files = getHighestJarVersions(files); - for (int i=0;i<files.length;i++) { + for (int i = 0; i < files.length; i++) { root_class_loader = addFileToClassPath(root_class_loader, - root_class_loader, files[i] ); + root_class_loader, files[i]); } } @@ -182,174 +191,165 @@ return root_class_loader; } - private static File - getApplicationFile( - String filename) - { + private static File getApplicationFile (String filename) { String path = SystemProperties.getApplicationPath(); - if (Constants.isOSX ) { + if (Constants.isOSX) { - path = path + "/" + SystemProperties.getApplicationName() + ".app/Contents/"; + path = path + "/" + SystemProperties.getApplicationName() + + ".app/Contents/"; } return new File(path, filename); } - public static File[] getHighestJarVersions (File[] files) // currently the version of last versioned jar found... + public static File[] getHighestJarVersions (File[] files) // currently the version of last versioned jar found... { - List res = new ArrayList(); - Map version_map = new HashMap(); + List<File> res = new ArrayList<File>(); + Map<String, String> version_map = new HashMap<String, String>(); - for (int i=0;i<files.length;i++){ + for (int i = 0; i < files.length; i++) { - File f = files[i]; + File f = files[i]; - String name = f.getName().toLowerCase(); + String name = f.getName().toLowerCase(); - if ( name.endsWith(".jar") ) { - System.out.println("Checking: "+name); + if (name.endsWith(".jar")) { + System.out.println("Checking: " + name); int cvs_pos = name.lastIndexOf("_cvs"); int sep_pos; - if (cvs_pos <= 0) + if (cvs_pos <= 0) { sep_pos = name.lastIndexOf("_"); - else + } else { sep_pos = name.lastIndexOf("_", cvs_pos - 1); + } - String prefix; + String prefix; - String version;; + String version; + ; + if (sep_pos == -1 || sep_pos == name.length() - 1 + || !Character.isDigit(name.charAt(sep_pos + 1))) { - if ( sep_pos == -1 || - sep_pos == name.length()-1 || - !Character.isDigit(name.charAt(sep_pos+1))){ - prefix = name.substring(0, name.indexOf('.')); version = "-1.0"; } else { - prefix = name.substring(0,sep_pos); + prefix = name.substring(0, sep_pos); - version = name.substring(sep_pos+1, (cvs_pos <= 0) ? name.length()-4 : cvs_pos); + version = name.substring(sep_pos + 1, (cvs_pos <= 0) ? name + .length() - 4 : cvs_pos); } - String prev_version = (String)version_map.get(prefix); + String prev_version = version_map.get(prefix); - if ( prev_version == null ){ + if (prev_version == null) { - version_map.put( prefix, version ); + version_map.put(prefix, version); } else { - if ( compareVersions( prev_version, version ) < 0 ){ + if (compareVersions(prev_version, version) < 0) { - version_map.put( prefix, version ); + version_map.put(prefix, version); } } } } - Iterator it = version_map.keySet().iterator(); + Iterator<String> it = version_map.keySet().iterator(); - while(it.hasNext()){ + while (it.hasNext()) { - String prefix = (String)it.next(); - String version = (String)version_map.get(prefix); - String target; - if (version.equalsIgnoreCase("-1.0")) + String prefix = it.next(); + String version = version_map.get(prefix); + String target; + if (version.equalsIgnoreCase("-1.0")) { target = prefix; - else + } else { target = prefix + "_" + version; + } - for (int i=0;i<files.length;i++){ + for (int i = 0; i < files.length; i++) { - File f = files[i]; + File f = files[i]; - String lc_name = f.getName().toLowerCase(); + String lc_name = f.getName().toLowerCase(); - if ( lc_name.equals( target + ".jar" ) || - lc_name.equals( target + "_cvs.jar" )){ - System.out.println("Adding "+target+" to PluginClasspath."); - res.add( f ); + if (lc_name.equals(target + ".jar") + || lc_name.equals(target + "_cvs.jar")) { + System.out.println("Adding " + target + + " to PluginClasspath."); + res.add(f); break; } } } - File[] res_array = new File[res.size()]; + File[] res_array = new File[res.size()]; - res.toArray( res_array ); + res.toArray(res_array); - return( res_array ); + return (res_array); } - public static int - compareVersions( - String version_1, - String version_2 ) - { - try{ - if ( version_1.startsWith("." )){ + public static int compareVersions (String version_1, String version_2) { + try { + if (version_1.startsWith(".")) { version_1 = "0" + version_1; } - if ( version_2.startsWith("." )){ + if (version_2.startsWith(".")) { version_2 = "0" + version_2; } - StringTokenizer tok1 = new StringTokenizer(version_1,"."); - StringTokenizer tok2 = new StringTokenizer(version_2,"."); + StringTokenizer tok1 = new StringTokenizer(version_1, "."); + StringTokenizer tok2 = new StringTokenizer(version_2, "."); - while( true ){ - if ( tok1.hasMoreTokens() && tok2.hasMoreTokens()){ + while (true) { + if (tok1.hasMoreTokens() && tok2.hasMoreTokens()) { - int i1 = Integer.parseInt(tok1.nextToken()); - int i2 = Integer.parseInt(tok2.nextToken()); + int i1 = Integer.parseInt(tok1.nextToken()); + int i2 = Integer.parseInt(tok2.nextToken()); - if ( i1 != i2 ){ + if (i1 != i2) { - return( i1 - i2 ); + return (i1 - i2); } - }else if ( tok1.hasMoreTokens()){ + } else if (tok1.hasMoreTokens()) { - int i1 = Integer.parseInt(tok1.nextToken()); + int i1 = Integer.parseInt(tok1.nextToken()); - if ( i1 != 0 ){ + if (i1 != 0) { - return( 1 ); + return (1); } - }else if ( tok2.hasMoreTokens()){ + } else if (tok2.hasMoreTokens()) { - int i2 = Integer.parseInt(tok2.nextToken()); + int i2 = Integer.parseInt(tok2.nextToken()); - if ( i2 != 0 ){ + if (i2 != 0) { - return( -1 ); + return (-1); } - }else{ - return( 0 ); + } else { + return (0); } } - }catch( Throwable e ){ + } catch (Throwable e) { e.printStackTrace(); - return( 0 ); + return (0); } } - public static ClassLoader - addFileToClassPath( - ClassLoader root, - ClassLoader classLoader, - File f) - { - if ( f.exists() && - (!f.isDirectory())&& - f.getName().endsWith(".jar")){ + public static ClassLoader addFileToClassPath (ClassLoader root, + ClassLoader classLoader, File f) { + if (f.exists() && (!f.isDirectory()) && f.getName().endsWith(".jar")) { try { @@ -358,26 +358,25 @@ // make sure that all of our added URLs end up within a single URLClassloader // with its parent being the one that loaded this class itself - if ( classLoader instanceof URLClassLoader ){ + if (classLoader instanceof URLClassLoader) { - URL[] old = ((URLClassLoader)classLoader).getURLs(); + URL[] old = ((URLClassLoader) classLoader).getURLs(); - URL[] new_urls = new URL[old.length+1]; + URL[] new_urls = new URL[old.length + 1]; - System.arraycopy( old, 0, new_urls, 0, old.length ); + System.arraycopy(old, 0, new_urls, 0, old.length); - new_urls[new_urls.length-1]= f.toURL(); + new_urls[new_urls.length - 1] = f.toURL(); - classLoader = new URLClassLoader( - new_urls, - classLoader==root? - classLoader: - classLoader.getParent()); - }else{ + classLoader = new URLClassLoader(new_urls, + classLoader == root ? classLoader : classLoader + .getParent()); + } else { - classLoader = new URLClassLoader(new URL[]{f.toURL()},classLoader); + classLoader = new URLClassLoader(new URL[] { f.toURL() }, + classLoader); } - }catch( Exception e){ + } catch (Exception e) { // don't use Debug/lglogger here as we can be called before AZ has been initialised @@ -385,6 +384,6 @@ } } - return( classLoader ); + return (classLoader); } } Modified: trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/ipc/IPCInterfaceImpl.java =================================================================== --- trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/ipc/IPCInterfaceImpl.java 2008-11-16 19:48:49 UTC (rev 1698) +++ trunk/azsmrc/lbms/azsmrc/remote/client/pluginsimpl/ipc/IPCInterfaceImpl.java 2008-11-16 21:40:23 UTC (rev 1699) @@ -19,7 +19,7 @@ reference = new WeakReference<Object>(_target); } - public Object invoke(String methodName, Object[] params) + public Object invoke (String methodName, Object[] params) throws IPCException { Object target = reference.get(); @@ -33,7 +33,7 @@ params = new Object[0]; } - Class[] paramTypes = new Class[params.length]; + Class<?>[] paramTypes = new Class[params.length]; for (int i = 0; i < params.length; i++) { if (params[i] instanceof Boolean) { paramTypes[i] = boolean.class; @@ -69,7 +69,7 @@ Method method = methods[i]; - Class[] method_params = method.getParameterTypes(); + Class<?>[] method_params = method.getParameterTypes(); if (method.getName().equals(methodName) && method_params.length == paramTypes.length) { @@ -78,8 +78,8 @@ for (int j = 0; j < method_params.length; j++) { - Class declared = method_params[j]; - Class supplied = paramTypes[j]; + Class<?> declared = method_params[j]; + Class<?> supplied = paramTypes[j]; if (!declared.isAssignableFrom(supplied)) { Modified: trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/RCMain.java =================================================================== --- trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/RCMain.java 2008-11-16 19:48:49 UTC (rev 1698) +++ trunk/azsmrc/lbms/azsmrc/remote/client/swtgui/RCMain.java 2008-11-16 21:40:23 UTC (rev 1699) @@ -98,59 +98,66 @@ public class RCMain { - public static final String LOGGER_ROOT = "lbms.azsmrc"; - public static final String USER_DIR = System.getProperty("user.dir"); - public static final String FSEP = System.getProperty("file.separator"); + public static final String LOGGER_ROOT = "lbms.azsmrc"; + public static final String USER_DIR = System + .getProperty("user.dir"); + public static final String FSEP = System + .getProperty("file.separator"); - protected Shell shell; - protected Display display; - private static RCMain rcMain; - private Client client; - private ExtendedProperties properties; - private Properties azsmrcProperties; - private File confFile; - private Timer timer; - private TimerEventPeriodic updateTimer; - private boolean connect; - private Logger logger; - private Updater updater; - private Proxy proxy; - private PluginManagerImpl pluginManager; + protected Shell shell; + protected Display display; + private static RCMain rcMain; + private Client client; + private ExtendedProperties properties; + private Properties azsmrcProperties; + private File confFile; + private Timer timer; + private TimerEventPeriodic updateTimer; + private boolean connect; + private Logger logger; + private Updater updater; + private Proxy proxy; + private PluginManagerImpl pluginManager; - private TrayItem systrayItem; - private DownloadManagerShell mainWindow; - private long runTime; - private boolean manifestInUse; - private StartServer startServer; + private TrayItem systrayItem; + private DownloadManagerShell mainWindow; + private long runTime; + private boolean manifestInUse; + private StartServer startServer; - private boolean firstRun; + private boolean firstRun; - // I18N prefix - public static final String PFX = "rcmain."; + public static final String PFX = "rcmain."; - private Transferable emptyTransfer = new Transferable() { - private DataFlavor[] emptyArray = new DataFlavor[0]; - public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { - throw new UnsupportedFlavorException(flavor); - } + private Transferable emptyTransfer = new Transferable() { + private DataFlavor[] emptyArray = new DataFlavor[0]; - public DataFlavor[] getTransferDataFlavors() { - return emptyArray; - } + public Object getTransferData ( + DataFlavor flavor) + throws UnsupportedFlavorException, + IOException { + throw new UnsupportedFlavorException( + flavor); + } - public boolean isDataFlavorSupported(DataFlavor flavor) { - return false; - } - }; + public DataFlavor[] getTransferDataFlavors () { + return emptyArray; + } - protected boolean terminated, failedConnection; + public boolean isDataFlavorSupported ( + DataFlavor flavor) { + return false; + } + }; - public static void main(String[] args) { + protected boolean terminated, failedConnection; + + public static void main (String[] args) { start(args); } - public static boolean start(String[] args) { + public static boolean start (String[] args) { if (rcMain == null) { //if it is launched by launchable then rcMain should already exist new RCMain(); } @@ -168,22 +175,23 @@ startServer = new StartServer(); - if (args.length > 0 && args[0].equalsIgnoreCase( "--closedown" )){ - closedown = true; + if (args.length > 0 && args[0].equalsIgnoreCase("--closedown")) { + closedown = true; } boolean another_instance = startServer.getState() != StartServer.STATE_LISTENING; - if( another_instance && !properties.getPropertyAsBoolean("multiInstance") ) { + if (another_instance + && !properties.getPropertyAsBoolean("multiInstance")) { StartSocket ss = new StartSocket(args); closedown = true; - if( !ss.sendArgs() ) { //arg passing attempt failed, so start core anyway + if (!ss.sendArgs()) { //arg passing attempt failed, so start core anyway closedown = false; String msg = "There appears to be another program process already listening on socket [127.0.0.1: 6880].\nLoading of torrents via command line parameter will fail until this is fixed."; - System.out.println( msg ); + System.out.println(msg); } } else { - String[] args2 = new String[args.length+1]; + String[] args2 = new String[args.length + 1]; args2[0] = "args"; System.arraycopy(args, 0, args2, 1, args.length); startServer.processArgs(args2); @@ -198,14 +206,14 @@ return true; } - public void open() { + public void open () { DownloadContainer.loadColumns(); SeedContainer.loadColumns(); terminated = false; display.asyncExec(new SWTSafeRunnable() { @Override - public void runSafe() { + public void runSafe () { createContents(); } }); @@ -213,7 +221,8 @@ connect = properties.getPropertyAsBoolean("auto_connect"); if (connect) { try { - LoginData login = new LoginData(properties.getProperty("lastConnection","")); + LoginData login = new LoginData(properties.getProperty( + "lastConnection", "")); if (login.isComplete()) { connect(false); updateTimer(properties.getPropertyAsBoolean("auto_open")); @@ -225,7 +234,8 @@ connect = false; } } - File error = new File(System.getProperty("user.dir")+System.getProperty("file.separator")+"error.log"); + File error = new File(System.getProperty("user.dir") + + System.getProperty("file.separator") + "error.log"); if (error.exists()) { System.out.println("Crash Detected"); ErrorDialog.createAndOpen(); @@ -235,8 +245,8 @@ System.out.println("openQueuedTorrents"); startServer.openQueuedTorrents(); while (!terminated) { //runnig - if (!display.readAndDispatch ()) { - display.sleep (); + if (!display.readAndDispatch()) { + display.sleep(); } } if (mainWindow != null) { //cleanup @@ -245,52 +255,52 @@ shutdown(); display.dispose(); /* - * Have yet to trace the reason why, but OSX will not - * kill the whole application on SWT disposal- call exit to force end. + * Have yet to trace the reason why, but OSX will not kill the whole + * application on SWT disposal- call exit to force end. */ - if(Utilities.isOSX) { + if (Utilities.isOSX) { System.exit(0); } } - protected void createContents() { + protected void createContents () { shell = new Shell(); SplashScreen.setProgressAndText("Loading Images", 80); ImageRepository.preloadImages(display); SplashScreen.setProgressAndText("Creating GUI", 90); -/* //Show Splash - if(properties.getPropertyAsBoolean("show_splash",true)){ - SplashScreen.open(getDisplay(), 20); - }*/ + /* + * //Show Splash + * if(properties.getPropertyAsBoolean("show_splash",true)){ + * SplashScreen.open(getDisplay(), 20); } + */ - final Tray systray = display.getSystemTray (); + final Tray systray = display.getSystemTray(); if (systray != null) { - systrayItem = new TrayItem (systray, SWT.NONE); + systrayItem = new TrayItem(systray, SWT.NONE); //Listener for the system tray - systrayItem.addSelectionListener(new SelectionListener() - { - public void widgetDefaultSelected(SelectionEvent arg0) { + systrayItem.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected (SelectionEvent arg0) { // this is a double click .. if we ever want to do something with this // do it here } - public void widgetSelected(SelectionEvent arg0) { + public void widgetSelected (SelectionEvent arg0) { //normal selection is a single click - try{ + try { Shell dms_shell = getMainWindow().getShell(); - if(dms_shell.getMinimized()){ + if (dms_shell.getMinimized()) { dms_shell.setMinimized(false); dms_shell.setVisible(true); - } else{ + } else { dms_shell.setMinimized(true); dms_shell.setVisible(false); } - }catch(Exception e1){ + } catch (Exception e1) { if (mainWindow == null) { mainWindow = new DownloadManagerShell(); } @@ -309,21 +319,22 @@ setTrayIcon(0); //Open mainWindow if AutoOpen is true - if(properties.getPropertyAsBoolean("auto_open")){ + if (properties.getPropertyAsBoolean("auto_open")) { if (mainWindow == null) { mainWindow = new DownloadManagerShell(); } mainWindow.open(); } - final Menu menu = new Menu(shell, SWT.POP_UP); final MenuItem openMainWindowMenuItem = new MenuItem(menu, SWT.PUSH); - openMainWindowMenuItem.setText(I18N.translate(PFX + "traymenu.openMainWindow")); + openMainWindowMenuItem.setText(I18N.translate(PFX + + "traymenu.openMainWindow")); final MenuItem openStatusShellMenuItem = new MenuItem(menu, SWT.PUSH); - openStatusShellMenuItem.setText(I18N.translate(PFX + "traymenu.openStatusShell")); + openStatusShellMenuItem.setText(I18N.translate(PFX + + "traymenu.openStatusShell")); final MenuItem addMenuItem = new MenuItem(menu, SWT.CASCADE); addMenuItem.setText(I18N.translate(PFX + "traymenu.add")); @@ -331,10 +342,10 @@ final Menu addMenu = new Menu(addMenuItem); addMenuItem.setMenu(addMenu); - final MenuItem addByFile = new MenuItem(addMenu,SWT.PUSH); + final MenuItem addByFile = new MenuItem(addMenu, SWT.PUSH); addByFile.setText(I18N.translate(PFX + "traymenu.add.byFile")); - final MenuItem addByUrl = new MenuItem(addMenu,SWT.PUSH); + final MenuItem addByUrl = new MenuItem(addMenu, SWT.PUSH); addByUrl.setText(I18N.translate(PFX + "traymenu.add.byURL")); final MenuItem quickMenuItem = new MenuItem(menu, SWT.CASCADE); @@ -343,29 +354,36 @@ final Menu quickMenu = new Menu(quickMenuItem); quickMenuItem.setMenu(quickMenu); - final MenuItem pauseDownloads_1min = new MenuItem(quickMenu,SWT.PUSH); - pauseDownloads_1min.setText(I18N.translate(PFX + "traymenu.quickmenu.pause1min")); + final MenuItem pauseDownloads_1min = new MenuItem(quickMenu, SWT.PUSH); + pauseDownloads_1min.setText(I18N.translate(PFX + + "traymenu.quickmenu.pause1min")); - final MenuItem pauseDownloads_5min = new MenuItem(quickMenu,SWT.PUSH); - pauseDownloads_5min.setText(I18N.translate(PFX + "traymenu.quickmenu.pause5min")); + final MenuItem pauseDownloads_5min = new MenuItem(quickMenu, SWT.PUSH); + pauseDownloads_5min.setText(I18N.translate(PFX + + "traymenu.quickmenu.pause5min")); - final MenuItem pauseDownloads_UserSpecified = new MenuItem(quickMenu, SWT.PUSH); - pauseDownloads_UserSpecified.setText(I18N.translate(PFX + "traymenu.quickmenu.pauseUserSpecified")); + final MenuItem pauseDownloads_UserSpecified = new MenuItem(quickMenu, + SWT.PUSH); + pauseDownloads_UserSpecified.setText(I18N.translate(PFX + + "traymenu.quickmenu.pauseUserSpecified")); - new MenuItem (menu, SWT.SEPARATOR); + new MenuItem(menu, SWT.SEPARATOR); final MenuItem connectDisconnectMenuItem = new MenuItem(menu, SWT.PUSH); if (!connect) { - connectDisconnectMenuItem.setText(I18N.translate(PFX + "traymenu.connect")); + connectDisconnectMenuItem.setText(I18N.translate(PFX + + "traymenu.connect")); } else { - connectDisconnectMenuItem.setText(I18N.translate(PFX + "traymenu.disconnect")); + connectDisconnectMenuItem.setText(I18N.translate(PFX + + "traymenu.disconnect")); } final MenuItem silentItem = new MenuItem(menu, SWT.CHECK); silentItem.setText(I18N.translate(PFX + "traymenu.silentMode")); final MenuItem disablePopupItem = new MenuItem(menu, SWT.CHECK); - disablePopupItem.setText(I18N.translate(PFX + "traymenu.disablePopups")); + disablePopupItem + .setText(I18N.translate(PFX + "traymenu.disablePopups")); final MenuItem closeMenuItem = new MenuItem(menu, SWT.PUSH); closeMenuItem.setText(I18N.translate(PFX + "traymenu.close")); @@ -374,7 +392,7 @@ openMainWindowMenuItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { if (mainWindow == null) { mainWindow = new DownloadManagerShell(); mainWindow.open(); @@ -382,35 +400,36 @@ } }); - openStatusShellMenuItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { StatusShell.open(); } }); closeMenuItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { terminated = true; } }); connectDisconnectMenuItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { if (connect) { - connectDisconnectMenuItem.setText(I18N.translate(PFX + "traymenu.connect")); + connectDisconnectMenuItem.setText(I18N.translate(PFX + + "traymenu.connect")); disconnect(); setTrayIcon(0); - if(mainWindow != null){ + if (mainWindow != null) { mainWindow.setConnectionStatusBar(0); mainWindow.setLogInOutButtons(false); mainWindow.clearMapsAndChildred(); } } else { - connectDisconnectMenuItem.setText(I18N.translate(PFX + "traymenu.disconnect")); + connectDisconnectMenuItem.setText(I18N.translate(PFX + + "traymenu.disconnect")); client.sendGetGlobalStats(); if (mainWindow != null) { connect(true); @@ -423,89 +442,102 @@ }); //----------listener for the menu before it opens------\\ - menu.addMenuListener(new MenuListener(){ + menu.addMenuListener(new MenuListener() { - public void menuHidden(MenuEvent arg0) { + public void menuHidden (MenuEvent arg0) { } - public void menuShown(MenuEvent arg0) { - if (!connect){ - connectDisconnectMenuItem.setText(I18N.translate(PFX + "traymenu.connect")); + public void menuShown (MenuEvent arg0) { + if (!connect) { + connectDisconnectMenuItem.setText(I18N.translate(PFX + + "traymenu.connect")); addMenuItem.setEnabled(false); quickMenuItem.setEnabled(false); - }else{ - connectDisconnectMenuItem.setText(I18N.translate(PFX + "traymenu.disconnect")); + } else { + connectDisconnectMenuItem.setText(I18N.translate(PFX + + "traymenu.disconnect")); addMenuItem.setEnabled(true); quickMenuItem.setEnabled(true); } silentItem.setSelection(SoundManager.isSilent()); - disablePopupItem.setSelection(!properties.getPropertyAsBoolean("popups_enabled")); + disablePopupItem.setSelection(!properties + .getPropertyAsBoolean("popups_enabled")); } }); addByUrl.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { OpenByURLDialog.open(); } }); addByFile.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { OpenByFileDialog.open(); } }); pauseDownloads_1min.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { client.getDownloadManager().pauseDownloads(60); } }); pauseDownloads_5min.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { client.getDownloadManager().pauseDownloads(300); } }); - pauseDownloads_UserSpecified.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - try{ - InputShell is = new InputShell(I18N.translate(PFX + "traymenu.quickmenu.pauseUserSpecified.inputShell.title"), - I18N.translate(PFX + "traymenu.quickmenu.pauseUserSpecified.inputShell.message")); - String str_minutes = is.open(); - int mins = Integer.parseInt(str_minutes); - client.getDownloadManager().pauseDownloads(mins*60); - logger.info("Pausing all downloads for " + mins*60 + " seconds (" + mins + " minutes)"); - }catch(Exception ex) {} + pauseDownloads_UserSpecified + .addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected (SelectionEvent e) { + try { + InputShell is = new InputShell( + I18N + .translate(PFX + + "traymenu.quickmenu.pauseUserSpecified.inputShell.title"), + I18N + .translate(PFX + + "traymenu.quickmenu.pauseUserSpecified.inputShell.message")); + String str_minutes = is.open(); + int mins = Integer.parseInt(str_minutes); + client.getDownloadManager().pauseDownloads( + mins * 60); + logger.info("Pausing all downloads for " + mins + * 60 + " seconds (" + mins + " minutes)"); + } catch (Exception ex) { + } + } + }); - } - }); - silentItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected (SelectionEvent e) { SoundManager.setSilentMode(silentItem.getSelection()); } }); disablePopupItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { - properties.setProperty("popups_enabled", silentItem.getSelection()); + public void widgetSelected (SelectionEvent e) { + properties.setProperty("popups_enabled", !disablePopupItem + .getSelection()); } }); if (systrayItem != null) { - systrayItem.addListener (SWT.MenuDetect, new Listener () { + systrayItem.addListener(SWT.MenuDetect, new Listener() { public void handleEvent (Event event) { - try{ - menu.setVisible (true); - }catch (Exception e){} + try { + menu.setVisible(true); + } catch (Exception e) { + } } }); } @@ -519,14 +551,15 @@ } } - private void initConfig() { - confFile = new File(USER_DIR+FSEP+"config.cfg"); + private void initConfig () { + confFile = new File(USER_DIR + FSEP + "config.cfg"); properties = null; { Properties defaultProps = new Properties(); InputStream is = null; try { - is = RCMain.class.getClassLoader().getResourceAsStream("default.cfg"); + is = RCMain.class.getClassLoader().getResourceAsStream( + "default.cfg"); defaultProps.loadFromXML(is); is.close(); properties = new ExtendedProperties(defaultProps); //read in default values @@ -534,8 +567,11 @@ properties = new ExtendedProperties(); //if something happens create empty properties e1.printStackTrace(); } finally { - if (is!=null) { - try { is.close(); } catch (IOException e) {} + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } } } } @@ -548,9 +584,12 @@ properties.loadFromXML(fin); } catch (IOException e) { e.printStackTrace(); - } finally { - if (fin!=null) { - try { fin.close(); } catch (IOException e) {} + } finally { + if (fin != null) { + try { + fin.close(); + } catch (IOException e) { + } } } } @@ -558,14 +597,18 @@ { InputStream is = null; try { - is = RCMain.class.getClassLoader().getResourceAsStream("azsmrc.properties"); + is = RCMain.class.getClassLoader().getResourceAsStream( + "azsmrc.properties"); azsmrcProperties.load(is); is.close(); } catch (IOException e1) { e1.printStackTrace(); } finally { - if (is!=null) { - try { is.close(); } catch (IOException e) {} + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } } } } @@ -579,17 +622,18 @@ System.out.println("Checking javaw.exe.manifest"); javawExeManifest(); - if(properties.getPropertyAsBoolean("show_splash")){ + if (properties.getPropertyAsBoolean("show_splash")) { SplashScreen.open(display, 20); } - SplashScreen.setProgressAndText("Creating Logger.",10); + SplashScreen.setProgressAndText("Creating Logger.", 10); PropertyConfigurator.configure(Loader.getResource("log4j.properties")); logger = Logger.getLogger(LOGGER_ROOT); - SplashScreen.setProgressAndText("Loading I18N.",15); + SplashScreen.setProgressAndText("Loading I18N.", 15); try { if (properties.getProperty("language") != null) { - I18N.setLocalized("lbms/azsmrc/remote/client/internat/"+properties.getProperty("language")+".lang"); + I18N.setLocalized("lbms/azsmrc/remote/client/internat/" + + properties.getProperty("language") + ".lang"); } I18N.reload(); if (I18N.isInitialized()) { @@ -602,35 +646,48 @@ e1.printStackTrace(); } - SplashScreen.setProgressAndText("Loading Plugins.",20); + SplashScreen.setProgressAndText("Loading Plugins.", 20); pluginManager = new PluginManagerImpl(); PluginLoader.findAndLoadPlugins(pluginManager, getProperties()); - SESecurityManager.getSingleton().addSecurityListner(new SESecurityManagerListener() { - public boolean trustCertificate(String ressource, X509Certificate x509_cert) { - // TODO Change it - logger.debug("Trusting Certificate: "+ressource); - return true; - } - }); - SplashScreen.setProgressAndText("Creating Client.",25); + SESecurityManager.getSingleton().addSecurityListner( + new SESecurityManagerListener() { + public boolean trustCertificate (String ressource, + X509Certificate x509_cert) { + // TODO Change it + logger.debug("Trusting Certificate: " + ressource); + return true; + } + }); + SplashScreen.setProgressAndText("Creating Client.", 25); try { - LoginData login = new LoginData(properties.getProperty("lastConnection","")); + LoginData login = new LoginData(properties.getProperty( + "lastConnection", "")); client = new Client(login); } catch (MalformedURLException e1) { client = new Client(); } if (properties.getPropertyAsBoolean("connection.proxy.use")) { - Proxy.Type type = Proxy.Type.valueOf(properties.getProperty("connection.proxy.type")); - InetSocketAddress inetAddress = new InetSocketAddress(properties.getProperty("connection.proxy.url"),properties.getPropertyAsInt("connection.proxy.port")); - proxy = new Proxy(type,inetAddress); - if (properties.getProperty("connection.proxy.username") != null && properties.getProperty("connection.proxy.password") != null) { + Proxy.Type type = Proxy.Type.valueOf(properties + .getProperty("connection.proxy.type")); + InetSocketAddress inetAddress = new InetSocketAddress(properties + .getProperty("connection.proxy.url"), properties + .getPropertyAsInt("connection.proxy.port")); + proxy = new Proxy(type, inetAddress); + if (properties.getProperty("connection.proxy.username") != null + && properties.getProperty("connection.proxy.password") != null) { Authenticator.setDefault(new Authenticator() { - PasswordAuthentication pw = new PasswordAuthentication(properties.getProperty("connection.proxy.username"),properties.getProperty("connection.proxy.password").toCharArray()); + PasswordAuthentication pw = new PasswordAuthentication( + properties + .getProperty("connection.proxy.username"), + properties + .getProperty( + "connection.proxy.password") + .toCharArray()); @Override - protected PasswordAuthentication getPasswordAuthentication() { + protected PasswordAuthentication getPasswordAuthentication () { return pw; } }); @@ -639,21 +696,43 @@ } client.setFastMode(properties.getPropertyAsBoolean("client.fastmode")); client.addGlobalStatsListener(new GlobalStatsListener() { - public void updateStats(final int d, final int u, final int seeding, final int seedqueue, final int downloading, final int downloadqueue) { - if(display != null) { + public void updateStats (final int d, final int u, + final int seeding, final int seedqueue, + final int downloading, final int downloadqueue) { + if (display != null) { display.syncExec(new SWTSafeRunnable() { @Override - public void runSafe() { + public void runSafe () { //setTrayToolTip("AzSMRC: D:"+DisplayFormatters.formatByteCountToBase10KBEtcPerSec(d)+" - U:"+DisplayFormatters.formatByteCountToBase10KBEtcPerSec(u)); - setTrayToolTip(seeding + " ("+ seedqueue+") " - + I18N.translate(PFX + "tray.tooltip.part1") + " " - + downloading + " ("+ downloadqueue+") " - + I18N.translate(PFX + "tray.tooltip.part2") + "\n" - + I18N.translate(PFX + "tray.tooltip.part3") - + " "+DisplayFormatters.formatByteCountToBase10KBEtcPerSec(d) - + I18N.translate(PFX + "tray.tooltip.part4") - + " "+DisplayFormatters.formatByteCountToBase10KBEtcPerSec(u)); + setTrayToolTip(seeding + + " (" + + seedqueue + + ") " + + I18N + .translate(PFX + + "tray.tooltip.part1") + + " " + + downloading + + " (" + + downloadqueue + + ") " + + I18N + .translate(PFX + + "tray.tooltip.part2") + + "\n" + + I18N + .translate(PFX + + "tray.tooltip.part3") + + " " + + DisplayFormatters + .formatByteCountToBase10KBEtcPerSec(d) + + I18N + .translate(PFX + + "tray.tooltip.part4") + + " " + + DisplayFormatters + .formatByteCountToBase10KBEtcPerSec(u)); } }); } @@ -661,184 +740,284 @@ }); client.addHTTPErrorListener(new HTTPErrorListener() { - public void httpError(int statusCode) { + public void httpError (int statusCode) { if (statusCode == UNAUTHORIZED) { if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.failed") + " " + statusCode - + I18N.translate(PFX + "mainwindow.statusbar.badUsername_badPassword"), SWT.COLOR_RED); + mainWindow + .setStatusBarText( + I18N + .translate(PFX + + "mainwindow.statusbar.failed") + + " " + + statusCode + + I18N + .translate(PFX + + "mainwindow.statusbar.badUsername_badPassword"), + SWT.COLOR_RED); } - logger.warn("Connection failed: " + statusCode + " Bad Username or Password"); - new MessageSlideShell(display,SWT.ICON_ERROR,I18N.translate(PFX + "mainwindow.statusbar.failed"),statusCode + " " + I18N.translate(PFX + "mainwindow.statusbar.badUsername_badPassword"),(String)null); - /*MessageDialog.error(display,I18N.translate(PFX + "mainwindow.statusbar.failed") - ,statusCode + " " + I18N.translate(PFX + "mainwindow.statusbar.badUsername_badPassword"));*/ + logger.warn("Connection failed: " + statusCode + + " Bad Username or Password"); + new MessageSlideShell( + display, + SWT.ICON_ERROR, + I18N.translate(PFX + "mainwindow.statusbar.failed"), + statusCode + + " " + + I18N + .translate(PFX + + "mainwindow.statusbar.badUsername_badPassword"), + (String) null); + /* + * MessageDialog.error(display,I18N.translate(PFX + + * "mainwindow.statusbar.failed") ,statusCode + " " + + * I18N.translate(PFX + + * "mainwindow.statusbar.badUsername_badPassword")); + */ disconnect(); } else { if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.failed") + " "+statusCode, SWT.COLOR_RED); + mainWindow.setStatusBarText(I18N.translate(PFX + + "mainwindow.statusbar.failed") + + " " + statusCode, SWT.COLOR_RED); } - logger.warn("Connection failed: "+statusCode); + logger.warn("Connection failed: " + statusCode); } } }); client.addConnectionListener(new ConnectionListener() { - public void connectionState(final int state) { - logger.debug("Connection State: "+state); - if(display != null) { + public void connectionState (final int state) { + logger.debug("Connection State: " + state); + if (display != null) { display.syncExec(new SWTSafeRunnable() { @Override - public void runSafe() { + public void runSafe () { setTrayIcon(state); } }); } if (state == ST_CONNECTION_ERROR) { - int delay = client.getFailedConnections()*30000; - delay = (delay>120000)?120000:delay; - logger.warn("Connection failed "+client.getFailedConnections()+" times, delay: "+(delay/1000)+"sec"); + int delay = client.getFailedConnections() * 30000; + delay = (delay > 120000) ? 120000 : delay; + logger.warn("Connection failed " + + client.getFailedConnections() + " times, delay: " + + (delay / 1000) + "sec"); if (mainWindow != null) { - updateTimer(true,delay); + updateTimer(true, delay); } else { - updateTimer(false,delay); + updateTimer(false, delay); } if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.failed") + " " + mainWindow.setStatusBarText(I18N.translate(PFX + + "mainwindow.statusbar.failed") + + " " + client.getFailedConnections() - + " " + I18N.translate(PFX + "mainwindow.statusbar.numTimes"), SWT.COLOR_RED); + + " " + + I18N.translate(PFX + + "mainwindow.statusbar.numTimes"), + SWT.COLOR_RED); } failedConnection = true; - if(client.getFailedConnections() > 0 && client.getFailedConnections()%3 == 0){ - new MessageSlideShell(RCMain.getRCMain().getDisplay(),SWT.ICON_ERROR, - I18N.translate(PFX + "mainwindow.statusbar.connectionError") - ,I18N.translate(PFX + "mainwindow.statusbar.connectionError.failed") - + " " + RCMain.getRCMain().getClient().getFailedConnections() + " " - + I18N.translate(PFX + "mainwindow.statusbar.connectionError.failed_part2"), - (String)null); + if (client.getFailedConnections() > 0 + && client.getFailedConnections() % 3 == 0) { + new MessageSlideShell( + RCMain.getRCMain().getDisplay(), + SWT.ICON_ERROR, + I18N + .translate(PFX + + "mainwindow.statusbar.connectionError"), + I18N + .translate(PFX + + "mainwindow.statusbar.connectionError.failed") + + " " + + RCMain.getRCMain().getClient() + .getFailedConnections() + + " " + + I18N + .translate(PFX + + "mainwindow.statusbar.connectionError.failed_part2"), + (String) null); - /*MessageDialog.error(RCMain.getRCMain().getDisplay(), - I18N.translate(PFX + "mainwindow.statusbar.connectionError") - , I18N.translate(PFX + "mainwindow.statusbar.connectionError.failed") - + " " + RCMain.getRCMain().getClient().getFailedConnections() + " " - + I18N.translate(PFX + "mainwindow.statusbar.connectionError.failed_part2"));*/ - return; - } + /* + * MessageDialog.error(RCMain.getRCMain().getDisplay(), + * I18N.translate(PFX + + * "mainwindow.statusbar.connectionError") , + * I18N.translate(PFX + + * "mainwindow.statusbar.connectionError.failed") + " " + * + + * RCMain.getRCMain().getClient().getFailedConnections() + * + " " + I18N.translate(PFX + + * "mainwindow.statusbar.connectionError.failed_part2" + * )); + */ + return; + } } else if (failedConnection && (state == ST_CONNECTED)) { if (mainWindow != null) { - updateTimer(true,0); - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.connectionSuccessful") - , SWT.COLOR_DARK_GREEN); + updateTimer(true, 0); + mainWindow.setStatusBarText(I18N.translate(PFX + + "mainwindow.statusbar.connectionSuccessful"), + SWT.COLOR_DARK_GREEN); } else { - updateTimer(false,0); + updateTimer(false, 0); } } } }); client.getDownloadManager().addListener(new DownloadManagerListener() { - public void downloadAdded(Download download) { - logger.info("Download Added: "+download.getName()); + public void downloadAdded (Download download) { + logger.info("Download Added: " + download.getName()); } - public void downloadRemoved(Download download) { - logger.info("Download Removed: "+download.getName()); + + public void downloadRemoved (Download download) { + logger.info("Download Removed: " + download.getName()); }; }); client.addClientEventListener(new ClientEventListener() { - public void handleEvent(int type, long time, Element event) { + public void handleEvent (int type, long time, Element event) { String msg = event.getAttributeValue("message"); switch (type) { case RemoteConstants.EV_DL_FINISHED: if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.downloadFinished") - + " " + event.getAttributeValue("name"), SWT.COLOR_DARK_GREEN); + mainWindow.setStatusBarText(I18N.translate(PFX + + "mainwindow.statusbar.downloadFinished") + + " " + event.getAttributeValue("name"), + SWT.COLOR_DARK_GREEN); } SoundManager.playSound(Sound.DOWNLOADING_FINISHED); if (event.getAttributeValue("duration") != null) { - long duration = Long.parseLong(event.getAttributeValue("duration")); - String avgDl = (event.getAttributeValue("avgDownload") != null)?event.getAttributeValue("avgDownload") : ""; - logger.info(I18N.translate(PFX + "mainwindow.statusbar.downloadFinished")+" "+event.getAttributeValue("name") - +" "+I18N.translate(PFX + "mainwindow.statusbar.downloadFinishedIn")+DisplayFormatters.formatTime(duration*1000)+" "+avgDl); + long duration = Long.parseLong(event + .getAttributeValue("duration")); + String avgDl = (event.getAttributeValue("avgDownload") != null) ? event + .getAttributeValue("avgDownload") + : ""; + logger + .info(I18N + .translate(PFX + + "mainwindow.statusbar.downloadFinished") + + " " + + event.getAttributeValue("name") + + " " + + I18N + .translate(PFX + + "mainwindow.statusbar.downloadFinishedIn") + + DisplayFormatters + .formatTime(duration * 1000) + + " " + avgDl); new MessageSlideShell( display, SWT.ICON_INFORMATION, - I18N.translate(PFX + "mainwindow.statusbar.downloadFinished"), - event.getAttributeValue("name")+"\n"+I18N.translate(PFX + "mainwindow.statusbar.downloadFinished")+DisplayFormatters.formatTime(duration*1000)+" "+avgDl, - (String)null); - /*MessageDialog.message(display,I18N.translate(PFX + "mainwindow.statusbar.downloadFinished"), - event.getAttributeValue("name")+"\n"+I18N.translate(PFX + "mainwindow.statusbar.downloadFinished")+DisplayFormatters.formatTime(duration*1000)+" "+avgDl);*/ + I18N + .translate(PFX + + "mainwindow.statusbar.downloadFinished"), + event.getAttributeValue("name") + + "\n" + + I18N + .translate(PFX + + "mainwindow.statusbar.downloadFinished") + + DisplayFormatters + .formatTime(duration * 1000) + + " " + avgDl, (String) null); + /* + * MessageDialog.message(display,I18N.translate(PFX + + * "mainwindow.statusbar.downloadFinished"), + * event.getAttributeValue + * ("name")+"\n"+I18N.translate(PFX + + * "mainwindow.statusbar.downloadFinished" + * )+DisplayFormatters + * .formatTime(duration1000)+" "+avgDl); + */ + } else { + logger.info(I18N.translate(PFX + + "mainwindow.statusbar.downloadFinished") + + " " + event.getAttributeValue("name")); + MessageDialog.message(display, I18N.translate(PFX + + "mainwindow.statusbar.downloadFinished"), + event.getAttributeValue("name")); } - else { - logger.info(I18N.translate(PFX + "mainwindow.statusbar.downloadFinished")+" "+event.getAttributeValue("name")); - MessageDialog.message(display,I18N.translate(PFX + "mainwindow.statusbar.downloadFinished"),event.getAttributeValue("name")); - } break; case RemoteConstants.EV_DL_EXCEPTION: if (mainWindow != null) { - mainWindow.setStatusBarText("Download Exception: "+msg, SWT.COLOR_RED); + mainWindow.setStatusBarText("Download Exception: " + + msg, SWT.COLOR_RED); } - logger.error("Download Exception: "+msg); + logger.error("Download Exception: " + msg); break; case RemoteConstants.EV_EXCEPTION: if (mainWindow != null) { - mainWindow.setStatusBarText("Remote Exception: "+msg, SWT.COLOR_RED); + mainWindow.setStatusBarText("Remote Exception: " + msg, + SWT.COLOR_RED); } - logger.error(I18N.translate(PFX + "mainwindow.statusbar.remoteException") + " " + msg); + logger.error(I18N.translate(PFX + + "mainwindow.statusbar.remoteException") + + " " + msg); break; case RemoteConstants.EV_UPDATE_AVAILABLE: if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.remoteUpdateAvailable"), SWT.COLOR_DARK_GREEN); + mainWindow + .setStatusBarText( + I18N + .translate(PFX + + "mainwindow.statusbar.remoteUpdateAvailable"), + SWT.COLOR_DARK_GREEN); } logger.info("Remote Update Available"); client.getRemoteUpdateManager().load(); break; case RemoteConstants.EV_MESSAGE: if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.serverMessage") + ": " + msg); + mainWindow.setStatusBarText(I18N.translate(PFX + + "mainwindow.statusbar.serverMessage") + + ": " + msg); } - new MessageSlideShell( - display, - SWT.ICON_INFORMATION, - I18N.translate(PFX + "mainwindow.statusbar.serverMessage"), - msg, - (String)null); - /*MessageDialog.message(getDisplay(), I18N.translate(PFX + "mainwindow.statusbar.serverMessage"), msg);*/ - logger.debug("Server Message: "+msg); + new MessageSlideShell(display, SWT.ICON_INFORMATION, I18N + .translate(PFX + + "mainwindow.statusbar.serverMessage"), + msg, (String) null); + /* + * MessageDialog.message(getDisplay(), I18N.translate(PFX + + * "mainwindow.statusbar.serverMessage"), msg); + */ + logger.debug("Server Message: " + msg); break; case RemoteConstants.EV_ERROR_MESSAGE: if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.serverErrorMessage") + ": " + msg, SWT.COLOR_RED); + mainWindow.setStatusBarText(I18N.translate(PFX + + "mainwindow.statusbar.serverErrorMessage") + + ": " + msg, SWT.COLOR_RED); } - logger.error("Server ErrorMessage: "+msg); + logger.error("Server ErrorMessage: " + msg); new MessageSlideShell( display, SWT.ICON_ERROR, - I18N.translate(PFX + "mainwindow.statusbar.serverErrorMessage"), - msg, - (String)null); + I18N + .translate(PFX + + "mainwindow.statusbar.serverErrorMessage"), + msg, (String) null); //MessageDialog.error(getDisplay(), I18N.translate(PFX + "mainwindow.statusbar.serverErrorMessage"), msg); break; } } }); client.addExceptionListener(new ExceptionListener() { - public void exceptionOccured(Exception e, boolean serious) { + public void exceptionOccured (Exception e, boolean serious) { if (e instanceof SSLHandshakeException) { - new MessageSlideShell( - display, - SWT.ICON_ERROR, - "Connection Error", - "Server doesn't support SSL.", - (String)null); + new MessageSlideShell(display, SWT.ICON_ERROR, + "Connection Error", "Server doesn't support SSL.", + (String) null); //MessageDialog.message(display,true,5000,"Connection Error","Server doesn't support SSL."); disconnect(); - logger.error("Connection Error: Server doesn't support SSL."); + logger + .error("Connection Error: Server doesn't support SSL."); } } }); client.addClientUpdateListener(new ClientUpdateListener() { - public void update(long updateSwitches) { + public void update (long updateSwitches) { if ((updateSwitches & Constants.UPDATE_UPDATE_INFO) != 0) { if (client.getRemoteUpdateManager().updatesAvailable()) { ServerUpdateDialog.open(); @@ -847,89 +1026,102 @@ } }); - - SplashScreen.setProgressAndText("Creating Updater.",40); + SplashScreen.setProgressAndText("Creating Updater.", 40); try { - updater = new Updater(new URL(RemoteConstants.UPDATE_URL),new File("AzSMRCupdate.xml.gz"),new File(USER_DIR)); + updater = new Updater(new URL(RemoteConstants.UPDATE_URL), + new File("AzSMRCupdate.xml.gz"), new File(USER_DIR)); updater.setProxy(getProxy()); } catch (MalformedURLException e2) { } updater.addListener(new UpdateListener() { - public void exception(Exception e) { - System.out.println("Update Exception: "+e.getLocalizedMessage()); - System.out.println("Update Exception: "+e.getMessage()); + public void exception (Exception e) { + System.out.println("Update Exception: " + + e.getLocalizedMessage()); + System.out.println("Update Exception: " + e.getMessage()); if (mainWindow != null) { - mainWindow.setStatusBarText(I18N.translate(PFX + "mainwindow.statusbar.updateException") + ": "+e.getLocalizedMessa... [truncated message content] |