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

import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

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.GridSelectionListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.ImageResolver;
import org.eclipse.swt.core.MessageDialog;
import org.eclipse.swt.core.utils.FileDialogUtils;
import org.eclipse.swt.core.utils.SwtUtils;
import org.eclipse.swt.core.utils.WidgetUtils;
import org.eclipse.swt.core.widgets.ELink;
import org.eclipse.swt.core.widgets.EMenu;
import org.eclipse.swt.core.widgets.ESepator;
import org.eclipse.swt.core.widgets.ImageButton;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StackLayout;
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.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;

import com.gx.obe.ColorConstants;
import com.gx.obe.answer.dialog.ImportAnswerQuestionDialog;
import com.gx.obe.answer.dialog.InquireEnvelopListDialog;
import com.gx.obe.bidata.action.BidDataAction;
import com.gx.obe.bidata.action.SupplierInfoAction;
import com.gx.obe.bidata.action.SupplierInfoDialogAction;
import com.gx.obe.bidata.vo.SupplierDTO;
import com.gx.obe.business.entity.MenuFunction;
import com.gx.obe.business.enumeration.MenuFunctionEnum;
import com.gx.obe.common.file.dialog.BidFileLocalBorwseDialog;
import com.gx.obe.common.file.entity.BidFile;
import com.gx.obe.common.file.entity.BiddingFile;
import com.gx.obe.common.file.entity.EvaluationPoint;
import com.gx.obe.common.file.enumeration.FileConstants;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.common.widget.button.EvalLeftButton;
import com.gx.obe.common.widget.button.EvaluationButton;
import com.gx.obe.common.widget.dialog.InputDialog;
import com.gx.obe.common.widget.shell.OpenFileTipsShell;
import com.gx.obe.common.widget.shell.ToolsShell;
import com.gx.obe.common.widget.utils.MenuFunctionUtils;
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.components.core.enumeration.ExpertEnum;
import com.gx.obe.config.ConfigConstants;
import com.gx.obe.config.utils.PropertiesUtils;
import com.gx.obe.evaluation.step.composite.struct.EvaluationView;
import com.gx.obe.evaluation.step.dialog.BidFileOpinionDialog;
import com.gx.obe.evaluation.step.dialog.EvaluationOpinionDialog;
import com.gx.obe.evaluation.step.dialog.FactorOpinionDialog;
import com.gx.obe.evaluation.step.dialog.ImportBidBondDialog;
import com.gx.obe.evaluation.step.dialog.ReReasonDialog;
import com.gx.obe.evaluation.step.dialog.ViewResultDialog;
import com.gx.obe.evaluation.step.inter.IEvaluationTable;
import com.gx.obe.evaluation.step.listener.CompareBidFileListener;
import com.gx.obe.evaluation.step.listener.CompareSupplierFileListener;
import com.gx.obe.evaluation.step.listener.EvaluationSupplierFactorListener;
import com.gx.obe.evaluation.step.review.composite.ComplianceEvaluationTableComposite;
import com.gx.obe.evaluation.step.review.composite.ScoreEvaluationTableComposite;
import com.gx.obe.evaluation.step.shell.ListEvaluationItemShell;
import com.gx.obe.evaluation.step.shell.ShowCompareSupplierListShell;
import com.gx.obe.evaluation.step.widgets.EvalLeftGroupButton;
import com.gx.obe.evaluation.step.widgets.LeftMenuEnum;
import com.gx.obe.evaluation.step.widgets.LeftMenuMouseAdapter;
import com.gx.obe.message.Messages;
import com.gx.obe.util.utils.CollectionUtils;
import com.gx.obe.util.utils.FileUtils;
import com.gx.obe.util.utils.LogUtils;
import com.gx.obe.util.utils.ObjectUtils;
import com.gx.obe.util.utils.RuntimeUtils;
import com.gx.obe.util.utils.ScreenUtils;
import com.gx.obe.util.utils.StringUtils;
import com.gx.obe.web.entity.EvaluationFactorResult;
import com.gx.obe.web.entity.Supplier;
import com.gx.obe.web.entity.auth.Menu;
import com.gx.obe.web.entity.evaluation.EvaluationFactor;
import com.gx.obe.web.entity.evaluation.EvaluationStep;
import com.gx.obe.web.entity.expert.ExpertEvaluationResult;
import com.gx.obe.web.entity.tender.TenderProjectEntity;
import com.gx.tools.listener.LocationBidFileListener;
import com.gx.tools.ole.DocumentFactory;
import com.gx.tools.ole.DocumentLoader;
import com.gx.tools.ole.LoadFileListener;
import com.gx.tools.ole.dianju.DianJuConstant;
import com.gx.tools.ole.jinge.JingeConstant;
import com.gx.tools.utils.CaInfoUtil;
import com.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

/**
 * @Description: 指标评标界面
 * @author guoyr
 */
public class FactorEvaluationComposite extends EvaluationView {
	
	private final String TYPE_BID = "bidFile";
	private final String TYPE_BIDDING = "biddingFile";
	private ImageResolver imageResolver = new ImageResolver();
	private SashForm bid_file_evaluation_panel_sashform;
	private Composite viewContentComposite;
	private Composite evaluation_panel_composite;
	private Text supplier_name;
	
//	private EvalLeftButton file_panel_both_ver;
//	private EvalLeftButton file_panel_both_hor;
//	private EvalLeftButton show_file_only;
//	private EvalLeftButton evaluation_panel_only;
	private Composite button_composite;
	private SashForm bid_bidding_sashform;
	private Composite bid_file_list_composite;
	private Composite bidFileComposite;
	private final int RIGHT_COMPOSITE_WIDTH = 180;
	private List<Supplier> supplierList;
	private CTabFolder bid_file_tabfolder;
	private CTabItem no_bid_file_item;
	private Supplier curSupplier;
	private boolean hasBidFile = false;
	private boolean viewBidPrice = true;
	private EvaluationButton init_default_btn;
	private EvaluationButton save_result_btn;
	private EvaluationButton submit_result_btn;
	private Grid evaluationPointGrid;
	private Grid bidFileGrid;
	private GridColumn bidFileGridColumn;
	private Composite evaluation_point_composite;
	private DocumentLoader bidFileDocumentLoader;
	private DocumentLoader supplierCurDocumentLoader;
	private boolean scoreOnly = true;
	private Composite bidding_composite;
//	private EvalLeftButton curPanelBtn;
	private LeftMenuEnum viewContentMenu; 
	private EvalLeftGroupButton viewContentGroupButton; 
	private LeftMenuEnum evaluationPanelLayoutMenu; 
	private EvalLeftGroupButton evalPanelLayoutGroupButton; 
	private EvalLeftGroupButton opinionGroupButton; 
	private EvalLeftGroupButton creditGroupButton; 
	private EvalLeftGroupButton radioGroupButton; 
	
//	private EvalLeftButton evaluationPanelBtn;
//	private EvalLeftGroupButton bid_file_only;
//	private EvalLeftButton bidding_file_only;
//	private EvalLeftButton bidding_bid_file_both_hor;
//	private EvalLeftButton bidding_bid_file_both_ver;
	private ListEvaluationItemShell showEvalPointShell;
	private ELink moreEvalPointLink;
	private Composite bidPoint_composite;
	private IEvaluationTable evaluationTable = null;
	private EvaluationSupplierFactorListener evaluationSupplierFactorListener;
	private EvaluationButton import_other_expert_result_btn;
	private EvaluationButton import_history_result_btn;
	private Composite left_tool_composite;
	private Composite evaluation_talbe_composite;
	private boolean evaluationPanelOnly = true;
	private int fontSize = 9;
	private int bidFileCacheCount = 3;
	private int fileCacheCount = 2;
	private boolean showOnloadFileTips = true;
//	private ELink viewInquireEnvelopLink;
	private ELink compareFile_link;
	private ELink localFile_link;
	private ShowCompareSupplierListShell compareBiddingFileShell;
	private List<Supplier> compareSupplierList = new ArrayList<Supplier>();
	private ELink evaluationButton;
	private ExpertEvaluationResult curExpertEvaluationResult;
	public static int evalPanlGoientation = SWT.VERTICAL;
	private ImageButton hideOrShowSupplier_btn;
	private CLabel supplierNameTitle;
	private EvaluationFactor curEvaluationFactor;
	private Map<String, LocationBidFileListener> locationBidFileListenerMap;
	private boolean showOleToolBar = true;
	private EvalLeftButton moreTools;
	boolean useSpecialPdf = true;
//	private ELink compare_btn;
	private boolean isOpen = false;
	private String pdfType;
	private List<BidFile> bidFileList;
	private Grid biddingFileGrid;
	private GridColumn biddingFileGridColumn;
	private Composite biddingFileComposite;
	private StackLayout fileStackLayout;
	private Composite bidFileSection_composite;
	private ImageButton curButton;
	private Composite fileComposite;
	private EvaluationStep noComplateFilterStep = null;
	private EvalLeftButton inquireEnvelop;
	private EvalLeftButton answerQuestionBtn;
//	private EvalLeftButton bidPrice;
	private EvalLeftButton viewFinalResult;
	public static boolean isShowBidFileOpinion;
	private boolean isShowFactorEvalOpinion;
	private boolean isShowCredit;
	private List<EvaluationFactor> allEvaluationFactorList;
	private CompareEvaluationTableComposite compareEvaluationTableComposite;
	private FactorEvaluationOpinionComposite factorEvaluationOpinionComposite;
	private StackLayout opinionStackLayout;
	private Composite opinionComposite;
	private Composite opinionLoadComposite;
	private MenuFunctionUtils menuFunctionUtils = new MenuFunctionUtils();
	private Menu menu;
	private EvalLeftButton bidBondBtn;
	private EvalLeftGroupButton clarificationAnswerGroupButton;
	private ELink viewCredit_link;
	private List<SupplierDTO> supplierDTOList;
	private OpenFileTipsShell openFileTipsShell;
	private Map<String,String> supplierNameMap = new HashMap<String,String>();
	
	{
		LogUtils.logClass(FactorEvaluationComposite.class);
	}
	
	/**
	 * @param parent
	 * @param style
	 */
	public FactorEvaluationComposite(Composite parent, int style) {
		super(parent, style);
		menu = (Menu) parent.getData("menu");
		GridLayout gridLayout = new GridLayout(3, false);
		gridLayout.verticalSpacing = 0;
		gridLayout.horizontalSpacing = 0;
		gridLayout.marginHeight = 0;
		gridLayout.marginWidth = 0;
		setLayout(gridLayout);
		
		final Listener deactivateListener = new Listener() {
			public void handleEvent(Event arg0) {
				evaluationTable.closeCellEditor();
			}
		};
		
		addListener(SWT.Deactivate, deactivateListener);
		
		addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				disposite();
				removeListener(SWT.Deactivate, deactivateListener);
			}
		});
		
		left_tool_composite = new Composite(this, SWT.NONE);
		left_tool_composite.setBackground(EvalLeftButton.BG);
		left_tool_composite.setBackgroundMode(SWT.INHERIT_FORCE);
		left_tool_composite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1));
		GridLayout gl_left_tool_composite = new GridLayout(1, false);
		gl_left_tool_composite.verticalSpacing = 2;
		left_tool_composite.setLayout(gl_left_tool_composite);
		
		EvalLeftButton goto_back = new EvalLeftButton(left_tool_composite, SWT.NONE);
		goto_back.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		goto_back.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/back.png"));
		goto_back.setToolTipText(Messages.Button_return);
		goto_back.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				goBackAction();
			}
		});
		
		EvalLeftButton refresh_evaluation = new EvalLeftButton(left_tool_composite, SWT.NONE);
		refresh_evaluation.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/refresh.png"));
		refresh_evaluation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		refresh_evaluation.setToolTipText(Messages.Button_refresh);
		refresh_evaluation.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				refreshAction();
			}
		});
		
		ESepator sep = new ESepator(left_tool_composite, SWT.NONE);
		sep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		
		evalPanelLayoutGroupButton = new EvalLeftGroupButton(left_tool_composite, SWT.NONE);
		evalPanelLayoutGroupButton.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/file_eval.png"));
		evalPanelLayoutGroupButton.setBackground(ColorConstants.SKIN_SELECTION_BG);
		evalPanelLayoutGroupButton.setTitle(Messages.Tips_changeEvalPanelLayout);
		
		viewContentGroupButton = new EvalLeftGroupButton(left_tool_composite, SWT.NONE);
		viewContentGroupButton.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/bid_file.png"));
