package com.gx.obe.management.dialog;

import java.math.BigDecimal;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.nebula.widgets.grid.listener.GridCheckedListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.CallBack;
import org.eclipse.swt.core.ImageResolver;
import org.eclipse.swt.core.MessageDialog;
import org.eclipse.swt.core.listener.FloatInputListener;
import org.eclipse.swt.core.listener.IntegerInputListener;
import org.eclipse.swt.core.listener.TextHintListener;
import org.eclipse.swt.core.listener.VerifyFloatListener;
import org.eclipse.swt.core.listener.VerifyMaxListener;
import org.eclipse.swt.core.listener.VerifyMinListener;
import org.eclipse.swt.core.listener.VerifyRequiredListener;
import org.eclipse.swt.core.utils.GridUtils;
import org.eclipse.swt.core.utils.ValidateUtils;
import org.eclipse.swt.core.utils.WidgetUtils;
import org.eclipse.swt.core.widgets.EButton;
import org.eclipse.swt.core.widgets.EDialog;
import org.eclipse.swt.core.widgets.ELink;
import org.eclipse.swt.core.widgets.ESepator;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.gx.obe.ColorConstants;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.common.widget.button.Tips;
import com.gx.obe.common.widget.dialog.SelectStepExpertDialog;
import com.gx.obe.common.widget.listener.SelectExpertListener;
import com.gx.obe.components.core.I18NEnum;
import com.gx.obe.components.core.enumeration.CommonEnum;
import com.gx.obe.components.core.enumeration.EvaluationFactorEnum;
import com.gx.obe.components.core.enumeration.EvaluationStepEnum;
import com.gx.obe.config.ConfigConstants;
import com.gx.obe.config.utils.PropertiesUtils;
import com.gx.obe.message.Messages;
import com.gx.obe.util.utils.BigDecimalUtils;
import com.gx.obe.util.utils.CollectionUtils;
import com.gx.obe.util.utils.LogUtils;
import com.gx.obe.util.utils.NumberFormatUtils;
import com.gx.obe.util.utils.ObjectUtils;
import com.gx.obe.util.utils.StringUtils;
import com.gx.obe.web.entity.evaluation.EvaluationFactor;
import com.gx.obe.web.entity.evaluation.EvaluationStep;
import com.gx.obe.web.entity.expert.Expert;
import com.gx.obe.web.entity.tender.TenderProjectEntity;
import com.gx.obe.web.service.evaluation.EvaluationFactorService;
import com.gx.obe.web.service.evaluation.EvaluationStepFactorService;
import com.gx.obe.web.service.evaluation.EvaluationStepService;
import com.gx.obe.web.service.expert.ExpertService;
import com.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

/**
 * @Description: 
 * @author guoyr
 */
public class FixedFactorEvaluationStepDialog extends EDialog {
	
	private Text stepNameText;
	private Composite roleTypeComposite;
	private Composite composite;
	private Composite customComposite;
	private Composite finalistRuleCompose;
	private Grid grid;
	private EButton save_btn;
	private GridColumn gridColumn;
	private ImageResolver imageResolver = new ImageResolver();
	private Image menuOpenImage;
	private Image menuImage;
	private EvaluationFactorService evaluationFactorService = new EvaluationFactorService();
	private EvaluationStepService evaluationStepService = new EvaluationStepService();
	private EvaluationStepFactorService evaluationStepFactorService;
	private ExpertService expertService ;
//	private EvaluationStepExpertService evaluationStepExpertService ;
	private TenderProjectEntity tenderProjectEntity;
	private EvaluationStep evaluationStep;
	private List<Object> factorList;
	private Text stepMemoText;
	private Label expertNamesLabel;
	private List<Expert> stepExpertUserIdList ;
	private CallBack callBack;
	private Text finalistNumText;
	private Button button_2;
	private Button button_4;
	private boolean isInEvaluation = false;// 是否在评审中
	private Label label_11;
	private Button importTypeBtn;
//	private Button param_exper_signature;
	private Button param_sealed_bid;
	private Button param_orderby_sealed_bid_code;
	private Button summaryByAllExpertAvg_btn;
	private Button removeMaxAndMin_btn;
	private Button removeFactorMaxAndMin_btn;
//	private Button summaryByFactorSum_btn;
	private Button importHistoryBtn;
	private Button evaluationBySupplierBtn;
	private Button showAggregateBtn;
	private Composite sortNoComposite;
	private Text warningRangeText;
	private Label warningRangeLabel;
	private Button ignoreWarningRangeBtn;
	private Label ignoreWarningRangeLabel;
	private GridItem topGridItem;
	private Button evalBidBusBtn;
	private Button evalBidTecBtn;
	private Label scoreAndWeight;
	private Button expertRoleNameBtn;
	private Label customExpertLabel;
	private Label evalBidTypeLabel;
	private Composite evalBidTypeComposite;
	private Button evalByGroupBtn;
//	private Composite evalTypeComposite;
	private Text expertScoreRoundText;
	private Composite filterRuleCompose;
	private Composite filterScoreComposite;
	private Text filterScoreText;
	private Label expertScoreRoundTip;
	private Label finalistBySortNoTips;
	private Label finalistByScoreTips;
//	private Composite sealedBidFileTypeComposite;
	
	
	{
		LogUtils.logClass(FixedFactorEvaluationStepDialog.class);
	}
	
	/**
	 * Create the dialog.
	 * @param parentShell
	 */
	public FixedFactorEvaluationStepDialog(Shell parentShell, TenderProjectEntity tenderProjectEntity, EvaluationStep evaluationStep) {
		super(parentShell);
		setTitle(Messages.Step_step);
		this.tenderProjectEntity = tenderProjectEntity;
		this.evaluationStep = evaluationStep;
	}

