package com.gx.obe.evaluation.step.dialog;

import org.eclipse.swt.SWT;
import org.eclipse.swt.core.widgets.EDialog;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.gx.obe.ColorConstants;
import com.gx.obe.message.Messages;
import com.gx.obe.util.utils.LogUtils;
import com.gx.obe.web.entity.Supplier;
import com.gx.obe.web.entity.SupplierEvaluationResult;
import com.gx.obe.web.entity.tender.TenderProjectEntity;
import com.gx.obe.web.service.SupplierEvaluationResultService;
import com.swtdesigner.SWTResourceManager;

/**
 * @Description: 详细评审对话框
 * @author guoyr
 */
public class SupplierEvaluationOpinionDetailDialog extends EDialog {
	private TenderProjectEntity tenderProjectEntity;
	private Supplier supplier;
	private SupplierEvaluationResultService supplierEvaluationResultService ;
	private SupplierEvaluationResult supplierEvaluationResult;
	private Text requirementText;
	private Text supplierEvalOpinionText;
	
	{
		LogUtils.logClass(SupplierEvaluationOpinionDetailDialog.class);
	}
	
	/**
	 * @param parentShell
	 * @param tenderProjectEntity
	 * @param supplier
	 * @param evaluationFactor
	 * @param expertEvaluationResult
	 * @param evalFactorResult
	 * @param callBack
	 */
	public SupplierEvaluationOpinionDetailDialog(Shell parentShell, TenderProjectEntity tenderProjectEntity, Supplier supplier) {
		super(parentShell);
		setTitle(supplier.getSupplierName());
		this.tenderProjectEntity = tenderProjectEntity;
		this.supplier = supplier;
		supplierEvaluationResultService = new SupplierEvaluationResultService();
	}

	/** 
	 * @Description: 
	 * @param parent
	 * @return
	 */
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite top = (Composite) super.createDialogArea(parent);
		GridLayout gl_top = new GridLayout(1, false);
		gl_top.verticalSpacing = 0;
		gl_top.horizontalSpacing = 0;
		gl_top.marginHeight = 0;
		gl_top.marginWidth = 0;
		top.setLayout(gl_top);
		
		Composite container = new Composite(top, SWT.NONE);
		container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_container = new GridLayout(1, false);
		gl_container.marginHeight = 10;
		gl_container.marginWidth = 10;
		container.setLayout(gl_container);
		
		Composite composite_3 = new Composite(container, SWT.NONE);
		GridData gd_composite_3 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_composite_3.heightHint = 50;
		composite_3.setLayoutData(gd_composite_3);
		GridLayout gl_composite_3 = new GridLayout(1, false);
		gl_composite_3.verticalSpacing = 1;
		gl_composite_3.horizontalSpacing = 0;
		gl_composite_3.marginHeight = 1;
		gl_composite_3.marginWidth = 1;
		composite_3.setLayout(gl_composite_3);
		composite_3.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
		Composite composite_1 = new Composite(composite_3, SWT.NONE);
		composite_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		composite_1.setLayout(new GridLayout(3, false));
		
		Label label_2 = new Label(composite_1, SWT.NONE);
		label_2.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		label_2.setForeground(ColorConstants.FONT_BLACK_COLOR);
		label_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		label_2.setText(Messages.Title_biddingFileRequir);
		
		
//		ESepator req_sep = new ESepator(composite_3, SWT.NONE);
//		req_sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
//		req_sep.setBackground(ColorConstants.BORDER_LINE_COLOR);
//		req_sep.setLineStyle(SWT.LINE_DOT);
//		req_sep.setLineWidth(2);
		
		requirementText = new Text(composite_3, SWT.V_SCROLL | SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
		requirementText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		requirementText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		Composite composite_2 = new Composite(container, SWT.NONE);
		GridData gd_composite_2 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_composite_2.heightHint = 50;
		composite_2.setLayoutData(gd_composite_2);
		GridLayout gl_composite_2 = new GridLayout(1, false);
		gl_composite_2.verticalSpacing = 1;
		gl_composite_2.horizontalSpacing = 1;
		gl_composite_2.marginHeight = 1;
		gl_composite_2.marginWidth = 1;
		composite_2.setLayout(gl_composite_2);
		composite_2.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
		Composite composite_4 = new Composite(composite_2, SWT.NONE);
		composite_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		composite_4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		composite_4.setLayout(new GridLayout(2, false));
		
		Label label_1 = new Label(composite_4, SWT.NONE);
		label_1.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		label_1.setForeground(ColorConstants.FONT_BLACK_COLOR);
		label_1.setText(Messages.Button_evalOrWasteOpinion);
		
//		ESepator opi_sep = new ESepator(composite_2, SWT.NONE);
//		opi_sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
//		opi_sep.setBackground(ColorConstants.BORDER_LINE_COLOR);
//		opi_sep.setLineStyle(SWT.LINE_DOT);
//		opi_sep.setLineWidth(2);
		
		supplierEvalOpinionText = new Text(composite_2, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI);
		supplierEvalOpinionText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		supplierEvalOpinionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		supplierEvalOpinionText.setTextLimit(500);
		
		init();
		return container;
	}

	/**
	 * @Description: 初始化界面数据
	 * @author guoyr
	 */
	private void init(){
		this.setTitle(supplier.getSupplierName() + Messages.Button_evalOrWasteOpinion);
		supplierEvaluationResult = supplierEvaluationResultService.getSupplierEvaluationResultByTenderIdAndSupplierId(tenderProjectEntity.getId(), supplier.getId());
		if(null != supplierEvaluationResult){
			requirementText.setText(null != supplierEvaluationResult.getBiddingRequest() ? supplierEvaluationResult.getBiddingRequest() : "");
			supplierEvalOpinionText.setText(null != supplierEvaluationResult.getEvaluationOpinion() ? supplierEvaluationResult.getEvaluationOpinion() : "");
		}
	}
	
	@Override
	protected Point getInitialSize() {
		return new Point(678, 451);
	}
}