//		viewContentGroupButton.setBackground(ColorConstants.SKIN_SELECTION_BG);
		viewContentGroupButton.setTitle(Messages.Tips_changeEvalContent);
		
		opinionGroupButton = new EvalLeftGroupButton(left_tool_composite, SWT.NONE);
    	opinionGroupButton.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/eval_opinion.png"));
    	
    	creditGroupButton = new EvalLeftGroupButton(left_tool_composite, SWT.NONE);
    	creditGroupButton.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/credit.png"));
    	creditGroupButton.setTitle("查看征信风险");
    	
		
		ESepator panel_bottom_sep = new ESepator(left_tool_composite, SWT.NONE);
		panel_bottom_sep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		
		viewFinalResult = new EvalLeftButton(left_tool_composite, SWT.NONE);
        viewFinalResult.addMouseListener(new MouseAdapter() {
            public void mouseUp(MouseEvent e) {
                viewFinalResultAction();
            }
        });
        viewFinalResult.setToolTipText(Messages.Button_viewBidEvaluationResults);
        viewFinalResult.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/result.png"));
    	menuFunctionUtils.addFunction(viewFinalResult, "EVALUATION_VIEW_SHOWBIDEVALUATIONRESULTS");
    	
    	clarificationAnswerGroupButton = new EvalLeftGroupButton(left_tool_composite, SWT.NONE);
    	clarificationAnswerGroupButton.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/clairfy_queswer.png"));
		
		bidBondBtn = new EvalLeftButton(left_tool_composite, SWT.NONE);
		bidBondBtn.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/bond.png"));
		bidBondBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		bidBondBtn.setText("");
		bidBondBtn.setToolTipText(Messages.BidBond);
		bidBondBtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				importBidBondAction();
			}
		});
		menuFunctionUtils.addFunction(bidBondBtn, "BID_BOND");
		
		EvalLeftButton fontSizeReduce = new EvalLeftButton(left_tool_composite, SWT.NONE);
		fontSizeReduce.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/size_reduce.png"));
		fontSizeReduce.setText("");
		fontSizeReduce.setToolTipText(Messages.Button_reduceFontSize);
		fontSizeReduce.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				setTableFontSize(-1);
			}
		});
		menuFunctionUtils.addFunction(fontSizeReduce, "EVALUATION_VIEW_REDUCEFONTSIZE");
		
		EvalLeftButton fontSizeAdd = new EvalLeftButton(left_tool_composite, SWT.NONE);
		fontSizeAdd.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/size_enlarge.png"));
		fontSizeAdd.setText("");
		fontSizeAdd.setToolTipText(Messages.Button_enlargeFont);
		fontSizeAdd.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				setTableFontSize(1);
			}
		});
		menuFunctionUtils.addFunction(fontSizeAdd, "EVALUATION_VIEW_ENLARGEFONTSIZE");
		
		moreTools = new EvalLeftButton(left_tool_composite, SWT.NONE);
		moreTools.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/more.png"));
		moreTools.setText("");
		moreTools.setToolTipText(Messages.More +"...");
		moreTools.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				moreConfigAction();
			}
		});
		menuFunctionUtils.addFunction(moreTools, "EVALUATION_VIEW_MORE");
		
		ESepator toolv_sepator = new ESepator(this, SWT.VERTICAL);
		toolv_sepator.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1));
		toolv_sepator.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		
		Composite right_composite = new Composite(this, SWT.NONE);
		GridLayout gl_right_composite = new GridLayout(1, false);
		gl_right_composite.verticalSpacing = 0;
		gl_right_composite.horizontalSpacing = 0;
		gl_right_composite.marginHeight = 0;
		gl_right_composite.marginWidth = 0;
		right_composite.setLayout(gl_right_composite);
		right_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		Composite supplier_composite = new Composite(right_composite, SWT.NONE);
		GridLayout gl_supplier_composite = new GridLayout(6, false);
		supplier_composite.setLayout(gl_supplier_composite);
		supplier_composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		supplier_composite.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/title_bg.png"));
		
		supplierNameTitle = new CLabel(supplier_composite, SWT.NONE);
		supplierNameTitle.setText("当前供应商：");
		supplierNameTitle.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		supplierNameTitle.setFont(SWTResourceManager.getFont("微软雅黑", 12, SWT.NORMAL));
		supplierNameTitle.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/supplier.png"));
		
		supplier_name = new Text(supplier_composite, SWT.READ_ONLY);
		supplier_name.setText("              ");
		supplier_name.setFont(SWTResourceManager.getFont("微软雅黑", 12, SWT.NORMAL));
		supplier_name.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		supplier_name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		viewCredit_link = new ELink(supplier_composite, SWT.NONE);
		viewCredit_link.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/view.png"));
		viewCredit_link.setText("查看征信");
		viewCredit_link.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				viewCreditAction();
			}
		});
		