	/**
	 * Create contents of the dialog.
	 * @param parent
	 */
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite topContainer = (Composite) super.createDialogArea(parent);
		topContainer.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				imageResolver.disposite();
				if(null != stepExpertUserIdList){
					stepExpertUserIdList.clear();
				}
			}
		});
		GridLayout gl_topContainer = new GridLayout(1, false);
		gl_topContainer.verticalSpacing = 0;
		gl_topContainer.horizontalSpacing = 0;
		gl_topContainer.marginHeight = 0;
		gl_topContainer.marginWidth = 0;
		topContainer.setLayout(gl_topContainer);
		
		Composite container = new Composite(topContainer, SWT.NONE);
		container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_container = new GridLayout(2, false);
		gl_container.marginHeight = 10;
		gl_container.marginWidth = 10;
		container.setLayout(gl_container);
		this.setOperator(SWT.MAX|SWT.CLOSE);
		
		Tips label_6 = new Tips(container, SWT.WRAP);
		label_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
		label_6.setText(MessageFormat.format(Messages.Tips_factorStep, Messages.Factor_score));
		label_6.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, EvaluationStepEnum.getEvaluationStepIco(EvaluationStepEnum.DETAIL)));
		label_6.setSurroundColor(SWTResourceManager.getColor(60, 138, 226));
		
		composite = new Composite(container, SWT.NONE);
		GridLayout gl_composite = new GridLayout(2, false);
		gl_composite.verticalSpacing = 5;
		composite.setLayout(gl_composite);
		GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_composite.widthHint = 414;
		composite.setLayoutData(gd_composite);
		
		Label step_name = new Label(composite, SWT.NONE);
		step_name.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		step_name.setAlignment(SWT.RIGHT);
		step_name.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		step_name.setText(Messages.StepName + ": ");
		
		Composite composite_2 = new Composite(composite, SWT.NONE);
		composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_composite_2 = new GridLayout(2, false);
		gl_composite_2.marginWidth = 0;
		gl_composite_2.verticalSpacing = 1;
		gl_composite_2.marginHeight = 0;
		composite_2.setLayout(gl_composite_2);
		
		stepNameText = new Text(composite_2, SWT.NONE);
		stepNameText.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		stepNameText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
		stepNameText.addPaintListener(new TextHintListener(Messages.Tips_EnterEvaluationStepName));
		stepNameText.addVerifyListener(new VerifyRequiredListener(stepNameText, MessageFormat.format(Messages.Tips_required, Messages.StepName)));
		stepNameText.setTextLimit(20);
		stepNameText.setText("");
		
		scoreAndWeight = new Label(composite_2, SWT.NONE);
		scoreAndWeight.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.NORMAL));
		scoreAndWeight.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		scoreAndWeight.setText("");
		
		
		ESepator label = new ESepator(composite_2, SWT.NONE);
		label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
		label.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		
		Label label_1 = new Label(composite, SWT.NONE);
		label_1.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
		label_1.setText(Messages.EvalExpert + "：");
		
		roleTypeComposite = new Composite(composite, SWT.NONE);
		RowLayout rl_roleTypeComposite = new RowLayout(SWT.HORIZONTAL);
		rl_roleTypeComposite.marginLeft = 0;
		roleTypeComposite.setLayout(rl_roleTypeComposite);
		roleTypeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		
		button_2 = new Button(roleTypeComposite, SWT.RADIO);
		button_2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				selectRoleTypeAction(EvaluationStepEnum.EXPERT);
			}
		});
		button_2.setSelection(true);
		button_2.setText(Messages.AllExperts);
		button_2.setData("roleType", EvaluationStepEnum.EXPERT);
		
		expertRoleNameBtn = new Button(roleTypeComposite, SWT.RADIO);
		expertRoleNameBtn.setData("roleType", EvaluationStepEnum.EVAL_BID_TYPE);
		expertRoleNameBtn.setText(Messages.Business + "、" + Messages.Technology + Messages.Expert);
		expertRoleNameBtn.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				selectRoleTypeAction(EvaluationStepEnum.EVAL_BID_TYPE);
			}
		});
		
		button_4 = new Button(roleTypeComposite, SWT.RADIO);
		button_4.setText(Messages.SpecifyExpert);
		button_4.setData("roleType", EvaluationStepEnum.CUSTOM);
		button_4.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				selectRoleTypeAction(EvaluationStepEnum.CUSTOM);
			}
		});
		
		evalByGroupBtn = new Button(roleTypeComposite, SWT.RADIO);
		evalByGroupBtn.setText(Messages.UseEvalGroup);
		evalByGroupBtn.setData("roleType", EvaluationStepEnum.EVAL_GROUP);
		evalByGroupBtn.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				selectRoleTypeAction(EvaluationStepEnum.EVAL_GROUP);
				evalByGroupSelectionAction();
			}
		});
		
		customExpertLabel = new Label(composite, SWT.NONE);
		customExpertLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		
		customComposite = new Composite(composite, SWT.NONE);
		customComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_customComposite = new GridLayout(2, false);
		gl_customComposite.verticalSpacing = 0;
		gl_customComposite.horizontalSpacing = 0;
		gl_customComposite.marginHeight = 0;
		gl_customComposite.marginWidth = 0;
		customComposite.setLayout(gl_customComposite);
		
		expertNamesLabel = new Label(customComposite, SWT.WRAP);
		expertNamesLabel.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, true, 1, 1));
		expertNamesLabel.setText("郭永荣");
		
		ELink select_expert = new ELink(customComposite, SWT.NONE);
		select_expert.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/search.png"));
		select_expert.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				selectStepExpert();
			}
		});
		select_expert.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, true, 1, 1));
		select_expert.setText(MessageFormat.format(Messages.Button_selectFormat, Messages.Expert));
		
		ESepator exp_sep = new ESepator(customComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
		exp_sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		exp_sep.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		
		evalBidTypeLabel = new Label(composite, SWT.NONE);
		evalBidTypeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		evalBidTypeLabel.setText(Messages.EvalType + "：");
		evalBidTypeLabel.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		
		evalBidTypeComposite = new Composite(composite, SWT.NONE);
		evalBidTypeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		
		GridLayout gl_evalBidTypeComposite = new GridLayout(2, false);
		gl_evalBidTypeComposite.marginHeight = 0;
		gl_evalBidTypeComposite.marginWidth = 0;
		evalBidTypeComposite.setLayout(gl_evalBidTypeComposite);
		
		evalBidBusBtn = new Button(evalBidTypeComposite, SWT.CHECK);
		evalBidBusBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		evalBidBusBtn.setText(Messages.BusinessBid);
		
		evalBidTecBtn = new Button(evalBidTypeComposite, SWT.CHECK);
		evalBidTecBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		evalBidTecBtn.setText(Messages.TechnologyBid);
		
		label_11 = new Label(composite, SWT.NONE);
		label_11.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_11.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
		label_11.setText(Messages.EvaluationSet + "：");
		
		Composite composite_import = new Composite(composite, SWT.NONE);
		RowLayout rl_composite_import = new RowLayout(SWT.HORIZONTAL);
		rl_composite_import.marginRight = 0;
		rl_composite_import.marginBottom = 0;
		rl_composite_import.marginTop = 0;
		rl_composite_import.marginLeft = 0;
		composite_import.setLayout(rl_composite_import);
		composite_import.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		
//		evalByGroupBtn = new Button(composite_import, SWT.CHECK);
//		evalByGroupBtn.setText("按评审要素单元评审");
//		evalByGroupBtn.addSelectionListener(new SelectionAdapter() {
//			public void widgetSelected(SelectionEvent e) {
//				evalByGroupSelectionAction();
//			}
//		});
		
		importTypeBtn = new Button(composite_import, SWT.CHECK);
		importTypeBtn.setText(Messages.Tips_allowedImportOtherResult);
		
		importHistoryBtn = new Button(composite_import, SWT.CHECK);
		importHistoryBtn.setText(Messages.Tips_allowedImportHisResult);
		
		evaluationBySupplierBtn = new Button(composite_import, SWT.CHECK);
		evaluationBySupplierBtn.setText("按"+com.gx.obe.components.core.I18N.getString(I18NEnum.SUPPLIERNAME, tenderProjectEntity.getTenderType())+"打分");
		evaluationBySupplierBtn.setLayoutData(new RowData());
		
		showAggregateBtn = new Button(composite_import, SWT.CHECK);
		showAggregateBtn.setText(Messages.Tips_allowedViewSummaryResults);
		
		Label label_10 = new Label(composite, SWT.NONE);
		label_10.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
		label_10.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_10.setText(Messages.ScoreDecimalDigits + "：");
		
		Composite scoreRoundComposite = new Composite(composite, SWT.NONE);
		scoreRoundComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_composite_6 = new GridLayout(2, false);
		gl_composite_6.marginHeight = 0;
		gl_composite_6.marginWidth = 0;
		gl_composite_6.verticalSpacing = 0;
		scoreRoundComposite.setLayout(gl_composite_6);
		
		expertScoreRoundText = new Text(scoreRoundComposite,  SWT.CENTER);
		GridData gd_text = new GridData(SWT.FILL, SWT.BOTTOM, false, true, 1, 1);
		gd_text.widthHint = 30;
		expertScoreRoundText.setLayoutData(gd_text);
		expertScoreRoundText.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		expertScoreRoundText.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		
		expertScoreRoundTip = new Label(scoreRoundComposite, SWT.WRAP);
		expertScoreRoundTip.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 2));
		expertScoreRoundTip.setText("专家评审得分保留2位小数，之后一位四舍五入。");
		
		ESepator expertScoreRoundSubline = new ESepator(scoreRoundComposite, SWT.NONE);
		expertScoreRoundSubline.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true, 1, 1));
		expertScoreRoundSubline.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
		Label label_9 = new Label(composite, SWT.NONE);
		label_9.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
		label_9.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_9.setText(Messages.EarlyWarningRange + "：");
		
		Composite composite_4 = new Composite(composite, SWT.NONE);
		composite_4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_composite_4 = new GridLayout(2, false);
		gl_composite_4.marginHeight = 0;
		gl_composite_4.marginWidth = 0;
		gl_composite_4.horizontalSpacing = 0;
		gl_composite_4.verticalSpacing = 0;
		composite_4.setLayout(gl_composite_4);
		
		warningRangeText = new Text(composite_4, SWT.CENTER);
		warningRangeText.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		warningRangeText.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		GridData gd_warningRangeText = new GridData(SWT.FILL, SWT.BOTTOM, false, true, 1, 1);
		gd_warningRangeText.widthHint = 30;
		warningRangeText.setLayoutData(gd_warningRangeText);
		warningRangeText.setTextLimit(5);
		
		warningRangeLabel = new Label(composite_4, SWT.WRAP);
		warningRangeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 2));
		warningRangeLabel.setText("");
		
		ESepator warningRangeSubline = new ESepator(composite_4, SWT.NONE);
		warningRangeSubline.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true, 1, 1));
		warningRangeSubline.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
		
		Label label_7 = new Label(composite, SWT.NONE);
		label_7.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
		label_7.setText(Messages.FinalAverageScore + "：");
		
		Composite composite_5 = new Composite(composite, SWT.NONE);
		composite_5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_composite_5 = new GridLayout(2, false);
		gl_composite_5.verticalSpacing = 0;
		gl_composite_5.horizontalSpacing = 5;
		gl_composite_5.marginHeight = 0;
		gl_composite_5.marginWidth = 0;
		composite_5.setLayout(gl_composite_5);
		
		summaryByAllExpertAvg_btn = new Button(composite_5, SWT.CHECK);
		summaryByAllExpertAvg_btn.setData("SUMMARY_TYPE", EvaluationStepEnum.SUMMARY_ALL);
		Label summaryByAllExpertAvgLabel = new Label(composite_5, SWT.NONE);
		summaryByAllExpertAvgLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		summaryByAllExpertAvgLabel.setText(Messages.Tips_takeAllAverageScore);
		
		/**
		Composite removeTipsComposite = new Composite(composite_5, SWT.NONE);
		removeTipsComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
		GridLayout rl_remove_tips = new GridLayout(2, false);
		rl_remove_tips.verticalSpacing = 0;
		rl_remove_tips.horizontalSpacing = 5;
		rl_remove_tips.marginHeight = 0;
		rl_remove_tips.marginWidth = 0;
		removeTipsComposite.setLayout(rl_remove_tips);
		
		Text removeExpertMinText = new Text(removeTipsComposite, SWT.CENTER);
		removeExpertMinText.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		removeExpertMinText.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		removeExpertMinText.setTextLimit(1); 
		GridData gd_removeExpertMinText = new GridData(SWT.FILL, SWT.BOTTOM, false, true, 1, 1);
		gd_removeExpertMinText.widthHint = 30;
		removeExpertMinText.setLayoutData(gd_removeExpertMinText);
		removeExpertMinText.setText("5");
		
		Label labe1 = new Label(removeTipsComposite, SWT.CHECK);
		labe1.setText("当评审专家人数>=5人时，以下条件生效！");
		labe1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 2));
		
		ESepator remove_sub_line = new ESepator(removeTipsComposite, SWT.NONE);
		remove_sub_line.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		remove_sub_line.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
		**/
		removeMaxAndMin_btn = new Button(composite_5, SWT.CHECK);
		removeMaxAndMin_btn.setData("SUMMARY_TYPE", EvaluationStepEnum.SUMMARY_REMOVE_MAX_MIN);
		Label removeMaxAndMinLabel = new Label(composite_5, SWT.WRAP);
		removeMaxAndMinLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		removeMaxAndMinLabel.setText(Messages.Tips_removeHighestLowstByExpert);
		
		ignoreWarningRangeBtn = new Button(composite_5, SWT.CHECK| SWT.WRAP);
		ignoreWarningRangeBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		ignoreWarningRangeBtn.setData("SUMMARY_TYPE", EvaluationStepEnum.SUMMARY_IGNORE_OVER_WARNING_CORE);
		ignoreWarningRangeLabel = new Label(composite_5, SWT.WRAP);
		ignoreWarningRangeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		ignoreWarningRangeLabel.setText("按专家剔除超过预警范围的打分");
		
		removeFactorMaxAndMin_btn = new Button(composite_5, SWT.CHECK);
		removeFactorMaxAndMin_btn.setData("SUMMARY_TYPE", EvaluationStepEnum.SUMMARY_REMOVE_FACTOR_MAX_MIN);
		Label removeFactorMaxAndMinLabel = new Label(composite_5, SWT.WRAP);
		removeFactorMaxAndMinLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		removeFactorMaxAndMinLabel.setText(Messages.Tips_removeHighestLowstByFactor);
		
