com.clustercontrol.collect.composite.CollectSettingComposite.java Source code

Java tutorial

Introduction

Here is the source code for com.clustercontrol.collect.composite.CollectSettingComposite.java

Source

/*
    
Copyright (C) 2006 NTT DATA Corporation
    
This program is free software; you can redistribute it and/or
Modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 2.
    
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the GNU General Public License for more details.
    
 */

package com.clustercontrol.collect.composite;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import com.clustercontrol.ClusterControlPlugin;
import com.clustercontrol.collect.bean.SummaryTypeConstant;
import com.clustercontrol.collect.bean.SummaryTypeMessage;
import com.clustercontrol.collect.util.CollectEndpointWrapper;
import com.clustercontrol.collect.view.CollectGraphView;
import com.clustercontrol.repository.bean.FacilityConstant;
import com.clustercontrol.util.HinemosMessage;
import com.clustercontrol.util.Messages;
import com.clustercontrol.util.WidgetTestUtil;
import com.clustercontrol.ws.collect.CollectKeyInfoPK;
import com.clustercontrol.ws.collect.HinemosUnknown_Exception;
import com.clustercontrol.ws.collect.InvalidRole_Exception;
import com.clustercontrol.ws.collect.InvalidUserPass_Exception;
import com.clustercontrol.ws.repository.FacilityTreeItem;

/**
 * ??<BR>
 *
 * @version 5.0.0
 * @since 4.0.0
 */
public class CollectSettingComposite extends Composite {
    private static Log m_log = LogFactory.getLog(CollectSettingComposite.class);

    /**
     * 
     */
    private CollectGraphView m_collectGraphView;

    /** ? */
    private org.eclipse.swt.widgets.List m_listCollectorItem = null;
    /** ? */
    private Combo m_comboSummaryItem = null;
    /** ? */
    private Combo m_comboGraphTypeItem = null;

    /** ??? */
    private Button returnButton = null;
    /** ??? */
    private Button returnKindButton = null;
    /**  */
    private Button approximateButton = null;
    /**  */
    private Button thresholdButton = null;
    /**  */
    private Button legendButton = null;
    /** ID??index?? */
    private List<Integer> selectIndexList = new ArrayList<>();
    /** [?] */
    private Button apply = null;

    private static final int SUMMARY_CODE_INVALID = -1;

    /** (#) */
    protected static final String SEPARATOR_HASH = "#";
    /** (##@##) */
    protected static final String SEPARATOR_HASH_HASH_AT_HASH_HASH = "##@##";
    /** (#!#) */
    protected static final String SEPARATOR_HASH_EX_HASH = "#!#";
    /** (@) */
    protected static final String SEPARATOR_AT = "@";

    /** ??? */
    public static final String P_COLLECT_GRAPH_SIZE_RETURN_FLG = "collectGraphSizeReturnFlg";

    /** ?? */
    public static final String P_COLLECT_GRAPH_KIND_RETURN_FLG = "collectGraphKindReturnFlg";

    /** ??? */
    public static final String P_COLLECT_GRAPH_TOTAL_FLG = "collectGraphTotalFlg";

    /** ??? */
    public static final String P_COLLECT_GRAPH_STACK_FLG = "collectGraphStackFlg";

    /** ?? */
    public static final String P_COLLECT_GRAPH_APPROX_FLG = "collectGraphApproxFlg";

    /**  */
    public static final String P_COLLECT_GRAPH_THRESHOLD_FLG = "collectGraphThresholdFlg";

    /**  */
    public static final String P_COLLECT_GRAPH_LEGEND_FLG = "collectGraphLegendFlg";

    /** ? */
    public static final String P_COLLECT_GRAPH_SELECT_NODE_INFO = "collectGraphSelectNodeInfo";

    /**  */
    public static final String P_COLLECT_GRAPH_ZOOM_LEVEL = "collectGraphZoomLevel";

    /** ? */
    public static final String P_COLLECT_GRAPH_SELECT_ITEM_INFO = "collectGraphSelectItemInfo";

    /** ? */
    public static final String P_COLLECT_GRAPH_SELECT_SUMMARY_INFO = "collectGraphSelectSummaryInfo";