//		ELink link = new ELink(supplier_composite, SWT.NONE);
//		link.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/view.png"));
//		link.setText("查看关联关系");
//		link.addMouseListener(new MouseAdapter() {
//			public void mouseUp(MouseEvent e) {
//				BidDataMutiModesAction.actiocn(getShell(), supplierDTOList);
//			}
//		});
		
		menuFunctionUtils.addFunction(viewCredit_link, "VIEW_CREDIT");
		
		compareFile_link = new ELink(supplier_composite, SWT.NONE);
		compareFile_link.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				addCompareSupplierAction();
			}
		});
		compareFile_link.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/enlarge.png"));
		compareFile_link.setText(Messages.Button_bidFileCompare);
		menuFunctionUtils.addFunction(compareFile_link, "BID_FILE_COMPARE");
		
		evaluationButton = new ELink(supplier_composite, SWT.NONE);
		evaluationButton.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/edit.png"));
		evaluationButton.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				setSupplierEvaluationOpinion();
			}
		});
		evaluationButton.setText(Messages.Button_viewEvalOpinion);
		menuFunctionUtils.addFunction(evaluationButton, "VIEW_EVAL_OPINION");
		
		localFile_link = new ELink(supplier_composite, SWT.NONE);
        localFile_link.addMouseListener(new MouseAdapter() {
            public void mouseUp(MouseEvent e) {
                evaluationSupplierFactorListener.openLocalFile(curTender, curSupplier);
            }
        });
        localFile_link.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/location.png"));
        localFile_link.setText(Messages.Button_viewLocalFiles);
        menuFunctionUtils.addFunction(localFile_link, "VIEW_LOCAL_FILE");
		
		ESepator supllerSep = new ESepator(right_composite, SWT.HORIZONTAL);
		supllerSep.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		supllerSep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		bid_file_evaluation_panel_sashform = new SashForm(right_composite, SWT.HORIZONTAL);
		bid_file_evaluation_panel_sashform.setSashWidth(2);
		bid_file_evaluation_panel_sashform.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));
		bid_file_evaluation_panel_sashform.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		opinionComposite = new Composite(bid_file_evaluation_panel_sashform, SWT.NONE);
        opinionStackLayout = new StackLayout();
        opinionComposite.setLayout(opinionStackLayout);
		
		viewContentComposite = new Composite(opinionComposite, SWT.NONE);
		viewContentComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		GridLayout gl_bid_file_composite = new GridLayout(3, false);
		gl_bid_file_composite.verticalSpacing = 0;
		gl_bid_file_composite.horizontalSpacing = 0;
		gl_bid_file_composite.marginHeight = 0;
		gl_bid_file_composite.marginWidth = 0;
		viewContentComposite.setLayout(gl_bid_file_composite);
		
		bid_bidding_sashform = new SashForm(viewContentComposite, SWT.NONE);
		bid_bidding_sashform.setSashWidth(2);
		bid_bidding_sashform.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));
		bid_bidding_sashform.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		bidding_composite = new Composite(bid_bidding_sashform, SWT.NONE);
		bidding_composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		bidding_composite.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		Composite no_bidding_file_composite = new Composite(bidding_composite, SWT.NONE);
		no_bidding_file_composite.setLayout(new GridLayout(1, false));
		
		Label no_bidding_file_label = new Label(no_bidding_file_composite, SWT.NONE);
		no_bidding_file_label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1));
		no_bidding_file_label.setText(Messages.Tips_noBiddingFiles);
		no_bidding_file_label.setForeground(SWTResourceManager.getColor(200, 200, 200));
		no_bidding_file_label.setFont(SWTResourceManager.getFont("宋体", 40, SWT.BOLD));
		
		bid_file_tabfolder = new CTabFolder(bid_bidding_sashform, SWT.FLAT);
		bid_file_tabfolder.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		bid_file_tabfolder.setTabHeight(0);
		
		no_bid_file_item = new CTabItem(bid_file_tabfolder, SWT.NONE);
		Composite no_bid_file_composite = new Composite(bid_file_tabfolder, SWT.NONE);
		no_bid_file_composite.setLayout(new GridLayout(1, false));
		no_bid_file_item.setControl(no_bid_file_composite);
		
		Label no_bid_file_label = new Label(no_bid_file_composite, SWT.NONE);
		no_bid_file_label.setForeground(SWTResourceManager.getColor(200, 200, 200));
		no_bid_file_label.setFont(SWTResourceManager.getFont("宋体", 40, SWT.BOLD));
		no_bid_file_label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1));
		no_bid_file_label.setText(Messages.Tips_noBidFiles);
		
		bid_bidding_sashform.setWeights(new int[] { 1, 1 });
		
		hideOrShowSupplier_btn = new ImageButton(viewContentComposite, SWT.NONE);
		hideOrShowSupplier_btn.setBorderColor(ColorConstants.BORDER_LINE_COLOR);
		hideOrShowSupplier_btn.setBackgroundColor(SWTResourceManager.getColor(242, 242, 242));
		hideOrShowSupplier_btn.setActiveBackgroundColor(SWTResourceManager.getColor(255, 153, 0));
		hideOrShowSupplier_btn.setRightMargin(0);
		hideOrShowSupplier_btn.setTopMargin(50);
		hideOrShowSupplier_btn.setBottomMargin(50);
		hideOrShowSupplier_btn.setLeftMargin(0);
		hideOrShowSupplier_btn.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, true, 1, 1));
		hideOrShowSupplier_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				hideOrShowSupplierAction();
			}
		});
		hideOrShowSupplier_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/right_arrow.png"));
		
		bid_file_list_composite = new Composite(viewContentComposite, SWT.NONE);
		GridData gd_bid_file_list_composite = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
		gd_bid_file_list_composite.widthHint = RIGHT_COMPOSITE_WIDTH;
		bid_file_list_composite.setLayoutData(gd_bid_file_list_composite);
		GridLayout gl_bid_file_list_composite = new GridLayout(2, false);
		gl_bid_file_list_composite.verticalSpacing = 0;
		gl_bid_file_list_composite.horizontalSpacing = 0;
		gl_bid_file_list_composite.marginWidth = 0;
		gl_bid_file_list_composite.marginHeight = 0;
		bid_file_list_composite.setLayout(gl_bid_file_list_composite);
		bid_file_list_composite.addControlListener(new ControlAdapter() {
			public void controlResized(ControlEvent e) {
				loactionEvaluationPointShell();
				super.controlResized(e);
			}
		});
		
		ESepator file_right_ver = new ESepator(bid_file_list_composite, SWT.VERTICAL);
		file_right_ver.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		GridData gd_file_right_ver = new GridData(SWT.CENTER, SWT.FILL, false, true, 1, 2);
		gd_file_right_ver.widthHint = 1;
		file_right_ver.setLayoutData(gd_file_right_ver);
		
		evaluation_point_composite = new Composite(bid_file_list_composite, SWT.NONE);
		GridLayout gl_evaluation_point_composite = new GridLayout(1, false);
		gl_evaluation_point_composite.horizontalSpacing = 0;
		gl_evaluation_point_composite.marginWidth = 0;
		gl_evaluation_point_composite.verticalSpacing = 0;
		gl_evaluation_point_composite.marginHeight = 0;
		evaluation_point_composite.setLayout(gl_evaluation_point_composite);
		GridData gd_evaluation_point_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_evaluation_point_composite.heightHint = 100;
		evaluation_point_composite.setLayoutData(gd_evaluation_point_composite);
		
		bidPoint_composite = new Composite(evaluation_point_composite, SWT.NONE);
		bidPoint_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_bidPoint_composite = new GridLayout(2, false);
		gl_bidPoint_composite.verticalSpacing = 0;
		gl_bidPoint_composite.marginHeight = 0;
		gl_bidPoint_composite.marginWidth = 0;
		bidPoint_composite.setLayout(gl_bidPoint_composite);
		
		ImageButton bidPointTitle = new ImageButton(bidPoint_composite, SWT.NONE);
		bidPointTitle.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
		bidPointTitle.setBackground(ColorConstants.SKIN_BG);
		bidPointTitle.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		bidPointTitle.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		bidPointTitle.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/location.png"));
		bidPointTitle.setText(Messages.Button_locationPoint);
		
		moreEvalPointLink = new ELink(bidPoint_composite, SWT.NONE);
		moreEvalPointLink.setShowSubLine(false);
		moreEvalPointLink.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				listMoreEvalPointAction();
			}
		});
		moreEvalPointLink.setText(Messages.More+">>");
		
		ESepator pointSep = new ESepator(bidPoint_composite, SWT.NONE);
		pointSep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
		pointSep.setBackground(ColorConstants.SKIN_BG);
		pointSep.setLineWidth(2);
		
		Composite supplierEvalPointComposite = new Composite(evaluation_point_composite, SWT.NONE);
		GridData gd_supplierEvalPointComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_supplierEvalPointComposite.widthHint = 150;
		supplierEvalPointComposite.setLayoutData(gd_supplierEvalPointComposite);
		supplierEvalPointComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		evaluationPointGrid = new Grid(supplierEvalPointComposite, SWT.V_SCROLL);
		evaluationPointGrid.setAutoHeight(true);
		evaluationPointGrid.addListener(SWT.Selection, new GridSelectionListener() {
			public void leftMouseButtonDown(GridItem item) {
				locationBidFileByFactorPointAction();
			}
		});
		
		GridColumn gridColumn = new GridColumn(evaluationPointGrid, SWT.NONE);
		gridColumn.setWidth(150);
		gridColumn.setWordWrap(true);
		
		bidFileSection_composite = new Composite(bid_file_list_composite, SWT.NONE);
		GridLayout gl_bidFileSection_composite = new GridLayout(2, false);
		gl_bidFileSection_composite.verticalSpacing = 0;
		gl_bidFileSection_composite.marginHeight = 0;
		gl_bidFileSection_composite.marginWidth = 0;
		bidFileSection_composite.setLayout(gl_bidFileSection_composite);
		GridData gd_bidFileSection_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_bidFileSection_composite.heightHint = 100;
		bidFileSection_composite.setLayoutData(gd_bidFileSection_composite);
		
		curButton = createImageButton(Messages.BidFile, TYPE_BID);
		curButton.setSelection(true);
		createImageButton(Messages.BiddingFile, TYPE_BIDDING);
		new Label(bidFileSection_composite, SWT.NONE);
		
		ESepator bidFileSectionSep = new ESepator(bidFileSection_composite, SWT.NONE);
		bidFileSectionSep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
		bidFileSectionSep.setBackground(ColorConstants.SKIN_BG);
		bidFileSectionSep.setLineWidth(2);
		
		fileStackLayout = new StackLayout();
		
		fileComposite = new Composite(bidFileSection_composite, SWT.NONE);
		fileComposite.setLayout(fileStackLayout);
		fileComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
		
		bidFileComposite = new Composite(fileComposite, SWT.NONE);
		bidFileComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		bidFileGrid = new Grid(bidFileComposite, SWT.V_SCROLL);
		bidFileGrid.setAutoHeight(true);
		bidFileGrid.addListener(SWT.Selection, new GridSelectionListener() {
			public void leftMouseButtonDown(GridItem item) {
				loacationBidFileByDocumtntAction();
			}
			
			public void rightMouseButtonDown(GridItem item) {
				bidFileMouseRightClickAction();
			}
		});
		
		bidFileGridColumn = new GridColumn(bidFileGrid, SWT.NONE);
		bidFileGridColumn.setWidth(150);
		bidFileGridColumn.setWordWrap(true);
		
		biddingFileComposite = new Composite(fileComposite, SWT.NONE);
		biddingFileComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		biddingFileGrid = new Grid(biddingFileComposite, SWT.V_SCROLL);
		biddingFileGrid.setAutoHeight(true);
		biddingFileGrid.addListener(SWT.Selection, new GridSelectionListener() {
			public void leftMouseButtonDown(GridItem item) {
				loacationBiddingFileByDocumtntAction();
			}
			
			public void rightMouseButtonDown(GridItem item) {
				biddingFileMouseRightClickAction();
			}
		});
		
		biddingFileGridColumn = new GridColumn(biddingFileGrid, SWT.NONE);
		biddingFileGridColumn.setWidth(150);
		biddingFileGridColumn.setWordWrap(true);
		
		opinionLoadComposite = new Composite(opinionComposite, SWT.NONE);
        opinionLoadComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		evaluation_panel_composite = new Composite(bid_file_evaluation_panel_sashform, SWT.NONE);
		evaluation_panel_composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		GridLayout gl_evaluation_panel_composite = new GridLayout(1, false);
		gl_evaluation_panel_composite.verticalSpacing = 0;
		gl_evaluation_panel_composite.horizontalSpacing = 0;
		gl_evaluation_panel_composite.marginHeight = 0;
		gl_evaluation_panel_composite.marginWidth = 0;
		evaluation_panel_composite.setLayout(gl_evaluation_panel_composite);
		
		evaluation_talbe_composite = new Composite(evaluation_panel_composite, SWT.NONE);
		evaluation_talbe_composite.setLayout(new FillLayout(SWT.HORIZONTAL));
		evaluation_talbe_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		ESepator sepLab = new ESepator(evaluation_panel_composite, SWT.HORIZONTAL);
		sepLab.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		sepLab.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		
		button_composite = new Composite(evaluation_panel_composite, SWT.NONE);
		GridLayout gl_button_composite = new GridLayout(1, false);
		button_composite.setLayout(gl_button_composite);
		button_composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		button_composite.setBackgroundMode(SWT.INHERIT_FORCE);
		
		Composite composite_5 = new Composite(button_composite, SWT.NONE);
		RowLayout rl_composite_5 = new RowLayout(SWT.HORIZONTAL);
		rl_composite_5.justify = true;
		rl_composite_5.fill = true;
		rl_composite_5.spacing = 5;
		composite_5.setLayout(rl_composite_5);
		composite_5.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 1, 1));
		
		EvaluationButton switch_oordinate_btn = new EvaluationButton(composite_5, SWT.NONE);
		switch_oordinate_btn.setText(Messages.Button_switchAxis);
		switch_oordinate_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/switch.png"));
		switch_oordinate_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				evaluationTable.switchCoordinateAction();
			}
		});
		
		init_default_btn = new EvaluationButton(composite_5, SWT.NONE);
		init_default_btn.setText(Messages.Button_quickEvaluation);
		init_default_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/select_all.png"));
		init_default_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				evaluationTable.initDefaultFactorResult();
			}
		});
		
		import_other_expert_result_btn = new EvaluationButton(composite_5, SWT.NONE);
		import_other_expert_result_btn.setText(Messages.Button_importOtherExpertResults);
		import_other_expert_result_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/import.png"));
		import_other_expert_result_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				evaluationTable.importOtherExpertResult();
			}
		});
		
		import_history_result_btn = new EvaluationButton(composite_5, SWT.NONE);
		import_history_result_btn.setText(Messages.Button_importHistoryResults);
		import_history_result_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/import.png"));
		import_history_result_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				evaluationTable.importHistoryResult();
			}
		});
		
		save_result_btn = new EvaluationButton(composite_5, SWT.NONE);
		save_result_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/save.png"));
		save_result_btn.setText(Messages.Button_saveEvaluationResult);
		save_result_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				saveEvaluationResultAction();
			}
		});
		
		submit_result_btn = new EvaluationButton(composite_5, SWT.NONE);
		submit_result_btn.setText(Messages.Button_submitEvaluationResult);
		submit_result_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/submit.png"));
		submit_result_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				submitEvaluationResultAction();
			}
		});
		bid_file_evaluation_panel_sashform.setWeights(new int[] { 6, 4 });
		
		init();
	}
	
	private ImageButton createImageButton(String buttonName, final String type) {
		final ImageButton imageButton = new ImageButton(bidFileSection_composite, SWT.NONE);
		imageButton.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
//		imageButton.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/items.png"));
		imageButton.setText(buttonName);
		imageButton.setData("fileType", type);
		imageButton.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		imageButton.setBackgroundColor(SWTResourceManager.getColor(245, 245, 245));
		imageButton.setActiveBackgroundColor(ColorConstants.SKIN_ACTIVE_BG);
		imageButton.setSelectionBgColor(ColorConstants.SKIN_BG);
		imageButton.setActiveForeground(ColorConstants.SKIN_ACTIVE_FOREGROUND);
		imageButton.setSelectionForeground(ColorConstants.SKIN_SELECTOIN_FOREGROUND);
		imageButton.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				showFilesList(type);
			}
		});
		return imageButton;
	}
	
	/**
	 * @Description: 显示投标文件或 招标文件
	 * @author guoyr
	 * @param fileType 
	 */
	private void showFilesList(String fileType) {
		if (null != curButton && !curButton.isDisposed()) {
			curButton.setSelection(false);
		}
		for (Control control : bidFileSection_composite.getChildren()) {
			if (null != control.getData("fileType") && control.getData("fileType").equals(fileType)) {
				curButton = (ImageButton) control;
				break;
			}
		}
		if (null != curButton && !curButton.isDisposed()) {
			curButton.setSelection(true);
		}
		if (TYPE_BIDDING.equals(fileType)) {
			fileStackLayout.topControl = biddingFileComposite;
			listBiddingFiles();
		} else if (TYPE_BID.equals(fileType)) {
			fileStackLayout.topControl = bidFileComposite;
			listSupplierBidFiles(curSupplier);
		}
		fileComposite.layout();
	}
	
	/**
	 * @Description: 列出招标文件列表
	 * @author guoyr 
	 */
	private void listBiddingFiles() {
		
		// 如果切换到查看招标文件时，发现当前查看投标文件，则需要切换查看招标文件面版
		if(null != viewContentMenu && viewContentMenu.equals(LeftMenuEnum.BID_FILE_ONLY)) {
			showBiddingFileOnlyAction();
			return;
		}
		biddingFileGrid.removeAll();
		List<BiddingFile> biddingFileList = BiddingFile.getBiddingFileList(curTender);
		if (null != biddingFileList && biddingFileList.size() > 0) {
			int fileCount = 1;
			for (BiddingFile biddingFile : biddingFileList) {
				GridItem gridItem = new GridItem(biddingFileGrid, SWT.NONE);
				gridItem.setText((fileCount++) + "、" + biddingFile.getSimpleName());
				gridItem.setData("biddingFile", biddingFile);
				gridItem.setData("fileName", biddingFile.getName());
			}
		}
		biddingFileComposite.layout();
	}
	
	/**
	 * @Description: 列出供应商的投标分册
	 * @author guoyr
	 * @param supplier
	 */
	private void listSupplierBidFiles(final Supplier supplier) {
		// 如果切换到查看投标文件时，发现当前查看招标文件，则需要切换查看投标文件面版
		if(null != viewContentMenu && viewContentMenu.equals(LeftMenuEnum.BIDDING_FILE_ONLY)) {
			showBidFileOnlyAction();
			return;
		}
		
		bidFileGrid.removeAll();
		if (null == supplier) {
			return;
		}
		final boolean isSealedBidEvaluation = curStep.getEvaluationParamByKey(com.gx.obe.components.core.enumeration.EvaluationStepEnum.PARAM_SEALED_BID, Boolean.class);
//		if(isSealedBidEvaluation){
//			Integer PARAM_SEALED_BID_FILE_ROLE = curStep.getEvaluationParamByKey(EvaluationStepEnum.PARAM_SEALED_BID_FILE_ROLE);
//			if(null != PARAM_SEALED_BID_FILE_ROLE && PARAM_SEALED_BID_FILE_ROLE > 0){
//				evalBidFileType = PARAM_SEALED_BID_FILE_ROLE;
//			}
//		}
		
		bidFileList = BidFile.getBidFileExamineList(curTender.getId(), supplier.getId(), curExpert.getEvalBidTypeNotNull());
		CollectionUtils.filter(bidFileList, t -> {
			if (!viewBidPrice && null != t.getFileType() && t.getFileType().startsWith(BidFile.TYPE_BIDPRICE)) return false;
			if (isSealedBidEvaluation ^ t.isNotPublicBid()) return false;
			return true;
		});
		
		if (null != bidFileList && bidFileList.size() > 0) {
			int fileCount = 1;
			for (BidFile bidFile : bidFileList) {
				GridItem gridItem = new GridItem(bidFileGrid, SWT.NONE);
				gridItem.setText((fileCount++) + "、" + bidFile.getSimpleName());
				gridItem.setData("bidFile", bidFile);
				gridItem.setData("fileName", bidFile.getName());
			}
		}
		bidFileComposite.layout();
	}
	
	/**
	 * @Description: 初始化界面数据
	 * @author guoyr
	 */
	private void init() {
		menuFunctionUtils.initFunctionAuthority(menu);
	    
	    initLayoutPanelGroup();
	    initFilePanelGroup();
	    initOpinionGroup();
	    initCreditGroup();
	    initClarifyAnswerGroup();
		supplierNameTitle.setText(MessageFormat.format(Messages.Title_currentSupplier, com.gx.obe.components.core.I18N.getString(I18NEnum.SUPPLIERNAME, curTender.getTenderType())) + "：");
		useSpecialPdf = PropertiesUtils.getProperty(ConfigConstants.USE_SPECIAL_PDF, "00").equals("01");
		//缓存5家供应商的标书文件
		bidFileCacheCount =  ObjectUtils.getIntValue(PropertiesUtils.getProperty(ConfigConstants.BIDFILE_CACHE_COUNT, "3"), 3);
		// 每家缓存2份文件
		fileCacheCount = ObjectUtils.getIntValue(PropertiesUtils.getProperty(ConfigConstants.FILE_CACHE_COUNT, "2"), 2);
		showOnloadFileTips =  "01".equals(PropertiesUtils.getProperty(ConfigConstants.SHOW_ONLOAD_FILE_TIPS, "01"));
		if (curStep.getStepType().equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.COMPLIANCE)) {
			init_default_btn.setText(Messages.Button_quickEvaluation);
			init_default_btn.setToolTipText(MessageFormat.format(Messages.Tips_quickEvaluation, EvaluationFactorEnum.getEvalPassTypeCN(EvaluationFactorEnum.CONFORM)));
		} else {
			init_default_btn.setText(Messages.Button_quickEvaluationScore);
			init_default_btn.setToolTipText(Messages.Tips_quickEvaluationScore);
		}
		
		evaluationSupplierFactorListener = new EvaluationSupplierFactorListener() {
			public void clickSupplierFactor(Supplier supplier, EvaluationFactor evaluationFactor, ExpertEvaluationResult expertEvaluationResult) {
				selectSupplierAndFactorAction(supplier, evaluationFactor, expertEvaluationResult);
			}
			
			public void configLoadFileCacheCount() {
				InputDialog dialog = new InputDialog(getShell(), Messages.Tips_bidFileLoadCache, bidFileCacheCount + "");
				dialog.open();
				
				int cacheCount = Integer.parseInt(dialog.getInputValue());
				if (cacheCount == bidFileCacheCount && cacheCount <= 0) return;
				
				// 当设置的缓存数量少于当前缓存数量,则重新加载
				if (null != curSupplier && cacheCount < bidFileCacheCount) {
					for (CTabItem item : bid_file_tabfolder.getItems()) {
						Control control = item.getControl();
						if (null != control && !control.isDisposed()) {
							control.dispose();
						}
						item.dispose();
					}
					// 如果未能通过评审点定位文件，则直接定位供应商的文件
					if (!locationBidFileByFactorPointAction()) {
						loacationBidFileByDocumtntAction();
					}
				}
				
				bidFileCacheCount = cacheCount;
				PropertiesUtils.saveProperty(ConfigConstants.BIDFILE_CACHE_COUNT, cacheCount + "");
			}
			
			public void releaseResource(Supplier supplier) {
				for (CTabItem item : bid_file_tabfolder.getItems()) {
					Control control = item.getControl();
					if (null != control && !control.isDisposed()) {
						control.dispose();
					}
					item.dispose();
				}
			}
			
			public void openLocalFile(TenderProjectEntity tenderProject, Supplier supplier) {
				if (null != tenderProject && null != supplier) {
					BidFileLocalBorwseDialog dialog = new BidFileLocalBorwseDialog(getShell(), tenderProject,curSupplier, bidFileList, menuFunctionUtils);
					dialog.setTitle(supplier.getSupplierName());
					dialog.open();
				}
			}
		};
		
