package com.gx.obe.management.composite;

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

import org.eclipse.swt.SWT;
import org.eclipse.swt.core.ImageResolver;
import org.eclipse.swt.core.MessageDialog;
import org.eclipse.swt.core.utils.SwtUtils;
import org.eclipse.swt.core.utils.WidgetUtils;
import org.eclipse.swt.core.widgets.ConfirmDialog;
import org.eclipse.swt.core.widgets.ELink;
import org.eclipse.swt.core.widgets.ESepator;
import org.eclipse.swt.core.widgets.ImageButton;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
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.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;

import com.gx.obe.ColorConstants;
import com.gx.obe.WebserviceConstants;
import com.gx.obe.action.bean.Action;
import com.gx.obe.business.entity.ExpertEvaluationStep;
import com.gx.obe.business.entity.MenuFunction;
import com.gx.obe.business.enumeration.ExpertEnum;
import com.gx.obe.business.enumeration.UserEnum;
import com.gx.obe.business.http.HttpUrl;
import com.gx.obe.business.http.HttpUtils;
import com.gx.obe.common.file.dialog.ClearProjectBidFileDialog;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.common.widget.button.StepProgressButton;
import com.gx.obe.common.widget.thread.SyncThread;
import com.gx.obe.common.widget.utils.MenuFunctionUtils;
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.components.core.enumeration.TenderProjectEnum;
import com.gx.obe.config.ConfigConstants;
import com.gx.obe.config.utils.PropertiesUtils;
import com.gx.obe.business.http.HttpResponse;
import com.gx.obe.listener.StartEvaluationListener;
import com.gx.obe.management.dialog.StartEvaluationStepShell;
import com.gx.obe.message.Messages;
import com.gx.obe.step.dialog.ReEvaluationConfirmDialog;
import com.gx.obe.thread.SyncThreadSet;
import com.gx.obe.util.utils.LogUtils;
import com.gx.obe.util.utils.ObjectUtils;
import com.gx.obe.util.utils.StringUtils;
import com.gx.obe.web.entity.auth.Menu;
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.entity.tender.TenderProjectRuleEntity;
import com.gx.obe.web.service.ProjectRuleService;
import com.gx.obe.web.service.TenderProjectService;
import com.gx.obe.web.service.evaluation.EvaluationGroupService;
import com.gx.obe.web.service.evaluation.EvaluationStepExpertService;
import com.gx.obe.web.service.evaluation.EvaluationStepService;
import com.gx.obe.web.service.expert.ExpertEvaluationStepService;
import com.gx.obe.web.service.expert.ExpertService;
import com.gx.utils.ActionLogUtils;
import com.gx.utils.NowTimeUtils;
import com.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

/**
 * @Description: 
 * @author guoyr
 */
public class EvaluationStepProgressComposite extends Composite implements StartEvaluationListener{
	
	private EvaluationStepService evaluationStepService = new EvaluationStepService();
	private EvaluationGroupService evaluationGroupService ;
	private ExpertEvaluationStepService expertEvaluationStepService ;
	private ExpertService expertService;
	private EvaluationStepExpertService evaluationStepExpertService ;
	private ProjectRuleService projectRuleService;
	private List<EvaluationStep> evaluationStepList ;
	private List<Expert> expertList;
	private TenderProjectEntity tenderProjectEntity;
	private Menu menu;
	private TenderProjectRuleEntity tenderProjectRuleEntity;
	private ImageResolver imageResolver = new ImageResolver();
	private Composite expert_progress_content;
	private Composite expert_progress;
	private ScrolledComposite scrolledComposite;
	private Composite composite;
	private ELink restartEvaluationBtn;
	private Composite orderReviewComposite;
	private StartEvaluationStepShell startEvaluationStepShell ;
	private int startNodeShellWidth;
	private int startNodeShellHeight;
	private StepProgressButton curOperatorLabel;
	private Composite top_composite;
	private Label progressMessage_label;
	private boolean needReback = true;
	private boolean showKeyCharacter = false;
	private Button orderOperatorBtn;
	private Button orderComplateBtn;
	private Button orderTotalFreeBtn;
	private MenuFunctionUtils menuFunctionUtils = new  MenuFunctionUtils();
	private Button orderSelfFreeBtn;
	private TenderProjectService tenderProjectService;
	private Action projectAction;
	private ELink completeButton;

	{
		LogUtils.logClass(EvaluationStepProgressComposite.class);
	}
	
