package com.gx.obe.management;

import java.text.MessageFormat;
import java.util.List;

import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.MessageDialog;
import org.eclipse.swt.core.utils.SwtUtils;
import org.eclipse.swt.core.widgets.ELabel;
import org.eclipse.swt.core.widgets.EMenu;
import org.eclipse.swt.core.widgets.ImageButton;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
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.Shell;

import com.gx.obe.AboutDialog;
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.business.enumeration.TaskEnum;
import com.gx.obe.common.dialog.UpdateInitPasswordDialog;
import com.gx.obe.common.dialog.UpdateUserInfoDialog;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.components.core.Constants;
import com.gx.obe.components.core.enumeration.CommonEnum;
import com.gx.obe.config.ConfigConstants;
import com.gx.obe.config.utils.PropertiesUtils;
import com.gx.obe.im.dialog.ChatWindow;
import com.gx.obe.im.dialog.ClientDialog;
import com.gx.obe.message.Messages;
import com.gx.obe.message.menu.MenuMessages;
import com.gx.obe.thread.CheckLogoutThread;
import com.gx.obe.util.utils.ScreenUtils;
import com.gx.obe.web.entity.auth.AuthUser;
import com.gx.obe.web.entity.auth.Menu;
import com.gx.obe.web.service.MenuService;
import com.gx.obe.web.service.TaskService;
import com.gx.obe.web.service.UserService;
import com.gx.security.CertificateException;
import com.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

import im.IChatWindow;
import im.IMClientAdapter;
import im.entity.Employee;
import im.entity.Group;
import im.entity.Message;
import im.enumeration.PropertieEnum;
import im.listener.ChatListener;
import im.listener.ChatWindowListener;
import im.listener.NoticeListener;
import im.server.GroupService;

public class MainDialog implements ActionListener{

	protected Object result;
	protected Shell shell;
	private ELabel max_size_btn;
	private CLabel product_title;
	private Composite load_composite;
	private Composite menu_composite;
	private Composite top_composite;
	private CheckLogoutThread checkLogoutThread;
	private ELabel menu_btn;
	private boolean maxSize = true;
	private int screenHight;
	private ScreenUtils  util = new ScreenUtils();
	private MenuService menuService;
	private ImageButton firstMenuButton;
	private Logger LOG = Logger.getLogger(MainDialog.class);	
	private ClientDialog clientDialog;
	private IMClientAdapter imClientAdapter;
	
	private ImageButton myTaskButton;
	
