MenuFactory.java

Index Score
org.gudy.azureus2.ui.swt.mainwindow
Azureus

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
FUNCTIONSNumber of function declarations
INTERFACE_COMPLEXITYInterface complexity
PARAMSNumber of formal parameter declarations
JAVA0081JAVA0081 Boolean literal in comparison
RETURNSNumber of return points from functions
CYCLOMATICCyclomatic complexity
BLOCKSNumber of blocks
UNIQUE_OPERANDSNumber of unique operands
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
PROGRAM_VOCABHalstead program vocabulary
OPERANDSNumber of operands
JAVA0117JAVA0117 Missing javadoc: method 'method'
ELOCEffective lines of code
LOCLines of code
EXITSProcedure exits
SIZESize of the file in bytes
LOGICAL_LINESNumber of statements
LINESNumber of lines in the source file
COMPARISONSNumber of comparison operators
JAVA0145JAVA0145 Tab character used in source file
EXEC_COMMENTSComments in executable code
LOOPSNumber of loops
JAVA0034JAVA0034 Missing braces in if statement
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
WHITESPACENumber of whitespace lines
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
UNIQUE_OPERATORSNumber of unique operators
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0035JAVA0035 Missing braces in for statement
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0123JAVA0123 Use all three components of for loop
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
BLOCK_COMMENTNumber of block comment lines
NEST_DEPTHMaximum nesting depth
package org.gudy.azureus2.ui.swt.mainwindow; import java.util.Iterator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; import org.eclipse.swt.widgets.*; import org.gudy.azureus2.core3.config.COConfigurationManager; import org.gudy.azureus2.core3.config.ParameterListener; import org.gudy.azureus2.core3.download.DownloadManager; import org.gudy.azureus2.core3.internat.MessageText; import org.gudy.azureus2.core3.logging.LogEvent; import org.gudy.azureus2.core3.logging.LogIDs; import org.gudy.azureus2.core3.logging.Logger; import org.gudy.azureus2.core3.util.AERunnable; import org.gudy.azureus2.core3.util.Constants; import org.gudy.azureus2.plugins.ui.menus.MenuManager; import org.gudy.azureus2.plugins.ui.tables.TableCell; import org.gudy.azureus2.plugins.ui.tables.TableManager; import org.gudy.azureus2.plugins.ui.tables.TableRow; import org.gudy.azureus2.plugins.ui.tables.TableRowMouseListener; import org.gudy.azureus2.plugins.update.UpdateCheckInstance; import org.gudy.azureus2.plugins.update.UpdateCheckInstanceListener; import org.gudy.azureus2.pluginsimpl.local.download.DownloadManagerImpl; import org.gudy.azureus2.ui.common.util.MenuItemManager; import org.gudy.azureus2.ui.swt.*; import org.gudy.azureus2.ui.swt.components.shell.ShellManager; import org.gudy.azureus2.ui.swt.config.wizard.ConfigureWizard; import org.gudy.azureus2.ui.swt.debug.UIDebugGenerator; import org.gudy.azureus2.ui.swt.exporttorrent.wizard.ExportTorrentWizard; import org.gudy.azureus2.ui.swt.help.AboutWindow; import org.gudy.azureus2.ui.swt.help.HealthHelpWindow; import org.gudy.azureus2.ui.swt.importtorrent.wizard.ImportTorrentWizard; import org.gudy.azureus2.ui.swt.maketorrent.NewTorrentWizard; import org.gudy.azureus2.ui.swt.minibar.AllTransfersBar; import org.gudy.azureus2.ui.swt.minibar.MiniBarManager; import org.gudy.azureus2.ui.swt.nat.NatTestWindow; import org.gudy.azureus2.ui.swt.pluginsinstaller.InstallPluginWizard; import org.gudy.azureus2.ui.swt.pluginsuninstaller.UnInstallPluginWizard; import org.gudy.azureus2.ui.swt.sharing.ShareUtils; import org.gudy.azureus2.ui.swt.speedtest.SpeedTestWizard; import org.gudy.azureus2.ui.swt.update.UpdateMonitor; import org.gudy.azureus2.ui.swt.views.table.TableViewSWT; import org.gudy.azureus2.ui.swt.views.table.utils.TableContextMenuManager; import org.gudy.azureus2.ui.swt.views.utils.ManagerUtils; import org.gudy.azureus2.ui.swt.welcome.WelcomeWindow; import com.aelitis.azureus.core.AzureusCore; import com.aelitis.azureus.core.AzureusCoreFactory; import com.aelitis.azureus.core.vuzefile.VuzeFileComponent; import com.aelitis.azureus.core.vuzefile.VuzeFileHandler; import com.aelitis.azureus.ui.UIFunctions; import com.aelitis.azureus.ui.UIFunctionsManager; import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT; import com.aelitis.azureus.ui.swt.UIFunctionsSWT; public class MenuFactory implements IMenuConstants { public static boolean isAZ3_ADV = COConfigurationManager.getBooleanParameter("v3.Start Advanced"); private static boolean isAZ3 = "az3".equalsIgnoreCase(COConfigurationManager.getStringParameter("ui")); public static MenuItem createFileMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_FILE); } public static MenuItem createTransfersMenuItem(Menu menuParent) { MenuItem transferMenuItem = createTopLevelMenuItem(menuParent, MENU_ID_TRANSFERS); Menu transferMenu = transferMenuItem.getMenu(); MenuFactory.addStartAllMenuItem(transferMenu); MenuFactory.addStopAllMenuItem(transferMenu); final MenuItem itemPause = MenuFactory.addPauseMenuItem(transferMenu); final MenuItem itemResume = MenuFactory.addResumeMenuItem(transferMenu); // if (notMainWindow) { // MenuFactory.performOneTimeDisable(itemPause, true); // MenuFactory.performOneTimeDisable(itemResume, true); // } transferMenu.addMenuListener(new MenuListener() { public void menuShown(MenuEvent menu) { itemPause.setEnabled(getCore().getGlobalManager().canPauseDownloads()); itemResume.setEnabled(getCore().getGlobalManager().canResumeDownloads()); } public void menuHidden(MenuEvent menu) { } }); return transferMenuItem; } public static MenuItem createViewMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_VIEW); } public static MenuItem createAdvancedMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_ADVANCED); } public static MenuItem createTorrentMenuItem(final Menu menuParent) { final MenuItem torrentItem = createTopLevelMenuItem(menuParent, MENU_ID_TORRENT); /* * The Torrents menu is context-sensitive to which torrent is selected in the UI. * For this reason we need to dynamically build the menu when ever it is about to be displayed * so that the states of the menu items accurately reflect what was selected in the UI. */ MenuBuildUtils.addMaintenanceListenerForMenu(torrentItem.getMenu(), new MenuBuildUtils.MenuBuilder() { public void buildMenu(Menu menu) { DownloadManager[] current_dls = (DownloadManager[]) torrentItem.getData("downloads"); if (current_dls == null) { return; } boolean is_detailed_view = ((Boolean) torrentItem.getData("is_detailed_view")).booleanValue(); TableViewSWT tv = (TableViewSWT) torrentItem.getData("TableView"); TorrentUtil.fillTorrentMenu(menu, current_dls, getCore(), menuParent.getShell(), !is_detailed_view, 0, tv); /* * KN: This is a reference to a plugins class from a core class; * maybe MenuItem should be moved to core? * * AMC: No, because we need to add menu items that plugins have * registered to add. */ org.gudy.azureus2.plugins.ui.menus.MenuItem[] menu_items; menu_items = MenuItemManager.getInstance().getAllAsArray( new String[] { MenuManager.MENU_TORRENT_MENU, MenuManager.MENU_DOWNLOAD_CONTEXT }); final Object[] plugin_dls = DownloadManagerImpl.getDownloadStatic(current_dls); if (menu_items.length > 0) { addSeparatorMenuItem(menu); MenuBuildUtils.addPluginMenuItems(menuParent.getShell(), menu_items, menu, true, true, new MenuBuildUtils.MenuItemPluginMenuControllerImpl( plugin_dls)); } menu_items = null; /** * OK, "hack" time - we'll allow plugins which add menu items against * a table to appear in this menu. We'll have to fake the table row * object though. All downloads need to share a common table. */ String table_to_use = null; for (int i = 0; i < current_dls.length; i++) { String table_name = (current_dls[i].isDownloadComplete(false) ? TableManager.TABLE_MYTORRENTS_COMPLETE : TableManager.TABLE_MYTORRENTS_INCOMPLETE); if (table_to_use == null || table_to_use.equals(table_name)) { table_to_use = table_name; } else { table_to_use = null; break; } } if (table_to_use != null) { menu_items = TableContextMenuManager.getInstance().getAllAsArray( table_to_use); } if (menu_items != null) { addSeparatorMenuItem(menu); TableRow[] dls_as_rows = null; dls_as_rows = new TableRow[plugin_dls.length]; for (int i = 0; i < plugin_dls.length; i++) { dls_as_rows[i] = wrapAsRow(plugin_dls[i], table_to_use); } MenuBuildUtils.addPluginMenuItems(menuParent.getShell(), menu_items, menu, true, true, new MenuBuildUtils.MenuItemPluginMenuControllerImpl( dls_as_rows)); } } }); return torrentItem; } public static MenuItem createToolsMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_TOOLS); } /** * Creates the Plugins menu item and all it's children * @param menuParent * @param includeGetPluginsMenu if <code>true</code> then also include a menu item for getting new plugins * @return */ public static MenuItem createPluginsMenuItem(final Menu menuParent, final boolean includeGetPluginsMenu) { MenuItem pluginsMenuItem = createTopLevelMenuItem(menuParent, MENU_ID_PLUGINS); MenuBuildUtils.addMaintenanceListenerForMenu(pluginsMenuItem.getMenu(), new MenuBuildUtils.MenuBuilder() { public void buildMenu(Menu menu) { PluginsMenuHelper.getInstance().buildPluginMenu(menu, menuParent.getShell(), includeGetPluginsMenu); } }); return pluginsMenuItem; } public static MenuItem createWindowMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_WINDOW); } public static MenuItem createHelpMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_HELP); } public static MenuItem addCreateMenuItem(Menu menuParent) { MenuItem file_create = addMenuItem(menuParent, MENU_ID_CREATE, new Listener() { public void handleEvent(Event e) { new NewTorrentWizard(getCore(), getDisplay()); } }); return file_create; } public static MenuItem createOpenMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_OPEN); } public static MenuItem addLogsViewMenuItem(Menu menuParent) { return createTopLevelMenuItem(menuParent, MENU_ID_LOG_VIEWS); } public static MenuItem addOpenTorrentMenuItem(Menu menuParent) { return addMenuItem(menuParent, MENU_ID_OPEN_TORRENT, new Listener() { public void handleEvent(Event e) { TorrentOpener.openTorrentWindow(); } }); } public static MenuItem addOpenTorrentForTrackingMenuItem(Menu menuParent) { MenuItem file_new_torrent_for_tracking = addMenuItem(menuParent, MENU_ID_OPEN_TORRENT_FOR_TRACKING, new Listener() { public void handleEvent(Event e) { TorrentOpener.openTorrentTrackingOnly(); } }); return file_new_torrent_for_tracking; } public static MenuItem addOpenVuzeFileMenuItem(final Menu menuParent) { return addMenuItem(menuParent, MENU_ID_OPEN_VUZE_FILE, new Listener() { public void handleEvent(Event e) { Display display = menuParent.getDisplay(); display.asyncExec(new AERunnable() { public void runSupport() { FileDialog dialog = new FileDialog(menuParent.getShell(), SWT.SYSTEM_MODAL | SWT.OPEN); dialog.setFilterPath(TorrentOpener.getFilterPathData()); dialog.setText(MessageText.getString("MainWindow.dialog.select.vuze.file")); dialog.setFilterExtensions(new String[] { "*.vuze", "*.vuz", Constants.FILE_WILDCARD }); dialog.setFilterNames(new String[] { "*.vuze", "*.vuz", Constants.FILE_WILDCARD }); String path = TorrentOpener.setFilterPathData(dialog.open()); if (path != null) { VuzeFileHandler vfh = VuzeFileHandler.getSingleton(); if (vfh.loadAndHandleVuzeFile(path, VuzeFileComponent.COMP_TYPE_NONE) == null) { TorrentOpener.openTorrent(path); } } } }); } }); } public static MenuItem createShareMenuItem(Menu menuParent) { MenuItem file_share = createTopLevelMenuItem(menuParent, MENU_ID_SHARE); return file_share; } public static MenuItem addShareFileMenuItem(final Menu menuParent) { MenuItem file_share_file = addMenuItem(menuParent, MENU_ID_SHARE_FILE, new Listener() { public void handleEvent(Event e) { ShareUtils.shareFile(getCore(), menuParent.getShell()); } }); return file_share_file; } public static MenuItem addShareFolderMenuItem(final Menu menuParent) { MenuItem file_share_dir = addMenuItem(menuParent, MENU_ID_SHARE_DIR, new Listener() { public void handleEvent(Event e) { ShareUtils.shareDir(getCore(), menuParent.getShell()); } }); return file_share_dir; } public static MenuItem addShareFolderContentMenuItem(final Menu menuParent) { MenuItem file_share_dircontents = addMenuItem(menuParent, MENU_ID_SHARE_DIR_CONTENT, new Listener() { public void handleEvent(Event e) { ShareUtils.shareDirContents(getCore(), menuParent.getShell(), false); } }); return file_share_dircontents; } public static MenuItem addShareFolderContentRecursiveMenuItem( final Menu menuParent) { MenuItem file_share_dircontents_rec = addMenuItem(menuParent, MENU_ID_SHARE_DIR_CONTENT_RECURSE, new Listener() { public void handleEvent(Event e) { ShareUtils.shareDirContents(getCore(), menuParent.getShell(), true); } }); return file_share_dircontents_rec; } public static MenuItem addImportMenuItem(Menu menuParent) { MenuItem file_import = addMenuItem(menuParent, MENU_ID_IMPORT, new Listener() { public void handleEvent(Event e) { new ImportTorrentWizard(getCore(), getDisplay()); } }); return file_import; } public static MenuItem addExportMenuItem(Menu menuParent) { MenuItem file_export = addMenuItem(menuParent, MENU_ID_EXPORT, new Listener() { public void handleEvent(Event e) { new ExportTorrentWizard(getCore(), getDisplay()); } }); return file_export; } public static MenuItem addCloseWindowMenuItem(final Menu menuParent) { MenuItem closeWindow = addMenuItem(menuParent, MENU_ID_WINDOW_CLOSE, new Listener() { public void handleEvent(Event event) { Shell shell = menuParent.getShell(); if (shell != null && !shell.isDisposed()) { menuParent.getShell().close(); } } }); return closeWindow; } public static MenuItem addCloseTabMenuItem(Menu menu, final MainWindow mainWindow) { return addMenuItem(menu, MENU_ID_CLOSE_TAB, new Listener() { public void handleEvent(Event event) { if (MainWindow.isAlreadyDead) { return; } mainWindow.closeViewOrWindow(); } }); } public static MenuItem addCloseDetailsMenuItem(Menu menu) { final MenuItem item = addMenuItem(menu, MENU_ID_CLOSE_ALL_DETAIL, new Listener() { public void handleEvent(Event e) { UIFunctionsManagerSWT.getUIFunctionsSWT().closeAllDetails(); } }); Listener enableHandler = new Listener() { public void handleEvent(Event event) { if (true == MenuFactory.isEnabledForCurrentMode(item)) { if (false == item.isDisposed() && false == event.widget.isDisposed()) { boolean hasDetails = UIFunctionsManagerSWT.getUIFunctionsSWT().hasDetailViews(); item.setEnabled(hasDetails); } } } }; menu.addListener(SWT.Show, enableHandler); return item; } public static MenuItem addCloseDownloadBarsToMenu(Menu menu) { final MenuItem item = addMenuItem(menu, MENU_ID_CLOSE_ALL_DL_BARS, new Listener() { public void handleEvent(Event e) { MiniBarManager.getManager().closeAll(); } }); Listener enableHandler = new Listener() { public void handleEvent(Event event) { if (false == item.isDisposed()) { item.setEnabled(false == MiniBarManager.getManager().getShellManager().isEmpty()); } } }; menu.addListener(SWT.Show, enableHandler); // shell.addListener(SWT.FocusIn, enableHandler); return item; } public static MenuItem addRestartMenuItem(Menu menuParent) { MenuItem file_restart = new MenuItem(menuParent, SWT.NULL); Messages.setLanguageText(file_restart, MENU_ID_RESTART); //$NON-NLS-1$ file_restart.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { UIFunctionsManagerSWT.getUIFunctionsSWT().dispose(true, false); } }); return file_restart; } public static MenuItem addExitMenuItem(Menu menuParent) { final MenuItem file_exit = new MenuItem(menuParent, SWT.NULL); if (!COConfigurationManager.getBooleanParameter("Enable System Tray") || !COConfigurationManager.getBooleanParameter("Close To Tray")) { KeyBindings.setAccelerator(file_exit, MENU_ID_EXIT); } Messages.setLanguageText(file_exit, MENU_ID_EXIT); //$NON-NLS-1$ file_exit.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { UIFunctionsManagerSWT.getUIFunctionsSWT().dispose(false, false); } }); // let platform decide ParameterListener paramListener = new ParameterListener() { public void parameterChanged(String parameterName) { if (COConfigurationManager.getBooleanParameter("Enable System Tray") && COConfigurationManager.getBooleanParameter("Close To Tray")) { KeyBindings.removeAccelerator(file_exit, MENU_ID_EXIT); } else { KeyBindings.setAccelerator(file_exit, MENU_ID_EXIT); } } }; COConfigurationManager.addParameterListener("Enable System Tray", paramListener); COConfigurationManager.addParameterListener("Close To Tray", paramListener); return file_exit; } public static MenuItem addStartAllMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_START_ALL_TRANSFERS, new Listener() { public void handleEvent(Event event) { getCore().getGlobalManager().startAllDownloads(); /* * KN: Not sure why we can not use the call below as opposed to the line above * which was the exiting code */ // ManagerUtils.asyncStartAll(); } }); } public static MenuItem addStopAllMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_STOP_ALL_TRANSFERS, new Listener() { public void handleEvent(Event event) { ManagerUtils.asyncStopAll(); } }); } public static MenuItem addPauseMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_PAUSE_TRANSFERS, new Listener() { public void handleEvent(Event event) { ManagerUtils.asyncPause(); } }); } public static MenuItem addResumeMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_RESUME_TRANSFERS, new Listener() { public void handleEvent(Event event) { ManagerUtils.asyncResume(); } }); } public static MenuItem addMyTorrentsMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_MY_TORRENTS, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_MYTORRENTS, null); } } }); } public static MenuItem addDetailedListMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_DETAILED_LIST, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_DETAILED_LISTVIEW, null); } } }); } public static MenuItem addAllPeersMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_ALL_PEERS, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_ALLPEERS, null); } } }); } public static MenuItem addMyTrackerMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_MY_TRACKERS, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_MYTRACKER, null); } } }); } public static MenuItem addMySharesMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_MY_SHARES, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_MYSHARES, null); } } }); } public static MenuItem addViewToolbarMenuItem(Menu menu) { final MenuItem item = addMenuItem(menu, SWT.CHECK, MENU_ID_TOOLBAR, new Listener() { public void handleEvent(Event e) { UIFunctionsSWT uiFunctions = getUIFunctionSWT(); if (null != uiFunctions) { IMainWindow mainWindow = uiFunctions.getMainWindow(); boolean isToolbarVisible = mainWindow.isVisible(IMainWindow.WINDOW_ELEMENT_TOOLBAR); mainWindow.setVisible(IMainWindow.WINDOW_ELEMENT_TOOLBAR, !isToolbarVisible); } } }); final ParameterListener listener = new ParameterListener() { public void parameterChanged(String parameterName) { item.setSelection(COConfigurationManager.getBooleanParameter(parameterName)); } }; COConfigurationManager.addAndFireParameterListener("IconBar.enabled", listener); item.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { COConfigurationManager.removeParameterListener("IconBar.enabled", listener); } }); return item; } public static MenuItem addTransferBarToMenu(final Menu menu) { final MenuItem item = addMenuItem(menu, SWT.CHECK, MENU_ID_TRANSFER_BAR, new Listener() { public void handleEvent(Event e) { if (AllTransfersBar.getManager().isOpen( getCore().getGlobalManager())) { AllTransfersBar.close(getCore().getGlobalManager()); } else { AllTransfersBar.open(getCore().getGlobalManager(), menu.getShell()); } } }); menu.addListener(SWT.Show, new Listener() { public void handleEvent(Event event) { item.setSelection(!MiniBarManager.getManager().getShellManager().isEmpty()); } }); return item; } public static MenuItem addBlockedIPsMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_IP_FILTER, new Listener() { public void handleEvent(Event event) { // if (MainWindow.isAlreadyDead) { // return; // } BlockedIpsWindow.showBlockedIps(getCore(), getUIFunctionSWT().getMainShell()); } }); } public static MenuItem addConsoleMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_CONSOLE, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_CONSOLE, null); } } }); } public static MenuItem addStatisticsMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_STATS, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_STATS, null); } } }); } public static MenuItem addNatTestMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_NAT_TEST, new Listener() { public void handleEvent(Event e) { new NatTestWindow(); } }); } public static MenuItem addSpeedTestMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_SPEED_TEST, new Listener() { public void handleEvent(Event e) { new SpeedTestWizard(getCore(), getDisplay()); } }); } public static MenuItem addConfigWizardMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_CONFIGURE, new Listener() { public void handleEvent(Event e) { new ConfigureWizard(getCore(), false); } }); } public static MenuItem addOptionsMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_OPTIONS, new Listener() { public void handleEvent(Event e) { UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions(); if (uiFunctions != null) { uiFunctions.openView(UIFunctions.VIEW_CONFIG, null); } } }); } public static MenuItem addMinimizeWindowMenuItem(Menu menu) { final Shell shell = menu.getShell(); final MenuItem item = addMenuItem(menu, MENU_ID_WINDOW_MINIMIZE, new Listener() { public void handleEvent(Event event) { if (null == shell || shell.isDisposed()) { event.doit = false; return; } shell.setMinimized(true); } }); Listener enableHandler = new Listener() { public void handleEvent(Event event) { if (null == shell || true == shell.isDisposed() || true == item.isDisposed()) { event.doit = false; return; } if (((shell.getStyle() & SWT.MIN) != 0)) { item.setEnabled(false == shell.getMinimized()); } else { item.setEnabled(false); } } }; menu.addListener(SWT.Show, enableHandler); shell.addListener(SWT.FocusIn, enableHandler); shell.addListener(SWT.Iconify, enableHandler); shell.addListener(SWT.Deiconify, enableHandler); return item; } public static MenuItem addBringAllToFrontMenuItem(Menu menu) { final MenuItem item = addMenuItem(menu, MENU_ID_WINDOW_ALL_TO_FRONT, new Listener() { public void handleEvent(Event event) { Iterator iter = ShellManager.sharedManager().getWindows(); while (iter.hasNext()) { Shell shell = (Shell) iter.next(); if (!shell.isDisposed() && !shell.getMinimized()) shell.open(); } } }); final Listener enableHandler = new Listener() { public void handleEvent(Event event) { Iterator iter = ShellManager.sharedManager().getWindows(); boolean hasNonMaximizedShell = false; while (iter.hasNext()) { Shell shell = (Shell) iter.next(); if (false == shell.isDisposed() && false == shell.getMinimized()) { hasNonMaximizedShell = true; break; } } item.setEnabled(hasNonMaximizedShell); } }; menu.addListener(SWT.Show, enableHandler); menu.getShell().addListener(SWT.FocusIn, enableHandler); ShellManager.sharedManager().addWindowAddedListener(enableHandler); ShellManager.sharedManager().addWindowRemovedListener(enableHandler); item.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { ShellManager.sharedManager().removeWindowAddedListener(enableHandler); ShellManager.sharedManager().removeWindowRemovedListener(enableHandler); } }); return item; } /** * Appends the list of opened interactive windows to the bottom of the specified shell menu * @param menuParent The shell menu * @param shell */ public static void appendWindowMenuItems(final Menu menuParent) { final Shell shell = menuParent.getShell(); final int numTopItems = menuParent.getItemCount(); Listener rebuild = new Listener() { public void handleEvent(Event event) { try { if (menuParent.isDisposed() || shell.isDisposed()) return; final int size = ShellManager.sharedManager().getSize(); if (size == menuParent.getItemCount() - numTopItems) { for (int i = numTopItems; i < menuParent.getItemCount(); i++) { final MenuItem item = menuParent.getItem(i); item.setSelection(item.getData() == shell); } return; } for (int i = numTopItems; i < menuParent.getItemCount();) menuParent.getItem(i).dispose(); Iterator iter = ShellManager.sharedManager().getWindows(); for (int i = 0; i < size; i++) { final Shell sh = (Shell) iter.next(); if (sh.isDisposed() || sh.getText().length() == 0) continue; final MenuItem item = new MenuItem(menuParent, SWT.CHECK); item.setText(sh.getText()); item.setSelection(shell == sh); item.setData(sh); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (event.widget.isDisposed() || sh.isDisposed()) return; if (sh.getMinimized()) sh.setMinimized(false); sh.open(); } }); } } catch (Exception e) { Logger.log(new LogEvent(LogIDs.GUI, "rebuild menu error", e)); } } }; ShellManager.sharedManager().addWindowAddedListener(rebuild); ShellManager.sharedManager().addWindowRemovedListener(rebuild); shell.addListener(SWT.FocusIn, rebuild); menuParent.addListener(SWT.Show, rebuild); } public static MenuItem addZoomWindowMenuItem(Menu menuParent) { final Shell shell = menuParent.getShell(); final MenuItem item = addMenuItem(menuParent, MENU_ID_WINDOW_ZOOM, new Listener() { public void handleEvent(Event event) { if (shell.isDisposed()) { event.doit = false; return; } shell.setMaximized(!shell.getMaximized()); } }); Listener enableHandler = new Listener() { public void handleEvent(Event event) { if ( !shell.isDisposed() && !item.isDisposed()) { if (false == Constants.isOSX) { if (true == shell.getMaximized()) { Messages.setLanguageText( item, MessageText.resolveLocalizationKey(MENU_ID_WINDOW_ZOOM_RESTORE)); } else { Messages.setLanguageText( item, MessageText.resolveLocalizationKey(MENU_ID_WINDOW_ZOOM_MAXIMIZE)); } } if (((shell.getStyle() & SWT.MAX) != 0)) { item.setEnabled(false == shell.getMinimized()); } else { item.setEnabled(false); } } } }; menuParent.addListener(SWT.Show, enableHandler); shell.addListener(SWT.FocusIn, enableHandler); shell.addListener(SWT.Iconify, enableHandler); shell.addListener(SWT.Deiconify, enableHandler); return item; } public static MenuItem addAboutMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_ABOUT, new Listener() { public void handleEvent(Event e) { AboutWindow.show(getDisplay()); } }); } public static MenuItem addHealthMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_HEALTH, new Listener() { public void handleEvent(Event e) { HealthHelpWindow.show(getDisplay()); } }); } public static MenuItem addWhatsNewMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_WHATS_NEW, new Listener() { public void handleEvent(Event e) { Utils.launch("http://azureus.sourceforge.net/changelog.php?version=" + Constants.AZUREUS_VERSION); } }); } /** * Add the FAQ menu item to the given menu * @param menu * @param faq_url the fully qualified url to the appropriate FAQ (Vuze uses a different url than Classic) * @return */ public static MenuItem addFAQMenuItem(Menu menu, final String faq_url) { return addMenuItem(menu, MENU_ID_FAQ, new Listener() { public void handleEvent(Event e) { Utils.launch(faq_url); } }); } public static MenuItem addReleaseNotesMenuItem(final Menu menu) { return addMenuItem(menu, MENU_ID_RELEASE_NOTES, new Listener() { public void handleEvent(Event e) { new WelcomeWindow(menu.getShell()); } }); } public static MenuItem addGetPluginsMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_PLUGINS_HELP, new Listener() { public void handleEvent(Event e) { Utils.launch("http://azureus.sourceforge.net/plugin_list.php"); } }); } public static MenuItem addDebugHelpMenuItem(Menu menu) { return addMenuItem(menu, MENU_ID_DEBUG_HELP, new Listener() { public void handleEvent(Event e) { UIDebugGenerator.generate(); } }); } public static MenuItem addCheckUpdateMenuItem(final Menu menu) { return addMenuItem(menu, MENU_ID_UPDATE_CHECK, new Listener() { public void handleEvent(Event e) { UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT(); if (uiFunctions != null) { uiFunctions.bringToFront(); } UpdateMonitor.getSingleton(getCore()).performCheck(true, false, false, new UpdateCheckInstanceListener() { public void cancelled(UpdateCheckInstance instance) { } public void complete(UpdateCheckInstance instance) { if (instance.getUpdates().length == 0) { Utils.execSWTThread(new AERunnable() { public void runSupport() { Utils.openMessageBox(menu.getShell(), SWT.ICON_INFORMATION | SWT.OK, "window.update.noupdates", (String[]) null); } }); } } }); } }); } public static MenuItem addPluginInstallMenuItem(Menu menuParent) { return addMenuItem(menuParent, MENU_ID_PLUGINS_INSTALL, new Listener() { public void handleEvent(Event e) { new InstallPluginWizard(getCore(), getDisplay()); } }); } public static MenuItem addPluginUnInstallMenuItem(Menu menuParent) { return addMenuItem(menuParent, MENU_ID_PLUGINS_UNINSTALL, new Listener() { public void handleEvent(Event e) { new UnInstallPluginWizard(getCore(), getDisplay()); } }); } /** * Creates a menu item that is simply a label; it does nothing is selected * @param menu * @param localizationKey * @return */ public static final MenuItem addLabelMenuItem(Menu menu, String localizationKey) { MenuItem item = new MenuItem(menu, SWT.NULL); Messages.setLanguageText(item, localizationKey); item.setEnabled(false); return item; } //========================== public static MenuItem addSeparatorMenuItem(Menu menuParent) { return new MenuItem(menuParent, SWT.SEPARATOR); } public static MenuItem createTopLevelMenuItem(Menu menuParent, String localizationKey) { Menu menu = new Menu(menuParent.getShell(), SWT.DROP_DOWN); MenuItem menuItem = new MenuItem(menuParent, SWT.CASCADE); Messages.setLanguageText(menuItem, localizationKey); menuItem.setMenu(menu); /* * A top level menu and its menu item has the same ID; this is used to locate them at runtime */ menu.setData(KEY_MENU_ID, localizationKey); menuItem.setData(KEY_MENU_ID, localizationKey); return menuItem; } public static final MenuItem addMenuItem(Menu menu, String localizationKey, Listener selListener) { return addMenuItem(menu, localizationKey, selListener, SWT.NONE); } public static final MenuItem addMenuItem(Menu menu, String localizationKey, Listener selListener, int style) { MenuItem menuItem = new MenuItem(menu, style); Messages.setLanguageText(menuItem, MessageText.resolveLocalizationKey(localizationKey)); KeyBindings.setAccelerator(menuItem, MessageText.resolveAcceleratorKey(localizationKey)); if (null != selListener) { menuItem.addListener(SWT.Selection, selListener); } /* * Using the localizationKey as the id for the menu item; this can be used to locate it at runtime * using .KN: missing method pointers */ menuItem.setData(KEY_MENU_ID, localizationKey); return menuItem; } public static final MenuItem addMenuItem(Menu menu, int style, String localizationKey, Listener selListener) { return addMenuItem(menu, style, -1, localizationKey, selListener); } public static final MenuItem addMenuItem(Menu menu, int style, int index, String localizationKey, Listener selListener) { if (index < 0 || index > menu.getItemCount()) { index = menu.getItemCount(); } MenuItem menuItem = new MenuItem(menu, style, index); Messages.setLanguageText(menuItem, localizationKey); KeyBindings.setAccelerator(menuItem, localizationKey); menuItem.addListener(SWT.Selection, selListener); /* * Using the localizationKey as the id for the menu item; this can be used to locate it at runtime * using .KN: missing method pointers */ menuItem.setData(KEY_MENU_ID, localizationKey); return menuItem; } private static UIFunctionsSWT getUIFunctionSWT() { UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT(); if (null != uiFunctions) { return uiFunctions; } throw new IllegalStateException( "No instance of UIFunctionsSWT found; the UIFunctionsManager might not have been initialized properly"); } private static AzureusCore getCore() { return AzureusCoreFactory.getSingleton(); } private static Display getDisplay() { return SWTThread.getInstance().getDisplay(); } public static void updateMenuText(Object menu) { if (menu == null) return; if (menu instanceof Menu) { MenuItem[] menus = ((Menu) menu).getItems(); for (int i = 0; i < menus.length; i++) { updateMenuText(menus[i]); } } else if (menu instanceof MenuItem) { MenuItem item = (MenuItem) menu; if (item.getData(KEY_MENU_ID) instanceof String) { String localizationKey = (String) item.getData(KEY_MENU_ID); item.setText(MessageText.getString(localizationKey)); KeyBindings.setAccelerator(item, MessageText.resolveAcceleratorKey(localizationKey)); updateMenuText(item.getMenu()); } } } public static void performOneTimeDisable(MenuItem item, boolean affectsChildMenuItems) { item.setEnabled(false); if (affectsChildMenuItems) { Menu childMenu = item.getMenu(); if (childMenu == null) return; for (int i = 0; i < childMenu.getItemCount(); i++) { childMenu.getItem(i).setEnabled(false); } } } /** * Find and return the menu with the given id starting from the given menu * * @param menuToStartWith * @param idToMatch any of the menu keys listed in {@link org.gudy.azureus2.ui.swt.mainwindow.IMenuConstants} * @return may return <code>null</code> if not found */ public static Menu findMenu(Menu menuToStartWith, String idToMatch) { /* * This is a recursive method; it will start at the given menuToStartWith * and recursively traverse to all its sub menus until a matching * menu is found or until it has touched all sub menus */ if (null == menuToStartWith || true == menuToStartWith.isDisposed() || null == idToMatch || idToMatch.length() < 1) { return null; } /* * The given menuToStartWith may be the one we're looking for */ if (true == idToMatch.equals(getID(menuToStartWith))) { return menuToStartWith; } MenuItem[] items = menuToStartWith.getItems(); /* * Go deeper into each child to try and find it */ for (int i = 0; i < items.length; i++) { MenuItem item = items[i]; Menu menuToFind = findMenu(item.getMenu(), idToMatch); if (null != menuToFind) { return menuToFind; } } return null; } /** * Find and return the menu item with the given id starting from the given menu * * @param menuToStartWith * @param idToMatch any of the menu keys listed in {@link org.gudy.azureus2.ui.swt.mainwindow.IMenuConstants} * @return may return <code>null</code> if not found */ public static MenuItem findMenuItem(Menu menuToStartWith, String idToMatch) { /* * This is a recursive method; it will start at the given menuToStartWith * and recursively traverse to all its sub menus until a matching * menu item is found or until it has touched all existing menu items */ if (null == menuToStartWith || true == menuToStartWith.isDisposed() || null == idToMatch || idToMatch.length() < 1) { return null; } MenuItem[] items = menuToStartWith.getItems(); for (int i = 0; i < items.length; i++) { MenuItem item = items[i]; if (true == idToMatch.equals(getID(item))) { return item; } /* * Go deeper into each child to try and find it */ MenuItem menuItemToFind = findMenuItem(item.getMenu(), idToMatch); if (null != menuItemToFind) { return menuItemToFind; } } return null; } private static String getID(Widget widget) { if (null != widget && false == widget.isDisposed()) { Object id = widget.getData(KEY_MENU_ID); if (null != id) { return id.toString(); } } return ""; } public static void setEnablementKeys(Widget widget, int keys) { if (null != widget && false == widget.isDisposed()) { widget.setData(KEY_ENABLEMENT, new Integer(keys)); } } public static int getEnablementKeys(Widget widget) { if (null != widget && false == widget.isDisposed()) { Object keys = widget.getData(KEY_ENABLEMENT); if (keys instanceof Integer) { return ((Integer) keys).intValue(); } } return -1; } /** * Updates the enabled state of the given menu and all its applicable children * <p><b>NOTE:</b> This method currently iterates through the menu hierarchy to * set the enablement which may be inefficient since most menus do not have this flag set; * it may be desirable to employ a map of only the effected menus for efficient direct * access to them</p> * @param menuToStartWith */ public static void updateEnabledStates(Menu menuToStartWith) { /* * This is a recursive method; it will start at the given menuToStartWith * and recursively traverse to all its sub menus until a matching * menu item is found or until it has touched all existing menu items */ if (null == menuToStartWith || true == menuToStartWith.isDisposed()) { return; } /* * If the given menu itself is disabled then just return since * its menu items can not be seen anyway */ if (false == setEnablement(menuToStartWith)) { return; } MenuItem[] items = menuToStartWith.getItems(); for (int i = 0; i < items.length; i++) { MenuItem item = items[i]; /* * If the current menu item is disabled then just return since * its children items can not be seen anyway */ if (false == setEnablement(item)) { continue; } /* * Go deeper into the children items and set their enablement */ updateEnabledStates(item.getMenu()); } } /** * Sets whether the given widget is enabled or not based on the value of the * KEY_ENABLEMENT object data set into the given widget. * @param widget * @return */ public static boolean setEnablement(Widget widget) { if (null != widget && false == widget.isDisposed()) { boolean isEnabled = isEnabledForCurrentMode(widget); if (widget instanceof MenuItem) { ((MenuItem) widget).setEnabled(isEnabled); } else if (widget instanceof Menu) { ((Menu) widget).setEnabled(isEnabled); } return isEnabled; } return false; } /** * Returns whether the given widget should be enabled for the current mode; * current mode can be az2, az3, or az3 advanced. * @param widget * @return */ public static boolean isEnabledForCurrentMode(Widget widget) { int keys = getEnablementKeys(widget); if (keys <= 0) { return true; } else if (true == isAZ3_ADV) { return ((keys & FOR_AZ3_ADV) != 0); } else if (true == isAZ3) { return ((keys & FOR_AZ3) != 0); } else { return ((keys & FOR_AZ2) != 0); } } private static TableRow wrapAsRow(final Object o, final String table_name) { return new TableRow() { public Object getDataSource() {return o;} public String getTableID() {return table_name;} private void notSupported() { throw new RuntimeException("method is not supported - table row is a \"virtual\" one, only getDataSource and getTableID are supported."); } // Everything below is unsupported. public void setForeground(int red, int green, int blue) {notSupported();} public void setForeground(int[] rgb) {notSupported();} public void setForegroundToErrorColor() {notSupported();} public boolean isValid() {notSupported(); return false;} public TableCell getTableCell(String sColumnName) {notSupported(); return null;} public boolean isSelected() {notSupported(); return false;} public void addMouseListener(TableRowMouseListener listener) {notSupported();} public void removeMouseListener(TableRowMouseListener listener) {notSupported();} }; } }

The table below shows all metrics for MenuFactory.java.

MetricValueDescription
BLOCKS242.00Number of blocks
BLOCK_COMMENT62.00Number of block comment lines
COMMENTS136.00Comment lines
COMMENT_DENSITY 0.17Comment density
COMPARISONS112.00Number of comparison operators
CYCLOMATIC269.00Cyclomatic complexity
DECL_COMMENTS11.00Comments in declarations
DOC_COMMENT62.00Number of javadoc comment lines
ELOC812.00Effective lines of code
EXEC_COMMENTS21.00Comments in executable code
EXITS146.00Procedure exits
FUNCTIONS159.00Number of function declarations
HALSTEAD_DIFFICULTY77.78Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY363.00Interface complexity
JAVA0001 1.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 1.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 1.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 7.00JAVA0034 Missing braces in if statement
JAVA0035 1.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA008126.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 0.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 1.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 1.00JAVA0116 Missing javadoc: field 'field'
JAVA011767.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 1.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 1.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 1.00JAVA0144 Line exceeds maximum M characters
JAVA01453674.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 1.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 2.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 1.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 5.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 1.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1348.00Number of lines in the source file
LINE_COMMENT12.00Number of line comments
LOC1034.00Lines of code
LOGICAL_LINES447.00Number of statements
LOOPS12.00Number of loops
NEST_DEPTH 5.00Maximum nesting depth
OPERANDS2492.00Number of operands
OPERATORS4765.00Number of operators
PARAMS172.00Number of formal parameter declarations
PROGRAM_LENGTH7257.00Halstead program length
PROGRAM_VOCAB885.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS191.00Number of return points from functions
SIZE42777.00Size of the file in bytes
UNIQUE_OPERANDS833.00Number of unique operands
UNIQUE_OPERATORS52.00Number of unique operators
WHITESPACE178.00Number of whitespace lines