//		summaryByFactorSum_btn = new Button(composite_5, SWT.CHECK);
//		summaryByFactorSum_btn.setData("SUMMARY_TYPE", EvaluationStepEnum.SUMMARY_BY_FACTOR_SUM);
//		Composite summaryByFactorSumComposite = new Composite(composite_5, SWT.NONE);
//		summaryByFactorSumComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
//		GridLayout gl_summaryByFactorSumComposite = new GridLayout(2, false);
//		gl_summaryByFactorSumComposite.marginHeight = 0;
//		gl_summaryByFactorSumComposite.marginWidth = 0;
//		summaryByFactorSumComposite.setLayout(gl_summaryByFactorSumComposite);
//		Label summaryByFactorSumLabel = new Label(summaryByFactorSumComposite, SWT.NONE);
//		summaryByFactorSumLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
//		summaryByFactorSumLabel.setText("按指标平均分汇总");
//		
//		allowEmptyBtn = new Button(summaryByFactorSumComposite, SWT.CHECK);
//		allowEmptyBtn.setText("允许不打分");
		
		
		Label label_2 = new Label(composite, SWT.NONE);
		label_2.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_2.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
		label_2.setText(Messages.ShortlistedRules + "：");
		
		filterRuleCompose = new Composite(composite, SWT.NONE);
		filterRuleCompose.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		filterRuleCompose.setLayout(new GridLayout(2, false));
		
		finalistRuleCompose = new Composite(filterRuleCompose, SWT.NONE);
		finalistRuleCompose.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		GridLayout gl_finalistRuleCompose = new GridLayout(2, false);
		gl_finalistRuleCompose.verticalSpacing = 1;
		gl_finalistRuleCompose.marginHeight = 0;
		gl_finalistRuleCompose.horizontalSpacing = 0;
		gl_finalistRuleCompose.marginWidth = 0;
		finalistRuleCompose.setLayout(gl_finalistRuleCompose);
		
		finalistNumText = new Text(finalistRuleCompose, SWT.CENTER);
		finalistNumText.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		finalistNumText.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		GridData gd_finalistNumText = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		gd_finalistNumText.widthHint = 30;
		finalistNumText.setLayoutData(gd_finalistNumText);
		finalistNumText.setTextLimit(3);
		
		finalistBySortNoTips = new Label(finalistRuleCompose, SWT.WRAP);
		finalistBySortNoTips.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 2));
		finalistBySortNoTips.setText("最终排名前3名入围！");
		
		ESepator num_sub_line = new ESepator(finalistRuleCompose, SWT.NONE);
		num_sub_line.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		num_sub_line.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
		Label label_4 = new Label(filterRuleCompose, SWT.WRAP);
		label_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 2));
		label_4.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_4.setText(Messages.Tips_shortlistRoles);
		label_4.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		
		filterScoreComposite = new Composite(filterRuleCompose, SWT.NONE);
		filterScoreComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		GridLayout gl_filterScoreCompose = new GridLayout(2, false);
		gl_filterScoreCompose.verticalSpacing = 1;
		gl_filterScoreCompose.marginHeight = 0;
		gl_filterScoreCompose.horizontalSpacing = 0;
		gl_filterScoreCompose.marginWidth = 0;
		filterScoreComposite.setLayout(gl_filterScoreCompose);
		
		filterScoreText = new Text(filterScoreComposite, SWT.CENTER);
		filterScoreText.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		filterScoreText.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		GridData gd_filterScoreText = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		gd_filterScoreText.widthHint = 30;
		filterScoreText.setLayoutData(gd_filterScoreText);
		filterScoreText.setTextLimit(6);
		
		finalistByScoreTips = new Label(filterScoreComposite, SWT.NONE);
		finalistByScoreTips.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 2));
		finalistByScoreTips.setText("最终得分>=80 分入围！");
		
		ESepator score_sub_line = new ESepator(filterScoreComposite, SWT.NONE);
		GridData gd_label_score = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		gd_label_score.widthHint = 30;
		score_sub_line.setLayoutData(gd_label_score);
		score_sub_line.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
//		Label evalTypeLabel = new Label(composite, SWT.NONE);
//		evalTypeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
//		evalTypeLabel.setText("评审视图：");
//		
//		evalTypeComposite = new Composite(composite, SWT.NONE);
//		RowLayout rl_evalTypeComposite = new RowLayout(SWT.HORIZONTAL);
//		rl_evalTypeComposite.marginLeft = 0;
//		evalTypeComposite.setLayout(rl_evalTypeComposite);
//		evalTypeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
//		
//		Button evalTypeDefault = new Button(evalTypeComposite, SWT.RADIO);
//		evalTypeDefault.setSelection(true);
//		evalTypeDefault.setText(Messages.CentralizedReview);
//		evalTypeDefault.setData(EvaluationStepEnum.EVALUATION_TYPE_COLLECT);
//		
//		Button evalTypeSingle = new Button(evalTypeComposite, SWT.RADIO);
//		evalTypeSingle.setText(Messages.IndividualReview);
//		evalTypeSingle.setData(EvaluationStepEnum.EVALUATION_TYPE_SINGLE);
//		
//		Button evalTypeAI = new Button(evalTypeComposite, SWT.RADIO);
//		evalTypeAI.setText(Messages.SmartReview);
//		evalTypeAI.setData(EvaluationStepEnum.EVALUATION_TYPE_AI);
		
		Label label_3 = new Label(composite, SWT.NONE);
		label_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		label_3.setText(Messages.DartBid + "：");
		
		Composite composite_3 = new Composite(composite, SWT.NONE);
		composite_3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_sealedbidcomposite_3 = new GridLayout(2, false);
		gl_sealedbidcomposite_3.marginHeight = 0;
		gl_sealedbidcomposite_3.marginWidth = 0;
		gl_sealedbidcomposite_3.verticalSpacing = 0;
		composite_3.setLayout(gl_sealedbidcomposite_3);
		
		param_sealed_bid = new Button(composite_3, SWT.CHECK);
		param_sealed_bid.setText(Messages.DartBid);
//		param_sealed_bid.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				checkSealedBidAction();
//			}
//		});
		
		param_orderby_sealed_bid_code = new Button(composite_3, SWT.CHECK);
		param_orderby_sealed_bid_code.setText(Messages.SortByDarkCode);
		
//		sealedBidFileTypeComposite = new Composite(composite_3, SWT.NONE);
//		sealedBidFileTypeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
//		GridLayout gl_sealedBidFileType = new GridLayout(4, false);
//		gl_sealedBidFileType.marginHeight = 0;
//		gl_sealedBidFileType.marginWidth = 0;
//		sealedBidFileTypeComposite.setLayout(gl_sealedBidFileType);
//		
//		Label sealedBidFileType = new Label(sealedBidFileTypeComposite, SWT.NONE);
//		sealedBidFileType.setForeground(ColorConstants.FONT_BLACK_COLOR);
//		sealedBidFileType.setText("暗标文件为：");
//		sealedBidFileType.setToolTipText("当标识暗标文件后，仅能看到已标识为暗标类型的文件（不标识时以专家权限为准）。");
//		
//		Button busFileBtn = new Button(sealedBidFileTypeComposite, SWT.CHECK);
//		busFileBtn.setText(Messages.BusinessBid);
//		busFileBtn.setData("evalBidType", ExpertEnum.EXPERT_BUS);
//		
//		Button tecFileBtn = new Button(sealedBidFileTypeComposite, SWT.CHECK);
//		tecFileBtn.setText(Messages.TechnologyBid);
//		tecFileBtn.setData("evalBidType", ExpertEnum.EXPERT_TEC);
//		
//		Button priceFileBtn = new Button(sealedBidFileTypeComposite, SWT.CHECK);
//		priceFileBtn.setText(Messages.EconomicBid);
//		priceFileBtn.setData("evalBidType", ExpertEnum.EXPERT_PRICE);
		
