/**
*
*/
package com.lgnortel.equipment.menu;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPopupMenu;
import com.lgnortel.platform.db.DBManager;
import com.lgnortel.platform.model.NetworkElement;
import com.lgnortel.profile.olt.manager.menu.ces.OLTCesProfileMenuManager;
import com.lgnortel.profile.olt.manager.menu.igmp.OLTIgmpProfileMenuManager;
import com.lgnortel.profile.olt.manager.menu.qos.OLTQosProfileMenuManager;
import com.lgnortel.profile.ont.manager.menu.ces.ONTCesProfileMenuManager;
import com.lgnortel.profile.ont.manager.menu.pots.ONTPotsProfileMenuManager;
import com.lgnortel.profile.ont.manager.menu.qos.ONTQosProfileMenuManager;
import com.lgnortel.profile.template.ont.manager.OntTemplateMenuManager;
import com.lgnortel.r3.r3equipment.r3menu.R3MenuManager;
import com.lgnortel.r4.r4equipment.management.menu.R4MenuManager;
import com.lgnortel.r4.r4equipment.navigator.R4NavigatorSaveAndLoadMenu;
import com.lgnortel.r4.r4equipment.wizard.tree.R4WizardTreeNodeManager;
/**
* Copyright (c) 2008 LG-Nortel, Inc. All Rights Reserved.
*
* CONFIDENTIALITY AND LIMITED USE: This software, including any software of <br>
* third parties embodied herein, contains code, information, data and concepts <br>
* which are confidential and/or proprietary to LG-Nortel and such third <br>
* parties. This software is licensed for use solely in accordance with the <br>
* terms and conditions of the applicable license agreement with LG-Nortel or <br>
* its authorized distributor, and not for any other use or purpose. No <br>
* redistribution of this software by any party is permitted. <br>
*
* Title: EquipmentMenuManager.java<br>
* Description: <br>
* Copyright: Copyright(c) 2009 LG-NORTEL ALL Rights Reserved<br>
* Company: LG-Nortel<br>
*
* @author Jonghwa, Lee
* @version 0.1
* @created 2009. 2. 13.
* @modified 2009. 2. 13.
* @product EFA R4.0 EMS
* @sw_block Client Block
*/
public class EquipmentMenuManager {
public static final int R31_SYSTEM_TYPE = 31;
public static final int R40_SYSTEM_TYPE = 40;
public static final int WIZARD_TREE_MENU = 50;
public static final int OLT_QOS_PROFILE_TREE_MENU = 60;
public static final int OLT_CES_PROFILE_TREE_MENU = 70;
public static final int ONT_CES_PROFILE_TREE_MENU = 80;
public static final int ONT_POTS_PROFILE_TREE_MENU = 90;
public static final int ONT_QOS_PROFILE_TREE_MENU = 100;
public static final int OLT_IGMP_PROFILE_TREE_MENU = 200;
public static final int ONT_TEMPLATE_MENU = 1000;
public static final int R4_NAVIGATOR_SAVE_AND_LOAD_MENU = 10000;
public static final int NE_ID = 0;
private HashMap<Integer, EquipmentMenuIF> menus;
private static EquipmentMenuManager instance;
/**
*
* @return
*/
public static EquipmentMenuManager getInstance() {
if (instance == null) {
instance = new EquipmentMenuManager();
}
return instance;
}
private EquipmentMenuManager() {
menus = new HashMap<Integer, EquipmentMenuIF>();
menus.put(R31_SYSTEM_TYPE, new R3MenuManager());
menus.put(R40_SYSTEM_TYPE, new R4MenuManager());
menus.put(WIZARD_TREE_MENU, new R4WizardTreeNodeManager());
menus.put(OLT_QOS_PROFILE_TREE_MENU, new OLTQosProfileMenuManager());
menus.put(OLT_CES_PROFILE_TREE_MENU, new OLTCesProfileMenuManager());
menus.put(ONT_CES_PROFILE_TREE_MENU, new ONTCesProfileMenuManager());
menus.put(ONT_POTS_PROFILE_TREE_MENU, new ONTPotsProfileMenuManager());
menus.put(ONT_QOS_PROFILE_TREE_MENU, new ONTQosProfileMenuManager());
menus.put(OLT_IGMP_PROFILE_TREE_MENU, new OLTIgmpProfileMenuManager());
menus.put(ONT_TEMPLATE_MENU, new OntTemplateMenuManager());
menus.put(R4_NAVIGATOR_SAVE_AND_LOAD_MENU, new R4NavigatorSaveAndLoadMenu());
}
private int getSystemType(int nodeId) {
NetworkElement networkElement = DBManager.getInstance().getNetworkElement(nodeId);
return networkElement.getSystemType();
}
private int getSystemType(String nodeName) {
return this.getSystemType(DBManager.getInstance().getNodeId(nodeName));
}
/**
*
* @param nodeName
* @return
*/
public List<JMenu> getMenuList(String nodeName) {
return this.getMenuList(this.getSystemType(nodeName));
}
/**
*
* @param nodeId
* @return
*/
public List<JMenu> getMenuList(int nodeId) {
EquipmentMenuIF menu = menus.get(this.getSystemType(nodeId));
Iterator<JMenu> menuIter = menu.getMenuList(nodeId);
List<JMenu> menuList = new ArrayList<JMenu>();
while (menuIter.hasNext()) {
menuList.add(menuIter.next());
}
return menuList;
}
public List<JMenu> getWizardTreeNodeList(int nodeId) {
EquipmentMenuIF menu = menus.get(WIZARD_TREE_MENU);
Iterator<JMenu> menuIter = menu.getMenuList(nodeId);
List<JMenu> menuList = new ArrayList<JMenu>();
while (menuIter.hasNext()) {
menuList.add(menuIter.next());
}
return menuList;
}
public List<JMenu> getProfileTreeNodeList(int profileKey){
EquipmentMenuIF menu = menus.get(profileKey);
Iterator<JMenu> menuIter = menu.getMenuList(NE_ID);
List<JMenu> menuList = new ArrayList<JMenu>();
while (menuIter.hasNext()) {
menuList.add(menuIter.next());
}
return menuList;
}
/**
*
* @param nodeId
* @return
*/
public JMenuBar getJMenuBar(int nodeId) {
EquipmentMenuIF menuList = menus.get(this.getSystemType(nodeId));
JMenuBar menuBar = new JMenuBar();
Iterator<JMenu> menuIter = menuList.getMenuList(nodeId);
while (menuIter.hasNext()) {
try {
menuBar.add(menuIter.next());
} catch (NullPointerException e) {
continue;
}
}
return menuBar;
}
/**
*
* @param profileId Profile Menu Manager ID.
* @return JMenuBar
*/
public JMenuBar getProfileMenuBar(int profileId) {
EquipmentMenuIF menuList = menus.get(profileId);
JMenuBar menuBar = new JMenuBar();
Iterator<MenuAbs> menuIter = menuList.getMenuList();
while (menuIter.hasNext()) {
try {
MenuAbs menu = menuIter.next();
menuBar.add(menu.getMenu(UNIT.DEFAULT));
} catch (NullPointerException e) {
continue;
}
}
return menuBar;
}
public JPopupMenu getNavigatorPopupMenu() {
EquipmentMenuIF menuList = menus.get(R4_NAVIGATOR_SAVE_AND_LOAD_MENU);
Iterator<MenuAbs> menuIter = menuList.getMenuList();
return menuIter.next().getMenu(UNIT.DEFAULT).getPopupMenu();
}
/**
*
* @param nodeName
* @return
*/
public JPopupMenu getJPopupMenu(String nodeName) {
return this.getJPopupMenu(this.getSystemType(nodeName));
}
/**
*
* @param nodeId
* @return
*/
public JPopupMenu getJPopupMenu(int nodeId) {
EquipmentMenuIF menuList = menus.get(this.getSystemType(nodeId));
JPopupMenu popupMenu = new JPopupMenu();
Iterator<JMenu> menuIter = menuList.getMenuList(nodeId);
while (menuIter.hasNext()) {
try {
popupMenu.add(menuIter.next());
} catch (NullPointerException e) {
continue;
}
}
return popupMenu;
}
/**
*
* @param nodeId
* @param slotId
* @return
*/
public JPopupMenu getJPopupMenu(int nodeId, int slotId) {
EquipmentMenuIF menuList = menus.get(this.getSystemType(nodeId));
JPopupMenu popupMenu = new JPopupMenu();
Iterator<JMenu> menuIter = menuList.getMenuList(nodeId, slotId);
while (menuIter.hasNext()) {
try {
popupMenu.add(menuIter.next());
} catch (NullPointerException e) {
continue;
}
}
return popupMenu;
}
/**
*
* @param nodeId
* @param slotId
* @param portId
* @return
*/
public JPopupMenu getJPopupMenu(int nodeId, int slotId, int portId) {
EquipmentMenuIF menuList = menus.get(this.getSystemType(nodeId));
JPopupMenu popupMenu = new JPopupMenu();
Iterator<JMenu> menuIter = menuList.getMenuList(nodeId, slotId, portId);
while (menuIter.hasNext()) {
try {
popupMenu.add(menuIter.next());
} catch (NullPointerException e) {
continue;
}
}
return popupMenu;
}
}
|