	private final TaskService taskService = new TaskService();
	
	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		modifyPassWord();
		Display display = Display.getDefault();
		while (!shell.isDisposed()) {
			try {
				if (!display.readAndDispatch()) {
					display.sleep();
				}
			} catch (Exception e) {
				StackTraceElement[] stackTraceElements = e.getStackTrace();
				if(null != stackTraceElements && stackTraceElements.length > 0) {
					LOG.error("操作发生异常："+e.toString());
					for(StackTraceElement stackTraceElement : stackTraceElements) {
						LOG.error(stackTraceElement.toString());
					}
				}
			}
		
		}
		checkLogoutThread.stop();
		if(null != imClientAdapter) {
			imClientAdapter.quitOut();
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 * @wbp.parser.entryPoint
	 */
	private void createContents() {
		shell = new Shell(SWT.NO_TRIM);
//		shell.setSize(800, 600);
		//计算电脑屏幕空间，电脑显示屏 整个 高度减去任务栏高度
		screenHight = util.getScreenHight() -util.getTaskBarHight();
		shell.setSize(util.getScreenWight(), screenHight);
		shell.setLocation(0, 0);
		shell.setText(Messages.Terminal_management);
		shell.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/evaluation-ico.png"));
		GridLayout gl_shell = new GridLayout(1, false);
		gl_shell.horizontalSpacing = 0;
		gl_shell.verticalSpacing = 0;
		gl_shell.marginHeight = 0;
		gl_shell.marginWidth = 0;
		shell.setLayout(gl_shell);
		
		shell.addControlListener(new ControlAdapter() {
			@Override
			public void controlResized(ControlEvent e) {
				shellResizedAction();
			}
		});
		
		top_composite = new Composite(shell, SWT.NONE);
		top_composite.setBackground(ColorConstants.SKIN_BG);
		top_composite.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/main_title_bg.png"));
		top_composite.setBackgroundMode(SWT.INHERIT_FORCE);
		GridLayout gl_top_composite = new GridLayout(3, false);
		gl_top_composite.marginHeight = 0;
		gl_top_composite.marginWidth = 0;
		top_composite.setLayout(gl_top_composite);
		top_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		
		product_title = new CLabel(top_composite, SWT.NONE);
		product_title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		product_title.setFont(SWTResourceManager.getFont("微软雅黑", 13, SWT.BOLD));
		product_title.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		product_title.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/logo.png"));
		product_title.setText(Messages.Terminal_management);
		
		menu_composite = new Composite(top_composite, SWT.NONE);
		RowLayout rl_menu_composite = new RowLayout(SWT.HORIZONTAL);
		rl_menu_composite.fill = true;
		rl_menu_composite.marginLeft = 80;
		menu_composite.setLayout(rl_menu_composite);
		menu_composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
//		ImageButton myProject_btn = new ImageButton(menu_composite, SWT.NONE);
//		myProject_btn.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
//		myProject_btn.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
//		myProject_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/main_home.png"));
//		myProject_btn.addMouseListener(new MouseAdapter() {
//			@Override
//			public void mouseUp(MouseEvent e) {
//				myProjectAction();
//			}
//		});
//		myProject_btn.setActiveForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
//		myProject_btn.setBackground(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/main_mydesk.png"));
//		myProject_btn.setActiveBgImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/main_mydesk_on.png"));
//		myProject_btn.setLeftOffset(20);
//		myProject_btn.setRightOffset(20);
//		myProject_btn.setLeftMargin(10);
//		myProject_btn.setRightMargin(10);
//		myProject_btn.setText(Messages.TenderProjectListComposite_myProject);
		
		
		Composite composite_2 = new Composite(top_composite, SWT.NONE | SWT.SELECTED);
		composite_2.setLayout(new GridLayout(5, false));
		
		ELabel config_btn = new ELabel(composite_2, SWT.NONE | SWT.SELECTED);
		config_btn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				
				//TODO 添加配置文件信息
				
			}
		});
		config_btn.setVisible(false);
		config_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/more_op.png"));
		config_btn.setMargins(5, 5, 5, 5);
		config_btn.setActiveColor(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		config_btn.setAlpha(10);
		
		menu_btn = new ELabel(composite_2, SWT.NONE | SWT.SELECTED);
		menu_btn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				showConfigMenu();
			}
		}); 
		menu_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/more_op.png"));
		menu_btn.setMargins(5, 5, 5, 5);
		menu_btn.setActiveColor(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		menu_btn.setAlpha(10);
		
		ELabel min_size_btn = new ELabel(composite_2, SWT.NONE | SWT.SELECTED);
		min_size_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/min_size.png"));
		min_size_btn.setMargins(5, 5, 5, 5);
		min_size_btn.setActiveColor(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		min_size_btn.setAlpha(10);
		min_size_btn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				shell.setMinimized(true);
			}
		});
		
		max_size_btn = new ELabel(composite_2, SWT.NONE | SWT.SELECTED);
		max_size_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/back_size.png"));
		max_size_btn.setMargins(5, 5, 5, 5);
		max_size_btn.setActiveColor(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		max_size_btn.setAlpha(10);
		
		ELabel close_btn = new ELabel(composite_2, SWT.NONE | SWT.SELECTED);
		close_btn.setActiveColor(SWTResourceManager.getColor(SWT.COLOR_RED));
		close_btn.setMargins(5, 5, 5, 5);
		close_btn.setFillGradient(false);
		close_btn.setAlpha(10);
		close_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/main_close.png"));
		close_btn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				systemClose();
			}
		});
		
		Composite content_composite = new Composite(shell, SWT.NONE);
		content_composite.setBackground(ColorConstants.SKIN_BG);
		content_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_content_composite = new GridLayout(1, false);
		gl_content_composite.marginBottom = 1;
		gl_content_composite.marginHeight = 0;
		gl_content_composite.marginRight = 1;
		gl_content_composite.marginLeft = 1;
		gl_content_composite.marginWidth = 0;
		content_composite.setLayout(gl_content_composite);
		
		load_composite = new Composite(content_composite, SWT.NONE);
		load_composite.setBackgroundMode(SWT.INHERIT_FORCE);
		load_composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		load_composite.setLayout(new FillLayout(SWT.HORIZONTAL));
		load_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		init();
	}
	
	/**
	 * @Description: 初始化
	 * @author guoyr 
	 */
	private void init(){
		SwtUtils.setMouseDragListener(product_title);
		SwtUtils.setMouseDragListener(top_composite);
		/**
		 * 第二层验证
		 * **/
		try {
			com.gx.security.CertValidator.getInstance().validateAuthorization();
		} catch (CertificateException e) {
			throw new com.gx.security.SecurityRuntimeException(e);
		}
		
//		Action action = (Action)ActionUtil.getAction(MyProjectAction.class.getName());
//		action.addActionListener(this);
//		action.run();
		loadTopMenu();
		top_composite.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDoubleClick(MouseEvent e) {
				max_size_btn.notifyListeners(SWT.MouseUp, null);
			}
		});
		product_title.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDoubleClick(MouseEvent e) {
				max_size_btn.notifyListeners(SWT.MouseUp, null);
			}
		});
		max_size_btn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				maxSize = !maxSize;
				if(maxSize){
					shell.setSize(util.getScreenWight(), screenHight);
					shell.setLocation(0, 0);
				}else{
					shell.setSize((int)(util.getScreenWight() * 0.8), (int)(screenHight * 0.8));
					SwtUtils.setCenter(shell);
				}
				shell.redraw();
			}
		});
		
		checkLogoutThread = new CheckLogoutThread(Constants.USER, Constants.TERMINAL_MANAGEMENT, new CheckLogoutThread.LogoutListener(){
			public void loginout() {
				Display.getDefault().asyncExec(new Runnable() {
					public void run() {
						if(!shell.isDisposed()){
							if(MessageDialog.openConfirm(null, Messages.Dialog_warmTips , MessageFormat.format(Messages.Login_reLoginTips, new Object[]{Constants.USER.getUserAccount()}), new String[]{Messages.Login_reLogin, Messages.Login_closeSystem})){
								ManagementApplication.restart();
					    	}else {
					    		ManagementApplication.exit();
					    	}			
						}
					}
				});
			}
		});
		checkLogoutThread.start();
		connectServer();
	}
	
	private void loadTopMenu(){
		new Thread(new Runnable(){
			public void run(){
				if(null == menuService ){
					menuService = new MenuService();
				}
				List<Menu> menuEntityList = menuService.getUserRoleMenuList(Constants.USER.getId(), Constants.USER.getAuthRole().getId(), MenuEnum.MANAGEMENT_TOP_MENU);
				if(null != menuEntityList){
					final List<Menu> tempMenuEntityList = menuEntityList;
					Display.getDefault().syncExec(new Runnable(){
						public void run(){
							if(!menu_composite.isDisposed()){
								for(final Menu topMenu : tempMenuEntityList){
									addTopMenu(topMenu);	
								}
								refreshMyTaskButton();
								menu_composite.layout();
								top_composite.layout();
								if(null != firstMenuButton && !firstMenuButton.isDisposed()){
									firstMenuButton.notifyListeners(SWT.MouseUp, null);
								}
							}
						}
					});
				}
			}
		}).start();
	}
	
	private void addTopMenu(Menu menu){
		final ImageButton topButton = new ImageButton(menu_composite, SWT.NONE);
		topButton.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		topButton.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		topButton.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/lan.png"));
		topButton.setActiveForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		topButton.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/main_mydesk.png"));
		topButton.setActiveBgImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/main_mydesk_on.png"));
		topButton.setText(MenuMessages.getValue(menu.getLanguageCode(), menu.getMenuShortName()));
		topButton.setLeftOffset(20);
		topButton.setRightOffset(20);
		topButton.setLeftMargin(10);
		topButton.setRightMargin(10);
		Image menuImage = ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, menu.getMenuIcon());
		if(null != menuImage){
			topButton.setImage(menuImage, 16, 16);
		}
		if(null == firstMenuButton){
			firstMenuButton = topButton;
		}
		if("01".equals(menu.getParam("firstMenu"))){
			firstMenuButton = topButton;
		}
		if ("my_task".equals(menu.getParam("menu_type"))) {
			myTaskButton = topButton;
		}
		final Action action = (Action)ActionUtil.getAction(menu.getMenuUrl());
		if(null != action){
			action.setMenu(menu);
			action.setData("menu", menu);
			action.addActionListener(this);
			action.setMenu(menu);
			topButton.addMouseListener(new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					action.run();
				}
			});
		}
	}
	
	/**
	 * @Description: 刷新我的待办按钮
	 * @author chenxw 
	 */
	private void refreshMyTaskButton() {
		if (myTaskButton == null) {
			return;
		}
		int taskCount = taskService.getTaskCount(Constants.USER.getId(), TaskEnum.STATE.NOT_STARTED.getKey());
		Display.getDefault().syncExec(() -> {
			if (myTaskButton.isDisposed()) {
				return;
			}
			if (taskCount == 0) {
				myTaskButton.setSubText(null);
			} else {
				myTaskButton.setSubText(String.valueOf(taskCount));
				myTaskButton.setSubTextHorAlign(SWT.RIGHT);
				myTaskButton.setSubTextVerAlign(SWT.TOP);
			}
		});
	}
	
	/**
	 * @Description: 强制弹出修改密码
	 * @author guoyr 
	 */
	private void modifyPassWord(){
		if (CommonEnum.YES.equals(Constants.USER.getDefaultPassword())) {
			UpdateInitPasswordDialog dialog = new UpdateInitPasswordDialog(shell, Constants.USER);
			dialog.open();
		}
		if (CommonEnum.YES.equals(Constants.USER.getDefaultPassword())) {
			ManagementApplication.exit();
		}
	}
	
	/**
	 * @Description: 最大化，还原最大化图标设置
	 * @author guoyr 
	 */
	private void shellResizedAction(){
		if(maxSize){
			max_size_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/back_size.png"));
		}else {
			max_size_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/max_size.png"));
		}
	}

	public void onLoad(Action action) {
		for(Control control : load_composite.getChildren()){
			control.dispose();
		}
	}

	public void loadComposite(Action action, Composite composite) {
		load_composite.layout();	
	}

	public Composite getParentComposite() {
		return load_composite;
	}
	
	/**
	 * @Description: 打开聊天窗口
	 * @author guoyr 
	 */
	private void openChatGroupAction(){
		if(IMClientAdapter.getInstance().hasNewMessage()){
			IMClientAdapter.getInstance().showNewMessage();
			return;
		}
        if (IMClientAdapter.getInstance().hasNewGroupMessage() ){
        	IMClientAdapter.getInstance().showNewGroupMessage();
            return;
        }
        if(null == clientDialog || clientDialog.isDisposed()){
        	clientDialog = new ClientDialog(null);
        }
        clientDialog.open();
	}
	
	private void connectServer() {
		//聊天
		imClientAdapter = IMClientAdapter.getInstance();
		
		String serverIp = PropertiesUtils.getProperty(ConfigConstants.OBE_WEB_SERVICE_URL, "127.0.0.1");
		int serverPort = Integer.parseInt(PropertiesUtils.getProperty(PropertieEnum.SERVER_PORT, "1987"));
		int serverChatPort = Integer.parseInt(PropertiesUtils.getProperty(PropertieEnum.CHAT_PORT, "1988"));
		imClientAdapter.connectionServer(serverIp, serverPort, serverChatPort, Constants.USER.getId());
		imClientAdapter.addChatWindowListener(new ChatWindowListener(){
			UserService userService = new UserService();
			GroupService groupService = new GroupService();
			public IChatWindow openWindow(final String serverIp, final int serverChatPort, String receiveId, final List<Message> messageList, final ChatListener chatListener) {
				final AuthUser user = userService.findById(receiveId);
				final IChatWindow[] window = new IChatWindow[]{null};
				Display.getDefault().syncExec(new Runnable() {
					public void run() {
						Employee me = new Employee();
						me.setId(Constants.USER.getId());
						me.setEmployeeName(Constants.USER.getUserName());
						Employee receiveUser = new Employee();
						me.setId(user.getId());
						me.setEmployeeName(user.getUserName());
						final IChatWindow chatWindow = new ChatWindow(serverIp, serverChatPort, me, receiveUser, messageList, chatListener);
						chatWindow.open();
						window[0] = chatWindow;
					}
				});
				return window[0];
			}
			
			public IChatWindow openGroupWindow(final String serverIp, final int serverChatPort, final String groupId, final List<Message> messageList, final ChatListener chatListener) {
				final Group group = groupService.getById(groupId);
				final IChatWindow[] window = new IChatWindow[]{null};
				Display.getDefault().syncExec(new Runnable() {
					public void run() {
						Employee me = new Employee();
						me.setId(Constants.USER.getId());
						me.setEmployeeName(Constants.USER.getUserName());
						final IChatWindow chatWindow = new ChatWindow(serverIp, serverChatPort, me, group, messageList, chatListener);
						chatWindow.open();
						window[0] = chatWindow;
					}
				});
				return window[0];
			}
		});
		imClientAdapter.addNoticeListener(new NoticeListener("MY_TASK") {
			public void refreshNotice(String notice) {
				refreshMyTaskButton();
			}
		});
	}
	
	/**
	 * @Description: 系统关闭按钮事件
	 * @author guoyr 
	 */
	public void systemClose(){
		shell.close();
	}
	/**
	 * @Description: 显示配置菜单
	 * @author guoyr 
	 */
	private void showConfigMenu(){

		final EMenu gmenu = new EMenu(this.shell);
		gmenu.addMenuItem(Messages.About, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/about.png"), true, new EMenu.ClickListener() {
			public void click() {
				AboutDialog aboutDialog = new AboutDialog(shell, SWT.NONE);
				aboutDialog.open();
			}
		});
		