//		Label label_s2 = new Label(composite, SWT.NONE);
//		label_s2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
//		label_s2.setText(Messages.Esignature + "：");
//		
//		param_exper_signature = new Button(composite, SWT.CHECK);
//		param_exper_signature.setText(Messages.Tips_signatureBeforeSubmit);
		
		Label label_index4 = new Label(composite, SWT.NONE);
		label_index4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		label_index4.setText(Messages.ListNum + "：");
		
		sortNoComposite = new Composite(composite, SWT.NONE);
		sortNoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		GridLayout gl_compositea_4 = new GridLayout(2, false);
		gl_compositea_4.verticalSpacing = 0;
		gl_compositea_4.horizontalSpacing = 0;
		gl_compositea_4.marginHeight = 0;
		gl_compositea_4.marginWidth = 0;
		sortNoComposite.setLayout(gl_compositea_4);
		
		Button button_bidNo = new Button(sortNoComposite, SWT.RADIO);
		button_bidNo.setData("indexIsBidNumber", CommonEnum.NO);
		button_bidNo.setText(Messages.Num);
		
		Button button_bidyes = new Button(sortNoComposite, SWT.RADIO);
		button_bidyes.setData("indexIsBidNumber", CommonEnum.YES);
		button_bidyes.setText(Messages.TenderNumber);
		
		Label label_5 = new Label(composite, SWT.NONE);
		label_5.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_5.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, true, 1, 1));
		label_5.setText(Messages.Note + ": ");
		
		stepMemoText = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
		stepMemoText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		stepMemoText.setTextLimit(100);
		
		Composite table_border_composite = new Composite(container, SWT.NONE);
		table_border_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
		GridLayout gl_composite_3 = new GridLayout(1, false);
		gl_composite_3.marginHeight = 1;
		gl_composite_3.marginWidth = 1;
		table_border_composite.setLayout(gl_composite_3);
		table_border_composite.setBackground(ColorConstants.BORDER_LINE_COLOR);
		
		Composite table_composite = new Composite(table_border_composite, SWT.NONE);
		table_composite.setBackground(SWTResourceManager.getColor(255, 255, 255));
		table_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_tab_composite_4 = new GridLayout(1, false);
		gl_tab_composite_4.marginWidth = 0;
		gl_tab_composite_4.marginBottom = 5;
		gl_tab_composite_4.marginHeight = 0;
		gl_tab_composite_4.verticalSpacing = 0;
		table_composite.setLayout(gl_tab_composite_4);
		
		grid = new Grid(table_composite, SWT.H_SCROLL | SWT.V_SCROLL);
		GridData gd_grid = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_grid.widthHint = 280;
		grid.setLayoutData(gd_grid);
		
		gridColumn = new GridColumn(grid, SWT.CHECK);
		gridColumn.setText("New Column");
		gridColumn.setWidth(150);
		
		topGridItem = new GridItem(grid, SWT.NONE);
		topGridItem.setText(Messages.Factor_score);
		topGridItem.setImage(0, menuOpenImage);
		topGridItem.setExpanded(true);
		
		ESepator but_sep = new ESepator(topContainer, SWT.SEPARATOR | SWT.HORIZONTAL);
		but_sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		but_sep.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		
		Composite composite_1 = new Composite(topContainer, SWT.NONE);
		composite_1.setBackgroundMode(SWT.INHERIT_FORCE);
		composite_1.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/fill_bg.png"));
		composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		GridLayout gl_composite_1 = new GridLayout(2, false);
		composite_1.setLayout(gl_composite_1);
		
		save_btn = new EButton(composite_1, SWT.NONE);
		save_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/save.png"));
		GridData gd_confirmBtn = new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1);
		gd_confirmBtn.widthHint = 90;
		save_btn.setLayoutData(gd_confirmBtn);
		save_btn.setText(Messages.Button_save);
		save_btn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				saveEvaluationStepAction();
			}
		});
		EButton cancel_btn = new EButton(composite_1, SWT.NONE);
		cancel_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/close.png"));
		cancel_btn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				cancelAction();
			}
		});
		GridData gd_button = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		gd_button.widthHint = 90;
		cancel_btn.setLayoutData(gd_button);
		cancel_btn.setText(Messages.Button_close);

		init();
		return container;
	}

	/**
	 * @Description: 初始化
	 * @author guoyr
	 */
	private void init(){
		expertService = new ExpertService();
		evaluationStepFactorService = new EvaluationStepFactorService();
//		evaluationStepExpertService = new EvaluationStepExpertService(); 
		
		if(null == evaluationStep){
			evaluationStep = new EvaluationStep();
			evaluationStep.setFilterType(EvaluationStepEnum.FILTER_NO);
			evaluationStep.setPassType(EvaluationStepEnum.PASS_ALL);
			evaluationStep.setRoleType(EvaluationStepEnum.EXPERT);
			evaluationStep.setStepStatus(CommonEnum.NOT_START);
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_EXPER_SIGNATURE, false);
			int maxSortNo = evaluationStepService.getMaxEvaluationStepSortNo(tenderProjectEntity.getId());
			evaluationStep.setSortNo(maxSortNo + 1);
			this.setTitle(MessageFormat.format(Messages.Title_create, Messages.Step_step));
		}else {
			this.setTitle(MessageFormat.format(Messages.Title_edit, Messages.Step_step));
			if(ObjectUtils.equals(evaluationStep.getStepStatus(), CommonEnum.COMPLETE)){
//				composite.setEnabled(false);
				save_btn.setEnabled(false);
				isInEvaluation = true;
			}else {
				isInEvaluation = evaluationStepService.isInEvaluationStep(tenderProjectEntity.getId(), evaluationStep.getId());
				if(isInEvaluation){
					for(Control control : roleTypeComposite.getChildren()){
						control.setEnabled(false);
					}
				}
			}
		}
		evaluationBySupplierBtn.setText(MessageFormat.format(Messages.Tips_scoredForSupplier, com.gx.obe.components.core.I18N.getString(I18NEnum.SUPPLIERNAME, tenderProjectEntity.getTenderType())));
		
		addExpertSocreListener();
		addWarningRangeListener();
		addShortListRuleListener();
		
//		WidgetUtils.setRadioChecked(evalTypeComposite, PropertiesUtils.getProperty(ConfigConstants.DEFAULT_EVALUATION_TYPE, EvaluationStepEnum.EVALUATION_TYPE_COLLECT));
		
		SelectionAdapter selectionAdapter = new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				Button summaryBtn = (Button)e.getSource();
				refrehsSummaryType((String)summaryBtn.getData("SUMMARY_TYPE"), summaryBtn.getSelection());
			}
		};
		
		removeMaxAndMin_btn.addSelectionListener(selectionAdapter);
		summaryByAllExpertAvg_btn.addSelectionListener(selectionAdapter);
