CmdTotalDownloadView.java :  » App » learnandroid » com » lgnortel » network » networkview » Android Open Source

Android Open Source » App » learnandroid 
learnandroid » com » lgnortel » network » networkview » CmdTotalDownloadView.java
package com.lgnortel.network.networkview;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import com.lgnortel.lib.logger.LoggerUtil;
import com.lgnortel.platform.model.LabelMenuMgr;
import com.lgnortel.platform.model.Language;
import com.lgnortel.platform.model.NetworkMgr;
import com.lgnortel.r4.r4equipment.common.R4CloseButton;
import com.lgnortel.rmi.common.EmsCode;

/**
 * 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: CmdTotalDownloadView.java<br>
 * Description: Download Frame <br>
 * Copyright: Copyright(c) 2008 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * 
 * @author JungGu Lee
 * @version 0.1
 * @created 2009. 1. 21.
 * @modified 2009. 1. 21.
 * @product EFA R4.0 EMS
 * @sw_block Client
 */

public class CmdTotalDownloadView extends JFrame {

  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  // Log4J
  private Logger logger = LoggerUtil.getInstance().getLogger(this.getClass().getName());

  private JPanel pnlContent = null;
  public JTabbedPane pnlTab = null;
  public int pnlTabPrevious = 0;

  public CmdRtrvDownloadView pnlRtrvDownload = null;
  public MultiBootView pnlBootView = null;
  public MultiRdlCfgView pnlRdlCfgView = null;
  public UpgradeManagerNetworkView pnlUpgradeMgrNetwork = null;
  public UpgradeManagerNEView pnlUpgradeMgrNE = null;

  private JButton btnClose = null;

  private String sTitle = null;
  int viewId;

  LabelMenuMgr labelMenuMgr = LabelMenuMgr.getInstance();
  NetworkMgr networkMgr = NetworkMgr.getInstance();


  private static CmdTotalDownloadView cmdTotalLpbkView = null;

  /**
   * Singleton pattern getInstance()
   * @return
   */
  public static CmdTotalDownloadView getInstance() {

    if (cmdTotalLpbkView == null) {
      cmdTotalLpbkView = new CmdTotalDownloadView();
    }

    return cmdTotalLpbkView;
  }

