R4ManagementFrame.java :  » App » learnandroid » com » lgnortel » r4 » r4equipment » frame » Android Open Source

Android Open Source » App » learnandroid 
learnandroid » com » lgnortel » r4 » r4equipment » frame » R4ManagementFrame.java
package com.lgnortel.r4.r4equipment.frame;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.lgnortel.network.networkview.MainMenuBar;
import com.lgnortel.platform.model.LabelMenuMgr;
import com.lgnortel.platform.model.NetworkMgr;
import com.lgnortel.r4.r4equipment.common.CommandResponseInterface;
import com.lgnortel.r4.r4equipment.common.TotalViewInterface;
/**
 * 
 * Copyright (c) 2009 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: CmdTotalFacilityOntStatusView.java<br>
 * Description:  <br>
 * Copyright: Copyright(c) 2009 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * Title: R4ManagementFrame.java<br>
 * Description: <br>
 * Copyright: Copyright(c) 2009 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * 
 * @author SangHee, Kim
 * @version 0.1
 * @created 2009. 7. 20.
 * @modified 2009. 7. 20.
 * @product R4 EMS 4.0
 * @sw_block CLIENT BLOCK
 */
public class R4ManagementFrame extends JFrame implements CommandResponseInterface {

  /**
   * 
   */
  private static final long serialVersionUID = 8674154115038978683L;

  // Log4J
//  private Logger logger = LoggerUtil.getInstance().getLogger(this.getClass().getName());

  private JPanel pnlContent = null;

  private R4ManagementMainView managementMainView = null;
  private R4RefreshTimeView refreshTimeView = null;

  int viewId;
  int neId;

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

  /**
   * the constructor.
   * 
   * @param neId
   *            the node id.
   * @param shelfId
   *            the shelf id.
   */
  private R4ManagementFrame(int _neId, TotalViewInterface menuView) {
    try {
      this.neId = _neId;
      managementMainView = new R4ManagementMainView(this.neId, menuView);
      refreshTimeView = new R4RefreshTimeView(this.neId,0);
      jbInit();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  
  private void jbInit() throws Exception {
    pnlContent = new JPanel();
    pnlContent.setLayout(new GridBagLayout());
    pnlContent.add(managementMainView, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 0, 3, 3), 0, 0));
    pnlContent.add(refreshTimeView, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 3, 3, 3), 0, 0));
    this.setContentPane(pnlContent);
  }

  public static void showR4ManagementFrame(int neId, TotalViewInterface totalView){
    R4ManagementFrame frame = new R4ManagementFrame(neId, totalView);
    MainMenuBar mainMenuBar = MainMenuBar.getInstance();
    mainMenuBar.incrementViewId();
    mainMenuBar.putEquip((Object) frame);    
    frame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    frame.setLocation(200, 0);
    frame.setSize(1000, 1000);
    frame.setTitle("R4 Management View");
    frame.setViewId(mainMenuBar.getViewId());
    frame.setVisible(true);
    frame.requestInitialCmd();
  }
  /**
   * the response method.
   * 
   * @param viewId
   *            the view id.
   * @param userId
   *            the user id.
   * @param nodeId
   *            the node id.
   * @param cmdCode
   *            the command code.
   * @param data
   *            the Object array for the data.
   * @param result
   *            the int value about the result.
   * @return the true if call the method.
   */
  public boolean cmdResponse(int viewId, int userId, int nodeId, int cmdCode, Object[] data, int result, String errMessage) {
    managementMainView.cmdResponse(viewId, userId, nodeId, cmdCode, data, result, errMessage);
    return true;
  }

  private void close() {
    MainMenuBar mainMenuBar = MainMenuBar.getInstance();
    mainMenuBar.removeEquip(viewId);
    System.gc();
    dispose();
  }
  
  protected void processWindowEvent(WindowEvent e) {
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      close();
    }
  }

  /**
   * set the view id.
   * 
   * @param _viewId
   *            the view id.
   */
  public void setViewId(int _viewId) {
    this.viewId = _viewId;
    managementMainView.setViewId(_viewId);
  }

  /**
   * get the view id.
   * 
   * @return
   */
  public int getViewId() {
    return viewId;
  }

  public int getCurrentNodeId() {
    return neId;
  }

  public void refreshEquipmentFrame(int nedId) {
    refreshTimeView.exchangeNode(neId);
    repaint();
  }

  public void exchangeNode(int neId) {
    refreshTimeView.exchangeNode(neId);
    repaint();
  }

  private void requestInitialCmd(){
    managementMainView.requestInitialCmd();
  }
}
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.