//		summaryByFactorSum_btn.addSelectionListener(selectionAdapter);
		removeFactorMaxAndMin_btn.addSelectionListener(selectionAdapter);
		ignoreWarningRangeBtn.addSelectionListener(selectionAdapter);
		
		// 不显示评标步骤的类型
		WidgetUtils.setControlVisible(evalBidTypeLabel, false);
		WidgetUtils.setControlVisible(evalBidTypeComposite, false);
		
		grid.setAutoHeight(true);
		gridColumn.setWordWrap(true);
		gridColumn.setShowTreeTogglePic(true);
		gridColumn.setTreeTogglePic(ImageResolver.RESOLVER_INSTANCE.loadImage(IconsActivator.PLUGIN_ID,"icons/tree_expend.png"), ImageResolver.RESOLVER_INSTANCE.loadImage(IconsActivator.PLUGIN_ID,"icons/tree_close.png"));
		gridColumn.setTree(true);
		menuOpenImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID,"icons/tree_parent.png");
		menuImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID,"icons/tree_item.png");
		refreshFactorTree();
		// 添加选中监听事件
		grid.addListener(SWT.Selection, new GridCheckedListener(false));
		GridUtils.refreshGridCheckedStatus(grid, 0);
		grid.addListener(SWT.Selection, new Listener(){
			public void handleEvent(Event event) {
				// 选中了复选框事件
				if(event.detail == SWT.CHECK){
					checkFactorItemAction();
				}
			}
		});
		refreshEvaluationStepForm();
		if(!save_btn.getEnabled()){
			final String keyCharacter = PropertiesUtils.getProperty("keyCharacter", "g");
			if(null != keyCharacter && keyCharacter.length() > 0){
				final Listener keyListener = new Listener() {
					public void handleEvent(Event e) {
						if ((e.stateMask == SWT.CTRL) && e.keyCode == keyCharacter.charAt(0)){
							save_btn.setEnabled(!save_btn.getEnabled());
							composite.setEnabled(!composite.getEnabled());
						}
					}
				};
				composite.getDisplay().addFilter(SWT.KeyDown, keyListener);;
				composite.addDisposeListener(new DisposeListener() {
					public void widgetDisposed(DisposeEvent e) {
						composite.getDisplay().removeFilter(SWT.KeyDown, keyListener);  
					}
				});
			}
		}
		WidgetUtils.setControlVisible(evalByGroupBtn, false);
	}
	
	private void addExpertSocreListener(){
		final ModifyListener expertScoreRoundListener = new ModifyListener() {
			public void modifyText(ModifyEvent arg0) {
				int value = ObjectUtils.getIntValue(expertScoreRoundText.getText().trim(), 0);
				if(value < 0 || value > 5){
					value = 2;
					expertScoreRoundText.removeModifyListener(this);
					expertScoreRoundText.setText("2");
					expertScoreRoundText.addModifyListener(this);
				}
				expertScoreRoundTip.setText(MessageFormat.format(Messages.Tips_expertDecimalDigits, value));
				composite.layout();
			}
		};
		expertScoreRoundText.addModifyListener(expertScoreRoundListener);
	}
	
	private void addWarningRangeListener(){
		warningRangeText.addVerifyListener(new VerifyFloatListener(MessageFormat.format(Messages.Tips_pleaseEnterTheValid, Messages.EarlyWarningRange)));
		warningRangeText.addVerifyListener(new VerifyMinListener(0, MessageFormat.format(Messages.Tips_pleaseEnterTheValid, Messages.EarlyWarningRange)));
		warningRangeText.addVerifyListener(new VerifyMaxListener(100,  MessageFormat.format(Messages.Tips_pleaseEnterTheValid, Messages.EarlyWarningRange)));
		
		final ModifyListener warningRangeListener = new ModifyListener() {
			public void modifyText(ModifyEvent arg0) {
				BigDecimal warningRange = ObjectUtils.getObjBigDecimal(warningRangeText.getText().trim());
				if(null != warningRange && warningRange.compareTo(BigDecimal.ZERO) > 0){
					warningRangeLabel.setText(MessageFormat.format(Messages.Tips_earlyWarningRange, NumberFormatUtils.format(warningRange)));
					ignoreWarningRangeLabel.setText(MessageFormat.format(Messages.Tips_excludeOverWarningScore, NumberFormatUtils.format(warningRange)));
					WidgetUtils.setControlVisible(ignoreWarningRangeLabel, true);
					WidgetUtils.setControlVisible(ignoreWarningRangeBtn, true);
					ignoreWarningRangeBtn.setEnabled(true);
				}else {
					warningRangeText.removeModifyListener(this);
					warningRangeText.setText("");
					warningRangeText.addModifyListener(this);
					warningRangeLabel.setText(MessageFormat.format(Messages.Tips_earlyWarningRange, "__"));
					WidgetUtils.setControlVisible(ignoreWarningRangeLabel, false);
					WidgetUtils.setControlVisible(ignoreWarningRangeBtn, false);
					ignoreWarningRangeBtn.setSelection(false);
					ignoreWarningRangeBtn.setEnabled(false);
				}
				composite.layout();
			}
		};
		warningRangeText.addModifyListener(warningRangeListener);
	}
	
	
	private void addShortListRuleListener(){
		IntegerInputListener integerInputListener = new IntegerInputListener();
		integerInputListener.addMinEqCheck(0, null);
		finalistNumText.addKeyListener(integerInputListener);
		final ModifyListener bySortNoListener = new ModifyListener() {
			public void modifyText(ModifyEvent arg0) {
				int value = ObjectUtils.getIntValue(finalistNumText.getText().trim(), 0);
				if(value < 1){
					value = 0;
					finalistNumText.removeModifyListener(this);
					finalistNumText.setText("");
					finalistNumText.addModifyListener(this);
				}
				finalistBySortNoTips.setText(MessageFormat.format(Messages.Tips_shortlistBySortNo, value > 0 ? value : "___"));
				finalistRuleCompose.layout();
			}
		};
		finalistNumText.addModifyListener(bySortNoListener);
		
		FloatInputListener filterScoreInputListener = new FloatInputListener();
		filterScoreInputListener.addMinEqCheck(0, null);
		filterScoreInputListener.addMaxEqCheck(100, null);
		filterScoreText.addKeyListener(filterScoreInputListener);
		
		final ModifyListener bySortListener = new ModifyListener() {
			public void modifyText(ModifyEvent arg0) {
				int value = ObjectUtils.getIntValue(filterScoreText.getText().trim(), 0);
				if(value < 1){
					value = 0;
					filterScoreText.removeModifyListener(this);
					filterScoreText.setText("");
					filterScoreText.addModifyListener(this);
				}
				finalistByScoreTips.setText(MessageFormat.format(Messages.Tips_shortlistByMinScore, value > 0 ? value : "___"));
				finalistRuleCompose.layout();
			}
		};
		filterScoreText.addModifyListener(bySortListener);
	}
	
	/**
	 * @Description: 选中按评审要素单元评审
	 * @author guoyr 
	 */
	private void evalByGroupSelectionAction() {
		boolean isEvalByGroup = evalByGroupBtn.getSelection();
		if (isEvalByGroup) {
			importTypeBtn.setSelection(false);
			removeMaxAndMin_btn.setSelection(false);
			summaryByAllExpertAvg_btn.setSelection(false);
			removeFactorMaxAndMin_btn.setSelection(false);
			ignoreWarningRangeBtn.setSelection(false);
		}
		importTypeBtn.setEnabled(!isEvalByGroup);
		removeMaxAndMin_btn.setEnabled(!isEvalByGroup);
		summaryByAllExpertAvg_btn.setEnabled(!isEvalByGroup);
		removeFactorMaxAndMin_btn.setEnabled(!isEvalByGroup);
		ignoreWarningRangeBtn.setEnabled(!isEvalByGroup);
		warningRangeText.setEnabled(!isEvalByGroup);
	}
	
	
	/**
	 * @Description: 刷新指标树
	 * @author guoyr
	 * @param factorId
	 */
	public void refreshFactorTree(){
		grid.removeAll();
		List<EvaluationFactor> scoreFactorList = evaluationFactorService.getFactorListOfEvaluationStep(tenderProjectEntity.getId(), EvaluationFactorEnum.AUDIT_SCORE, evaluationStep.getId());
		List<EvaluationFactor> evaluationFactorList = new ArrayList<EvaluationFactor>();
		if(null != scoreFactorList){
			for(EvaluationFactor evaluationFactor : scoreFactorList){
//				if(null != evaluationFactor.getEvalBidType() && evaluationFactor.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_CREDIT)){
//					continue;
//				}
				
				if(null != evaluationFactor.getScoreType() && evaluationFactor.getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS)){
					evaluationFactorList.add(evaluationFactor);
				}else {
					boolean hasScoreTypePassFactor = false;
					if(null != evaluationFactor.getChildFactorList() && evaluationFactor.getChildFactorList().size() > 0){
						for(EvaluationFactor childFactor : evaluationFactor.getChildFactorList()){
							if(null != childFactor.getScoreType() && childFactor.getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS)){
								hasScoreTypePassFactor = true;
								break;
							}
						}
					}
					if(hasScoreTypePassFactor){
						if(null != evaluationFactor.getChildFactorList() && evaluationFactor.getChildFactorList().size() > 0){
							if(null == evaluationFactor.getScoreType() || !evaluationFactor.getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS_PARENT)){
								// 当出现这种情况时将父节点标识为在分配步指标时不显示，以免因为最在分配完最后一个二级指标时，因为把父级指标分配进去，导致其他步骤显示不出指标
								evaluationFactor.setScoreType(EvaluationFactorEnum.SCORE_TYPE_PASS_PARENT);
								evaluationFactorService.updateAssignProperty(evaluationFactor, new String[]{"scoreType"});
							}
							evaluationFactorList.addAll(evaluationFactor.getChildFactorList());
						}
					}else {
						if(null != evaluationFactor.getScoreType() && evaluationFactor.getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS_PARENT)){
							evaluationFactorList.addAll(evaluationFactor.getChildFactorList());
						}else {
							evaluationFactorList.add(evaluationFactor);
						}
					}
				}
			}
		}
		
		
		if(null != evaluationFactorList && evaluationFactorList.size() > 0){
			
			if(StringUtils.isNotEmpty(evaluationStep.getId())){
	 
				factorList = evaluationStepFactorService.getFactorIdLsitByStepId( evaluationStep.getId());
			}
			topGridItem = new GridItem(grid, SWT.NONE);
			topGridItem.setText(Messages.Factor_score);
			topGridItem.setImage(0, menuOpenImage);
			topGridItem.setExpanded(true);
			if(isInEvaluation){
//				topGridItem.setCheckVisible(0, false);
				topGridItem.setCheckable(0, false);
				topGridItem.setGrayed(0, true);
			}
			for(EvaluationFactor factor : evaluationFactorList){
				GridItem gridItem = new GridItem(topGridItem, SWT.NONE);
				gridItem.setText(0, factor.getFactorName());
				gridItem.setData("evaluationFactor", factor);
				if(isInEvaluation){
					gridItem.setGrayed(0, true);
					gridItem.setCheckable(0, false);
				}
//				gridItem.setCheckable(0, true);
				initChildGridItem(factor, gridItem);
			}
		}else {
			save_btn.setEnabled(false);
		}
		if(StringUtils.isNotEmpty(evaluationStep.getId())){
			GridUtils.refreshGridCheckedStatus(grid, 0);
		}else {
			GridUtils.checkAll(grid, 0, true);
			checkFactorItemAction();
		}
	}
	
	/**
	 * @Description: 递归实现指标树
	 * @author guoyr
	 * @param factor
	 * @param parentGridItem
	 * @param selectId
	 */
	private void initChildGridItem(EvaluationFactor factor, GridItem parentGridItem){
		if(null != factor.getChildFactorList() && factor.getChildFactorList().size() > 0){
			for(EvaluationFactor childFactor : factor.getChildFactorList()){
				if(ObjectUtils.equals(childFactor.getFactorType(), EvaluationFactorEnum.FACTOR_FLOAT)){
					continue;
				}
				GridItem gridItem = new GridItem(parentGridItem, SWT.NONE);
				gridItem.setText(0, childFactor.getFactorName());
				gridItem.setData("evaluationFactor", childFactor);
//				gridItem.setGrayed(0, true);
//				gridItem.setCheckable(0, false);
//				gridItem.setCheckVisible(0, false);
				gridItem.setGrayed(0, true);
				gridItem.setCheckable(0, false);
				initChildGridItem(childFactor, gridItem);
			}
			parentGridItem.setExpanded(true);
			parentGridItem.setImage(0, menuOpenImage);
		}else {
			parentGridItem.setImage(0, menuImage);
		}
		if(null != factorList && factorList.contains(factor.getId())){
			parentGridItem.setChecked(0, true);
		}
		// 如果顶级指标是通过性指标
		if(null != factor.getScoreType() && factor.getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS)){
			parentGridItem.setForeground(0,SWTResourceManager.getColor(SWT.COLOR_BLUE));
//			if(parentGridItem.getItemCount() > 0){
//				parentGridItem.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/ok.png"));
//			}
		}
		parentGridItem.setToolTipText(0, parentGridItem.getText());
	}

	/**
	 * @Description: 刷新合理均值
	 * @author guoyr
	 * @param summaryType
	 * @param isSelection 
	 */
	private void refrehsSummaryType(String summaryType, boolean isSelection){
		removeMaxAndMin_btn.setSelection(false);
		summaryByAllExpertAvg_btn.setSelection(false);
		ignoreWarningRangeBtn.setSelection(false);
		removeFactorMaxAndMin_btn.setSelection(false);
//		summaryByFactorSum_btn.setSelection(false);
//		allowEmptyBtn.setEnabled(false);
//		allowEmptyBtn.setSelection(false);
		if(null != summaryType && summaryType.equals(EvaluationStepEnum.SUMMARY_IGNORE_OVER_WARNING_CORE)){
			if(ignoreWarningRangeBtn.getVisible()){
				ignoreWarningRangeBtn.setSelection(isSelection);
			}
		}else if(null != summaryType && summaryType.equals(EvaluationStepEnum.SUMMARY_REMOVE_FACTOR_MAX_MIN)){
			removeFactorMaxAndMin_btn.setSelection(isSelection);
//		}else if(null != summaryType && summaryType.equals(EvaluationStepEnum.SUMMARY_BY_FACTOR_SUM)){
//			summaryByFactorSum_btn.setSelection(isSelection);
//			if(isSelection){
//				allowEmptyBtn.setEnabled(true);
//				Object evaluationEmpty = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_EVALUATION_EMPTY);
//				if(null != evaluationEmpty && (Boolean)evaluationEmpty){
//					allowEmptyBtn.setSelection(true);
//				}
//			}
		}else if(null != summaryType && summaryType.equals(EvaluationStepEnum.SUMMARY_REMOVE_MAX_MIN)){
			removeMaxAndMin_btn.setSelection(isSelection);
		}else {
			summaryByAllExpertAvg_btn.setSelection(true);
		}
	}
	
	/**
	 * @Description: 刷新评标步骤表单
	 * @author guoyr
	 */
	private void refreshEvaluationStepForm(){
		stepNameText.setText(ObjectUtils.getObjString(evaluationStep.getStepName()));
		stepMemoText.setText(ObjectUtils.getObjString(evaluationStep.getStepMemo()));
		WidgetUtils.setRadioChecked(roleTypeComposite, ObjectUtils.getObjString(evaluationStep.getRoleType()), "roleType");
		Object indexIsBidNumber = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_INDEX_IS_BIDNUMBER);
		WidgetUtils.setRadioChecked(sortNoComposite, null != indexIsBidNumber && indexIsBidNumber.equals(CommonEnum.YES) ? CommonEnum.YES : CommonEnum.NO, "indexIsBidNumber");