//		if(CommonEnum.NO.equals(curRule.getViewPriceScore()) && CommonEnum.NO.equals(curRule.getViewBidPrice())){
//			bidPrice.setVisible(false);
//			((GridData)inquireEnvelop.getLayoutData()).exclude = true;
//		}
		
		
		boolean sealedBid = curStep.getEvaluationParamByKey(com.gx.obe.components.core.enumeration.EvaluationStepEnum.PARAM_SEALED_BID, Boolean.class);
		if(sealedBid){
			WidgetUtils.setControlVisible(inquireEnvelop, false);
			WidgetUtils.setControlVisible(answerQuestionBtn, false);
		}
		
		// 是否允午导入其他专家的评标结果
		boolean importExpertResult = curStep.getEvaluationParamByKey(com.gx.obe.components.core.enumeration.EvaluationStepEnum.PARAM_IMPORT_OTHERE_EXPERT_RESULT, Boolean.class);
		WidgetUtils.setControlVisible(import_other_expert_result_btn, importExpertResult);
		// 是否允午导入历史评标结果
		boolean importHistoryResult = curStep.getEvaluationParamByKey(com.gx.obe.components.core.enumeration.EvaluationStepEnum.PARAM_IMPORT_HISTORY_RESULT, Boolean.class);
		WidgetUtils.setControlVisible(import_history_result_btn, importHistoryResult);
		
		// 投标文件目录
		File bidFileDir = new File(FileConstants.getBidFilePath(curTender.getId()));
		if (null != bidFileDir && FileUtils.getDirectorySize(bidFileDir) > 0) {
			// 检查是否存在可显示的标书
			List<File> fileList = FileUtils.getListFiles(bidFileDir.getAbsolutePath(), "doc,docx,pdf,xlsx");
			if (null != fileList && fileList.size() > 0) {
				hasBidFile = true;
			}
		}
		
		// 默认只显示投标文件
		opinionStackLayout.topControl = viewContentComposite;
		showBidFileOnlyAction();
		
		// 如果存在标书文件，则显示标书和评审面板
		if (hasBidFile) {
			fileAndEvalPanelBothAction(evalPanlGoientation);
		} else {
			evaluationPanelOnlyAction();
		}
		isShowBidFileOpinion = PropertiesUtils.getProperty(ConfigConstants.DEFAULT_SHOW_BID_FILE_OPINION, "00").equals("01");
	    if(MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority(MenuFunctionEnum.VIEW_BID_FILE_OPINION))){
	    	isShowBidFileOpinion = false;
		}
		if (curStep.getStepType().equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.COMPLIANCE)) {
			evaluationTable = new ComplianceEvaluationTableComposite(evaluation_talbe_composite, SWT.NONE);
		} else {
			if (null != curStep.getSummaryType() && curStep.getSummaryType().equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.SUMMARY_SCORE_BY_QUALIFIED)) {
				evaluationTable = new ComplianceEvaluationTableComposite(evaluation_talbe_composite, SWT.NONE);
			} else {
				evaluationTable = new ScoreEvaluationTableComposite(evaluation_talbe_composite, SWT.NONE);
			}
		}
		// 刷新评标界面
		refreshAction();
	}
	
	/**
	 * @Description: 评审面板布局
	 * @author guoyr 
	 */
	private void initLayoutPanelGroup() {
		
		 if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("EVALUATION_VIEW_SHOWFILEONLY"))){
			 evalPanelLayoutGroupButton.addMenuItem(LeftMenuEnum.SHOW_FILE_ONLY, new LeftMenuMouseAdapter(true, true) {
				 public void mouseUp(MouseEvent e) {
					 filePanelOnlyAction();
				 }
			 });
		 }
		 if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("EVALUATION_VIEW_SHOWFILEPANELBOTHVER"))){
			 evalPanelLayoutGroupButton.addMenuItem(LeftMenuEnum.FILE_EVAL_VER, new LeftMenuMouseAdapter(true, true) {
				 public void mouseUp(MouseEvent e) {
					 fileAndEvalPanelBothAction(SWT.VERTICAL);
				 }
			 });
			 
		 }
		 if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("EVALUATION_VIEW_SHOWFILEPANELBOTHHOR"))){
			 evalPanelLayoutGroupButton.addMenuItem(LeftMenuEnum.FILE_EVAL_HOR, new LeftMenuMouseAdapter(true, true) {
				 public void mouseUp(MouseEvent e) {
					 fileAndEvalPanelBothAction(SWT.HORIZONTAL);
				 }
			 });
		 }
		 if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("EVALUATION_VIEW_SHOWBIDDINGFILE"))){
			 evalPanelLayoutGroupButton.addMenuItem(LeftMenuEnum.SHOW_EVALUATION_ONLY, new LeftMenuMouseAdapter(true, true) {
				 public void mouseUp(MouseEvent e) {
					 evaluationPanelOnlyAction();
				 }
			 });
		 }
	}
	
	/**
	 * @Description: 文件布局
	 * @author guoyr 
	 */
	private void initFilePanelGroup() {
		if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("BID_FILE_ONLY"))){
			viewContentGroupButton.addMenuItem(LeftMenuEnum.BID_FILE_ONLY, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
					showBidFileOnlyAction();
				}
			});
		}
		if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("BIDDING_FID_FILE_HOR"))){
			viewContentGroupButton.addMenuItem(LeftMenuEnum.BIDDING_BID_FILE_BOTH_HOR, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
					showBiddingFileAndBidFileBothAction(SWT.HORIZONTAL);
				}
			});
		}
		if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("BIDDING_FID_FILE_VER"))){
			viewContentGroupButton.addMenuItem(LeftMenuEnum.BIDDING_BID_FILE_BOTH_VER, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
					showBiddingFileAndBidFileBothAction(SWT.VERTICAL);
				}
			});
		}
		if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("BIDDING_FILE_ONLY"))){
			viewContentGroupButton.addMenuItem(LeftMenuEnum.BIDDING_FILE_ONLY, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
					showBiddingFileOnlyAction();
				}
			});
		}
	}
	
	/**
	 * @Description: 在显示全屏打分之后再次查看标书时需要重新加载当前供应商标书（因为全屏打分时，切换供应商或指标是不会加载标书文件）
	 * @author guoyr 
	 */
	private void reLoadSupplierBidFileAfterFullEvaluation() {
		if(evaluationPanelOnly) {
			viewContentGroupButton.setEnabled(true);
			evaluationPanelOnly = false;
			clearOpinionPanel();
			if(null != viewContentMenu) {
				if(viewContentMenu.equals(LeftMenuEnum.VIEW_BID_FILE_OPINION)) {
					isShowBidFileOpinion = true;
				}else if(viewContentMenu.equals(LeftMenuEnum.VIEW_FACTOR_EVAL_OPINION)) {
					isShowFactorEvalOpinion = true;
				}
			}
			//如果当前正在查看征信，则从全屏切换回来是自动加载评审意见
			if(isShowBidFileOpinion || isShowFactorEvalOpinion) {
				opinionStackLayout.topControl = opinionLoadComposite;
				opinionComposite.layout();
				selectSupplierAndFactorAction(curSupplier, curEvaluationFactor, curExpertEvaluationResult);
			}else {
				opinionStackLayout.topControl = viewContentComposite;
				opinionComposite.layout();
				// 当从全打分界面切换为文件界面时，需要重新加载当前供应商的标书
				Supplier refreshSupplier = curSupplier;
				curSupplier = null;
				selectSupplierAndFactorAction(refreshSupplier, curEvaluationFactor, curExpertEvaluationResult);
			}
		}
	}
	
	/**
	 * @Description: 在显示评审意见之后再次查看标书时需要重新加载当前供应商标书（因为加载意见时，切换供应商或指标是不会加载标书文件）
	 * @author guoyr 
	 */
	private void reLoadSupplierBidFileAfterShowOpinion() {
		if(isShowBidFileOpinion || isShowFactorEvalOpinion || isShowCredit) {
			clearOpinionPanel();
			// 当从非文件界面切换为文件界面时，需要重新加载当前供应商的标书
			Supplier refreshSupplier = curSupplier;
			curSupplier = null;
			selectSupplierAndFactorAction(refreshSupplier, curEvaluationFactor, curExpertEvaluationResult);
			opinionStackLayout.topControl = viewContentComposite;
			opinionComposite.layout();
		}
		evaluationPanelOnly = false;
	}
	
	/**
	 * @Description: 清理评审意见面板
	 * @author guoyr 
	 */
	private void clearOpinionPanel() {
		isShowBidFileOpinion = false;
		isShowFactorEvalOpinion = false;
		isShowCredit = false;
		for(Control control : opinionLoadComposite.getChildren()) {
    		control.dispose();
    	}
	}
	
	/**
	 * @Description: 意见
	 * @author guoyr 
	 */
	private void initOpinionGroup() {
		int count = 0;
		if(MenuFunction.SHOW.equals(menuFunctionUtils.getAuthority(MenuFunctionEnum.VIEW_BID_FILE_OPINION))){
			opinionGroupButton.addMenuItem(LeftMenuEnum.VIEW_BID_FILE_OPINION, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
	                showBidFileOpinionAction();
				}
			});
			count ++;
		}
		if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("FACTOR_OPINION"))){
			opinionGroupButton.addMenuItem(LeftMenuEnum.VIEW_FACTOR_EVAL_OPINION, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
					showFactorEvalOpinionAction();
				}
			});
			count ++;
		}
		WidgetUtils.setControlVisible(opinionGroupButton, count > 0);
	}
	
	/**
	 * @Description: 征信列表
	 * @author guoyr 
	 */
	private void initCreditGroup() {
		int count = 0;
		if(MenuFunction.SHOW.equals(menuFunctionUtils.getAuthority(MenuFunctionEnum.VIEW_CREDIT_TYC))){
			creditGroupButton.setCurMenu(LeftMenuEnum.VIEW_CREDIT_TYC);
			creditGroupButton.addMenuItem(LeftMenuEnum.VIEW_CREDIT_TYC, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
					showCreditTYCAction();
				}
			});
			count ++;
		}
		if(MenuFunction.SHOW.equals(menuFunctionUtils.getAuthority(MenuFunctionEnum.VIEW_CREDIT_ZSZH))){
			creditGroupButton.setCurMenu(LeftMenuEnum.VIEW_CREDIT_ZSZH);
			creditGroupButton.addMenuItem(LeftMenuEnum.VIEW_CREDIT_ZSZH, new LeftMenuMouseAdapter(true, true) {
				public void mouseUp(MouseEvent e) {
					showCreditZSZHAction();
				}
			});
			count ++;
		}
		WidgetUtils.setControlVisible(creditGroupButton, count > 0);
		if(count == 0) {
			WidgetUtils.setControlVisible(viewCredit_link, false);
		}
	}
	
	/**
	 * @Description: 查看供应商征信
	 * @author guoyr 
	 */
	private void viewCreditAction() {
		final EMenu gmenu = new EMenu(getShell());
		gmenu.setAutoClickOnlyOneItem(true);
		if(MenuFunction.SHOW.equals(menuFunctionUtils.getAuthority(MenuFunctionEnum.VIEW_CREDIT_TYC))){
			gmenu.addMenuItem("天眼查", ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/view.png"), true, new EMenu.ClickListener() {
				public void click() {
					// TODO这里弹出查看供应商个人的征信（弹出窗口位于显示标书区域）
					MessageDialog.openInformation(getShell(), "天眼查正在开发中...");
				}
			});
		}