  /**
   * Constructor of this class
   */
  public CmdTotalDownloadView() {
    try {
      this.sTitle = "R3 MULTI DOWNLOAD";


      jbInit();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  /**
   * get initial data
   */
  public void getData() {
    switch (pnlTab.getSelectedIndex()) {
    case 0:
      pnlUpgradeMgrNetwork.getList();
      break;
    case 1:
      pnlUpgradeMgrNE.setDefaultData();
      pnlUpgradeMgrNE.getSlotList();
      break;
    case 2:
      pnlRtrvDownload.getDownload();
      break;
    case 3:
      pnlBootView.getBoot();
      break;
    case 4:
      pnlRdlCfgView.getRdlCfg();
      break;
    }
  }

  /**
   * get initial data of sub network
   */
  public void initEnabled() {
    pnlRtrvDownload.getSubnetList();
    pnlBootView.getSubnetList();
    pnlRdlCfgView.getSubnetList();
  }

  /**
   * set viewId
   * @param _viewId
   */
  public void setViewId(int _viewId) {
    this.viewId = _viewId;
    pnlRtrvDownload.setViewId(_viewId);
    pnlBootView.setViewId(_viewId);
    pnlRdlCfgView.setViewId(_viewId);
    pnlUpgradeMgrNetwork.setViewId(_viewId);
    pnlUpgradeMgrNE.setViewId(_viewId);
  }

  /**
   * get viewId
   * @return
   */
  public int getViewId() {
    return viewId;
  }

  /**
   * Initialization of GUI Component
   * @throws Exception
   */
  private void jbInit() throws Exception {

    btnClose = new R4CloseButton();
    btnClose.addActionListener(eventHandler);

    pnlRtrvDownload = CmdRtrvDownloadView.getInstance();
    pnlBootView = MultiBootView.getInstance();
    pnlRdlCfgView = MultiRdlCfgView.getInstance();
    pnlUpgradeMgrNetwork = UpgradeManagerNetworkView.getInstance();
    pnlUpgradeMgrNE = UpgradeManagerNEView.getInstance();

    pnlTab = new JTabbedPane();

    pnlTab.addMouseListener(new MouseAdapter() {
      public void mousePressed(MouseEvent e) {

        if (pnlTabPrevious == pnlTab.getSelectedIndex())
          return;
        pnlTabPrevious = pnlTab.getSelectedIndex();

        switch (pnlTab.getSelectedIndex()) {
        case 0:
          // pnlUpgradeMgrNetwork.getList();
          break;
        case 1:
          // pnlUpgradeMgrNE.getSlotList();
          break;
        case 2:
          pnlRtrvDownload.getDownload();
          break;
        case 3:
          pnlBootView.getBoot();
          break;
        case 4:
          pnlRdlCfgView.getRdlCfg();
          break;
        }
      }
    });

    if (Language.selectedLanguage == Language.KOREAN) {
      pnlTab.addTab("Multi Upgrade Manager", pnlUpgradeMgrNetwork);
      pnlTab.addTab("Detailed Upgrade Manager", pnlUpgradeMgrNE);
      pnlTab.addTab("Download ", pnlRtrvDownload);
      pnlTab.addTab("Boot ENV ", pnlBootView);
      pnlTab.addTab("ONT Auto RDL Config ", pnlRdlCfgView);
    } else {
      pnlTab.addTab("Multi Upgrade Manager", pnlUpgradeMgrNetwork);
      pnlTab.addTab("Detailed Upgrade Manager", pnlUpgradeMgrNE);
      pnlTab.addTab("Download View", pnlRtrvDownload);
      pnlTab.addTab("Boot ENV Config", pnlBootView);
      pnlTab.addTab("ONT Auto RDL Config", pnlRdlCfgView);
    }

    pnlContent = new JPanel();
    pnlContent.setLayout(new GridBagLayout());
    pnlContent.add(pnlTab, new GridBagConstraints(1, 1, 6, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));
    pnlContent.add(btnClose, new GridBagConstraints(6, 2, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 6, 1, 6), 0, 0));

    initialize();
  }

  /**
   * command response from server
   * @param viewId
   * @param userId
   * @param nodeId
   * @param cmdCode
   * @param data
   * @param result
   * @return
   */
  public boolean cmdResponse(int viewId, int userId, int nodeId, int cmdCode, Object[] data, int result) {

    switch (cmdCode) {

    case EmsCode.CMD_RTRV_VER:
    case EmsCode.CMD_RESET_SYS_OLT:
    case EmsCode.CMD_RESET_SYS_ONT:
      pnlUpgradeMgrNE.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      break;

    case EmsCode.CMD_RTRV_SW_DOWNLOAD:
      pnlRtrvDownload.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      break;

    case EmsCode.CMD_RTRV_BOOTENV:
    case EmsCode.CMD_PRV_BOOTENV:
      pnlBootView.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      break;

    case EmsCode.CMD_RTRV_AUTO_RDLCFG:
    case EmsCode.CMD_SET_AUTO_RDLCFG:
      pnlRdlCfgView.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      break;

    case EmsCode.CMD_RTRV_UPGRADE_MGR:
      pnlUpgradeMgrNetwork.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      pnlUpgradeMgrNE.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      break;

    case EmsCode.CMD_SET_UPGRADE_MGR:
      pnlUpgradeMgrNetwork.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      break;

    case EmsCode.CMD_RTRV_UPGRADE_MGR_SUB:
    case EmsCode.CMD_SET_UPGRADE_MGR_SUB:
    case EmsCode.CMD_RTRV_UPGRADE_VER:
      pnlUpgradeMgrNE.cmdResponse(viewId, userId, nodeId, cmdCode, data, result);
      break;
    }

    return true;
  }

  /**
   * remove this command window in the hashtable
   * and close command window
   */
  private void close() {
    MainMenuBar mainMenuBar = MainMenuBar.getInstance();
    mainMenuBar.removeCommand(viewId);

    setVisible(false);
  }

  /**
   * event handler
   * action with event occurred location.
   */
  IvjEventHandler eventHandler = new IvjEventHandler();

  class IvjEventHandler implements java.awt.event.ActionListener {
    public void actionPerformed(ActionEvent e) {

      java.lang.Object src = e.getSource();

      if (src == btnClose) {
        pnlUpgradeMgrNetwork.closeMultidown();
        pnlUpgradeMgrNE.closeMultidown();
        close();
      }
    }
  }


  /**
   * when window closing event is occured
   * call the close operation to dispose
   */
  protected void processWindowEvent(WindowEvent e) {
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      close();
    }
  }

  /**
   * window size & title initialization
   */
  private void initialize() {
    try {
      setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
      setSize(1100, 900);
      setLocation(0, 0);
      setResizable(true);
      setContentPane(pnlContent);
      setTitle(sTitle);
    } catch (java.lang.Throwable ivjExc) {
      logger.log(Level.SEVERE, "Exception", ivjExc);
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.