package com.gx.obe.opening.composite;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.core.ImageResolver;
import org.eclipse.swt.core.listener.ChangeTextListener;
import org.eclipse.swt.core.listener.RoundBorderLineListener;
import org.eclipse.swt.core.widgets.ESepator;
import org.eclipse.swt.core.widgets.ImageButton;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

import com.gx.obe.ColorConstants;
import com.gx.obe.action.bean.Action;
import com.gx.obe.action.listener.ActionListener;
import com.gx.obe.action.utils.ActionUtil;
import com.gx.obe.business.enumeration.MenuEnum;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.common.widget.thread.SyncThread;
import com.gx.obe.components.core.Constants;
import com.gx.obe.listener.ProgressMessageAdapter;
import com.gx.obe.message.menu.MenuMessages;
import com.gx.obe.opening.Activator;
import com.gx.obe.opening.action.EnterProjectAction;
import com.gx.obe.thread.AutoVerifyUserRemotePasswordThread;
import com.gx.obe.thread.RefreshProjectSupplierTenderInfoThread;
import com.gx.obe.thread.SyncThreadSet;
import com.gx.obe.util.utils.LogUtils;
import com.gx.obe.util.utils.StringUtils;
import com.gx.obe.web.entity.auth.Menu;
import com.gx.obe.web.entity.tender.TenderProjectEntity;
import com.gx.obe.web.entity.tender.TenderProjectRuleEntity;
import com.gx.obe.web.service.MenuService;
import com.gx.obe.web.service.ProjectRuleService;
import com.gx.obe.web.service.TenderProjectService;
import com.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

/**
 * @Description: 进入项目界面
 * @author guoyr
 */
public class SubTenderProjectEnterMenuComposite extends Composite implements ActionListener{
	
	private ImageResolver imageResolver = new ImageResolver();
	private Label tenderNoLabel;
	private Label tenderNameLabel;
	private TenderProjectEntity tenderProject;
	private TenderProjectRuleEntity tenderProjectRule;
	private Composite rightContentComposite;
	private Composite leftMenuComposite;
	private ScrolledComposite scrolledComposite;
	private Label packageNameLabel;
	private Composite topComposite;
	private ImageButton curMenu;
	private ActionListener topActionListener;
	private Composite projectComposite;
	private Image defaultTopIco;
	private MenuService menuService;
	private TenderProjectService tenderProjectService  ;
	private ProjectRuleService projectRuleService;
	private List<Menu> menuList;
	private ImageButton curTopMenuBtn;
	private Action defaultAction = null;
	public static String curMenuId;
	{
		LogUtils.logClass(SubTenderProjectEnterMenuComposite.class);
	}
	
	/** 
	 * @author guoyr
	 * @param parent
	 * @param tenderProjectEntity
	 * @param topActionListener
	 * @param style 
	 */
	public SubTenderProjectEnterMenuComposite(Composite parent, TenderProjectEntity tenderProjectEntity, ActionListener topActionListener, int style) {
		super(parent, style);
		this.tenderProject = tenderProjectEntity;
		this.topActionListener = topActionListener;
		this.setData("topComposite",parent);
		addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				imageResolver.disposite();
			}
		});
		GridLayout gridLayout = new GridLayout(3, false);
		gridLayout.horizontalSpacing = 0;
		gridLayout.verticalSpacing = 0;
		gridLayout.marginHeight = 0;
		gridLayout.marginWidth = 0;
		setLayout(gridLayout);
		
		Composite topComposite = new Composite(this, SWT.NONE);
		topComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
		GridLayout gl_topComposite = new GridLayout(4, false);
		gl_topComposite.verticalSpacing = 0;
		gl_topComposite.marginHeight = 0;
		topComposite.setLayout(gl_topComposite);
		
		CLabel label_2 = new CLabel(topComposite, SWT.NONE);
		label_2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, true, 1, 1));
		label_2.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/pid_plan.png"));
		label_2.setText("");
		
		projectComposite = new Composite(topComposite, SWT.NONE);
		RowLayout rl_projectComposite = new RowLayout(SWT.HORIZONTAL);
		rl_projectComposite.marginBottom = 0;
		rl_projectComposite.marginTop = 0;
		projectComposite.setLayout(rl_projectComposite);
		projectComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
		
		Composite parent_composite = new Composite(projectComposite, SWT.NONE);
		GridLayout gl_parent_composite = new GridLayout(2, false);
		gl_parent_composite.verticalSpacing = 0;
		gl_parent_composite.horizontalSpacing = 0;
		gl_parent_composite.marginHeight = 0;
		gl_parent_composite.marginWidth = 0;
		parent_composite.setLayout(gl_parent_composite);
		
		tenderNoLabel = new Label(parent_composite, SWT.NONE);
		tenderNoLabel.setFont(SWTResourceManager.getFont("微软雅黑", 12, SWT.NORMAL));
		tenderNoLabel.setForeground(SWTResourceManager.getColor(100, 100, 100));