//		if(MenuFunction.SHOW.equals(menuFunctionUtils.getAuthority(MenuFunctionEnum.VIEW_CREDIT_ZSZH))){
			gmenu.addMenuItem("中数智汇", ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID,"icons/btn/blue/view.png"), true, new EMenu.ClickListener() {
				public void click() {
					BidDataAction.action(getShell(),curSupplier.getOrgId(), "北京百度网讯科技有限公司");
				}
			});
		//}
		gmenu.open(viewCredit_link);
	}
	
	/**
	 * @Description: 澄清答疑
	 * @author guoyr 
	 */
	private void initClarifyAnswerGroup() {
		int count = 0;
		if(!MenuFunction.SHOW.equals(menuFunctionUtils.getAuthority("CLARIFY_ANSWER_CONTENT"))){
			clarificationAnswerGroupButton.setCurMenu(LeftMenuEnum.CLARIFY_ANSWER_CONTENT);
			clarificationAnswerGroupButton.addMenuItem(LeftMenuEnum.CLARIFY_ANSWER_CONTENT, new LeftMenuMouseAdapter(false, true) {
				public void mouseUp(MouseEvent e) {
					clarificationAnswerGroupButton.setCurMenu(LeftMenuEnum.CLARIFY_ANSWER_CONTENT);
					viewInquireEnvelopAction();
				}
			});
			count ++;
		}
		if(!MenuFunction.HIDE.equals(menuFunctionUtils.getAuthority("CLARIFY_ANSWER_DOCUMENTS"))){
			clarificationAnswerGroupButton.setCurMenu(LeftMenuEnum.CLARIFY_ANSWER_DOCUMENTS);
			clarificationAnswerGroupButton.addMenuItem(LeftMenuEnum.CLARIFY_ANSWER_DOCUMENTS, new LeftMenuMouseAdapter(false, true) {
				public void mouseUp(MouseEvent e) {
					clarificationAnswerGroupButton.setCurMenu(LeftMenuEnum.CLARIFY_ANSWER_DOCUMENTS);
					importAnswerQuestionAction();
				}
			});
			count ++;
		}
		WidgetUtils.setControlVisible(clarificationAnswerGroupButton, count > 0);
	}
	
	
	/**
     * @Description: 显示标书清标（评议）意见
     * @author guoyr 
     */
    private void showBidFileOpinionAction() {
    	if(!opinionGroupButton.getEnabled()) {
			return;
		}
    	initRadioGroupButton(opinionGroupButton);
    	isShowFactorEvalOpinion = false;
    	isShowBidFileOpinion = true;
//    	PropertiesUtils.saveProperty(ConfigConstants.IS_SHOW_BID_FILE_OPINION, isShowBidFileOpinion ? "01" : "00");
		viewContentMenu = LeftMenuEnum.VIEW_BID_FILE_OPINION;
		opinionGroupButton.setCurMenu(viewContentMenu);
		
		if(evaluationPanelOnly) {
			BidFileOpinionDialog dialog = new BidFileOpinionDialog(getShell(), curTender, curStep, supplierList, allEvaluationFactorList, curEvaluationFactor, true, false);
			dialog.open();
    		return;
    	}
		
        if(null == allEvaluationFactorList){
            allEvaluationFactorList = evaluationFactorService.getEvaluationStepFactorTreeList(curTender.getId(), curStep);
        }
        if(null == compareEvaluationTableComposite || compareEvaluationTableComposite.isDisposed()) {
        	for(Control control : opinionLoadComposite.getChildren()) {
        		control.dispose();
        	}
        	compareEvaluationTableComposite = new CompareEvaluationTableComposite(opinionLoadComposite, SWT.NONE, true, false);
        	opinionLoadComposite.layout();
        }
        compareEvaluationTableComposite.refresh(curTender, supplierList, allEvaluationFactorList, curEvaluationFactor);
        opinionStackLayout.topControl = opinionLoadComposite;
        opinionComposite.layout();
    }
    /**
     * @Description: 显示指标评审意见
     * @author guoyr 
     */
    private void showFactorEvalOpinionAction() {
    	if(!opinionGroupButton.getEnabled()) {
			return;
		}
    	initRadioGroupButton(opinionGroupButton);
    	
    	isShowBidFileOpinion = false;
    	isShowFactorEvalOpinion = true;
    	viewContentMenu = LeftMenuEnum.VIEW_FACTOR_EVAL_OPINION;
    	opinionGroupButton.setCurMenu(viewContentMenu);
    	
    	if(evaluationPanelOnly) {
    		FactorOpinionDialog dialog = new FactorOpinionDialog(getShell(), curTender, curStep, curUser, supplierList, allEvaluationFactorList, curEvaluationFactor);
			dialog.open();
    		return;
    	}
    	
    	if(null == allEvaluationFactorList){
    		allEvaluationFactorList = evaluationFactorService.getEvaluationStepFactorTreeList(curTender.getId(), curStep);
    	}
    	if(null == factorEvaluationOpinionComposite || factorEvaluationOpinionComposite.isDisposed()) {
        	for(Control control : opinionLoadComposite.getChildren()) {
        		control.dispose();
        	}
        	factorEvaluationOpinionComposite = new FactorEvaluationOpinionComposite(opinionLoadComposite, SWT.NONE);
        	opinionLoadComposite.layout();
        }
    	factorEvaluationOpinionComposite.refresh(curTender, curStep, curExpert.getUser().getId(), supplierList, allEvaluationFactorList, curEvaluationFactor);
    	opinionStackLayout.topControl = opinionLoadComposite;
    	opinionComposite.layout();
    }
	
    
    /**
     * @Description: 天眼查征信
     * @author guoyr 
     */
    private void showCreditTYCAction() {
    	initRadioGroupButton(creditGroupButton);
    	creditGroupButton.setCurMenu(LeftMenuEnum.VIEW_CREDIT_TYC);
    	viewContentMenu = LeftMenuEnum.VIEW_CREDIT_TYC;
    	creditGroupButton.setCurMenu(viewContentMenu);
		isShowCredit = true;
		if(evaluationPanelOnly) {
			// TODO单独打开征信风险窗口
//			BidFileOpinionDialog dialog = new BidFileOpinionDialog(getShell(), curTender, curStep, supplierList, allEvaluationFactorList, curEvaluationFactor, true, false);
//			dialog.open();
    		return;
    	}
		for(Control control : opinionLoadComposite.getChildren()) {
			control.dispose();
		}
		// TODO这里加载天眼查征信风险界面
        opinionStackLayout.topControl = opinionLoadComposite;
        opinionComposite.layout();
        
    }
    	
    /**
     * @Description: 中数智汇征信
     * @author guoyr 
     */
    private void showCreditZSZHAction() {
    	initRadioGroupButton(creditGroupButton);
    	creditGroupButton.setCurMenu(LeftMenuEnum.VIEW_CREDIT_ZSZH);
    	viewContentMenu = LeftMenuEnum.VIEW_CREDIT_ZSZH;
    	creditGroupButton.setCurMenu(viewContentMenu);
		isShowCredit = true;
		if(evaluationPanelOnly) {
			SupplierInfoDialogAction.action(getShell(), supplierDTOList);
    		return;
    	}
		for(Control control : opinionLoadComposite.getChildren()) {
			control.dispose();
		}
		SupplierInfoAction.action(opinionLoadComposite, supplierDTOList);
        opinionStackLayout.topControl = opinionLoadComposite;
        opinionComposite.layout();
    }
    
	/**
	 * @Description: 选中投标人或指标
	 * @author guoyr
	 * @param supplier
	 * @param evaluationFactor
	 */
	private void selectSupplierAndFactorAction(Supplier supplier, EvaluationFactor evaluationFactor, ExpertEvaluationResult expertEvaluationResult) {
        curEvaluationFactor = evaluationFactor;
        // 如果不是在比选界面
        if (null != supplier) {
            if (null == curSupplier || (null != curSupplier && !curSupplier.getId().equals(supplier.getId()))) {
            	// 显示供应商的投标文件
            	listSupplierBidFiles(supplier);
//                    listBiddingFiles();
            	fileStackLayout.topControl = bidFileComposite;
            	fileComposite.layout();
            }
            
            curSupplier = supplier;
            curExpertEvaluationResult = expertEvaluationResult;
            
            supplier_name.setText(supplier.getSupplierName());
            
            // 在只显示评标面板时不加载文件
            if (evaluationPanelOnly) return;
            // 显示清标意见时不加载文件
            if (isShowBidFileOpinion) {
            	showBidFileOpinionAction();
            	return ;
            }
            if (isShowFactorEvalOpinion) {
            	showFactorEvalOpinionAction();
            	return ;
            }
            if (isShowCredit) {
            	return;
            }
            fileAndEvalPanelBothAction(evalPanlGoientation);
            // 显示当前指标的评审点
            listFactorEvaluationPoints(supplier, evaluationFactor);
            
            // 如果未能通过评审点定位文件，则直接定位供应商的文件
            if (!locationBidFileByFactorPointAction()) {
                loacationBidFileByDocumtntAction();
            }
            
            if (bidFileGrid.getSelectionCount() > 0) {
                // 如果显示所有评审点的界面，则刷新所有评审点
                if (null != showEvalPointShell && !showEvalPointShell.isDisposed()) {
                    // 根据投标人加载投标分册和评审点
                    if (!ObjectUtils.getObjString(showEvalPointShell.getData("supplierId")).equals(supplier.getId())) {
                        showEvalPointShell.refreshEvalPointGrid(curTender.getId(), supplier.getId());
                        showEvalPointShell.setData("supplierId", supplier.getId());
                    }
                }
            }
        }
        
        if (null != locationBidFileListenerMap && locationBidFileListenerMap.size() > 0) {
            for (String supplierId : locationBidFileListenerMap.keySet()) {
                if (supplier.getId().equals(supplierId)) continue;//过滤当前供应商，
                LocationBidFileListener locationBidFileListener = locationBidFileListenerMap.get(supplierId);
                if (null != locationBidFileListener) {
                    locationBidFileListener.selectSupplierAndFactorAction(evaluationFactor);
                }
            }
        }
    }
	
	/**
	 * @Description: 列出当前指标的评审点
	 * @author guoyr
	 * @param supplier
	 * @param evaluationFactor
	 */
	private void listFactorEvaluationPoints(final Supplier supplier, EvaluationFactor evaluationFactor) {
		evaluationPointGrid.removeAll();
		
		String evalPointFilePath = FileConstants.getBidFilePath(curTender.getId(), supplier.getId()).concat(FileConstants.PSD_XML);
		String evaluationFactorCode = null == evaluationFactor ? null : evaluationFactor.getFactorCode();
		List<EvaluationPoint> evaluationPointList = BidFile.getBidFileEvaluationPointList(evalPointFilePath, evaluationFactorCode);
		int evalPointCount = 1;
		for (EvaluationPoint evaluationPoint : evaluationPointList) {
			final BidFile bidFile = evaluationPoint.getBidFile();
			if (null == bidFile) {
				continue;
			}
			if (null == CollectionUtils.get(bidFileList, t -> t.getAbsolutePath().equals(bidFile.getAbsolutePath()))) {
				continue;
			}
			GridItem gridItem = new GridItem(evaluationPointGrid, SWT.NONE);
			gridItem.setText((evalPointCount++) + "、" + evaluationPoint.getName());
			gridItem.setData("evaluationPoint", evaluationPoint);
		}
	}
	
	/**
	 * @Description: 返回
	 * @author guoyr
	 */
	private void goBackAction() {
		evaluationTable.closeCellEditor();
		if (null != expertEvaluationListener) {
			expertEvaluationListener.complete();
		}
	}
	
	/**
	 * @Description: 刷新项目信息
	 * @author guoyr
	 */
	private void refreshAction() {
		getNoComplateFilterStep();
		viewBidPrice = false;
		// 根据规则设置的查看价格相权限
		if ((curExpert.getEvalBidTypeNotNull() & ExpertEnum.EXPERT_PRICE) != 0) {
			viewBidPrice = true;
		} else if (ObjectUtils.equals(curRule.getViewBidPrice(), CommonEnum.YES)) {
			// 如果允许查看报价，则强制为当前专家设置为经济标专家的权限（了为查看报价文件）
			viewBidPrice = true;
			curExpert.setEvalBidType(curExpert.getEvalBidTypeNotNull() | ExpertEnum.EXPERT_PRICE);
		}
		supplierList = supplierService.getEvaluationStepSupplierList(curTender.getId(), curStep);
		if(null != supplierList && supplierList.size() > 0) {
			for(Supplier supplier : supplierList) {
				supplierNameMap.put(supplier.getId(), supplier.getSupplierName());
			}
		}
		supplierDTOList = supplierList.stream().map(t -> new SupplierDTO(t.getOrgId(), t.getSupplierName())).collect(Collectors.toList());
		evaluationTable.refresh(curTender, curRule, curExpert.getUser(), curStep, supplierList, evaluationSupplierFactorListener);
	}
	
	
	/**
	 * @Description: 显示投标文件
	 * @author guoyr
	 */
	private void showBidFileOnlyAction() {
		reLoadSupplierBidFileAfterShowOpinion();
		if(!viewContentGroupButton.getEnabled()) return;
		initRadioGroupButton(viewContentGroupButton);
		if(null != viewContentMenu && viewContentMenu.equals(LeftMenuEnum.BID_FILE_ONLY)) {
			return;
		}
		bid_bidding_sashform.setMaximizedControl(bid_file_tabfolder);
		if (null != supplierCurDocumentLoader) {
			supplierCurDocumentLoader.activate();
		}
		viewContentMenu = LeftMenuEnum.BID_FILE_ONLY;
		viewContentGroupButton.setCurMenu(viewContentMenu);
		if (evaluationPanelOnly) {
			evaluationPanelOnly = false;
			if (evalPanlGoientation == SWT.VERTICAL) {
				evaluationPanelLayoutMenu = LeftMenuEnum.FILE_EVAL_VER;
			} else {
				evaluationPanelLayoutMenu = LeftMenuEnum.FILE_EVAL_HOR;
			}
			evalPanelLayoutGroupButton.setCurMenu(evaluationPanelLayoutMenu);
			bid_file_evaluation_panel_sashform.setOrientation(evalPanlGoientation);
			bid_file_evaluation_panel_sashform.setMaximizedControl(null);
		}
		showFilesList(TYPE_BID);
	}
	
	/**
	 * @Description: 招标文件和投标文件一起显示
	 * @author guoyr
	 * @param goientation
	 */
	private void showBiddingFileAndBidFileBothAction(int goientation) {
		reLoadSupplierBidFileAfterShowOpinion();
		if(!viewContentGroupButton.getEnabled())return;
		initRadioGroupButton(viewContentGroupButton);
		if (goientation == SWT.VERTICAL) {
			viewContentMenu = LeftMenuEnum.BIDDING_BID_FILE_BOTH_VER;
		} else {
			viewContentMenu = LeftMenuEnum.BIDDING_BID_FILE_BOTH_HOR;
		}
		bid_bidding_sashform.setOrientation(goientation);
		bid_bidding_sashform.setMaximizedControl(null);
		loacationBiddingFileByDocumtntAction();
		if (null != supplierCurDocumentLoader) {
			supplierCurDocumentLoader.activate();
		}
		viewContentGroupButton.setCurMenu(viewContentMenu);
		
	}
	
	/**
	 * @Description: 只显示招标文件
	 * @author guoyr
	 */
	private void showBiddingFileOnlyAction() {
		reLoadSupplierBidFileAfterShowOpinion();
		if(!viewContentGroupButton.getEnabled()) return;
		initRadioGroupButton(viewContentGroupButton);
		if(null != viewContentMenu && viewContentMenu.equals(LeftMenuEnum.BIDDING_FILE_ONLY)) {
			return;
		}
		viewContentMenu = LeftMenuEnum.BIDDING_FILE_ONLY;
		bid_bidding_sashform.setMaximizedControl(bidding_composite);
		showFilesList(TYPE_BIDDING);
		loacationBiddingFileByDocumtntAction();
		if (null != supplierCurDocumentLoader) {
			supplierCurDocumentLoader.activate();
		}
		viewContentGroupButton.setCurMenu(viewContentMenu);
		evaluationPanelOnly = false;
	}
	
	private void initRadioGroupButton(EvalLeftGroupButton groupButton) {
		if(null != radioGroupButton && !radioGroupButton.isDisposed()) {
			radioGroupButton.setSelection(false);
		}
		radioGroupButton = groupButton;
		radioGroupButton.setSelection(true);
		isShowBidFileOpinion = false;
    	isShowFactorEvalOpinion = false;
    	isShowCredit = false;
	}
	
	/**
	 * @Description: 只查看文件面版
	 * @author guoyr
	 */
	private void filePanelOnlyAction() {
		reLoadSupplierBidFileAfterFullEvaluation();
		evaluationPanelLayoutMenu = LeftMenuEnum.SHOW_FILE_ONLY;
		bid_file_evaluation_panel_sashform.setMaximizedControl(opinionComposite);
		evalPanelLayoutGroupButton.setCurMenu(evaluationPanelLayoutMenu);
	}
	
	/**
	 * @Description: 投标文件和打分两者一起
	 * @author guoyr
	 */
	private void fileAndEvalPanelBothAction(int goientation) {
		reLoadSupplierBidFileAfterFullEvaluation();
		evalPanlGoientation = goientation;
		if (goientation == SWT.VERTICAL) {
			evaluationPanelLayoutMenu = LeftMenuEnum.FILE_EVAL_VER;
		} else {
			evaluationPanelLayoutMenu = LeftMenuEnum.FILE_EVAL_HOR;
		}
		evalPanelLayoutGroupButton.setCurMenu(evaluationPanelLayoutMenu);
		bid_file_evaluation_panel_sashform.setOrientation(goientation);
		bid_file_evaluation_panel_sashform.setMaximizedControl(null);
		if (null != evaluationTable) {
			evaluationTable.resizeColumn(110);
		}
	}
	
	
	/**
	 * @Description: 只打分
	 * @author guoyr
	 */
	private void evaluationPanelOnlyAction() {
		clearOpinionPanel();
		viewContentGroupButton.setEnabled(false);
		opinionGroupButton.setSelection(false);
		evaluationPanelLayoutMenu = LeftMenuEnum.SHOW_EVALUATION_ONLY;
		bid_file_evaluation_panel_sashform.setMaximizedControl(evaluation_panel_composite);
		evalPanelLayoutGroupButton.setCurMenu(evaluationPanelLayoutMenu);
		evaluationPanelOnly = true;
		if (null != evaluationTable) {
			evaluationTable.resizeColumn(110);
		}
	}
	
	/**
	 * @Description: 设置评标表格字体大小
	 * @author guoyr
	 * @param type
	 */
	private void setTableFontSize(int type) {
		if (type < 0 && fontSize <= 9) {
			return;
		}
		if (type > 0 && fontSize >= 15) {
			return;
		}
		fontSize += type;
		evaluationTable.setTableFontSize(fontSize);
	}
	
	/**
	 * @Description: 查看投标报价
	 * @author guoyr
	 * @param supplier
	 */