//		WidgetUtils.setRadioChecked(evalTypeComposite, evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.EVALUATION_TYPE, String.class));
		
		if(evaluationStep.getFinalistNumber() > 0){
			finalistNumText.setText(evaluationStep.getFinalistNumber()+"");
		}else {
			finalistNumText.setText("");
		}
		double filterScore = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_FILTER_SCORE, Double.class, Double.valueOf(0));
		if(filterScore > 0){
			filterScoreText.setText(filterScore+"");
		}else {
			filterScoreText.setText("");
		}
		refrehsSummaryType(evaluationStep.getSummaryType(), true);
		
		showScoreAndWeight(evaluationStep.getScore(), evaluationStep.getWeight());
		int evalBidBusCount = 0;
		int evalBidTecCount = 0;
		if(null != evaluationStep.getEvalBidType() && evaluationStep.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_BUS)){
			evalBidBusCount ++;
		}else if(null != evaluationStep.getEvalBidType() && evaluationStep.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_TEC)){
			evalBidTecCount ++;
		}else if(null != evaluationStep.getEvalBidType() && evaluationStep.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_DETAIL)){
			evalBidBusCount ++;
			evalBidTecCount ++;
		}
		StringBuilder expertTypeName = new StringBuilder();
		if(evalBidBusCount > 0){
			evalBidBusBtn.setSelection(true);
			expertTypeName.append(Messages.Business);
		}
		if(evalBidTecCount > 0){
			evalBidTecBtn.setSelection(true);
		}
		refreshRoleType(evalBidBusCount, evalBidTecCount, false);
		if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.CUSTOM)){
			if(StringUtils.isNotEmpty(evaluationStep.getId())){
				stepExpertUserIdList = expertService.getEvaluationStepExpertList(tenderProjectEntity.getId(), evaluationStep);
//				if(null == stepExpertUserIdList){
//					stepExpertUserIdList = new ArrayList<Expert>();
//				}else {
//					stepExpertUserIdList.clear();
//				}
//				if(null != userIdsList){
//					for(Expert userId : userIdsList){
//						stepExpertUserIdList.add(userId);
//					}
//				}
			}
		}
		
		boolean importExpertResult = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_IMPORT_OTHERE_EXPERT_RESULT, Boolean.class);
		importTypeBtn.setSelection(importExpertResult);
		boolean importHistoryResult = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_IMPORT_HISTORY_RESULT, Boolean.class);
		importHistoryBtn.setSelection(importHistoryResult);
		if(null != tenderProjectEntity.getParentId() && tenderProjectEntity.getParentId().length() > 0){
			boolean evaluationBySupplier = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_EVALUATION_BY_SUPPLIER, Boolean.class);
			evaluationBySupplierBtn.setSelection(evaluationBySupplier);
		}else {
			evaluationBySupplierBtn.setVisible(false);
			((RowData)evaluationBySupplierBtn.getLayoutData()).exclude = true;
		}
		
		showAggregateBtn.setSelection(PropertiesUtils.getProperty(ConfigConstants.SHOW_SUMMARY_SCORE, "00").equals("01"));
		
		BigDecimal warningRange = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_WARNING_RANGE, BigDecimal.class);
		if(null != warningRange && warningRange.compareTo(BigDecimal.ZERO) > 0) {
			warningRangeText.setText(warningRange.toString());
		}else {
			warningRangeText.setText("");
		}
		expertScoreRoundText.setText(ObjectUtils.getObjString(evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.EXPERT_SCORE_ROUND, Integer.class, 2), "2"));
//		Object ignoreWarningRange = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_IGNORE_OVER_WARNING_RANGE);
//		if(null != ignoreWarningRange && (Boolean)ignoreWarningRange){
//			ignoreWarningRangeBtn.setSelection(true);
//		}else {
//			ignoreWarningRangeBtn.setSelection(false);
//		}
		selectRoleTypeAction(evaluationStep.getRoleType());
		evalByGroupSelectionAction();
		boolean experSignature = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_EXPER_SIGNATURE, Boolean.class, false);