    /** ? */
    public static final String P_COLLECT_GRAPH_SELECT_TYPE_INFO = "collectGraphSelectTypeInfo";

    /** () */
    public static final String DEFAULT_COLLECT_GRAPH_ZOOM_LEVEL = "100%";

    /**
     * 
     *
     * @param settings ?
     * @param parent ??
     * @param style 
     */
    public CollectSettingComposite(Composite parent, int style, CollectGraphView collectGraphView) {
        super(parent, style);
        // ?
        initialize();
        m_collectGraphView = collectGraphView;
        GridData gridData = null;

        Composite graphCompo = this;
        WidgetTestUtil.setTestId(this, "graphCompo", graphCompo);
        GridLayout layout = new GridLayout(1, true);
        graphCompo.setLayout(layout);
        layout.marginHeight = 0;
        layout.marginWidth = 0;

        // itemCode
        Label itemCodeLabel = new Label(graphCompo, SWT.NONE | SWT.RIGHT);
        itemCodeLabel.setText(Messages.getString("collection.display.name") + " : ");
        // itemCode?
        m_listCollectorItem = new org.eclipse.swt.widgets.List(graphCompo,
                SWT.MULTI | SWT.V_SCROLL | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.NONE);
        WidgetTestUtil.setTestId(this, "collectorItem", this.m_listCollectorItem);
        gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalSpan = 1;
        gridData.heightHint = m_listCollectorItem.getItemHeight() * 100;
        gridData.grabExcessVerticalSpace = true;
        m_listCollectorItem.setLayoutData(gridData);

        // ????????
        m_listCollectorItem.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                // ID?????(??RCP?getSelectionIndex?RAP?getSelectionIndices??)
                if (ClusterControlPlugin.isRAP()) {
                    selectIndexList.clear();
                    for (int number : m_listCollectorItem.getSelectionIndices()) {
                        selectIndexList.add(number);
                    }
                } else {
                    if (m_listCollectorItem.getSelectionIndices().length == 0) {
                        // ??
                        selectIndexList.clear();
                    } else if (selectIndexList.size() == m_listCollectorItem.getSelectionIndices().length
                            || m_listCollectorItem.getSelectionIndices().length == 1) {
                        // ???(1??1?) or ??1?????
                        // 1??????
                        selectIndexList.clear();
                        selectIndexList.add(m_listCollectorItem.getSelectionIndex());
                    } else if (selectIndexList.size() < m_listCollectorItem.getSelectionIndices().length) {
                        // ???
                        // ctrl + a ???????????
                        if (!selectIndexList.contains((Integer) m_listCollectorItem.getSelectionIndex())) {
                            selectIndexList.add((Integer) m_listCollectorItem.getSelectionIndex());
                        }
                    } else {
                        // ???(1???)
                        Integer unselectedIndex = 0;
                        List<Integer> selectIndicesList = new ArrayList<>();
                        for (int i = 0; i < m_listCollectorItem.getSelectionIndices().length; i++) {
                            selectIndicesList.add(m_listCollectorItem.getSelectionIndices()[i]);
                        }
                        for (Integer number : selectIndexList) {
                            if (!selectIndicesList.contains(number)) {
                                unselectedIndex = number;
                                break;
                            }
                        }
                        selectIndexList.remove(unselectedIndex);
                    }
                }
                m_log.debug("??(index):" + selectIndexList.toString());
            }
        });
        // 
        Label graphTypeLabel = new Label(graphCompo, SWT.RIGHT | SWT.NONE);
        graphTypeLabel.setText(Messages.getString("collection.graph.graphkind") + " : ");

        m_comboGraphTypeItem = new Combo(graphCompo, SWT.DROP_DOWN | SWT.READ_ONLY);
        WidgetTestUtil.setTestId(this, "summaryItem", m_comboGraphTypeItem);
        gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalSpan = 1;
        m_comboGraphTypeItem.setLayoutData(gridData);
        m_comboGraphTypeItem.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                // ?????????
                setCheckBoxEnableByGraphKind();
            }
        });

        // summaryType 
        Label graphSummaryLabel = new Label(graphCompo, SWT.RIGHT | SWT.NONE);
        graphSummaryLabel.setText(Messages.getString("collection.summary.type") + " : ");

        m_comboSummaryItem = new Combo(graphCompo, SWT.DROP_DOWN | SWT.READ_ONLY);
        WidgetTestUtil.setTestId(this, "summaryItem", m_comboSummaryItem);
        gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalSpan = 1;
        m_comboSummaryItem.setLayoutData(gridData);

        Composite checkCompsite = new Composite(graphCompo, SWT.NONE);
        checkCompsite.setLayout(new GridLayout(2, true));

        // ??
        returnButton = new Button(checkCompsite, SWT.CHECK);
        returnButton.setText(Messages.getString("collection.graph.wordwrap"));// ???
        returnButton.setToolTipText(Messages.getString("collection.graph.wordwrap"));
        // preference??
        IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();
        returnButton.setSelection(store.getBoolean(P_COLLECT_GRAPH_SIZE_RETURN_FLG));

        // ??
        returnKindButton = new Button(checkCompsite, SWT.CHECK);
        returnKindButton.setText(Messages.getString("collection.graph.foldedinmonitorid")); // ??
        returnKindButton.setToolTipText(Messages.getString("collection.graph.foldedinmonitorid"));
        // preference??
        returnKindButton.setSelection(store.getBoolean(P_COLLECT_GRAPH_KIND_RETURN_FLG));

        // ??
        approximateButton = new Button(checkCompsite, SWT.CHECK);
        approximateButton.setText(Messages.getString("collection.graph.approximatestraightline")); // 
        approximateButton.setToolTipText(Messages.getString("collection.graph.approximatestraightline"));
        // preference??
        approximateButton.setSelection(store.getBoolean(P_COLLECT_GRAPH_APPROX_FLG));

        // ??
        thresholdButton = new Button(checkCompsite, SWT.CHECK);
        thresholdButton.setText(Messages.getString("collection.graph.upperandlowerlimits")); // ??
        thresholdButton.setToolTipText(Messages.getString("collection.graph.upperandlowerlimits"));
        // preference??
        thresholdButton.setSelection(store.getBoolean(P_COLLECT_GRAPH_THRESHOLD_FLG));

        // ??
        legendButton = new Button(checkCompsite, SWT.CHECK);
        legendButton.setText(Messages.getString("collection.graph.legend")); // 
        legendButton.setToolTipText(Messages.getString("collection.graph.legend"));
        // preference??
        legendButton.setSelection(store.getBoolean(P_COLLECT_GRAPH_LEGEND_FLG));

        // ?
        gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        apply = new Button(graphCompo, SWT.NONE);
        apply.setText(Messages.getString("apply"));
        apply.setToolTipText(Messages.getString("apply"));
        apply.setLayoutData(gridData);
        apply.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                m_log.debug("apply");
                String selectItemName = getSelectItemNameBySelectIndex();
                List<CollectKeyInfoPK> collectKeyInfoList = getCollectorItems();

                int summaryType = getSummaryItem();
                Boolean checkInput = checkTreeCombo(collectKeyInfoList, summaryType);
                if (checkInput) {
                    // ???
                    applySetting(selectItemName);

                    // ???
                    drawGraphs(collectKeyInfoList, summaryType, selectItemName);
                }
            }
        });
        // SWT?????
        checkAsyncExec(new Runnable() {
            @Override
            public void run() {
                // ??
                m_collectGraphView.setItemCodeCheckedTreeItems();
            }
        });
    }

    /**
     * ??????????(???????)
     * ????
     * ????(Boolean)
     * ???(Boolean)
     * ??(Boolean)
     * ???(Boolean)
     * ??(Boolean)
     * (String)
     * ?(String)
     * ?(String)
     * ?(String?EN)
     * (int)
     * 
     */
    private void applySetting(String selectItemName) {
        IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

        store.setValue(P_COLLECT_GRAPH_SIZE_RETURN_FLG, returnButton.getSelection());
        store.setValue(P_COLLECT_GRAPH_KIND_RETURN_FLG, returnKindButton.getSelection());
        store.setValue(P_COLLECT_GRAPH_APPROX_FLG, approximateButton.getSelection());
        store.setValue(P_COLLECT_GRAPH_THRESHOLD_FLG, thresholdButton.getSelection());
        store.setValue(P_COLLECT_GRAPH_LEGEND_FLG, legendButton.getSelection());
        store.setValue(P_COLLECT_GRAPH_ZOOM_LEVEL, m_collectGraphView.getCollectGraphComposite().getZoomLevel());
        String checkedTreeInfo = storeCheckedTreeInfo();
        m_log.debug("checkedTreeInfo : " + checkedTreeInfo);
        store.setValue(P_COLLECT_GRAPH_SELECT_NODE_INFO, checkedTreeInfo);
        store.setValue(P_COLLECT_GRAPH_SELECT_ITEM_INFO, selectItemName);
        String summaryEn = SummaryTypeMessage.typeToStringEN(m_comboSummaryItem.getSelectionIndex());
        store.setValue(P_COLLECT_GRAPH_SELECT_SUMMARY_INFO, summaryEn);
        store.setValue(P_COLLECT_GRAPH_SELECT_TYPE_INFO, m_comboGraphTypeItem.getSelectionIndex());
    }

    /**
     * ?????
     *
     * @param parent
     * @param style
     */
    private void initialize() {

        GridLayout layout = new GridLayout();
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        layout.horizontalSpacing = 0;
        layout.verticalSpacing = 0;
        this.setLayout(layout);
    }

    /**
     * ???(?)
     */
    @Override
    public void update() {
        super.update();
    }

    /**
     * ????????
     * 
     * @return 
     */
    private List<CollectKeyInfoPK> getCollectorItems() {
        if (selectIndexList == null || selectIndexList.size() == 0) {
            return null;
        }
        List<CollectKeyInfoPK> collectKeyInfoList = new ArrayList<>();
        for (Integer number : selectIndexList) {
            String key = m_listCollectorItem.getItem(number);
            String itemCodeName = (String) m_listCollectorItem.getData(key);
            CollectKeyInfoPK pk = new CollectKeyInfoPK();
            String itemName = itemCodeName.split(SEPARATOR_AT)[0];
            String displayName = itemCodeName.split(SEPARATOR_AT)[1];
            String monitorId = itemCodeName.split(SEPARATOR_AT)[2];
            pk.setItemName(itemName);
            pk.setDisplayName(displayName);
            pk.setMonitorId(monitorId);
            collectKeyInfoList.add(pk);
            m_log.info("getCollectorItem() ??? number:" + number + ", itemName:"
                    + pk.getItemName() + ", displayName:" + pk.getDisplayName() + ", monitorId:"
                    + pk.getMonitorId());
        }
        return collectKeyInfoList;
    }

    /**
     * ???????
     *
     * @param managers ?????
     */
    public void setCollectorItemCombo() {

        List<String> allItemList = new ArrayList<>();
        // ??????
        List<String> selectList = this.m_collectGraphView.getFacilityTreeComposite().getCheckedTreeInfo();
        TreeMap<String, List<String>> managerFacilityMap = new TreeMap<>();
        for (String selectStr : selectList) {
            String[] nodeDetail = selectStr.split(SEPARATOR_HASH_EX_HASH);
            if (nodeDetail.length != 0
                    && nodeDetail[nodeDetail.length - 1].equals(String.valueOf(FacilityConstant.TYPE_NODE))) {
                String facilityId = nodeDetail[nodeDetail.length - 2];
                String managerName = nodeDetail[0];
                List<String> facilityList = managerFacilityMap.get(managerName);
                if (facilityList == null) {
                    facilityList = new ArrayList<String>();
                    managerFacilityMap.put(managerName, facilityList);
                }
                if (!facilityList.contains(facilityId)) {
                    m_log.debug("????? managerName:" + managerName + ", facilityId:"
                            + facilityId);
                    facilityList.add(facilityId);
                }
            }
        }

        for (Map.Entry<String, List<String>> map : managerFacilityMap.entrySet()) {
            String managerName = map.getKey();
            List<String> facilityList = map.getValue();
            // ???
            List<CollectKeyInfoPK> collectKeyInfoList;
            try {
                CollectEndpointWrapper wrapper = CollectEndpointWrapper.getWrapper(managerName);
                collectKeyInfoList = wrapper.getItemCodeList(facilityList);
            } catch (InvalidRole_Exception e) {
                m_log.warn("setCollectorItemCombo() getItemCodeList, " + e.getMessage());
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.accesscontrol.16"));
                return;
            } catch (InvalidUserPass_Exception | HinemosUnknown_Exception e) {
                // ?
                m_log.warn("setCollectorItemCombo() getItemCodeList, " + e.getMessage(), e);
                MessageDialog.openInformation(null, Messages.getString("failed"),
                        Messages.getString("message.hinemos.failure.unexpected") + ", "
                                + HinemosMessage.replace(e.getMessage()));
                return;
            }
            // DB??????
            for (CollectKeyInfoPK collectKeyInfo : collectKeyInfoList) {
                String itemName = collectKeyInfo.getItemName();
                String monitorId = collectKeyInfo.getMonitorId();
                String displayName = collectKeyInfo.getDisplayName();
                if (!allItemList.contains(itemName + SEPARATOR_AT + displayName + SEPARATOR_AT + monitorId)) {
                    // itemCode@itemName ????
                    allItemList.add(itemName + SEPARATOR_AT + displayName + SEPARATOR_AT + monitorId);
                }
            }
        }

        // ??????????
        for (String itemCodeName : allItemList) {
            String itemName = HinemosMessage.replace(itemCodeName.split(SEPARATOR_AT)[0]);
            String displayName = itemCodeName.split(SEPARATOR_AT)[1];
            String monitorId = itemCodeName.split(SEPARATOR_AT)[2];
            // itemName?displayName???????
            if (!displayName.equals("") && !itemName.endsWith("[" + displayName + "]")) {
                itemName += "[" + displayName + "]";
            }
            String itemNameStr = itemName + "(" + monitorId + ")";
            if (!(Arrays.asList(m_listCollectorItem.getItems())).contains(itemNameStr)) {
                m_listCollectorItem.add(itemNameStr);
                m_listCollectorItem.setData(itemNameStr, itemCodeName);
            }
        }

        // ??
        setDefaultItemInfo();
    }

    /**
     * ??
     * @param r
     * @return
     */
    private boolean checkAsyncExec(Runnable r) {

        if (!m_collectGraphView.getFacilityTreeComposite().isDisposed()) {
            m_log.trace("CollectSettingComposite.checkAsyncExec() is true");
            m_collectGraphView.getFacilityTreeComposite().getDisplay().asyncExec(r);
            return true;
        } else {
            m_log.trace("CollectSettingComposite.checkAsyncExec() is false");
            return false;
        }
    }

    /**
     * ???????
     */
    public void clearItem() {
        m_listCollectorItem.removeAll();
        m_comboSummaryItem.removeAll();
        m_comboGraphTypeItem.removeAll();
        setCheckBoxEnableByGraphKind();
        selectIndexList.clear();
    }

    /**
     * ?????
     * 
     */
    public void setDefaultItemInfo() {
        m_log.debug("Preference???????");
        String treeSelect = ClusterControlPlugin.getDefault().getPreferenceStore()
                .getString(CollectSettingComposite.P_COLLECT_GRAPH_SELECT_ITEM_INFO);
        if (treeSelect == null || treeSelect.equals("")) {
            return;
        }

        // ???
        String array[] = treeSelect.split(SEPARATOR_HASH);
        m_listCollectorItem.setSelection(array);

        // ?????????
        this.selectIndexList = getSelectIndexListByItemName();
    }

    /**
     * ??????
     *
     */
    public void setGraphTypeItemCombo() {
        m_log.debug("?Combo???Preference????");
        List<String> graphTypeList = Arrays.asList(m_comboGraphTypeItem.getItems());
        if (graphTypeList == null || graphTypeList.size() == 0) {
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.line"));// 
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.line"), 1);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.line") + "("
                    + Messages.getString("collection.graph.summarizedinmonitorid") + ")"); // (?)
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.line") + "("
                    + Messages.getString("collection.graph.summarizedinmonitorid") + ")", 2);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.area"));// ????
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.area"), 3);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.scatter")); // 
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.scatter"), 6);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.scatter") + "("
                    + Messages.getString("collection.graph.summarized") + ")");// ()
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.scatter") + "("
                    + Messages.getString("collection.graph.summarized") + ")", 7);
            m_comboGraphTypeItem.add("--------------------");
            m_comboGraphTypeItem.setData("--------------------", 10);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.pie"));// 
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.pie"), 4);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.pie") + "("
                    + Messages.getString("collection.graph.summarizedinmonitorid") + ")");// (?)
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.pie") + "("
                    + Messages.getString("collection.graph.summarizedinmonitorid") + ")", 5);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.stackedbar"));// 
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.stackedbar"), 8);
            m_comboGraphTypeItem.add(Messages.getString("collection.graph.stackedbar") // (?)
                    + "(" + Messages.getString("collection.graph.summarizedinmonitorid") + ")");
            m_comboGraphTypeItem.setData(Messages.getString("collection.graph.stackedbar") + "("
                    + Messages.getString("collection.graph.summarizedinmonitorid") + ")", 9);

            // preference????
            int type = ClusterControlPlugin.getDefault().getPreferenceStore()
                    .getInt(CollectSettingComposite.P_COLLECT_GRAPH_SELECT_TYPE_INFO);
            m_comboGraphTypeItem.select(type);

            // ????
            setCheckBoxEnableByGraphKind();
        }
    }

    /**
     * ????????
     * 
     * @return (-1????or)
     */
    private int getGraphTypeItem() {
        String itemName = m_comboGraphTypeItem.getText();
        if (itemName == null || itemName.equals("")) {
            return SUMMARY_CODE_INVALID;
        }
        if ((Integer) m_comboGraphTypeItem.getData(itemName) == 10) {// ?[-----]
            return SUMMARY_CODE_INVALID;
        }
        return (Integer) m_comboGraphTypeItem.getData(itemName);
    }

    /**
     * ???????
     *
     */
    public void setSummaryItemCombo() {

        m_log.debug("?Combo???preference????");
        List<String> summaryList = Arrays.asList(m_comboSummaryItem.getItems());
        if (summaryList == null || summaryList.size() == 0) {
            List<String> summaryTypeList = SummaryTypeMessage.getSummaryTypeList();
            for (String summaryType : summaryTypeList) {
                m_comboSummaryItem.add(summaryType);
                m_comboSummaryItem.setData(summaryType, SummaryTypeMessage.stringToType(summaryType));
            }
            String summaryEn = ClusterControlPlugin.getDefault().getPreferenceStore()
                    .getString(CollectSettingComposite.P_COLLECT_GRAPH_SELECT_SUMMARY_INFO);
            int type = SummaryTypeMessage.stringENToType(summaryEn);
            m_comboSummaryItem.select(type);
        }
    }

    /**
     * ????????
     * 
     * @return 
     */
    private int getSummaryItem() {
        String itemName = m_comboSummaryItem.getText();
        if (itemName == null || itemName.equals("")) {
            return SUMMARY_CODE_INVALID;
        }
        int itemCode = (Integer) m_comboSummaryItem.getData(itemName);
        m_log.debug("getSummaryItem() itemName:" + itemName + ", itemCode:" + itemCode);
        return itemCode;
    }

    /**
     * ?Combobox?????
     * @param type
     */
    public void setSummaryTypeComboBox(int type) {
        m_log.debug("setSummaryTypeComboBox() type:" + type);
        m_comboSummaryItem.select(m_comboSummaryItem.indexOf(SummaryTypeMessage.typeToString(type)));
    }

    /**
     * 
     * @param itemCodeList
     * @param summaryType
     * @return
     */
    private boolean checkTreeCombo(List<CollectKeyInfoPK> itemCodeList, int summaryType) {

        if (itemCodeList == null || itemCodeList.isEmpty()) {
            m_log.debug("checkTreeCombo() ?");
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.collection.graph.selectdisplayname"));

            return false;
        }

        if (getGraphTypeItem() == SUMMARY_CODE_INVALID) {
            m_log.debug("checkTreeCombo() ??");
            MessageDialog.openInformation(null, Messages.getString("message"), // ????????
                    Messages.getString("message.collection.graph.select.one.graph.kind.from.the.list"));

            return false;
        }

        if ((getGraphTypeItem() == 6 || getGraphTypeItem() == 7) && itemCodeList.size() < 2) {
            m_log.debug("checkTreeCombo() ?ID????");
            MessageDialog.openInformation(null, Messages.getString("message"), // ?ID???????
                    Messages.getString("message.collection.graph.must.specify.more.than.two.monitorid.in.scatter"));

            return false;
        }

        if (itemCodeList.size() > 10) {
            m_log.debug("checkTreeCombo() 10? size:" + itemCodeList.size());
            MessageDialog.openInformation(null, Messages.getString("message"), // ????10??????
                    Messages.getString("message.collection.graph.morethan.selected.monitorid"));

            return false;
        }

        if ((getGraphTypeItem() == 3 || getGraphTypeItem() == 6 || getGraphTypeItem() == 7
                || getGraphTypeItem() == 8 || getGraphTypeItem() == 9)
                && summaryType == SummaryTypeConstant.TYPE_RAW) {
            // ????????????????
            m_log.debug("checkTreeCombo() ???????");
            MessageDialog.openInformation(null, Messages.getString("message"), // ??????
                    Messages.getString("message.collection.graph.do.not.display.in.law"));

            return false;
        }

        m_log.debug("checkTreeCombo() OK.");
        return true;
    }

    /**
     * ???????????
     * 
     */
    private void setCheckBoxEnableByGraphKind() {
        int type = getGraphTypeItem();
        returnButton.setEnabled(true);
        returnKindButton.setEnabled(true);
        switch (type) {
        case 1: // 
        case 2: // ()
            approximateButton.setEnabled(true);
            thresholdButton.setEnabled(true);
            legendButton.setEnabled(true);
            break;
        case 3: // ????
            approximateButton.setEnabled(false);
            thresholdButton.setEnabled(false);
            legendButton.setEnabled(true);
            break;
        case 4: // 
        case 5: // ()
        case 8: // ???
        case 9: // ???()
            approximateButton.setEnabled(false);
            thresholdButton.setEnabled(false);
            legendButton.setEnabled(false);
            break;
        case 6: // 
        case 7: // ()
            approximateButton.setEnabled(true);
            thresholdButton.setEnabled(false);
            legendButton.setEnabled(true);
            break;
        default: // -------
            returnButton.setEnabled(false);
            returnKindButton.setEnabled(false);
            approximateButton.setEnabled(false);
            thresholdButton.setEnabled(false);
            legendButton.setEnabled(false);
        }
    }

    /**
     * PerformanceGraphComposite???????
     * 
     * @param collectKeyList ???
     * @param summaryType ???
     */
    private void drawGraphs(List<CollectKeyInfoPK> collectKeyList, int summaryType, String selectItemName) {
        List<FacilityTreeItem> treeItemList = m_collectGraphView.getCheckedTreeItemList();
        int type = getGraphTypeItem();
        boolean totalflg = type == 1 ? false : true;
        boolean stackflg = type == 3 ? true : false;
        boolean pieflg = type == 4 || type == 5 ? true : false;
        totalflg = type == 4 ? false : totalflg;
        totalflg = type == 5 ? true : totalflg;
        boolean scatterflg = type == 6 || type == 7 ? true : false;
        totalflg = type == 6 ? false : totalflg;
        totalflg = type == 7 ? true : totalflg;
        boolean barflg = type == 8 || type == 9 ? true : false;
        totalflg = type == 8 ? false : totalflg;
        totalflg = type == 9 ? true : totalflg;

        try {
            // ?????
            apply.setEnabled(false);
            m_collectGraphView.getCollectGraphComposite().drawGraphs(collectKeyList, selectItemName, summaryType,
                    treeItemList, returnButton.getSelection(), returnKindButton.getSelection(), totalflg, stackflg,
                    approximateButton.getSelection(), thresholdButton.getSelection(), pieflg, scatterflg,
                    legendButton.getSelection(), barflg);
        } catch (InvalidRole_Exception e) {
            m_log.error("drawGraphs InvalidRole_Exception");
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
            m_collectGraphView.getCollectGraphComposite().removeGraphSliderDisp();
        } catch (InvalidUserPass_Exception e) {
            m_log.error("drawGraphs InvalidUserPass_Exception");
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.45"));
            m_collectGraphView.getCollectGraphComposite().removeGraphSliderDisp();
        } catch (Exception e) {
            m_log.error("drawGraphs ???? message=" + e.getMessage(), e);
            MessageDialog.openError(null, Messages.getString("error"),
                    Messages.getString("message.collection.graph.unexpected.error") + " : " + e.getMessage());
            m_collectGraphView.getCollectGraphComposite().removeGraphSliderDisp();
        } finally {
            // ????
            apply.setEnabled(true);
        }
    }

    /**
     * ????index??????????<br>
     * ??#????????<br>
     * List.getSelectionIndexrcp??????index????rap??????index????<br>
     * List.getSelectionIndicesrcp??????????(List???)??rap????????<br>
     * List.getSelectionrcp????????????(List???)??rap????????<br>
     * @return
     */
    private String getSelectItemNameBySelectIndex() {
        StringBuilder selectStrBuilder = new StringBuilder();
        if (selectIndexList.size() != m_listCollectorItem.getSelectionCount()) {
            // ctrl + A???
            // ??????
            selectIndexList.clear();
            for (int ctrlnumber : m_listCollectorItem.getSelectionIndices()) {
                selectIndexList.add((Integer) ctrlnumber);
            }
        }
        for (Integer index : selectIndexList) {
            try {
                selectStrBuilder.append(this.m_listCollectorItem.getItem(index) + SEPARATOR_HASH);
            } catch (Exception e) {
                // nop
                m_log.error("getSelectItemNameBySelectIndex() " + e.getMessage());
            }
        }
        m_log.debug("?? selectStr:" + selectStrBuilder.toString());
        return selectStrBuilder.toString();
    }

    /**
     * preference????????(???#??)?<br>
     * index?????????<br>
     * @return
     */
    private List<Integer> getSelectIndexListByItemName() {
        List<Integer> selectList = new ArrayList<>();
        String treeSelect = ClusterControlPlugin.getDefault().getPreferenceStore()
                .getString(CollectSettingComposite.P_COLLECT_GRAPH_SELECT_ITEM_INFO);
        if (treeSelect == null || treeSelect.equals("")) {
            return selectList;
        }
        for (String str : treeSelect.split(SEPARATOR_HASH)) {
            int number = 0;
            for (String item : m_listCollectorItem.getItems()) {
                if (item.equals(str)) {
                    selectList.add(number);
                }
                number++;
            }
        }
        m_log.debug("preference?index? :" + selectList.toString());
        return selectList;
    }

    /**
     * ?????<br>
     * ????<br>
     * FacilityTreeComposite.getCheckedTreeInfo()?<br>
     * ?3#!#REGISTERED#!#node_db_1#!#1##@##?4#!#REGISTERED#!#node_ap_1#!#1<br>
     * #!# -> ??([???]#!#[]#!#...#!#[ID]#!#)<br>
     * ##@## -> ?
     * 
     * @return
     */
    private String storeCheckedTreeInfo() {
        List<String> selectList = this.m_collectGraphView.getFacilityTreeComposite().getCheckedTreeInfo();
        StringBuilder sb = new StringBuilder();
        for (String selectParam : selectList) {
            sb.append(selectParam);
            sb.append(SEPARATOR_HASH_HASH_AT_HASH_HASH);
        }
        if (sb.length() == 0) {
            return "";
        }
        return sb.toString().substring(0, sb.toString().length() - SEPARATOR_HASH_HASH_AT_HASH_HASH.length());
    }
}