//	public void viewBidPice() {
//		EAction action = (EAction) ActionUtil.getEAction(ViewBidPriceEvaluationResultAction.class.getName());
//		action.setData("evaluationStep", curStep);
//		action.setData("tenderProjectEntity", curTender);
//		action.setData(Constants.CUR_EXPERT, curExpert);
//		action.setName("查看价格");
//		action.setParent(getShell());
//		action.run();
//	}
	
	/**
     * @Description: 
     * @author chenxw 
     */
    private void viewFinalResultAction() {
        String viewOpenResult = CommonEnum.NO;
        String viewEvalResult = CommonEnum.NO;
        String expertSelfUserId = null;
        // 如果是专家组长，则全部可以查看
//        if(!ExpertEnum.LEADER_YES.equals(curExpert.getIsLeader())){
            viewOpenResult = curRule.getViewBidPrice();
            if (StringUtils.isEmpty(viewOpenResult)) {
                viewOpenResult = PropertiesUtils.getProperty(ConfigConstants.VIEW_OPEN_RESULT, CommonEnum.YES);
            }
            viewEvalResult = curRule.getViewPriceScore();
            if (StringUtils.isEmpty(viewEvalResult)) {
                viewEvalResult = PropertiesUtils.getProperty(ConfigConstants.VIEW_EVAL_RESULT, CommonEnum.YES);
            }
            expertSelfUserId = curExpert.getUserId();
//        }
        new ViewResultDialog(getShell(), curTender, viewOpenResult, viewEvalResult, expertSelfUserId).open();
    }
	
	
	/**
	 * @Description: 更多设置
	 * @author guoyr
	 */
	private void moreConfigAction() {
		if (isOpen) return;
		isOpen = true;
		final ToolsShell moreToolsShell = new ToolsShell(getShell());
		Composite toolGroup = moreToolsShell.addToolBar(Messages.Title_bidFileLoadSetting, null, false);
		
		Image pdfImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/pdf.png");
		
		moreToolsShell.addTool(toolGroup, useSpecialPdf ? Messages.Button_useUniversalControl : Messages.Button_useSpecialControl, pdfImage, true, new ToolsShell.ClickListener() {
			public void click() {
				useSpecialPdf = !useSpecialPdf;
				PropertiesUtils.saveProperty(ConfigConstants.USE_SPECIAL_PDF, useSpecialPdf ? "01" : "00");
				moreToolsShell.close();
				evaluationSupplierFactorListener.releaseResource(curSupplier);
				if (useSpecialPdf) {
					MessageDialog.openShortMessage(Messages.Tips_switchSuccessAndReLoadingFile);
				} else {
					MessageDialog.openShortMessage(Messages.Tips_switchSuccessAndReLoadingFile+"\r\n("+Messages.Tips_notDisplaySignature+")");
				}
			}
		});
		moreToolsShell.addTool(toolGroup, Messages.Button_showOrHiddenToolbar, pdfImage, !evaluationPanelOnly, new ToolsShell.ClickListener() {
			public void click() {
				showOleToolBar = !showOleToolBar;
				if (null != bidFileDocumentLoader) {
					bidFileDocumentLoader.showOrHiddenToolBar(showOleToolBar);
				}
				if (null != supplierCurDocumentLoader) {
					supplierCurDocumentLoader.showOrHiddenToolBar(showOleToolBar);
				}
			}
		});
		
		Image locationImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/location.png");
		Image clearImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/clear.png");
		Image configImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/config.png");
		
		moreToolsShell.addTool(toolGroup, Messages.Button_viewLocalFiles, locationImage, null != curSupplier, new ToolsShell.ClickListener() {
			public void click() {
				evaluationSupplierFactorListener.openLocalFile(curTender, curSupplier);
			}
		});
		moreToolsShell.addTool(toolGroup, Messages.Button_releaseBidFileCache, clearImage, true, new ToolsShell.ClickListener() {
			public void click() {
				evaluationSupplierFactorListener.releaseResource(curSupplier);
			}
		});
		moreToolsShell.addTool(toolGroup, Messages.Button_setBidFileLoadCache, configImage, true, new ToolsShell.ClickListener() {
			public void click() {
				evaluationSupplierFactorListener.configLoadFileCacheCount();
			}
		});
		
		Composite toolGroup2 = moreToolsShell.addToolBar(Messages.Title_evalViewSetting, null, false);
		Image changeImage = imageResolver.loadImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/change.png");
		
		moreToolsShell.addTool(toolGroup2, Messages.Tips_viewFullFiles, changeImage, !evaluationPanelOnly, new ToolsShell.ClickListener() {
			public void click() {
				filePanelOnlyAction();
			}
		});
		moreToolsShell.addTool(toolGroup2, Messages.Tips_viewFullEvaluationPanel, changeImage, !evaluationPanelOnly, new ToolsShell.ClickListener() {
			public void click() {
				evaluationPanelOnlyAction();
			}
		});
		moreToolsShell.addTool(toolGroup2, Messages.Tips_viewFileEvaluationVer, changeImage, !evaluationPanelOnly, new ToolsShell.ClickListener() {
			public void click() {
				fileAndEvalPanelBothAction(SWT.VERTICAL);
			}
		});
		moreToolsShell.addTool(toolGroup2, Messages.Tips_viewFileEvaluationHor, changeImage, !evaluationPanelOnly, new ToolsShell.ClickListener() {
			public void click() {
				fileAndEvalPanelBothAction(SWT.HORIZONTAL);
			}
		});
		moreToolsShell.addTool(toolGroup2, Messages.Button_hideOrShowLoactionPointPanel, changeImage, !evaluationPanelOnly, new ToolsShell.ClickListener() {
			public void click() {
				hideOrShowSupplier_btn.notifyListeners(SWT.MouseUp, null);
			}
		});
		
		moreToolsShell.setWidth(500);
		moreToolsShell.pack();
		moreToolsShell.open();
		SwtUtils.setCenter(moreToolsShell);
		moreToolsShell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				isOpen = false;
			}
		});
	}
	
	/**
	 * @Description: 澄清答疑文件
	 * @author wangxiang
	 */
	private void importAnswerQuestionAction(){
 		ImportAnswerQuestionDialog dialog = new ImportAnswerQuestionDialog(getShell(), curTender, curExpert);
		dialog.setTitle(Messages.ClarificationAnswerDocuments);
		dialog.open();
	}
	
	/**
	 * @Description: 加载保证金
	 * @author wangxiang
	 */
	private void importBidBondAction(){
		ImportBidBondDialog dialog = new ImportBidBondDialog(getShell(), curTender);
		dialog.setTitle("保证金");
		dialog.open();
	}
	
	
	/**
	 * @Description: 添加对比列表，打开对比列表窗口
	 * @author guoyr
	 */
	private void addCompareSupplierAction() {
		if (!compareFile_link.getEnabled()) {
			return;
		}
		int maxCount = ObjectUtils.getIntValue(PropertiesUtils.getProperty(ConfigConstants.COMPARE_FILE_COUNT, "3"), 3);
		if (null != compareSupplierList && compareSupplierList.size() > maxCount) {
			MessageDialog.openShortMessage(MessageFormat.format(Messages.Tips_maxComparFilesCount, maxCount));
			return;
		}
		BidFile file = null;
		if (null != bidFileGrid.getSelection() && bidFileGrid.getSelection().length > 0) {
			GridItem gridItem = bidFileGrid.getSelection()[0];
			file = (BidFile) gridItem.getData("bidFile");
		}
		
		//当前面板显示不是当前供应商文件，说明当前供应商投标文件面板没有显示,在这情况下，需要去寻找供应商的投标文件路径，默认第一个文件为比选文件
		if (null == file || !file.exists() || !file.getAbsolutePath().contains(curSupplier.getId())) {
			List<BidFile> bidFileList = BidFile.getSupplierBidFileList(curTender.getId(), curSupplier.getId(), null);
			if (CollectionUtils.isNotNull(bidFileList)) {
				for (BidFile bidFile : bidFileList) {
					if (!viewBidPrice && BidFile.TYPE_BIDPRICE.equals(bidFile.getFileType())) continue;
					if (bidFile.getName().endsWith(".xml")) continue;
					file = bidFile;
					break;
				}
			}
		}
		if (null != file && file.exists()) {
			if (null == compareBiddingFileShell || compareBiddingFileShell.isDisposed()) compareBiddingFileShell = getShellInstance();
			compareBiddingFileShell.addCompareItem(curSupplier, file, curSupplier.getId());
			compareBiddingFileShell.open();
			compareBiddingFileShell.setLocation(new ScreenUtils().getScreenWight() - compareBiddingFileShell.getSize().x, compareFile_link.toDisplay(0, 0).y + 20);
		} else {
			MessageDialog.openShortMessage(MessageFormat.format(Messages.Tips_noFoundBidFiles, curSupplier.getSupplierName()));
		}
	}
	
	/**
	 * @Description: 获取compareBiddingFileShell实例
	 * @author guoyr
	 * @return
	 */
	private ShowCompareSupplierListShell getShellInstance() {
 		return new ShowCompareSupplierListShell(getShell(), curTender, curStep, menu ,new CompareBidFileListener() {
			public void initListener(Map<String, LocationBidFileListener> mapListener) {
				locationBidFileListenerMap = mapListener;
				if (!compareFile_link.isDisposed()) {
					compareFile_link.setEnabled(false);
				}
			}
			
			public void disponsed() {
				if (!compareFile_link.isDisposed()) {
					compareFile_link.setEnabled(true);
				}
				locationBidFileListenerMap.clear();
			}
			
			public EvaluationFactor getSelectEvaluationFactor() {
				return curEvaluationFactor;
			}
		}, new CompareSupplierFileListener() {
			public void addCompareSupplier() {
				addCompareSupplierAction();
			}
			public void refreshCompareSupplierList(List<Supplier> supplierList) {
				compareSupplierList = supplierList;
				if (!compareFile_link.isDisposed()) {
					if (compareSupplierList.size() > 5) {
						compareFile_link.setEnabled(false);
					} else {
						compareFile_link.setEnabled(true);
					}
				}
			}
		});
	}
	
	/**
	 * @Description: 专家录入评标意见
	 * @author guoyr
	 */
	private void setSupplierEvaluationOpinion() {
		EvaluationOpinionDialog dialog = new EvaluationOpinionDialog(getShell(), curTender, curSupplier, curExpert.getUser(), curExpertEvaluationResult);
		dialog.open();
	}
	
	/**
	 * @Description: 查看询标函
	 * @author guoyr
	 */
	private void viewInquireEnvelopAction() {
		InquireEnvelopListDialog dialog = new InquireEnvelopListDialog(Display.getDefault().getActiveShell(), curTender, curSupplier, false);
		dialog.setOperator(SWT.MAX | SWT.CLOSE);
		dialog.setTitle(Messages.ClarificationAnswer);
		dialog.open();
	}
	
	/**
	 * @Description: 显示或关闭供应商
	 * @author guoyr
	 */
	private void hideOrShowSupplierAction() {
		if (null != hideOrShowSupplier_btn.getData("hide")) {
			((GridData) bid_file_list_composite.getLayoutData()).widthHint = 180;
			hideOrShowSupplier_btn.setData("hide", null);
			hideOrShowSupplier_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/right_arrow.png"));
		} else {
			hideOrShowSupplier_btn.setData("hide", true);
			((GridData) bid_file_list_composite.getLayoutData()).widthHint = 0;
			hideOrShowSupplier_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/left_arrow.png"));
		}
		viewContentComposite.layout();
	}
	
	/**
	 * @Description: 设置界面显示位置
	 * @author guoyr
	 */
	private void loactionEvaluationPointShell() {
		if (null != showEvalPointShell && !showEvalPointShell.isDisposed()) {
			// 设置界面位置
			showEvalPointShell.setLocation(bid_file_list_composite.toDisplay(0, 0));
			Rectangle rectangle = bid_file_list_composite.getBounds();
			// 设置界面大小
			showEvalPointShell.setSize(rectangle.width, rectangle.height);
			showEvalPointShell.open();
		}
	}
	
	/**
	 * @Description: 更多评审点
	 * @author guoyr
	 */
	private void listMoreEvalPointAction() {
		if (null == curSupplier) return;
		if (null == showEvalPointShell || showEvalPointShell.isDisposed()) {
			showEvalPointShell = new ListEvaluationItemShell(getShell(), new ListEvaluationItemShell.EvaluationPointListener() {
				public void selectEvalPoint(String supplierId, File bidFile, String bookMark, int pageNumber) {
					openAndLocationBidFile(supplierId, bidFile, bookMark, pageNumber);
				}
			});
			// 刷新评审点
			showEvalPointShell.refreshEvalPointGrid(curTender.getId(), curSupplier.getId());
		}
		loactionEvaluationPointShell();
		// 存储数据
		showEvalPointShell.setData("supplierId", curSupplier.getId());
	}
	
	/**
	 * @Description: 通过评审点定位投标文件
	 * @author guoyr
	 */
	private boolean locationBidFileByFactorPointAction() {
		if (evaluationPointGrid.getItemCount() > 0 && null != curSupplier) {
			if (evaluationPointGrid.getSelectionCount() == 0) {
				evaluationPointGrid.setSelection(0);
			}
			
			GridItem item = evaluationPointGrid.getSelection()[0];
			EvaluationPoint evaluationPoint = (EvaluationPoint) item.getData("evaluationPoint");
			if (null != evaluationPoint.getBidFile() && evaluationPoint.getBidFile().exists()) {
				openAndLocationBidFile(curSupplier.getId(), evaluationPoint.getBidFile(), evaluationPoint.getBookmark(), evaluationPoint.getPageNo());
				return true;
			} else {
				MessageDialog.openShortMessage(Messages.Tips_notFindResponsePointFile);
			}
		}
		return false;
	}
	
	/**
	 * @Description: 通过投标分册定位投标文件
	 * @author guoyr
	 */
	private void loacationBidFileByDocumtntAction() {
		if (bidFileGrid.getItemCount() > 0 && null != curSupplier) {
			if (bidFileGrid.getSelectionCount() == 0) {
				bidFileGrid.setSelection(0);
			}
			// 当前为比选操作，若用户选中投标文件，则关闭比选界面。
			GridItem item = bidFileGrid.getSelection()[0];
			BidFile bidFile = (BidFile) item.getData("bidFile");
			openAndLocationBidFile(curSupplier.getId(), bidFile, "", 0);
		} else {
			bid_file_tabfolder.setSelection(no_bid_file_item);
		}
	}
	
	/**
	 * @Description: 打开并定位投标文件
	 * @author guoyr
	 * @param ID
	 * @param bidFile
	 * @param bookmark
	 * @param pageNumber
	 * @return
	 */
	private DocumentLoader openAndLocationBidFile(String ID, File bidFile, final String bookmark, final int pageNumber) {
		if (null != locationBidFileListenerMap && locationBidFileListenerMap.size() > 0) {
			LocationBidFileListener locationBidFileListener = locationBidFileListenerMap.get(ID);//若当前标书比对界面打开了，则刷新当前标书
			if (null != locationBidFileListener) {
				locationBidFileListener.openAndLocationBidFile(bidFile, bookmark, pageNumber);
			}
		}
		CTabItem supplierTopTabItem = null;
		for (CTabItem item : bid_file_tabfolder.getItems()) {
			if (ObjectUtils.equals(ID, (String) item.getData("ID"))) {
				supplierTopTabItem = item;
				break;
			}
		}
		if (null == supplierTopTabItem) {
			supplierTopTabItem = new CTabItem(bid_file_tabfolder, SWT.NONE);
			supplierTopTabItem.setText(ID);
			supplierTopTabItem.setData("ID", ID);
			supplierTopTabItem.setData("pdfType", CaInfoUtil.getCaType(curTender.getId(), ID).getPdfType());
			Composite topFileContent = new Composite(bid_file_tabfolder, SWT.NONE);
			topFileContent.setLayout(new FillLayout(SWT.HORIZONTAL));
			supplierTopTabItem.setControl(topFileContent);
		}
		bid_file_tabfolder.setSelection(supplierTopTabItem);
		pdfType = (String) supplierTopTabItem.getData("pdfType");
		// 全部采用默认配置的PDF加载器加载
		pdfType = PropertiesUtils.getProperty(ConfigConstants.PDF_ACTIVE_TYPE, DocumentFactory.DEFAULT_PDF_TYPE);
		// 缓存5家供应商的标书文件
		if (bid_file_tabfolder.getItemCount() > bidFileCacheCount) {
			Control control = bid_file_tabfolder.getItem(0).getControl();
			if (null != control && !control.isDisposed()) {
				control.dispose();
			}
			bid_file_tabfolder.getItem(0).dispose();
		}
		DocumentLoader documentLoader = null;
		CTabItem supplierFileItem = null;
		CTabFolder supplierBidFileFolder = (CTabFolder) supplierTopTabItem.getData("supplierCTabFolder");
		if (null == supplierBidFileFolder) {
			supplierBidFileFolder = new CTabFolder((Composite) supplierTopTabItem.getControl(), SWT.FLAT);
			supplierBidFileFolder.setTabHeight(0);
			supplierTopTabItem.setData("supplierCTabFolder", supplierBidFileFolder);
		}else if(supplierBidFileFolder.getItemCount() > 0){
			for (CTabItem item : supplierBidFileFolder.getItems()) {
				if (ObjectUtils.equals(bidFile.getAbsolutePath(), (String) item.getData("filePath"))) {
					supplierFileItem = item;
					break;
				}
			}
		}
		
		
		// 如果存在分册
		if (null != bidFile && bidFile.exists() && bidFile.isFile()) {
			if (null == supplierFileItem) {
				supplierFileItem = new CTabItem(supplierBidFileFolder, SWT.NONE);
				final Composite bidFileTabItemContent = new Composite(supplierBidFileFolder, SWT.NONE);
				bidFileTabItemContent.setLayout(new FillLayout(SWT.HORIZONTAL));
				supplierFileItem.setControl(bidFileTabItemContent);
				supplierFileItem.setText(bidFile.getName());
				supplierFileItem.setData("filePath", bidFile.getAbsolutePath());
				// 每家投标人只支持缓存2个文件
				if (supplierBidFileFolder.getItemCount() > fileCacheCount) {
					CTabItem firstItem = supplierBidFileFolder.getItems()[0];
					Control control = firstItem.getControl();
					if (null != control && !control.isDisposed()) {
						control.dispose();
					}
					firstItem.dispose();
				}
				
				documentLoader = DocumentFactory.getDocumentLoader(bidFile.getAbsolutePath(), useSpecialPdf ? pdfType : null);
				documentLoader.addLoadFileListener(new LoadFileListener() {
					
					public void fileLoaded(DocumentLoader loader) {
						if (null != loader && !bidFileTabItemContent.isDisposed()) {
							loader.showOrHiddenToolBar(showOleToolBar);
							if (null != bookmark) {
								if (!loader.bookmarkLocate(bookmark)) {
									if (pageNumber > 0) {
										loader.gotoPage(pageNumber);
									}
								}
							} else {
								if (pageNumber > 0) {
									loader.gotoPage(pageNumber);
								}
							}
							loader.activate();
						}
					}
				});
				boolean isNewOpenTipsShell = false;
				if(showOnloadFileTips) {
					if(null == openFileTipsShell || openFileTipsShell.isDisposed()) {
						openFileTipsShell = new OpenFileTipsShell(getShell(), null);
						isNewOpenTipsShell = true;
					}
					if(isNewOpenTipsShell) {
						// 设置界面位置
						openFileTipsShell.setLocation(bid_file_tabfolder.toDisplay(0, 0));
						Rectangle rectangle = bid_file_tabfolder.getBounds();
						// 设置界面大小
						openFileTipsShell.setSize(rectangle.width, rectangle.height);
						openFileTipsShell.open();
					}else {
						openFileTipsShell.setVisible(true);
					}
				}
				documentLoader.openDocument(bidFileTabItemContent, true);
				if (null != openFileTipsShell && !openFileTipsShell.isDisposed()) {
					openFileTipsShell.setVisible(false);
				}
				supplierFileItem.setData("documentLoader", documentLoader);
			} else {
				documentLoader = (DocumentLoader) supplierFileItem.getData("documentLoader");
				((Composite) supplierFileItem.getControl()).redraw();
				supplierFileItem.getParent().layout();
				if (null != documentLoader) {
					if (null != bookmark) {
						if (!documentLoader.bookmarkLocate(bookmark)) {
							if (pageNumber > 0) {
								documentLoader.gotoPage(pageNumber);
							}
						}
					} else {
						if (pageNumber > 0) {
							documentLoader.gotoPage(pageNumber);
						}
					}
					documentLoader.activate();
					
				}
			}
			supplierBidFileFolder.setSelection(supplierFileItem);
			supplierBidFileFolder.getParent().layout();
			for (GridItem item : bidFileGrid.getItems()) {
				if (ObjectUtils.equals((String) item.getData("fileName"), bidFile.getName())) {
					bidFileGrid.setSelection(new GridItem[] { item });
					break;
				}
			}
		}
		
		supplierCurDocumentLoader = documentLoader;
		return documentLoader;
	}
	
	/**
	 * @Description: 通过招标分册定位招标文件
	 * @author chenxw
	 */
	private void loacationBiddingFileByDocumtntAction() {
		if (biddingFileGrid.getItemCount() > 0) {
			if (biddingFileGrid.getSelectionCount() == 0) {
				biddingFileGrid.setSelection(0);
			}
			GridItem item = biddingFileGrid.getSelection()[0];
			BiddingFile biddingFile = (BiddingFile) item.getData("biddingFile");
			openBiddingFileDocument(biddingFile);
		}
	}
	
	/**
	 * @Description: 打开招标文件
	 * @author guoyr
	 * @param biddingFile
	 */
	private void openBiddingFileDocument(BiddingFile biddingFile) {
		
		if (null == biddingFile) {
			String uploadPath = FileConstants.getBiddingFilePath(curTender.getId());
			if (new File(uploadPath + FileConstants.PURCHASEFILE + FileConstants.PDF).exists()) {
				biddingFile = new BiddingFile(uploadPath + FileConstants.PURCHASEFILE + FileConstants.PDF);
			} else if (new File(uploadPath + FileConstants.PURCHASEFILE + FileConstants.DOCX).exists()) {
				biddingFile = new BiddingFile(uploadPath + FileConstants.PURCHASEFILE + FileConstants.DOCX);
			} else if (new File(uploadPath + FileConstants.PURCHASEFILE + FileConstants.DOC).exists()) {
				biddingFile = new BiddingFile(uploadPath + FileConstants.PURCHASEFILE + FileConstants.DOC);
			}
		}
		if (null != biddingFile && biddingFile.exists()) {
			for (Control control : bidding_composite.getChildren()) {
				control.dispose();
			}
			if(null != bidFileDocumentLoader) {
				bidFileDocumentLoader.close();
			}
			String pdfType = PropertiesUtils.getProperty(ConfigConstants.PDF_ACTIVE_TYPE, DocumentFactory.DEFAULT_PDF_TYPE);
			bidFileDocumentLoader = DocumentFactory.getDocumentLoader(biddingFile.getAbsolutePath(), useSpecialPdf ? pdfType : null);
			bidFileDocumentLoader.addLoadFileListener(new LoadFileListener() {
				
				public void fileLoaded(DocumentLoader loader) {
					if (null != loader && !bidding_composite.isDisposed()) {
						loader.showOrHiddenToolBar(showOleToolBar);
						loader.activate();
					}
				}
			});
			boolean isNewOpenTipsShell = false;
			if(showOnloadFileTips) {
				if(null == openFileTipsShell || openFileTipsShell.isDisposed()) {
					openFileTipsShell = new OpenFileTipsShell(getShell(), null);
					isNewOpenTipsShell = true;
				}
				// 设置界面位置
				openFileTipsShell.setLocation(bidding_composite.toDisplay(0, 0));
				Rectangle rectangle = bidding_composite.getBounds();
				// 设置界面大小
				openFileTipsShell.setSize(rectangle.width, rectangle.height);
				if(isNewOpenTipsShell) {
					openFileTipsShell.open();
				}else {
					openFileTipsShell.setVisible(true);
				}
			}
			bidFileDocumentLoader.openDocument(bidding_composite, true);
			bidding_composite.layout();
			if (null != openFileTipsShell && !openFileTipsShell.isDisposed()) {
				openFileTipsShell.setVisible(false);
			}
		}
	
		
		if (null != bidFileDocumentLoader) {
			bidFileDocumentLoader.activate();
		}
		if (scoreOnly) {
			fileAndEvalPanelBothAction(evalPanlGoientation);
		}
	}
	
	/**
	 * @Description: 投标文件右键点击事件
	 * @author chenxw
	 */
	private void bidFileMouseRightClickAction() {
		EMenu gmenu = new EMenu(getShell());
		gmenu.addMenuItem(Messages.Button_openFile, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/open.png"), true, new EMenu.ClickListener() {
			public void click() {
				GridItem item = bidFileGrid.getSelection()[0];
				File bidFile = (File) item.getData("bidFile");
				openFile(bidFile);
			}
		});
		gmenu.addMenuItem(Messages.Button_saveAs, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/save.png"), true, new EMenu.ClickListener() {
			public void click() {
				GridItem item = bidFileGrid.getSelection()[0];
				BidFile bidFile = (BidFile) item.getData("bidFile");
				exportFile(bidFile, bidFile.getSimpleName());
			}
		});
		gmenu.open();
	}
	
	/**
	 * @Description: 招标文件右键点击事件
	 * @author chenxw
	 */
	private void biddingFileMouseRightClickAction() {
		EMenu gmenu = new EMenu(getShell());
		gmenu.addMenuItem(Messages.Button_openFile, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/open.png"), true, new EMenu.ClickListener() {
			public void click() {
				GridItem item = biddingFileGrid.getSelection()[0];
				File biddingFile = (File) item.getData("biddingFile");
				openFile(biddingFile);
			}
		});
		gmenu.addMenuItem(Messages.Button_saveAs, ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/save.png"), true, new EMenu.ClickListener() {
			public void click() {
				GridItem item = biddingFileGrid.getSelection()[0];
				BiddingFile biddingFile = (BiddingFile) item.getData("biddingFile");
				exportFile(biddingFile, biddingFile.getSimpleName());
			}
		});
		gmenu.open();
	}
	
	/**
	 * @Description: 打开文件
	 * @author chenxw
	 * @param file
	 */
	public void openFile(File file) {
		if (file.getName().endsWith(".pdf")) {
			String pdfExe = "explorer.exe";
			String signaturePdf = PropertiesUtils.getProperty(ConfigConstants.PDF_ACTIVE_TYPE, "");
			if (signaturePdf.equals(DianJuConstant.PDF_TYPE)) {
				pdfExe = DianJuConstant.EXE;
			} else if (signaturePdf.equals(JingeConstant.PDF_TYPE)) {
				pdfExe = JingeConstant.EXE;
			}
			RuntimeUtils.openFIle(file, pdfExe);
		} else {
			RuntimeUtils.openFIle(file);
		}
	}
	
	/**
	 * @Description: 导出文件
	 * @author chenxw
	 * @param file
	 * @param fileName
	 */
	private void exportFile(File file, String fileName) {
		String suffx = "*.*";
		int indexOfPoint = file.getName().lastIndexOf(".");
		if (indexOfPoint > 0) {
			suffx = "*" + file.getName().substring(indexOfPoint);
		}
		String saveDir = FileDialogUtils.getFileSavePath(fileName, Messages.Button_saveAs, new String[] { suffx, "*.*" }, new String[] { suffx, "*.*" });//.getDirectorySavePath(Messages.Button_saveAs, "请选择保存路径");
		if (StringUtils.isNotEmpty(saveDir)) {
			File exportFile = new File(saveDir + File.separator + fileName);
			if (exportFile.exists()) {
				if (!MessageDialog.openConfirm(getShell(), Messages.Button_saveAs, MessageFormat.format(Messages.Tips_alreadyExistAndCover, exportFile.getName()), new String[] {Messages.Button_overwrite, Messages.Button_cancel })) {
					return;
				}
			}
			FileUtils.copy(file.getAbsolutePath(), saveDir);
		}
	}
	
	/**
	 * @Description: 保存评标结果
	 * @author guoyr
	 */
	private void saveEvaluationResultAction() {
	    if (save_result_btn.getEnabled()) {
            setButtonStatus(false);
            boolean saveSuccess = evaluationTable.saveEvaluationFactorResult();
            if (saveSuccess) {
            	// 如果当前正在查看指标评审意见，保存后重新加载指标评审意见
            	if(isShowFactorEvalOpinion && null != factorEvaluationOpinionComposite && !factorEvaluationOpinionComposite.isDisposed()) {
            		showFactorEvalOpinionAction();
            	}
                if (evaluationTable.checkRefresh()) {
                    refreshAction();
                    return;
                }
                MessageDialog.openShortMessage(Messages.Tips_saveEvalResultSuccess);
            } else {
                MessageDialog.openInformation(getShell(), Messages.Dialog_warmTips, Messages.Tips_saveEvalResultFailed);
            }
            setButtonStatus(true);
        }
	}
	
	/**
	 * @Description: 设置按钮的状态
	 * @author guoyr
	 * @param enable
	 */
	private void setButtonStatus(boolean enable) {
		for (Control control : button_composite.getChildren()) {
			if (!control.isDisposed() && control instanceof EvaluationButton) {
				((EvaluationButton) control).setEnabled(enable);
			}
		}
	}
	
	/**
	 * @Description: 评审完成
	 * @author guoyr
	 */
	private void submitEvaluationResultAction() {
		if (!submit_result_btn.getEnabled()) return;
		//判断是否是复议项目并且判断是否是专家组长 如果是的话填写得分修正原因
		if(!StringUtils.isEmpty(curTender.getTenderSourceId()) && curExpert.getIsLeader().equals("1")) {
		ReReasonDialog dialog = new ReReasonDialog(getShell(), curTender, curStep);
		dialog.open();
		if(dialog.isNull() && !dialog.isSave()) {
			  return;
			}
		}
		
		// 先保存
		if (!evaluationTable.saveEvaluationFactorResult()) {
			MessageDialog.openWarning(getShell(), Messages.Dialog_warmTips, Messages.Tips_saveEvalResultFailed);
			return;
		}
		String errorMessage = evaluationTable.checkSubmit();
		if (null != errorMessage) {
			MessageDialog.openInformation(getShell(), errorMessage);
			return;
		}
		
		//打分评审是否必须录入评审意见才能提交
		boolean needOpinion = "01".equals(curStep.getEvaluationParamByKey(EvaluationStepEnum.NEED_OPINION));
		if(needOpinion && (ObjectUtils.equals(curStep.getEvalBidType(), EvaluationFactorEnum.EVAL_BID_DETAIL) || ObjectUtils.equals(curStep.getEvalBidType(), EvaluationFactorEnum.EVAL_BID_BUS)  || ObjectUtils.equals(curStep.getEvalBidType(), EvaluationFactorEnum.EVAL_BID_TEC))) {
			boolean isReturn = false;
			// 评审当前评标专家所有的评标结果
			List<EvaluationFactorResult> expertEvaluateFactorResultList = evaluationFactorResultService.getExpertEvaluationFactorResult(curTender.getId(), curStep.getId(), curExpert.getUser().getId(), null);
			if(null != expertEvaluateFactorResultList && expertEvaluateFactorResultList.size() > 0) {
				for(EvaluationFactorResult evaluationFactorResult : expertEvaluateFactorResultList) {
					if(null == evaluationFactorResult.getEvaluationOpinion() || "".equals(evaluationFactorResult.getEvaluationOpinion())) {
						isReturn = true;
						MessageDialog.openWarning(getShell(), Messages.Dialog_warmTips, supplierNameMap.get(evaluationFactorResult.getSupplierId()).concat(evaluationFactorResult.getFactorName()).concat("的评审意见未填写，请检查录入！"));
						break;
					}
				}
			}
			if(isReturn) {
			   return;
			}
		}
		
		if (evaluationTable.checkRefresh()) {
            refreshAction();
            return;
        }
		
		// 检查是否存在当前评标步骤之前未完成的步骤
		if (ObjectUtils.equals(curRule.getOrderReview(), com.gx.obe.components.core.enumeration.EvaluationStepEnum.ORDER_SELF_FREE)) {
			List<EvaluationStep> evaluationStepList = evaluationStepService.getNotComplateStepList(curTender.getId(), curStep.getSortNo());
			if (CollectionUtils.isNotNull(evaluationStepList)) {
				MessageDialog.openWarning(getShell(), Messages.Dialog_warmTips, MessageFormat.format(Messages.Tips_saveAllComplate, evaluationStepList.get(0).getStepName()));
				return;
			}
		}
		
		if(null != noComplateFilterStep){
			if (MessageDialog.openConfirm(getShell(), Messages.Dialog_warmTips, MessageFormat.format(Messages.Tips_preStepNotCompletedBeforeEntry, noComplateFilterStep.getStepName()), new String[]{Messages.Button_refresh, Messages.Button_cancel})) {
				refreshAction();
			}
			return;
		}
		
		String message = MessageFormat.format(Messages.Tips_submitEvaluationResult, curStep.getStepName());
		if (!MessageDialog.openConfirm(getShell(), Messages.Button_submitEvaluationResult, message, new String[] { Messages.Button_confirmComplate, Messages.Button_continueEvaluation})) {
			return;
		}
		if (evaluationTable.submitEvaluationFactorResult()) {
			goBackAction();
		} else {
			MessageDialog.openWarning(getShell(), Messages.Dialog_warmTips, Messages.Tips_submitFail);
		}
	}
	
	/**
	 * @Description: 获得未完成的可能会存在废标的评审节点
	 * @author guoyr 
	 */
	private void getNoComplateFilterStep(){
		List<EvaluationStep> evaluationStepList = evaluationStepService.getNotComplateFilterStepList(curTender.getId(), curStep.getSortNo());
		if (null != evaluationStepList && evaluationStepList.size() > 0) {
			noComplateFilterStep =  evaluationStepList.get(0);
		}else {
			noComplateFilterStep = null;
		}
	}
	
	private void disposite() {
		if (null != evaluationTable) {
			evaluationTable.saveEvaluationFactorResult();
		}
		if (null != showEvalPointShell && !showEvalPointShell.isDisposed()) {
			showEvalPointShell.close();
		}
		if (null != compareBiddingFileShell && !compareBiddingFileShell.isDisposed()) {
			compareBiddingFileShell.close();
		}
		imageResolver.disposite();
		if (null != supplierList) {
			supplierList.clear();
		}
	}
	
	protected void checkSubclass() {}
}