//		tenderNoLabel.setText("[ZFCG2014Z0021]");
		
		tenderNameLabel = new Label(parent_composite, SWT.WRAP);
		tenderNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		tenderNameLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
		tenderNameLabel.setFont(SWTResourceManager.getFont("微软雅黑", 12, SWT.NORMAL));
//		tenderNameLabel.setText("2014年国家航空航天遥感影像获取项目(三期)");
		
		packageNameLabel = new Label(projectComposite, SWT.WRAP);
		packageNameLabel.setForeground(SWTResourceManager.getColor(80, 80, 80));
		packageNameLabel.setFont(SWTResourceManager.getFont("微软雅黑", 12, SWT.NORMAL));
//		packageNameLabel.setText("第一包");
 
		
 
//		living_button = new ELink(topComposite, SWT.NONE);
//		living_button.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/videoOpen.png"));
//		living_button.addMouseListener(new MouseAdapter() {
//			public void mouseUp(MouseEvent e) {
//				enterOrExitVideoLiveRoom();
//			}
//		});
//		living_button.setText("进入直播室");
		
		Label label = new Label(this, SWT.NONE);
		label.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		GridData gd_label = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
		gd_label.heightHint = 1;
		label.setLayoutData(gd_label);
		
		scrolledComposite = new ScrolledComposite(this, SWT.V_SCROLL);
		GridData gd_scrolledComposite = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
