FileDocCategorySizeDatePackage
TableContextMenuManager.javaAPI DocAzureus 3.0.3.43692Thu May 24 09:15:22 BST 2007org.gudy.azureus2.ui.swt.views.table.utils

TableContextMenuManager

public class TableContextMenuManager extends Object
author
TuxPaper XXX TODO TUX: This needs to be moved to common, and TableManagerImpl should add to it instead of UISWTInstanceImpl

Fields Summary
private static TableContextMenuManager
instance
private static org.gudy.azureus2.core3.util.AEMonitor
class_mon
private Map
items
private org.gudy.azureus2.core3.util.AEMonitor
items_mon
Constructors Summary
private TableContextMenuManager()



    
   items = new HashMap();
  
Methods Summary
public voidaddContextMenuItem(TableContextMenuItem item)

    try {
      String name = item.getResourceKey();
      String sTableID = item.getTableID();
      try{
      	items_mon.enter();
      	
        Map mTypes = (Map)items.get(sTableID);
        if (mTypes == null) {
          // LinkedHashMap to preserve order
          mTypes = new LinkedHashMap();
          items.put(sTableID, mTypes);
        }
        mTypes.put(name, item);
        
      }finally{
      	
      	items_mon.exit();
      }
    } catch (Exception e) {
      System.out.println("Error while adding Context Table Menu Item");
      Debug.printStackTrace( e );
    }
  
public TableContextMenuItem[]getAllAsArray(java.lang.String sMenuID)

		Map local_menu_item_map = (Map)this.items.get(sMenuID);
		Map global_menu_item_map = (Map)this.items.get(null);
		if (local_menu_item_map == null && global_menu_item_map == null) {
			return new TableContextMenuItem[0];
		}
		
		ArrayList l = new ArrayList();
		if (local_menu_item_map != null) {l.addAll(local_menu_item_map.values());}
		if (global_menu_item_map != null) {l.addAll(global_menu_item_map.values());}
		return (TableContextMenuItem[]) l.toArray(new TableContextMenuItem[l.size()]);
	
public static org.gudy.azureus2.ui.swt.views.table.utils.TableContextMenuManagergetInstance()
Retrieve the static TableContextMenuManager instance

return
the static TableContextMenuManager instance

  	try{
  		class_mon.enter();
  	
  		if (instance == null)
  			instance = new TableContextMenuManager();
  		return instance;
  	}finally{
  		
  		class_mon.exit();
  	}
  
public voidremoveContextMenuItem(TableContextMenuItem item)

		Map menu_item_map = (Map)this.items.get(item.getTableID());
		if (menu_item_map != null) {menu_item_map.remove(item.getResourceKey());}