package com.gx.obe.management.composite;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;

import com.gx.obe.action.bean.Action;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.common.widget.button.BigImageButton;
import com.gx.obe.management.shell.EvaluationRoomShell;
import com.gx.obe.message.Messages;
import com.swtdesigner.ResourceManager;

public class EnterEvaluationRoomComposite extends Composite {

	private Action projectAction;
	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public EnterEvaluationRoomComposite(Composite parent, Action projectAction, int style) {
		super(parent, style);
		setLayout(new GridLayout(1, false));
		this.projectAction = projectAction;
		
		BigImageButton label = new BigImageButton(this, SWT.BOTTOM);
		label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1));
		label.setText(Messages.Button_enterEvaluationHall);
		label.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/home.png"), 48, 48);
		label.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				enterEvaluationRoom();
			}
		});

		enterEvaluationRoom();
	}
	
	private void enterEvaluationRoom(){
		EvaluationRoomShell evaluationRoomShell = new EvaluationRoomShell(getShell());
		Composite parentComposite = evaluationRoomShell.getLoadParent();
		parentComposite.setData("tenderProjectEntity", projectAction.getTenderProject());
		parentComposite.setData("menu", projectAction.getMenu());
		parentComposite.setData("meetingRoomListener", evaluationRoomShell);
		EvaluationRoomHomeComposite bidOpeningRemoteComposite = new EvaluationRoomHomeComposite(parentComposite, SWT.NONE);
		bidOpeningRemoteComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		parentComposite.layout();
		evaluationRoomShell.open();
	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}

}