//		gd_scrolledComposite.widthHint = 150;
		scrolledComposite.setLayoutData(gd_scrolledComposite);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		
		leftMenuComposite = new Composite(scrolledComposite, SWT.NONE);
		leftMenuComposite.setBackgroundMode(SWT.INHERIT_FORCE);
		leftMenuComposite.setBackground(SWTResourceManager.getColor(36, 142, 230));
		leftMenuComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		leftMenuComposite.addPaintListener(new RoundBorderLineListener(ColorConstants.BORDER_LINE_COLOR, 0));
		GridLayout gl_leftComposite = new GridLayout(1, false);
		gl_leftComposite.verticalSpacing = 0;
		gl_leftComposite.horizontalSpacing = 0;
		gl_leftComposite.marginHeight = 0;
		gl_leftComposite.marginWidth = 1;
		leftMenuComposite.setLayout(gl_leftComposite);
		scrolledComposite.setContent(leftMenuComposite);
		scrolledComposite.setMinSize(leftMenuComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		ESepator verSepLabel = new ESepator(this, SWT.VERTICAL);
		GridData gd_label_5 = new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1);
		gd_label_5.widthHint = 1;
		verSepLabel.setLayoutData(gd_label_5);
		verSepLabel.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		
		scrolledComposite = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL);
		scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		
		rightContentComposite = new Composite(scrolledComposite, SWT.NONE);
		FillLayout fl_rightContentComposite = new FillLayout(SWT.HORIZONTAL);
		fl_rightContentComposite.marginHeight = 10;
		fl_rightContentComposite.marginWidth = 10;
		rightContentComposite.setLayout(fl_rightContentComposite);
		
		scrolledComposite.setContent(rightContentComposite);
		scrolledComposite.setMinSize(rightContentComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		init();
	}
	
	private void init(){
		tenderProjectService = new TenderProjectService();
		projectRuleService = new ProjectRuleService();
		menuService = new MenuService();
		
		tenderNameLabel.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				enterProjectAction();
			}
		});
		tenderNameLabel.addMouseTrackListener(new MouseTrackAdapter(){
			public void mouseEnter(MouseEvent e) {
				tenderNameLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
				tenderNameLabel.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_HAND));
			}
			public void mouseExit(MouseEvent e) {
				tenderNameLabel.setForeground(SWTResourceManager.getColor(80, 80, 80));
				tenderNameLabel.setCursor(null);
			}
			
		});
		SyncThreadSet myThreadSet = new SyncThreadSet(new SyncThreadSet.Runnable() {
			public void run() {
				Display.getDefault().syncExec(new Runnable(){
					public void run(){
						if(rightContentComposite.isDisposed())return;
						tenderNoLabel.setText("["+tenderProject.getParentProjectEntity().getTenderNo() + "]");
						tenderNameLabel.setText(tenderProject.getParentProjectEntity().getTenderName());
						packageNameLabel.setText(" --- [" + tenderProject.getTenderNo() + "]" + tenderProject.getTenderName());
						tenderNoLabel.getParent().layout();
						tenderNameLabel.getParent().layout();
						packageNameLabel.getParent().layout();
						rightContentComposite.setData("tenderProjectEntity", tenderProject);
						rightContentComposite.setData("parentProject", tenderProject.getParentProjectEntity());
						rightContentComposite.setData("topComposite", topComposite);
						
						loadTenderProjectLeftMenu(menuList);
						
					} 
				});	
			}
		});
		
		myThreadSet.addSyncExec(new SyncThread(new SyncThread.Runnable() {
			public void run() {
				tenderProject = tenderProjectService.getTenderProjectInfo(tenderProject.getId());
				if(StringUtils.isNotEmpty(tenderProject.getParentId())){
					TenderProjectEntity parentProject = tenderProjectService.getTenderProjectInfo(tenderProject.getParentId());
					tenderProject.setParentProjectEntity(parentProject);
 				}
			}
		}));
		
		myThreadSet.addSyncExec(new SyncThread(new SyncThread.Runnable() {
			public void run() {
				tenderProjectRule = projectRuleService.getProjectRule(tenderProject.getId());
			}
		}));

		myThreadSet.addSyncExec(new SyncThread(new SyncThread.Runnable() {
			public void run() {
				menuList = menuService.getUserRoleMenuList(Constants.USER.getId(),Constants.USER.getAuthRole().getId(), MenuEnum.OPENING_PROJECT);
			}
		}));
		myThreadSet.start();
		
		
		new AutoVerifyUserRemotePasswordThread(tenderProject,Constants.USER.getEncodePassWord()).start();
		// 如果未获取最新投标信息,则自动获取
		if(!tenderProjectService.isGetLatestBidinfo(tenderProject.getId())){
			new RefreshProjectSupplierTenderInfoThread(tenderProject, new ProgressMessageAdapter(){

				@Override
				public int getErrorMessagesSize() {
					// TODO Auto-generated method stub
					return 0;
				}}).start();
		}
		tenderNoLabel.addMouseListener(new ChangeTextListener());
	}

	/**
	 * @Description: 加载不带分包的项目的菜单
	 * @author guoyr
	 */
	private Action loadTenderProjectLeftMenu(List<Menu> menuList){
 		for(Control control : leftMenuComposite.getChildren()){
			control.dispose();
		}
		boolean  hasParentProject = null != tenderProject.getParentProjectEntity();
		rightContentComposite.setData("parentProject", tenderProject.getParentProjectEntity());
		if(null != menuList){
			int topMenuIndex = 0;
			boolean findFirstTopMenu = false;
			for(Menu menu : menuList){
				boolean showTopMenu = true;
 				if(!hasParentProject){
					if("00".equals(menu.getParam("parentVisible"))){
						showTopMenu = false;;
					}
				}else {
					if("00".equals(menu.getParam("packVisible"))){
						showTopMenu = false;;
					}
				}
				if(!showTopMenu){
					continue;
				}
				ImageButton topMenu = null;		
				List<Menu> subMenuList = menu.getChildList();
				if(null != subMenuList && subMenuList.size() > 0){
					int index = 0;
					boolean findFirstMenu = false;
					for(Menu subMenu : subMenuList){
						boolean showThisMenu = true;
						if(!hasParentProject){
							if("00".equals(subMenu.getParam("parentVisible"))){
								showThisMenu = false;;
							}
						}else {
							if("00".equals(subMenu.getParam("packVisible"))){
								showThisMenu = false;
							}
						}
						if(!showThisMenu){
							continue;
						}
						if(index == 0){
							topMenu =  createTopMenu(menu);
						}
						ImageButton subMenuBtn = addSubMenu(topMenu, subMenu, index);
						if(index == 0){
							topMenu.setData("firstMenuBtn", subMenuBtn);
						}
						if(null != curMenuId && curMenuId.equals(subMenu.getId())){
							topMenu.setData("firstMenuBtn", subMenuBtn);
							curTopMenuBtn = topMenu;
							findFirstMenu = true;
							findFirstTopMenu = true;
						}
						if(!findFirstMenu && "01".equals(subMenu.getParam("firstMenu"))){
							topMenu.setData("firstMenuBtn", subMenuBtn);
							findFirstMenu = true;
						}
						index ++;
					}
					if(null != topMenu){
						Composite subMenuComposite = (Composite)topMenu.getData("subMenuComposite"); 
						GridData gridData = (GridData)subMenuComposite.getLayoutData();
						if(subMenuComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y < 150){
							gridData.heightHint = 150;
						}
					}
				}else {
					topMenu = addSignMenu(leftMenuComposite, menu);
					if(null != curMenuId && curMenuId.equals(menu.getId())){
						curTopMenuBtn = topMenu;
						findFirstTopMenu = true;
					}
				}
				
				if(null == curTopMenuBtn || topMenuIndex == 0){
					curTopMenuBtn = topMenu;
				}
				topMenuIndex ++;
				if(!findFirstTopMenu && "01".equals(menu.getParam("firstMenu"))){

					// 避免一直进入选择包件界面
					if(null != curTopMenuBtn && null != menu.getParam("ignore")) {
						continue;
					}
					curTopMenuBtn = topMenu;
					findFirstTopMenu = true;
				}
			}
		}
		
		if(null != curTopMenuBtn){
			curTopMenuBtn.notifyListeners(SWT.MouseUp, null);
		}
		leftMenuComposite.layout();
 		scrolledComposite.setMinSize(leftMenuComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		scrolledComposite.getParent().layout();
		return defaultAction;
	}
	private ImageButton addSubMenu(final ImageButton topMenuBtn, Menu menu, int index){
		final Composite subMenuComposite = null != topMenuBtn ? (Composite)topMenuBtn.getData("subMenuComposite") : leftMenuComposite;
		ImageButton actionLabel = new ImageButton(subMenuComposite, SWT.LEFT);
		actionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		actionLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		actionLabel.setActiveForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		actionLabel.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.NORMAL));
		actionLabel.setTopMargin(6);
		actionLabel.setBottomMargin(6);
		actionLabel.setLeftMargin(15);
		actionLabel.setActiveBackgroundColor(SWTResourceManager.getColor(245, 150, 50));
		actionLabel.setSelectionBgColor(SWTResourceManager.getColor(255, 153, 51));
		actionLabel.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/point.png"));
		actionLabel.setText(MenuMessages.getValue(menu.getLanguageCode(), menu.getMenuShortName()));
		
		final Action action = (Action)ActionUtil.getAction(menu.getMenuUrl());
		if(null != action){
			if("01".equals(menu.getParam("firstMenu"))){
				defaultAction = action;
			}
			action.setMenu(menu);
			action.setData("menu", menu);
			action.setData("menuLabel", actionLabel);
			action.setParentProject(tenderProject.getParentProjectEntity());
  			action.setTenderProject(tenderProject);
			action.setData("topActionListener", topActionListener);
			action.addActionListener(this);
			actionLabel.addMouseListener(new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					if(null != topMenuBtn){
 						curTopMenuBtn = topMenuBtn;
					}
					if(null == menu.getParam("ignore")){
						curMenuId = menu.getId();
					}
					action.run();
				}
			});
		}
		return actionLabel;
	}
		
	private ImageButton addSignMenu(Composite subMenuComposite, Menu menu){
		ImageButton actionLabel = new ImageButton(subMenuComposite, SWT.LEFT);
		actionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		actionLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		actionLabel.setActiveForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		actionLabel.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		actionLabel.setLeftMargin(8);
		actionLabel.setGAP(10);
		actionLabel.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/default.png"));
		actionLabel.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/bg.png"));
		actionLabel.setActiveBgImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/active_bg.png"));
		actionLabel.setSubImageHorAlign(SWT.RIGHT);
		actionLabel.setSubImageVerAlign(SWT.CENTER);
		actionLabel.setSubImageRightMargin(10);
		actionLabel.setSubImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/right.png"));
		actionLabel.setMinWidth(150);
		
		Image menuImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID, menu.getMenuIcon());
		if(null != menuImage){
			actionLabel.setImage(menuImage, 16, 16);
		}else {
			if(null == defaultTopIco){
				defaultTopIco = ResourceManager.getPluginImage(Activator.PLUGIN_ID, "icons/left_menu/project_manage.png");
			} 
			actionLabel.setImage(defaultTopIco, 16, 16);
		}
		actionLabel.setText(MenuMessages.getValue(menu.getLanguageCode(), menu.getMenuShortName()));
		
		final Action action = (Action)ActionUtil.getAction(menu.getMenuUrl());
		if(null != action){
			if("01".equals(menu.getParam("firstMenu"))){
				defaultAction = action;
			}
			action.setData("menu", menu);
			action.setMenu(menu);
			action.setParentProject(tenderProject.getParentProjectEntity());
			action.setTenderProject(tenderProject);
			action.setTenderProjectRule(tenderProjectRule);
			action.setData("menuLabel", actionLabel);
			action.setData("topActionListener", topActionListener);
			action.addActionListener(this);
			actionLabel.addMouseListener(new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					if(null != curTopMenuBtn){
 						curTopMenuBtn.setSelection(false);
					}
					if(null == menu.getParam("ignore")){
						curMenuId = menu.getId();
					}
					action.run();
				}
			});
		}
		return actionLabel;
	}
	
	
	private ImageButton createTopMenu(Menu menu){
		final ImageButton menuTitle = new ImageButton(leftMenuComposite, SWT.LEFT);
		menuTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		menuTitle.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		menuTitle.setActiveForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		menuTitle.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		menuTitle.setGAP(10);
		menuTitle.setLeftMargin(8);
		menuTitle.setBackground(SWTResourceManager.getColor(34, 145, 226));
		menuTitle.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/bg.png"));
		
		menuTitle.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/default.png"));
		menuTitle.setActiveBgImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/active_bg.png"));
		
		menuTitle.setSubImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/down.png"));
		menuTitle.setSubImageHorAlign(SWT.RIGHT);
		menuTitle.setSubImageVerAlign(SWT.CENTER);
		menuTitle.setSubImageRightMargin(10);
		menuTitle.setMinWidth(150);
		Image menuImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID, menu.getMenuIcon());
		if(null != menuImage){
			menuTitle.setImage(menuImage, 16, 16);
		}else {
			if(null == defaultTopIco){
				defaultTopIco = ResourceManager.getPluginImage(Activator.PLUGIN_ID, "icons/menu/blue/default.png");
			} 
			menuTitle.setImage(defaultTopIco);
		}
		menuTitle.setText(MenuMessages.getValue(menu.getLanguageCode(), menu.getMenuShortName()));
		
		final Composite subMenuComposite = new Composite(leftMenuComposite, SWT.NONE);
		GridData menuGridData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
		subMenuComposite.setLayoutData(menuGridData);
		subMenuComposite.setBackground(SWTResourceManager.getColor(14, 115, 197));
		subMenuComposite.setBackgroundMode(SWT.INHERIT_FORCE);
		
		GridLayout gl_subMenuComposite = new GridLayout(1, false);
		gl_subMenuComposite.verticalSpacing = 0;
		gl_subMenuComposite.horizontalSpacing = 0;
		gl_subMenuComposite.marginHeight = 0;
		gl_subMenuComposite.marginWidth = 0;
		subMenuComposite.setLayout(gl_subMenuComposite);
		((GridData)subMenuComposite.getLayoutData()).exclude = true;
		subMenuComposite.setVisible(false);
		
		menuTitle.setData("subMenuComposite", subMenuComposite);
		menuTitle.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				if(null != curTopMenuBtn && !curTopMenuBtn.isDisposed() && !curTopMenuBtn.equals(menuTitle)){
					curTopMenuBtn.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/bg.png"));
					curTopMenuBtn.setSubImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/down.png"));
					Composite menuContent = (Composite)curTopMenuBtn.getData("subMenuComposite");
					if(null != menuContent && !menuContent.isDisposed() && menuContent.getVisible()){
						((GridData)menuContent.getLayoutData()).exclude = true;
						menuContent.setVisible(false);
					}
				}
				if(!subMenuComposite.getVisible()){
					((GridData)subMenuComposite.getLayoutData()).exclude = false;
					subMenuComposite.setVisible(true);
					menuTitle.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/open_bg.png"));
					menuTitle.setSubImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/up.png"));
					ImageButton firstMenuBtn = (ImageButton)menuTitle.getData("firstMenuBtn");
					if(null != firstMenuBtn && !firstMenuBtn.isDisposed()){
						firstMenuBtn.notifyListeners(SWT.MouseUp, null);
					}
				}else {
					((GridData)subMenuComposite.getLayoutData()).exclude = true;
					subMenuComposite.setVisible(false);
					menuTitle.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/bg.png"));
					menuTitle.setSubImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/menu/blue/down.png"));
				}
				curTopMenuBtn = menuTitle;
				leftMenuComposite.layout();
				scrolledComposite.setMinSize(leftMenuComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
			}
		});
		
		return menuTitle;
	}
	
	protected void checkSubclass() {
	}
	
	public void onLoad(Action action) {
		action.setTenderProject(tenderProject);
		action.setParentProject(tenderProject.getParentProjectEntity());
		action.setMenu(action.getMenu());
		action.setTenderProject(tenderProject);
		for(Control control : rightContentComposite.getChildren()){
			control.dispose();
		}
		if(null != curMenu){
			curMenu.setSelection(false);
		}
		if(null != action.getData("menuLabel")){
			curMenu = (ImageButton)action.getData("menuLabel");
		}
		if(null != curMenu){
			curMenu.setSelection(true);
		}
	}
	public void loadComposite(Action action, Composite content) {
		rightContentComposite.layout();
	}
	public Composite getParentComposite() {
		rightContentComposite.setData("tenderProjectEntity", tenderProject);
		rightContentComposite.setData("parentProject", tenderProject.getParentProjectEntity());
		rightContentComposite.setData("topComposite", topComposite);
		return rightContentComposite;
	}
//	private void refreshVideoRoomStatus(){
//		if(isInVideoRoom){
//			living_button.setText("退出直播室");
//			living_button.setImage(ResourceManager.getPluginImage("com.gx.obe.opening", "icons/v_stop.png"));
//		}else{
//			living_button.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/videoOpen.png"));
//			living_button.setText("进入直播室");
//		}
//	}
	
	private void enterProjectAction(){
		final Action action = ActionUtil.getAction(EnterProjectAction.class.getName());
		action.addActionListener(topActionListener);
		action.setTenderProject(tenderProject.getParentProjectEntity());
		action.run();
	}
//	/**
//	 * @Description: 进入直播
//	 * @author guoyr 
//	 */
//	private void enterOrExitVideoLiveRoom(){
//		if(isInVideoRoom){
//			VideoLiveShell.exitVideoLiveRoom();
//		}else {
//			if(!VideoLiveShell.enterVideoLiveRoom(videoLiveListener)){
//				MessageDialog.openWarning(getShell(), "已进入其他项目的直播室,请先退出直播室!");
//			}
//		}
//	}
}