//		param_exper_signature.setSelection(experSignature);
		boolean sealedBid = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_SEALED_BID, Boolean.class, false);
		if(sealedBid){
			param_sealed_bid.setSelection(true);
//			((GridData)sealedBidFileTypeComposite.getLayoutData()).exclude = false;
//			sealedBidFileTypeComposite.setVisible(true);
//			
//			Integer PARAM_SEALED_BID_FILE_ROLE = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_SEALED_BID_FILE_ROLE);
//			if(null != PARAM_SEALED_BID_FILE_ROLE && PARAM_SEALED_BID_FILE_ROLE != 0){
//				for(Control button : sealedBidFileTypeComposite.getChildren()){
//					if(button instanceof Button){
//						if(null != button.getData("evalBidType")){
//							try {
//								int evalBidType = Integer.parseInt(button.getData("evalBidType").toString());
//								if((evalBidType & PARAM_SEALED_BID_FILE_ROLE) != 0){
//									((Button)button).setSelection(true);
//								}
//							} catch (NumberFormatException e) {
//							}
//						}
//					}
//				}
//			}
		}else {
			param_sealed_bid.setSelection(false);
//			((GridData)sealedBidFileTypeComposite.getLayoutData()).exclude = true;
//			sealedBidFileTypeComposite.setVisible(false);
		}
		boolean orderbySealedBidCode = evaluationStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_ORDERBY_SEALED_BID_CODE, Boolean.class);
		param_orderby_sealed_bid_code.setSelection(orderbySealedBidCode);
		
	}
	
	/**
	 * @Description: 显示分值和权重
	 * @author guoyr
	 * @param score
	 * @param weight 
	 */
	private void showScoreAndWeight(BigDecimal score, BigDecimal weight){
		if(null != score){
			if(null != weight && (weight.compareTo(BigDecimal.ZERO) == 0 || weight.compareTo(new BigDecimal(100)) == 0)){
				weight = null;
			}
			scoreAndWeight.setText(NumberFormat.getInstance().format(score) + Messages.Points+(null !=  weight ? " （" + (NumberFormat.getInstance().format(weight)) +"%）": ""));
		}else {
			scoreAndWeight.setText("0" + Messages.Points);
		}
		evaluationStep.setScore(score);
		evaluationStep.setWeight(weight);
		scoreAndWeight.getParent().layout();
	}
	
	/**
	 * @Description: 选择指标事件
	 * @author guoyr
	 * @param gridItem 
	 */
	private void checkFactorItemAction(){
		int evalBidBusCount = 0;
		int evalBidTecCount = 0;
		BigDecimal score = null;
		BigDecimal weight = null;
		if(null != topGridItem && !topGridItem.isDisposed()){
			int evaluationScoreByPass = 0;
			List<EvaluationFactor> checkedTopFactorList = new ArrayList<EvaluationFactor>();
			for(GridItem topItem : topGridItem.getItems()){
				if(topItem.getCheckVisible(0) && topItem.getChecked(0)){
					EvaluationFactor topFactor = (EvaluationFactor)topItem.getData("evaluationFactor");
					checkedTopFactorList.add(topFactor);
					if(null != topFactor.getScoreType() && topFactor.getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS)){
						evaluationScoreByPass ++;
					}
				}
			}
			
			if(checkedTopFactorList.size() > 0){
				if(evaluationScoreByPass > 0){
					if(removeMaxAndMin_btn.getSelection()){
						removeMaxAndMin_btn.setSelection(false);
					}else if(removeFactorMaxAndMin_btn.getSelection()){
						removeFactorMaxAndMin_btn.setSelection(false);
					}else if(ignoreWarningRangeBtn.getSelection()){
						ignoreWarningRangeBtn.setSelection(false);
					}
				}
				if(stepNameText.getText().length() == 0){
					if(checkedTopFactorList.size() == 1){
						String firstFactorName = checkedTopFactorList.get(0).getFactorName();
						stepNameText.setText(firstFactorName.length() > 9 ? firstFactorName.substring(0,9):firstFactorName);
					}else {
						stepNameText.setText(com.gx.obe.components.core.I18N.getString(I18NEnum.SCORE_EVALUATION));
					}
				}
				
				List<String> parentIds = new ArrayList<String>();
				for(EvaluationFactor topFactor : checkedTopFactorList){
					BigDecimal factorScore = topFactor.getFactorScore();
					BigDecimal factorWeight = topFactor.getFactorWeight();
					if(null != topFactor.getParentFactor()){
//					factorScore = topFactor.getParentFactor().getFactorScore();
						if(!parentIds.contains(topFactor.getParentFactor().getId())){
							parentIds.add(topFactor.getParentFactor().getId());
							factorWeight = topFactor.getParentFactor().getFactorWeight();
						}
					}
					if(null != factorScore){
						score = null != score ? BigDecimalUtils.add(score, factorScore) : factorScore;
					}
					if(null != factorWeight){
						weight = null != weight ? BigDecimalUtils.add(weight, factorWeight) : factorWeight;
					}
					if(null != topFactor.getEvalBidType() && topFactor.getEvalBidType().length() > 0){
						if(topFactor.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_DETAIL)){
							evalBidBusCount ++;
							evalBidTecCount ++;
						}else if(topFactor.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_BUS)){
							evalBidBusCount ++;
						}else if(topFactor.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_TEC)){
							evalBidTecCount ++;
						}
					}
				}
			}
		}
		showScoreAndWeight(score, weight);
		evalBidBusBtn.setSelection(evalBidBusCount > 0);
		evalBidTecBtn.setSelection(evalBidTecCount > 0);
		refreshRoleType(evalBidBusCount, evalBidTecCount, true);
		
//		refreshEvalType();
	}
	
	private void refreshRoleType(int evalBidBusCount, int evalBidTecCount, boolean setEnable){
		if(evalBidBusCount + evalBidTecCount > 0){
			if(setEnable){
				expertRoleNameBtn.setEnabled(true);
			}
			if(null == evaluationStep.getId() || "".equals(ObjectUtils.getObjString(WidgetUtils.getRadioVal(roleTypeComposite,"roleType")))){
				evaluationStep.setRoleType(EvaluationStepEnum.EVAL_BID_TYPE);
				WidgetUtils.setRadioChecked(roleTypeComposite, EvaluationStepEnum.EVAL_BID_TYPE, "roleType");
			}
			StringBuilder expertTypeName = new StringBuilder();
			if(evalBidBusCount > 0){
				expertTypeName.append(Messages.Business);
			}
			if(evalBidTecCount > 0){
				if(expertTypeName.length() > 0){
					expertTypeName.append("、");
				}
				expertTypeName.append(Messages.Concat).append(Messages.Technology);
			}
			expertTypeName.append(Messages.Expert);
			expertRoleNameBtn.setText(expertTypeName.toString());
		}else {
			expertRoleNameBtn.setText(Messages.BusinessTechnology.concat(Messages.Concat).concat(Messages.Expert));
			if(setEnable){
				expertRoleNameBtn.setEnabled(false);
			}
			expertRoleNameBtn.setSelection(false);
		}
		roleTypeComposite.layout();
	}
	
	/**
	 * @Description: 刷新评审配置
	 * @author guoyr 
	 */
//	private void refreshEvalType(){
//		boolean existAIFactor = false;
//		for(GridItem topItem : grid.getItems()){
//			if(topItem.getChecked(0) && topItem.getItemCount() == 0){
//				EvaluationFactor evaluationFactor = (EvaluationFactor)topItem.getData("evaluationFactor");
//				if(EvaluationFactorEnum.SCORE_TYPE_AI.equals(evaluationFactor.getScoreType())){
//					existAIFactor = true;
//					break;
//				}
//			}
//		}
//		if(existAIFactor){
//			WidgetUtils.setRadioChecked(evalTypeComposite, EvaluationStepEnum.EVALUATION_TYPE_AI);
//		}
//	}
	
	/**
	 * @Description: 确定
	 * @author guoyr
	 */
	private void saveEvaluationStepAction(){
		if(save_btn.getEnabled()){
			if(!ValidateUtils.checkInput(composite)){
				return;
			}
			
			// 验证评标步骤名称是否已经存在
			if(evaluationStepService.valEvaluationStepNameExist(tenderProjectEntity.getId(), evaluationStep.getId(), stepNameText.getText().trim())){
				MessageDialog.openWarning(getShell(), Messages.Step_step +"["+stepNameText.getText().trim()+"]" + Messages.Tips_AlreadyExistsPleaseRetype);
				stepNameText.setFocus();
				stepNameText.setText("");
				return;
			}
			
			evaluationStep.setStepName(stepNameText.getText().trim());
			evaluationStep.setStepType(EvaluationStepEnum.FIXED_FACTOR);//评审评审
			evaluationStep.setStepMemo(stepMemoText.getText().trim());
			evaluationStep.setTenderId(tenderProjectEntity.getId());
			evaluationStep.setRoleType(ObjectUtils.getObjString(WidgetUtils.getRadioVal(roleTypeComposite,"roleType")));
			
			Object indexIsBidNumber = ObjectUtils.getObjString(WidgetUtils.getRadioVal(sortNoComposite,"indexIsBidNumber"));
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_INDEX_IS_BIDNUMBER, null != indexIsBidNumber && indexIsBidNumber.equals(CommonEnum.YES) ? CommonEnum.YES : CommonEnum.NO);
			evaluationStep.setFilterType(EvaluationStepEnum.FILTER_NO);
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_IMPORT_OTHERE_EXPERT_RESULT, importTypeBtn.getSelection());
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_IMPORT_HISTORY_RESULT, importHistoryBtn.getSelection());
			if(null != tenderProjectEntity.getParentId() && tenderProjectEntity.getParentId().length() > 0){
				evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_EVALUATION_BY_SUPPLIER, evaluationBySupplierBtn.getSelection());
			}
//			evaluationStep.setEvaluationParam(EvaluationStepEnum.EVALUATION_TYPE, ObjectUtils.getObjString(WidgetUtils.getRadioVal(evalTypeComposite)));
			
			BigDecimal warningRange = ObjectUtils.getObjBigDecimal(warningRangeText.getText().trim());
			if(null != warningRange && warningRange.compareTo(BigDecimal.ZERO) > 0){
				evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_WARNING_RANGE, warningRange);
//				evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_IGNORE_OVER_WARNING_RANGE, ignoreWarningRangeBtn.getSelection());
			}else {
				evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_WARNING_RANGE, null);
//				evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_IGNORE_OVER_WARNING_RANGE, false);
			}
			evaluationStep.setEvaluationParam(EvaluationStepEnum.EXPERT_SCORE_ROUND, ObjectUtils.getIntValue(expertScoreRoundText.getText(), 2));
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_EVAL_BY_GROUP, evalByGroupBtn.getSelection());
			if(evalByGroupBtn.getSelection()){
				evaluationStep.setSummaryType(EvaluationStepEnum.SUMMARY_BY_FACTOR_SUM);
				evaluationStep.setRoleType(EvaluationStepEnum.EVAL_GROUP);
			}else {
				if(removeMaxAndMin_btn.getSelection()){
					evaluationStep.setSummaryType(EvaluationStepEnum.SUMMARY_REMOVE_MAX_MIN);
				}else if(removeFactorMaxAndMin_btn.getSelection()){
					evaluationStep.setSummaryType(EvaluationStepEnum.SUMMARY_REMOVE_FACTOR_MAX_MIN);
//			}else if(summaryByFactorSum_btn.getSelection()){
//				evaluationStep.setSummaryType(EvaluationStepEnum.SUMMARY_BY_FACTOR_SUM);
//				evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_EVALUATION_EMPTY, allowEmptyBtn.getSelection());
				}else if(ignoreWarningRangeBtn.getSelection()){
					evaluationStep.setSummaryType(EvaluationStepEnum.SUMMARY_IGNORE_OVER_WARNING_CORE);
				}else {
					evaluationStep.setSummaryType(EvaluationStepEnum.SUMMARY_ALL);
				}
			}
			