	/**
	 * Create the progressComposite.
	 * @param parent
	 * @param style
	 */
	public EvaluationStepProgressComposite(Composite parent, Action projectAction, int style) {
		super(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout(1, false);
		gridLayout.verticalSpacing = 0;
		gridLayout.horizontalSpacing = 0;
		gridLayout.marginHeight = 0;
		gridLayout.marginWidth = 0;
		setLayout(gridLayout);
		this.projectAction = projectAction;
		
		setBackground(SWTResourceManager.getColor(211, 211, 211));

		top_composite = new Composite(this, SWT.NONE);
		GridLayout gl_top_composite = new GridLayout(1, false);
		gl_top_composite.verticalSpacing = 0;
		gl_top_composite.horizontalSpacing = 0;
		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, true, 1, 1));
		top_composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));

		Composite composite_title = new Composite(top_composite, SWT.NONE);
		GridLayout gl_composite_title = new GridLayout(5, false);
		gl_composite_title.verticalSpacing = 0;
		composite_title.setLayout(gl_composite_title);
		composite_title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
		
		ImageButton progressTitle = new ImageButton(composite_title, SWT.NONE);
		progressTitle.setBottomMargin(5);
		progressTitle.setTopMargin(5);
		progressTitle.setLeftMargin(10);
		progressTitle.setRightMargin(10);
		progressTitle.setBackground(ColorConstants.SKIN_BG);
		progressTitle.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		progressTitle.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		progressTitle.setText(Messages.Title_progressControl);
		
		orderReviewComposite = new Composite(composite_title, SWT.NONE);
		orderReviewComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
		GridLayout gl_composite_3 = new GridLayout(4, false);
		gl_composite_3.horizontalSpacing = 0;
		gl_composite_3.marginHeight = 0;
		gl_composite_3.marginWidth = 10;
		orderReviewComposite.setLayout(gl_composite_3);
		menuFunctionUtils.addFunction(orderReviewComposite, "ORDER_MANANGE");
		
		orderComplateBtn = new Button(orderReviewComposite, SWT.RADIO);
		orderComplateBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		orderComplateBtn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				updateOrderViewAction(e, EvaluationStepEnum.ORDER_REVIEW_YES);
			}
		});
		orderComplateBtn.setText(Messages.Button_progressOverall);
		orderComplateBtn.setToolTipText(Messages.Tips_progressOverall);
		orderComplateBtn.setData(EvaluationStepEnum.ORDER_REVIEW_YES);
		menuFunctionUtils.addFunction(orderComplateBtn, "ORDER_TOTAL");
		
		orderTotalFreeBtn = new Button(orderReviewComposite, SWT.RADIO);
		orderTotalFreeBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		orderTotalFreeBtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				updateOrderViewAction(e,EvaluationStepEnum.ORDER_SELF_FREE);
			}
		});
		orderTotalFreeBtn.setText(Messages.Button_progressFreeWithLimit);
		orderTotalFreeBtn.setToolTipText(Messages.Tips_progressFreeWithLimit);
		orderTotalFreeBtn.setData(EvaluationStepEnum.ORDER_SELF_FREE);
		menuFunctionUtils.addFunction(orderTotalFreeBtn, "ORDER_FREE_WITH_LIMIT");
		
		orderSelfFreeBtn = new Button(orderReviewComposite, SWT.RADIO);
		orderSelfFreeBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		orderSelfFreeBtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				updateOrderViewAction(e,EvaluationStepEnum.ORDER_REVIEW_NO);
			}
		});
		orderSelfFreeBtn.setText(Messages.Button_progressSelfFree);
		orderSelfFreeBtn.setToolTipText(Messages.Tips_progressSelfFree);
		orderSelfFreeBtn.setData(EvaluationStepEnum.ORDER_REVIEW_NO);
		menuFunctionUtils.addFunction(orderSelfFreeBtn, "ORDER_SELF_FREE");
		
		
		orderOperatorBtn = new Button(orderReviewComposite, SWT.RADIO);
		orderOperatorBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		orderOperatorBtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				updateOrderViewAction(e,EvaluationStepEnum.ORDER_OPERATOR);
			}
		});
		orderOperatorBtn.setText(Messages.Button_progressManual);
		orderOperatorBtn.setToolTipText(Messages.Tips_progressManual);
		orderOperatorBtn.setData(EvaluationStepEnum.ORDER_OPERATOR);
		menuFunctionUtils.addFunction(orderOperatorBtn, "ORDER_HAND");
		

		ELink button = new ELink(composite_title, SWT.NONE);
		button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
		button.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				refreshAction();
			}
		});
		button.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/refresh.png"));
		button.setText(Messages.Button_refresh);
		
		completeButton = new ELink(composite_title, SWT.NONE);
		completeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		completeButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				completeEvaluationAction();
			}
		});
		completeButton.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/flag_red.png"));
		completeButton.setText(Messages.Button_endEvaluation);
		menuFunctionUtils.addFunction(completeButton, "COMPLETE_TENDER");
		
		ELink clearBidFileButton = new ELink(composite_title, SWT.NONE);
		clearBidFileButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		clearBidFileButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				clearBidFilesAction();
			}
		});
		clearBidFileButton.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/delete.png"));
		clearBidFileButton.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.NORMAL));
		clearBidFileButton.setToolTipText(Messages.ClearBidFile);
		clearBidFileButton.setText(Messages.ClearBidFile);
		menuFunctionUtils.addFunction(clearBidFileButton, "CLEAR_BID_FILE");
		
		
		ESepator label_1 = new ESepator(composite_title, SWT.NONE);
		label_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 5, 1));
		label_1.setBackground(ColorConstants.SKIN_BG);
		label_1.setLineWidth(2);
		
		scrolledComposite = new ScrolledComposite(top_composite, SWT.H_SCROLL | SWT.V_SCROLL);
		GridData gd_scrolledComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_scrolledComposite.heightHint = 300;
		scrolledComposite.setLayoutData(gd_scrolledComposite);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		
		composite = new Composite(scrolledComposite, SWT.NONE);
		GridLayout gl_composite = new GridLayout(1, false);
		gl_composite.verticalSpacing = 0;
		gl_composite.horizontalSpacing = 0;
		gl_composite.marginHeight = 0;
		gl_composite.marginWidth = 0;
		composite.setLayout(gl_composite);
		
		Composite total_progress_composite = new Composite(composite, SWT.NONE);
		total_progress_composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		GridLayout gl_titleComposite = new GridLayout(2, false);
		gl_titleComposite.verticalSpacing = 0;
		gl_titleComposite.horizontalSpacing = 0;
		gl_titleComposite.marginHeight = 0;
		gl_titleComposite.marginWidth = 0;
		total_progress_composite.setLayout(gl_titleComposite);
		
		Composite total_progress_title = new Composite(total_progress_composite, SWT.NONE);
		GridData gd_progressTitleComposite = new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1);
		gd_progressTitleComposite.heightHint = 45;
		gd_progressTitleComposite.widthHint = 150;
		total_progress_title.setLayoutData(gd_progressTitleComposite);
		total_progress_title.setLayout(new GridLayout(1, false));
		
		Label total_name = new Label(total_progress_title, SWT.NONE);
		total_name.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
		total_name.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		total_name.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		total_name.setText(Messages.Button_progressOverall + "：");
		
		expert_progress_content = new Composite(total_progress_composite, SWT.NONE);
		expert_progress_content.setLayout(new RowLayout(SWT.HORIZONTAL));
		expert_progress_content.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
		
		ESepator sep = new ESepator(composite, SWT.NONE);
		sep.setForeground(ColorConstants.SEP_LIGHT_COLOR);
		sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		expert_progress = new Composite(composite, SWT.NONE);
		GridLayout gl_expert_progressComposite = new GridLayout(1, false);
		gl_expert_progressComposite.verticalSpacing = 0;
		gl_expert_progressComposite.horizontalSpacing = 0;
		gl_expert_progressComposite.marginHeight = 0;
		gl_expert_progressComposite.marginWidth = 0;
		expert_progress.setLayout(gl_expert_progressComposite);
		expert_progress.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		scrolledComposite.setContent(composite);
		scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		ESepator splabel = new ESepator(top_composite, SWT.SEPARATOR | SWT.HORIZONTAL);
		splabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		splabel.setBackground(ColorConstants.SEP_LIGHT_COLOR);
	
		Composite composite_1 = new Composite(top_composite, SWT.NONE);
		composite_1.setBackgroundMode(SWT.INHERIT_FORCE);
		SwtUtils.setCircleRegion(composite_1, 2);
		GridLayout gl_composite_1 = new GridLayout(11, false);
		gl_composite_1.verticalSpacing = 0;
		composite_1.setLayout(gl_composite_1);
		composite_1.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
		
		ImageButton label_7 = new ImageButton(composite_1, SWT.NONE);
		label_7.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/tips_white.png"));
		label_7.setSurroundColor(SWTResourceManager.getColor(60, 138, 226));
		label_7.setSurroundMargin(6);
		label_7.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 2));
		label_7.setText(" ");
		
		progressMessage_label = new Label(composite_1, SWT.WRAP);
		progressMessage_label.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		progressMessage_label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 9, 1));
		progressMessage_label.setImage(null);
		progressMessage_label.setText(MessageFormat.format(Messages.Tips_reEvaluation, Messages.Progress_complate));
		progressMessage_label.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		
		restartEvaluationBtn = new ELink(composite_1, SWT.NONE);
		restartEvaluationBtn.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 2));
		restartEvaluationBtn.setText(Messages.Button_reBidEvaluation);
		restartEvaluationBtn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/clear.png"));
		restartEvaluationBtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				restartEvaluationAction();
			}
		});
		
		StepProgressButton complate_step = new StepProgressButton(composite_1, SWT.NONE);
		complate_step.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		complate_step.setText("    ");
		complate_step.setBackground(StepProgressButton.COMPLATE_COLOR);
		
		Label label2 = new Label(composite_1, SWT.NONE);
		label2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		label2.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		label2.setText(Messages.Progress_complate + "    ");
		label2.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		
		StepProgressButton in_progress_step = new StepProgressButton(composite_1, SWT.NONE);
		in_progress_step.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		in_progress_step.setBackground(StepProgressButton.IN_PROGRESS_COLOR);
		in_progress_step.setText("    ");
		
		Label label_inprgs = new Label(composite_1, SWT.NONE);
		label_inprgs.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		label_inprgs.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		label_inprgs.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_inprgs.setText(Messages.Progress_inProgress + "    ");
		
		StepProgressButton no_start = new StepProgressButton(composite_1, SWT.NONE);
		no_start.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		no_start.setBackground(StepProgressButton.NO_START_COLOR);
		no_start.setText("    ");
		
		Label label_nostart = new Label(composite_1, SWT.NONE);
		label_nostart.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		label_nostart.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		label_nostart.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_nostart.setText(Messages.Progress_noStart + "    ");
		
		StepProgressButton re_author = new StepProgressButton(composite_1, SWT.NONE);
		re_author.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		re_author.setBackground(StepProgressButton.RE_AUTHORIZATION_COLOR);
		re_author.setText("    ");
		
		Label label_re_author = new Label(composite_1, SWT.NONE);
		label_re_author.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		label_re_author.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		label_re_author.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
		label_re_author.setText(Messages.Progress_reBack);
		new Label(composite_1, SWT.NONE);
		tenderProjectService = new TenderProjectService();
		projectRuleService = new ProjectRuleService();
		init();
	}
	
	/**
	 * @Description: 初始化
	 * @author guoyr
	 */
	private void init(){
		expertEvaluationStepService = new ExpertEvaluationStepService();
		expertService = new ExpertService();
		evaluationGroupService = new EvaluationGroupService();
		this.tenderProjectEntity = projectAction.getTenderProject();
		tenderProjectEntity = tenderProjectService.getById(tenderProjectEntity.getId());
		this.menu = projectAction.getMenu();
		menuFunctionUtils.initFunctionAuthority(menu);
		evaluationStepExpertService = new EvaluationStepExpertService();
		needReback = !MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("REBACK_EVALUATION"));
		if(!needReback){
			progressMessage_label.setText("点击“刷新进度”可刷新专家的评标进度！");
		}
		refreshAction();
		addControlListener(new ControlAdapter(){
			@Override
			public void controlResized(ControlEvent e) {
				if(null != curOperatorLabel && !curOperatorLabel.isDisposed()){
					curOperatorLabel.notifyListeners(SWT.Move, null);
				}
			}
		});
		
		restartEvaluationBtn.setVisible(false);
		restartEvaluationBtn.setEnabled(false);
		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)){
						showKeyCharacter = !showKeyCharacter;
//						boolean visible = !restartEvaluationBtn.getVisible();
//						restartEvaluationBtn.setVisible(visible);
//						restartEvaluationBtn.setEnabled(visible);
					}
				}
			};
			
			top_composite.getDisplay().addFilter(SWT.KeyDown, keyListener);;
			addDisposeListener(new DisposeListener() {
				public void widgetDisposed(DisposeEvent e) {
					top_composite.getDisplay().removeFilter(SWT.KeyDown, keyListener);  
					imageResolver.disposite();
					if(null != startEvaluationStepShell && !startEvaluationStepShell.isDisposed()){
						startEvaluationStepShell.close();
					}
				}
			});
		}
		
	}
	
	/**
	 * @Description: 完成评标
	 * @author wangx 
	 */
	private void completeEvaluationAction() {
		//判断是否废标或者已完成推荐
		if(!completeButton.getEnabled())return ;
		tenderProjectEntity = tenderProjectService.getById(tenderProjectEntity.getId());
		if(CommonEnum.COMPLETE.equals(tenderProjectEntity.getComplateStatus()) || TenderProjectEnum.EFFECTIVE_NO.equals(tenderProjectEntity.getEffectiveType())) {
			ConfirmDialog confirmDialog = new ConfirmDialog(getShell(), null, "是否确认结束评标流程？", null);
			//confirmDialog.setTips("注：结束评标流程后，专家将无法看到该项目！");
			confirmDialog.setTipsColor(SWTResourceManager.getColor(255, 0, 0));
			confirmDialog.addButton("确认结束评标流程", "01");
//			confirmDialog.setTipsAlignment(SWT.CENTER);
			confirmDialog.addCancel(Messages.Button_cancel, null);
			confirmDialog.open();
			if(!"01".equals(confirmDialog.getClickStatus())) {
				return;
			}
		}else {
			MessageDialog.openWarning(getShell(), "当前项目未完成评审，请先完成评审或废标。");
			return;
		}
		boolean updateStatus = false;
		if(null != tenderProjectEntity.getParentId()) {
			if(tenderProjectService.updateEvaluationComplateStatus(tenderProjectEntity.getId(),tenderProjectEntity.getParentId(),CommonEnum.ARCHIVE_STATUS)) {
				updateStatus = true;
			}
		}else {
			tenderProjectEntity.setUseStatus(CommonEnum.ARCHIVE_STATUS);
			if(tenderProjectService.updateAssignProperty(tenderProjectEntity, new String[]{"useStatus"})) {
				updateStatus = true;
			}
		}
		if(updateStatus) {
			MessageDialog.openWarning(getShell(), "当前项目已完成评标。");
			completeButton.setEnabled(false);
			top_composite.layout();
			
		}
		uploadTime();
		
	}
	
	private boolean uploadTime(){
		HttpUrl httpUrl = HttpUtils.getProjectHttpUrl(tenderProjectEntity, PropertiesUtils.getWebserviceProperty(WebserviceConstants.PUSH_DATE_TO_VEDIO_PLAT_FORM, ""));
		httpUrl.setName("上传结束评标时间");
		httpUrl.setAttribute("pushType", "03");
		httpUrl.setAttribute("tenderNo", tenderProjectEntity.getTenderNo());
		httpUrl.setAttribute("stageType", "");
		httpUrl.setAttribute("stageId", tenderProjectEntity.getStageId());
		httpUrl.setAttribute("tenderNoNumber", tenderProjectEntity.getTenderNumber());
		httpUrl.setAttribute("dateTime", NowTimeUtils.getDateTime());
		HttpResponse httpResponse = HttpUtils.doPost(httpUrl);
		if(httpResponse.getStatus()){
			return true;
		}else {
			return false;
		}
	}
	
	/**
	 * @Description: 刷新进度
	 * @author guoyr 
	 */
	private void refreshAction(){
		
		SyncThreadSet myThreadSet = new SyncThreadSet(new SyncThreadSet.Runnable() {
			public void run() {
				if(expert_progress_content.isDisposed())return;
				Display.getDefault().syncExec(new Runnable(){
					public void run(){
						if(orderReviewComposite.isDisposed()){
							return;
						}
						WidgetUtils.setRadioChecked(orderReviewComposite, tenderProjectRuleEntity.getOrderReview());
						showTotalProgress();
						refreshComplateStatus();
						
						if(expert_progress.isDisposed())return;
						showExpertProgress();
						composite.layout();
						scrolledComposite.setMinHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
					}
				});
			}
		});
		myThreadSet.addSyncExec(new SyncThread(new SyncThread.Runnable() {
			public void run() {
				tenderProjectRuleEntity = projectAction.refreshTenderProjectRule();
				if(null == tenderProjectRuleEntity.getOrderReview() || "".equals(tenderProjectRuleEntity.getOrderReview())){
					tenderProjectRuleEntity.setOrderReview(PropertiesUtils.getProperty(ConfigConstants.DEFAULT_STEP_PROGRESS, EvaluationStepEnum.ORDER_REVIEW_NO));
					projectRuleService.updateAssignProperty(tenderProjectRuleEntity, new String[]{"id", "orderReview"});
				}
			}
		}));
		myThreadSet.addSyncExec(new SyncThread(new SyncThread.Runnable() {
			public void run() {
				evaluationStepList = evaluationStepService.getEvaluationStepList(tenderProjectEntity.getId());
			}
		}));
		myThreadSet.addSyncExec(new SyncThread(new SyncThread.Runnable() {
			public void run() {
				expertList = expertService.getExpertList(tenderProjectEntity.getId(), ExpertEnum.ALL);
			}
		}));
		myThreadSet.start();
	}
	
	/**
	 * @Description: 刷新评标步骤
	 * @author guoyr
	 */
	private void showTotalProgress(){
		
		boolean[] showStartNodeShell = new boolean[]{false};
		
		for(Control control : expert_progress_content.getChildren()){
			control.dispose();
		}
		if(null != startEvaluationStepShell && !startEvaluationStepShell.isDisposed()){
			startEvaluationStepShell.close();
		}
		if(null != evaluationStepList && evaluationStepList.size() > 0){
			for(int nodeCount = 0; nodeCount < evaluationStepList.size(); nodeCount ++){
				final EvaluationStep evaluationStep = evaluationStepList.get(nodeCount);
				
				final StepProgressButton totalProgress = new StepProgressButton(expert_progress_content, SWT.NONE|SWT.SELECTED);
				totalProgress.setText((nodeCount+1)+"、"+evaluationStep.getStepName()+" >>");
				
				ExpertEvaluationStep operatorEvaluationStep = null;
				if(ObjectUtils.equals(evaluationStep.getStepStatus(), CommonEnum.COMPLETE)){
					totalProgress.setBackground(StepProgressButton.COMPLATE_COLOR);
//					if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.OPERATOR)){
//						operatorEvaluationStep = expertEvaluationStepService.getExpertEvaluationStep(tenderProjectEntity.getId(), evaluationStep.getId(), /*ExpertEnum.COMMON_EXPERT*/Constants.CUR_USER.getId());
//						if(null != operatorEvaluationStep){
//							if(null != operatorEvaluationStep.getApplyStatus() && operatorEvaluationStep.getApplyStatus().equals(CommonEnum.YES)){
//								totalProgress.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/hand.png"));
//							}else {
//								totalProgress.setImage(null);
//							}
//						}
//					}
				}else if(ObjectUtils.equals(evaluationStep.getStepStatus(), CommonEnum.RE_OPERATOR)){
					totalProgress.setBackground(StepProgressButton.RE_AUTHORIZATION_COLOR);
				}else if(ObjectUtils.equals(evaluationStep.getStepStatus(), CommonEnum.IN_PROGRESS)){
					totalProgress.setBackground(SWTResourceManager.getColor(60, 138, 226));
				}else {
					totalProgress.setBackground(StepProgressButton.NO_START_COLOR);
				}
				if(ObjectUtils.equals(evaluationStep.getStepStatus(), CommonEnum.IN_PROGRESS) || ObjectUtils.equals(evaluationStep.getStepStatus(), CommonEnum.COMPLETE)){
					
					if(needReback){
						final ExpertEvaluationStep _operatorEvaluationStep = operatorEvaluationStep;
						totalProgress.addMouseListener(new MouseAdapter() {
							@Override
							public void mouseUp(MouseEvent e) {
								rebackExperEvaluationStepAction(evaluationStep, _operatorEvaluationStep);
							}
						});
					}
						
					// 如果评标进度是授项目经理控制
				}else if(ObjectUtils.equals(tenderProjectRuleEntity.getOrderReview(), EvaluationStepEnum.ORDER_OPERATOR)){
					if(nodeCount == 0 || ObjectUtils.equals(evaluationStepList.get(nodeCount-1).getStepStatus(), CommonEnum.COMPLETE)){
						if(!showStartNodeShell[0]){
							showStartNodeShell[0] = true;
							// 如果状态不是开始评标，则认为项目经理还没同意评标
							if(!ObjectUtils.equals(evaluationStep.getControlStatus(), CommonEnum.START)){
								if(null == startEvaluationStepShell || startEvaluationStepShell.isDisposed()){
									startEvaluationStepShell = new StartEvaluationStepShell(getShell(), evaluationStep, this);
									startEvaluationStepShell.setVisible(false);
									startEvaluationStepShell.open();
									startEvaluationStepShell.setAlpha(150);
									startNodeShellWidth = startEvaluationStepShell.getBounds().width;
									startNodeShellHeight = startEvaluationStepShell.getBounds().height;
								}
								curOperatorLabel = totalProgress;
								totalProgress.addPaintListener(new PaintListener(){
									public void paintControl(PaintEvent arg0) {
										if(null != startEvaluationStepShell && !startEvaluationStepShell.isDisposed()){
											startEvaluationStepShell.setVisible(false);
											startEvaluationStepShell.setLocation(totalProgress.toDisplay((totalProgress.getBounds().width - startNodeShellWidth) / 2, (totalProgress.getBounds().height - startNodeShellHeight)/2));
											if(!startEvaluationStepShell.getVisible()){
												startEvaluationStepShell.setVisible(true);
											}
										}
									}
								});
							}
						}
					}
				}
			}
		}
		
		expert_progress_content.layout();
		expert_progress_content.getParent().layout();
	}
	
	private void refreshComplateStatus() {
		boolean enable = false;
		if(null != evaluationStepList && evaluationStepList.size() > 0) {
			int complateCount = 0;
			for(EvaluationStep evaluationStep : evaluationStepList){
				if(EvaluationStepEnum.WASTE_BID.equals(evaluationStep.getStepType())){
					if(CommonEnum.COMPLETE.equals(evaluationStep.getStepStatus())) {
						enable = true;
						break;
					}
				}else {
					if(CommonEnum.COMPLETE.equals(evaluationStep.getStepStatus())) {
						complateCount ++;
					}
				}
			}
			if(!enable) {
				enable = complateCount > 0 && complateCount == evaluationStepList.size();
			}
		}
		if(CommonEnum.ARCHIVE_STATUS.equals(tenderProjectEntity.getUseStatus())) {
			enable = false;
		}
		completeButton.setEnabled(enable);
	}
	
	/**
	 * @Description: 刷新评标步骤
	 * @author guoyr
	 */
	private void showExpertProgress(){
		if(expert_progress.isDisposed())return;
		for(Control control : expert_progress.getChildren()){
			control.dispose();
		}
		// 获得专家登录记录数据
		SyncThreadSet myThreadSet = new SyncThreadSet(new SyncThreadSet.Runnable() {
			public void run(){
				Display.getDefault().syncExec(new Runnable(){
					public void run(){
						if(expert_progress.isDisposed())return;
						expert_progress.layout();
					}
				});
			}
		});
		if(null != expertList && expertList.size() > 0){
			myThreadSet.addSyncExec(new SyncThread(new SyncThread.Runnable() {
				public void run(){
					for(final Expert expert : expertList){
						final Map<String, ExpertEvaluationStep> expertStepMap = new HashMap<String, ExpertEvaluationStep>();
						List<ExpertEvaluationStep> expertEvaluationStepList = expertEvaluationStepService.getExpertEvaluationStepList(tenderProjectEntity.getId(), expert.getUserId());
						if(null != expertEvaluationStepList && expertEvaluationStepList.size() > 0){
							for(ExpertEvaluationStep expertStep : expertEvaluationStepList){
								expertStepMap.put(expertStep.getStepId(), expertStep);
							}
						}
						Display.getDefault().syncExec(new Runnable(){
							public void run(){
								if(expert_progress.isDisposed())return;
								refreshExpertProgress(expert, expertStepMap);
							}
						});
					}
					Display.getDefault().syncExec(new Runnable(){
						public void run(){
							if(expert_progress.isDisposed())return;
							composite.layout();
							scrolledComposite.setMinSize(composite.computeSize(scrolledComposite.getBounds().width -20, SWT.DEFAULT));
						}
					});
				}
			}));
		}
		myThreadSet.start();
		
	}
	
	private void refreshExpertProgress(final Expert expert, final Map<String, ExpertEvaluationStep> expertStepMap){

		Composite expert_composite = new Composite(expert_progress, SWT.NONE);
		expert_composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		GridLayout gl_expert_composite = new GridLayout(2, false);
		gl_expert_composite.marginHeight = 0;
		gl_expert_composite.marginWidth = 0;
		gl_expert_composite.horizontalSpacing = 0;
		expert_composite.setLayout(gl_expert_composite);
		expert_composite.setBackgroundMode(SWT.INHERIT_FORCE);
		
		Composite member_name_composite = new Composite(expert_composite, SWT.NONE);
		GridData gd_memberComposite = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1);
		gd_memberComposite.widthHint = 150;
		member_name_composite.setLayoutData(gd_memberComposite);
		GridLayout gl_expert_name_composite = new GridLayout(1, false);
		gl_expert_name_composite.verticalSpacing = 0;
		gl_expert_name_composite.horizontalSpacing = 0;
		gl_expert_name_composite.marginHeight = 0;
		member_name_composite.setLayout(gl_expert_name_composite);
		member_name_composite.setLayoutData(gd_memberComposite);
		member_name_composite.setLayout(new GridLayout(1, false));
		
		ImageButton expert_name = new ImageButton(member_name_composite, SWT.NONE);
		expert_name.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		expert_name.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		expert_name.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
		boolean isExpertLeader = ExpertEnum.LEADER_YES.equals(expert.getIsLeader());
		expert_name.setText(Messages.Expert + "：");
		if(null != expert.getUser()){
			if(UserEnum.FEMALE.equals(expert.getUser().getGender())){
				expert_name.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/female_48.png"), 30, 30);
			}else {
				expert_name.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/male_48.png"), 30, 30);
			}
			if(null != expert.getUser().getUserName()){
				expert_name.setText(expert.getUser().getUserName()+"：");
			}else if(null != expert.getUser().getUserAccount()){
				expert_name.setText(expert.getUser().getUserAccount()+"：");
			}
		}
		if(isExpertLeader) {
			expert_name.setSubTextFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
			expert_name.setSubTextVerAlign(SWT.BOTTOM);
			expert_name.setSubTextSurroundAlpha(200);
			expert_name.setSubTextRightMargin(2);
			expert_name.setSubText("组长");
		}
		
		Composite memberNodeComposite = new Composite(expert_composite, SWT.NONE);
		memberNodeComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
		GridData gd_memberNodeComposite = new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1);
		memberNodeComposite.setLayoutData(gd_memberNodeComposite);
		
		int nodeCount = 0;
		boolean isNeedCorrectAndConfirmEvalPrice = false;
		
		// 获得当前专家指定评审的评标步骤
		List<String> customStepList = null;
		List<String> evalGroupStepList = null;
		
		for(final EvaluationStep evaluationStep : evaluationStepList){
			
			// 如果当前节点是价格节点，且需要进行修正报价和确认修正报价
			if(!isNeedCorrectAndConfirmEvalPrice && ObjectUtils.equals(evaluationStep.getStepType(), EvaluationStepEnum.PRICE) && ObjectUtils.equals(tenderProjectRuleEntity.getCorrectPrice(), CommonEnum.YES) && ObjectUtils.equals(tenderProjectRuleEntity.getConfirmPrice(), CommonEnum.YES)){
				isNeedCorrectAndConfirmEvalPrice = true;
				if(isConfirmEvalPrice(evaluationStep, isExpertLeader)){
					evaluationStep.setStepName(Messages.Button_confirm+Messages.EvaluationPrice);
				}
			} else if (ObjectUtils.equals(evaluationStep.getStepType(), EvaluationStepEnum.PRE_EVALUATION)) {
				if (!evaluationGroupService.isHasEvaluationGroupByUserId(tenderProjectEntity.getId(), expert.getUserId(), evaluationStep.getId())) {
					continue;
				}
			}else{
				if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.EXPERT_LEADER)){
					if(!ObjectUtils.equals(expert.getIsLeader(), ExpertEnum.LEADER_YES)){
						continue;
					}
				}else if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.OPERATOR)){
					continue;
				}else if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.CUSTOM)){
					if(null == customStepList){
						customStepList = evaluationStepExpertService.finStepIdByTenderIdAndUserId(tenderProjectEntity.getId(), expert.getUserId());
					}
					
					// 如果该专家没有指定评标步骤或，在当前评标步骤没有指定给该专家
					if (null == customStepList || !customStepList.contains(evaluationStep.getId())) {
						continue;
					}
				} else if (ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.EVAL_BID_TYPE)) {
					if (null != evaluationStep.getEvalBidType() && evaluationStep.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_BUS)) {
						if ((expert.getEvalBidTypeNotNull() & ExpertEnum.EXPERT_BUS) == 0) {
							continue;
						}
					} else if (null != evaluationStep.getEvalBidType() && evaluationStep.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_TEC)) {
						if ((expert.getEvalBidTypeNotNull() & ExpertEnum.EXPERT_TEC) == 0) {
							continue;
						}
					} else if (null != evaluationStep.getEvalBidType() && evaluationStep.getEvalBidType().equals(EvaluationFactorEnum.EVAL_BID_DETAIL)) {
						if ((expert.getEvalBidTypeNotNull() & (ExpertEnum.EXPERT_BUS | ExpertEnum.EXPERT_TEC)) == 0) {
							continue;
						}
					}
				}else if (ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.EVAL_GROUP)) {
					if(null == expert.getEvalGroup()){
						continue;
					}
					if(null == evalGroupStepList){
						evalGroupStepList = evaluationStepService.getEvalGroupEvalStepList(tenderProjectEntity.getId(), expert.getEvalGroup());
					}
					if (null == evalGroupStepList || !evalGroupStepList.contains(evaluationStep.getId())) {
						continue;
					}
				}
			}
				
			final StepProgressButton stepProgress= new StepProgressButton(memberNodeComposite, SWT.NONE);
			stepProgress.setText((nodeCount+1)+"、"+evaluationStep.getStepName()+" >>");
			
			// 专家在当前评标步骤的状态
			ExpertEvaluationStep newExpertEvaluationStep= new ExpertEvaluationStep();
			newExpertEvaluationStep.setUserId(expert.getUserId());
			final ExpertEvaluationStep expertEvaluationStep = null != expertStepMap.get(evaluationStep.getId())? expertStepMap.get(evaluationStep.getId()) : newExpertEvaluationStep;
			boolean canReOperator = false;
			if(StringUtils.isEmpty(expertEvaluationStep.getStepStatus())){
				if(ObjectUtils.equals(evaluationStep.getStepType(), EvaluationStepEnum.SIGIN) && StringUtils.isNotEmpty(expert.getSignType())){
					stepProgress.setBackground(StepProgressButton.COMPLATE_COLOR);
					canReOperator = true;
				}else {
					stepProgress.setBackground(StepProgressButton.NO_START_COLOR);
				}
			}else if(ObjectUtils.equals(expertEvaluationStep.getStepStatus(), CommonEnum.COMPLETE)){
				if(null != expertEvaluationStep.getApplyStatus() && expertEvaluationStep.getApplyStatus().equals(CommonEnum.YES)){
					stepProgress.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/hand.png"));
				}else {
					stepProgress.setImage(null);
				}
				stepProgress.setBackground(StepProgressButton.COMPLATE_COLOR);
				stepProgress.setActiveBackgroundColor(StepProgressButton.RE_AUTHORIZATION_COLOR);
				stepProgress.setActiveBorderColor(StepProgressButton.RE_AUTHORIZATION_COLOR);
				canReOperator = true;
			}else if(ObjectUtils.equals(expertEvaluationStep.getStepStatus(), CommonEnum.IN_EXPERT_REVIEW) 
					|| ObjectUtils.equals(expertEvaluationStep.getStepStatus(), CommonEnum.IN_MANAGER_REVIEW)){
				stepProgress.setBackground(StepProgressButton.IN_PROGRESS_COLOR);
			}else if(ObjectUtils.equals(expertEvaluationStep.getStepStatus(), CommonEnum.IN_PROGRESS)){
				stepProgress.setBackground(StepProgressButton.IN_PROGRESS_COLOR);
			}else if(ObjectUtils.equals(expertEvaluationStep.getStepStatus(), CommonEnum.RE_OPERATOR)){
				stepProgress.setBackground(StepProgressButton.RE_AUTHORIZATION_COLOR);
			}else {
				stepProgress.setBackground(StepProgressButton.NO_START_COLOR);
			}
			if(needReback && canReOperator){
				stepProgress.addMouseListener(new MouseAdapter() {
					public void mouseUp(MouseEvent e) {
						rebackExperEvaluationStepAction(evaluationStep, expertEvaluationStep);
					}
				});
			}
			nodeCount ++;
		}
		expert_progress.layout();
	}
	
	/**
	 * @Description: 是否确认修正评标价
	 * @author guoyr
	 * @param evaluationStep
	 * @return
	 */
	private boolean isConfirmEvalPrice(EvaluationStep evaluationStep, boolean isExpertLeader){
		boolean isConfirmEvalPrice = false;
		// 如果价格评审是由项目经理评审，则说明所有专家进行评标价修正确认
		if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.OPERATOR)){
			
			isConfirmEvalPrice = true;
		}else if(ObjectUtils.equals(evaluationStep.getRoleType(), EvaluationStepEnum.EXPERT_LEADER) && isExpertLeader){
			// 专家组长进行价格评审
			isConfirmEvalPrice = false;
		}else {
			// 其他专家确认修正报价
			isConfirmEvalPrice = true;
		}
		return isConfirmEvalPrice;
	}
	
	/**
	 * @Description: 回退评标专家的评标步骤操作
	 * @author guoyr
	 */
	private void rebackExperEvaluationStepAction(EvaluationStep evaluationStep, ExpertEvaluationStep expertEvaluationStep){
		ReEvaluationConfirmDialog reEvaluationConfirmDialog = new ReEvaluationConfirmDialog(getShell(), evaluationStep, expertEvaluationStep);
		reEvaluationConfirmDialog.open();
		if(reEvaluationConfirmDialog.isConfirmReback()){
			if(ObjectUtils.equals(evaluationStep.getStepType(), EvaluationStepEnum.SIGIN)){
				String userId = null ;
				if(null != expertEvaluationStep){
					userId = expertEvaluationStep.getUserId();
				}
				expertService.updateSignTypeByTenderIdOrUserId(null , tenderProjectEntity.getId(),userId);
				if(CommonEnum.ARCHIVE_STATUS.equals(tenderProjectEntity.getUseStatus())) {
					tenderProjectEntity.setUseStatus(CommonEnum.REAL_STATUS);
					tenderProjectService.updateAssignProperty(tenderProjectEntity, new String[]{"useStatus"});	
				}
				if(null != tenderProjectEntity.getParentId()) {
					TenderProjectEntity parent = tenderProjectService.getById(tenderProjectEntity.getParentId());
					parent.setUseStatus(CommonEnum.REAL_STATUS);
					tenderProjectService.updateAssignProperty(parent, new String[]{"useStatus"});	
				}
			}
			refreshAction();
		}
	}
	
	/**
	 * @Description: 重新评审
	 * @author guoyr
	 */
	private void restartEvaluationAction(){
		if(restartEvaluationBtn.getEnabled()){
			if(MessageDialog.openConfirm(getShell(), Messages.Button_reBidEvaluation, "“重新评标”将清除所有专家的评标进度，您确认需要重新评标吗？", "重新评标", Messages.Button_cancel)){
				boolean cleanData = MessageDialog.openConfirm(getShell(), "清除记录确认", "“重新评标”时是否保留专家的评标记录？", "清除记录", "保留记录");
				tenderProjectService.restartEvaluation(tenderProjectEntity.getId(), cleanData);
				tenderProjectEntity.setComplateStatus(CommonEnum.NOT_START);
				tenderProjectEntity.setUseStatus(CommonEnum.REAL_STATUS);
				tenderProjectService.updateAssignProperty(tenderProjectEntity, new String[]{"id","complateStatus","useStatus"});
				refreshAction();
			}
		}
	}

	/**
	 * @Description: 修改评审进度控制
	 * @author guoyr
	 */
	private void updateOrderViewAction(MouseEvent e, String value){
		Button button = (Button)e.getSource();
		MessageDialog.openShortMessage(Messages.Tips_saveSuccess +"\r\n"+button.getText()+"\r\n"+button.getToolTipText());
		tenderProjectRuleEntity.setOrderReview(value);
		ActionLogUtils.addServerLog(tenderProjectEntity.getId(),"修改项目进度为", button.getText());
		projectRuleService.updateAssignProperty(tenderProjectRuleEntity, new String[]{"id","orderReview"});
		PropertiesUtils.saveProperty(ConfigConstants.DEFAULT_STEP_PROGRESS, tenderProjectRuleEntity.getOrderReview());
		showTotalProgress();
	}
	
	/**
	 * @Description: 清空项目标书缓存
	 * @author guoyr 
	 */
	private void clearBidFilesAction() {
		ClearProjectBidFileDialog dialog = new ClearProjectBidFileDialog(getShell(), tenderProjectEntity);
		dialog.open();
	}
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}

	public void start(EvaluationStep evaluationStep) {
		evaluationStep.setControlStatus(CommonEnum.START);
		evaluationStepService.updateAssignProperty(evaluationStep, new String[]{"controlStatus"});
		showTotalProgress();
		
	}
}