//		gmenu.addMenuItem(Messages.PasswordModify, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/edit.png"), true, new EMenu.ClickListener() {
//			public void click() {
//				UpdatePasswordDialog dialog = new UpdatePasswordDialog(shell, Constants.USER);
//				dialog.open();
//			}
//			
//		});
		
		gmenu.addMenuItem(Messages.ModifyUserInfo, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/edit.png"), true, new EMenu.ClickListener() {
			public void click() {
				UpdateUserInfoDialog dialog = new UpdateUserInfoDialog(shell, Constants.USER);
				dialog.open();
			}
			
		});
		
//		gmenu.addMenuItem(Messages.BiddingCa, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/key.png"), true, new EMenu.ClickListener() {
//			public void click() {
//				CABindingDialog dialog = new CABindingDialog(shell, Constants.USER);
//				dialog.open();
//			}
//			
//		});
		gmenu.addMenuItem(Messages.Restart, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/reStart.png"), true, new EMenu.ClickListener() {
			public void click() {
				ManagementApplication.restart();
			}
			
		});
		gmenu.addMenuItem(Messages.Quit, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/exit.png"), true, new EMenu.ClickListener() {
			public void click() {
				ManagementApplication.exit();
			}
			
		});
		gmenu.open(menu_btn);
	
	}
}