//			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_EXPER_SIGNATURE, param_exper_signature.getSelection());
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_SEALED_BID, param_sealed_bid.getSelection());
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_ORDERBY_SEALED_BID_CODE, param_orderby_sealed_bid_code.getSelection());
//			int PARAM_SEALED_BID_FILE_ROLE = 0;
//			if(param_sealed_bid.getSelection()){
//				for(Control button : sealedBidFileTypeComposite.getChildren()){
//					if(button instanceof Button){
//						if(null != button.getData("evalBidType")){
//							if(((Button)button).getSelection()){
//								try {
//									int evalBidType = Integer.parseInt(button.getData("evalBidType").toString());
//									PARAM_SEALED_BID_FILE_ROLE = PARAM_SEALED_BID_FILE_ROLE | evalBidType;
//								} catch (NumberFormatException e) {
//								}
//							}
//						}
//					}
//				}
//			}
//			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_SEALED_BID_FILE_ROLE, PARAM_SEALED_BID_FILE_ROLE);
			
			int filterNort = 0;
			try {
				filterNort = Integer.parseInt(finalistNumText.getText().trim());
			} catch (NumberFormatException e) {
			}
			double filterScore = 0;
			try {
				filterScore = Double.parseDouble(filterScoreText.getText().trim());
			} catch (NumberFormatException e) {
			}
			if(filterNort > 0 && filterScore > 0){
				MessageDialog.openWarning(getShell(), "入围规则只能设置一项！");
				return;
			}
			if(null != evaluationStep.getScore() && filterScore > evaluationStep.getScore().doubleValue()){
				MessageDialog.openWarning(getShell(), "入围规则中入围分值超出最大分值！");
				return;
			}
			evaluationStep.setFinalistNumber(filterNort);
			evaluationStep.setEvaluationParam(EvaluationStepEnum.PARAM_FILTER_SCORE, filterScore);
			
			if((evalBidBusBtn.getSelection() && evalBidTecBtn.getSelection())){
				evaluationStep.setEvalBidType(EvaluationFactorEnum.EVAL_BID_DETAIL);
			}else if(evalBidBusBtn.getSelection()){
				evaluationStep.setEvalBidType(EvaluationFactorEnum.EVAL_BID_BUS);
			}else if(evalBidTecBtn.getSelection()){
				evaluationStep.setEvalBidType(EvaluationFactorEnum.EVAL_BID_TEC);
			} else {
				evaluationStep.setEvalBidType(null);
			}
			
			if(isInEvaluation){
				evaluationStepService.updateAssignProperty(evaluationStep, new String[]{"stepName", "finalistNumber", "roleType", "evalBidType", "darkEvaluation", "stepMemo", "summaryType", "params"});
				this.getShell().close();
				return;
			}
			
			// 如果选择的是自定义专家类型
			if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.CUSTOM) && (null == stepExpertUserIdList || stepExpertUserIdList.size() == 0)){
				MessageDialog.openWarning(getShell(), Messages.Tips_SelcetExpert);
				return;
			}

			List<EvaluationFactor> checkedEvaluationFactorList = GridUtils.getRealCheckedValues(grid, 0, "evaluationFactor");
			int checkTopCount = 0;
			List<String> factorWeightList = new ArrayList<String>();
			int evaluationScoreByPass = 0;
			for(GridItem topItem : topGridItem.getItems()){
				if(topItem.getCheckVisible(0) && topItem.getChecked(0)){
					EvaluationFactor topFactor = (EvaluationFactor)topItem.getData("evaluationFactor");
					if(null != topFactor.getParentFactor()){//} && null != topFactor.getParentFactor().getScoreType() && topFactor.getParentFactor().getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS_PARENT)){
						if(!checkedEvaluationFactorList.contains(topFactor.getParentFactor())){
							if(null == topFactor.getParentFactor().getScoreType() || !topFactor.getParentFactor().getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS_PARENT)){
								topFactor.getParentFactor().setScoreType(EvaluationFactorEnum.SCORE_TYPE_PASS_PARENT);
								evaluationFactorService.updateAssignProperty(topFactor.getParentFactor(), new String[]{"scoreType"});
							}
							checkedEvaluationFactorList.add(topFactor.getParentFactor());
						}
					}
					checkTopCount ++;
					if(null != topFactor && null != topFactor.getFactorWeight()){
						factorWeightList.add(topFactor.getId());
					}
					if(null != topFactor.getScoreType() && topFactor.getScoreType().equals(EvaluationFactorEnum.SCORE_TYPE_PASS)){
						evaluationScoreByPass ++;
					}
				}
				
			}
			if(evaluationScoreByPass > 0){
				if(evaluationScoreByPass > 0 && checkTopCount != evaluationScoreByPass){
					MessageDialog.openWarning(getShell(), "["+stepNameText.getText().trim()+"]已选择通过性评审指标，不能再选择其他类型指标！");
					return;
				}
				evaluationStep.setSummaryType(EvaluationStepEnum.SUMMARY_SCORE_BY_QUALIFIED);
				evaluationStep.setPassType(EvaluationStepEnum.PASS_MORE);
				evaluationStep.setFilterType(EvaluationStepEnum.FILTER_YES);
			}
			
			if(null == checkedEvaluationFactorList || checkedEvaluationFactorList.size() == 0){
				MessageDialog.openWarning(getShell(), Messages.Tips_select+stepNameText.getText().trim()+"的评审指标！");
				return;
			}
			
			if(null == evaluationStep.getRoleType() || evaluationStep.getRoleType().length() == 0){
				MessageDialog.openWarning(getShell(), "请选择评标专家！");
				return;
			}
			
			evaluationStep.setEvaluationParam(EvaluationStepEnum.SHOW_SUMMARY_RESULT, showAggregateBtn.getSelection() ? "01" : "00");
			List<String> expertIdList = new ArrayList<String>();
			if (CollectionUtils.isNotNull(stepExpertUserIdList)){
				for(Expert expert : stepExpertUserIdList){
					expertIdList.add(expert.getUserId());
				}
			}
			evaluationStep = (EvaluationStep) evaluationStepService.saveEvaluationStepAndFactors(evaluationStep, checkedEvaluationFactorList, factorWeightList, expertIdList);
			if(null != evaluationStep && null != callBack){
				PropertiesUtils.saveProperty(ConfigConstants.SHOW_SUMMARY_SCORE, showAggregateBtn.getSelection() ? "01" : "00");
				if(null != callBack){
					callBack.callBackObject(evaluationStep);
				}
			}else {
				MessageDialog.openWarning(getShell(), stepNameText.getText()+Messages.Tips_saveFail);
			}
			this.getShell().close();
		}
	}
	
	/**
	 * @Description: 取消
	 * @author guoyr
	 */
	private void cancelAction(){
		this.getShell().close();
	}

	/**
	 * @Description: 选择评审成员类型
	 * @author guoyr
	 * @param roleType
	 */
	private void selectRoleTypeAction(String roleType){
//		evaluationStep.setRoleType(roleType);
		// 如果选择的是自定义专家类型
		if(ObjectUtils.equals(roleType, EvaluationStepEnum.CUSTOM)){
			StringBuilder memberName = new StringBuilder("");
 			if(null != stepExpertUserIdList && stepExpertUserIdList.size() > 0){
				int memberCount = 0;
				for(Expert expert : stepExpertUserIdList){
					if(null != expert && null != expert.getUser()){
						if(memberCount > 0){
							memberName.append("；");
						}
						memberName.append(ObjectUtils.getObjString(expert.getUser().getUserName()));
						memberCount ++;
					}
				}
			}
		
			
			expertNamesLabel.setText(memberName.toString());
			customComposite.layout();
			((GridData)customExpertLabel.getLayoutData()).exclude = false;
			customExpertLabel.setVisible(true);
			((GridData)customComposite.getLayoutData()).exclude = false;
			customComposite.setVisible(true);
			
//			((GridData)customComposite.getLayoutData()).heightHint = customComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
		}else {
			((GridData)customComposite.getLayoutData()).exclude = true;
			customComposite.setVisible(false);
			((GridData)customExpertLabel.getLayoutData()).exclude = true;
			customExpertLabel.setVisible(false);
//			((GridData)customComposite.getLayoutData()).heightHint = 0;
		}
		composite.layout();
	}
 
	/**
	 * @Description: 选择自定义专家
	 * @author guoyr
	 */
	private void selectStepExpert(){
		if(!isInEvaluation){
			SelectStepExpertDialog dialog = new SelectStepExpertDialog(getShell(), tenderProjectEntity.getId(), stepExpertUserIdList, new SelectExpertListener(){
				public void setExpertList(List<Expert> expertList){
					if(null != expertList){
						stepExpertUserIdList = expertList;
						selectRoleTypeAction(EvaluationStepEnum.CUSTOM);
					}
				}
				
			});
			dialog.open();
		}
	}
	
	/**
	 * @Description: 设置暗标文件类型
	 * @author guoyr 
	 */
//	private void checkSealedBidAction(){
//		if(param_sealed_bid.getSelection()){
//			((GridData)sealedBidFileTypeComposite.getLayoutData()).exclude = false;
//			sealedBidFileTypeComposite.setVisible(true);
//		}else {
//			param_sealed_bid.setSelection(false);
//			((GridData)sealedBidFileTypeComposite.getLayoutData()).exclude = true;
//			sealedBidFileTypeComposite.setVisible(false);
//		}
//		sealedBidFileTypeComposite.getParent().layout();
//		composite.layout();
//	}
	
	public CallBack getCallBack() {
		return callBack;
	}

	public void setCallBack(CallBack callBack) {
		this.callBack = callBack;
	}

	/**
	 * Return the initial size of the dialog.
	 */
	@Override
	protected Point getInitialSize() {
		return new Point(900, 650);
	}
}
