com.clustercontrol.notify.dialog.NotifyInfraCreateDialog.java Source code

Java tutorial

Introduction

Here is the source code for com.clustercontrol.notify.dialog.NotifyInfraCreateDialog.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.notify.dialog;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.clustercontrol.ClusterControlPlugin;
import com.clustercontrol.bean.PriorityColorConstant;
import com.clustercontrol.bean.PriorityMessage;
import com.clustercontrol.bean.RequiredFieldColorConstant;
import com.clustercontrol.dialog.ScopeTreeDialog;
import com.clustercontrol.dialog.ValidateResult;
import com.clustercontrol.infra.util.InfraEndpointWrapper;
import com.clustercontrol.notify.action.AddNotify;
import com.clustercontrol.notify.action.GetNotify;
import com.clustercontrol.notify.action.ModifyNotify;
import com.clustercontrol.notify.bean.ExecFacilityConstant;
import com.clustercontrol.repository.FacilityPath;
import com.clustercontrol.util.HinemosMessage;
import com.clustercontrol.util.MessageConstant;
import com.clustercontrol.util.Messages;
import com.clustercontrol.util.WidgetTestUtil;
import com.clustercontrol.ws.infra.InfraManagementInfo;
import com.clustercontrol.ws.notify.NotifyInfo;
import com.clustercontrol.ws.notify.NotifyInfraInfo;
import com.clustercontrol.ws.repository.FacilityInfo;
import com.clustercontrol.ws.repository.FacilityTreeItem;

/**
 * ?<BR>
 *
 * @version 4.0.0
 * @since 3.0.0
 */
public class NotifyInfraCreateDialog extends NotifyBasicCreateDialog {

    /** ?? */
    private static final int WIDTH_PRIORITY = 2;

    /**  */
    private static final int WIDTH_INFRA_RUN = 2;

    /** ID */
    private static final int WIDTH_INFRA_ID = 7;

    /**  */
    private static final int WIDTH_FAILURE_PRIORITY = 4;

    // ----- instance  ----- //

    /** 
     * @see com.clustercontrol.bean.NotifyTypeConstant
     */
    private static final int TYPE_INFRA = 6;

    /** ???? */
    protected ValidateResult validateResult = null;

    /**  */
    private Text m_textScope = null;

    /** ID */
    private String m_facilityId = null;

    /**  */
    private String m_facilityPath = null;

    /**  */
    private Button m_radioGenerationNodeValue = null;

    /**  */
    private Button m_radioFixedValue = null;

    /** ? */
    private Button m_scopeSelect = null;

    /**  ? */
    private Button m_checkInfraRunInfo = null;
    /**  ? */
    private Button m_checkInfraRunWarning = null;
    /**  ? */
    private Button m_checkInfraRunCritical = null;
    /** ? ? */
    private Button m_checkInfraRunUnknown = null;

    /** ID  */
    private Combo m_comboInfraIdInfo = null;
    /** ID  */
    private Combo m_comboInfraIdWarning = null;
    /** ID  */
    private Combo m_comboInfraIdCritical = null;
    /** ID?  */
    private Combo m_comboInfraIdUnknown = null;

    /** ???  */
    private Combo m_comboFailurePriorityInfo = null;
    /** ???  */
    private Combo m_comboFailurePriorityWarning = null;
    /** ???  */
    private Combo m_comboFailurePriorityCritical = null;
    /** ????  */
    private Combo m_comboFailurePriorityUnknown = null;

    private List<InfraManagementInfo> m_infraList = new ArrayList<>();

    // ?ID??
    // key=CalendarId
    // value=CalendarName(CalendarId)
    private ConcurrentHashMap<String, String> dispMap = new ConcurrentHashMap<>();

    // -----  ----- //

    /**
     * ?????
     *
     * @param parent ?
     */
    public NotifyInfraCreateDialog(Shell parent) {
        super(parent);
    }

    /**
     * ????
     *
     * @param parent ?
     * @param managerName ???
     * @param notifyId ??ID
     * @param updateFlg true:?
     */
    public NotifyInfraCreateDialog(Shell parent, String managerName, String notifyId, boolean updateFlg) {
        super(parent, managerName, notifyId, updateFlg);
    }

    // ----- instance  ----- //

    /**
     * ????
     *
     * @param parent ??
     *
     * @see com.clustercontrol.notify.dialog.NotifyBasicCreateDialog#customizeDialog(Composite)
     * @see com.clustercontrol.notify.action.GetNotify#getNotify(String)
     * @see #setInputData(NotifyInfo)
     */
    @Override
    protected void customizeDialog(Composite parent) {

        super.customizeDialog(parent);

        // ID???????????
        NotifyInfo info = null;
        if (this.notifyId != null) {
            info = new GetNotify().getNotify(this.managerName, this.notifyId);
        } else {
            info = new NotifyInfo();
        }
        this.setInputData(info);
    }

    /**
     * ??????????
     *
     * @param parent ??
     *
     * @see com.clustercontrol.notify.dialog.NotifyBasicCreateDialog#customizeDialog(Composite)
     */
    @Override
    protected void customizeSettingDialog(Composite parent) {
        final Shell shell = this.getShell();

        // 
        shell.setText(Messages.getString("dialog.notify.infra.create.modify"));

        // ????
        Label label = null;
        // ????
        GridData gridData = null;

        // 
        GridLayout layout = new GridLayout(1, true);
        layout.marginWidth = 10;
        layout.marginHeight = 10;
        layout.numColumns = 15;
        parent.setLayout(layout);

        /*
         * 
         */
        // 
        Group groupInfra = new Group(parent, SWT.NONE);
        WidgetTestUtil.setTestId(this, "infra", groupInfra);
        layout = new GridLayout(1, true);
        layout.marginWidth = 5;
        layout.marginHeight = 5;
        layout.numColumns = 15;
        groupInfra.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalSpan = 15;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        groupInfra.setLayoutData(gridData);
        groupInfra.setText(Messages.getString("notifies.infra"));

        /*
         * 
         */
        Group groupScope = new Group(groupInfra, SWT.NONE);
        WidgetTestUtil.setTestId(this, "scope", groupScope);
        groupScope.setText(Messages.getString("notify.infra.scope"));
        layout = new GridLayout(1, true);
        layout.marginWidth = 5;
        layout.marginHeight = 5;
        layout.numColumns = 15;
        groupScope.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalSpan = 15;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        groupScope.setLayoutData(gridData);

        //  
        this.m_radioGenerationNodeValue = new Button(groupScope, SWT.RADIO);
        WidgetTestUtil.setTestId(this, "generationnodevalue", m_radioGenerationNodeValue);
        gridData = new GridData();
        gridData.horizontalSpan = 15;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        this.m_radioGenerationNodeValue.setLayoutData(gridData);
        this.m_radioGenerationNodeValue.setText(Messages.getString("notify.node.generation") + " : ");
        this.m_radioGenerationNodeValue.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Button check = (Button) e.getSource();
                WidgetTestUtil.setTestId(this, null, check);
                if (check.getSelection()) {
                    m_radioFixedValue.setSelection(false);
                    m_scopeSelect.setEnabled(false);
                }
            }
        });

        //  
        this.m_radioFixedValue = new Button(groupScope, SWT.RADIO);
        WidgetTestUtil.setTestId(this, "fixedvalue", m_radioFixedValue);
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        this.m_radioFixedValue.setLayoutData(gridData);
        this.m_radioFixedValue.setText(Messages.getString("notify.node.fix") + " : ");
        this.m_radioFixedValue.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Button check = (Button) e.getSource();
                WidgetTestUtil.setTestId(this, null, check);
                if (check.getSelection()) {
                    m_radioGenerationNodeValue.setSelection(false);
                    m_scopeSelect.setEnabled(true);
                }
                update();
            }
        });

        this.m_textScope = new Text(groupScope, SWT.BORDER | SWT.READ_ONLY);
        WidgetTestUtil.setTestId(this, "scope", m_textScope);
        gridData = new GridData();
        gridData.horizontalSpan = 5;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        this.m_textScope.setLayoutData(gridData);
        this.m_textScope.setText("");

        this.m_scopeSelect = new Button(groupScope, SWT.NONE);
        WidgetTestUtil.setTestId(this, "scopeselect", m_scopeSelect);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        this.m_scopeSelect.setLayoutData(gridData);
        this.m_scopeSelect.setText(Messages.getString("refer"));
        this.m_scopeSelect.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                ScopeTreeDialog dialog = new ScopeTreeDialog(shell,
                        m_notifyBasic.getManagerListComposite().getText(), m_notifyBasic.getRoleIdList().getText());
                if (dialog.open() == IDialogConstants.OK_ID) {
                    FacilityTreeItem selectItem = dialog.getSelectItem();
                    FacilityInfo info = selectItem.getData();
                    FacilityPath path = new FacilityPath(ClusterControlPlugin.getDefault().getSeparator());
                    m_facilityPath = path.getPath(selectItem);
                    m_facilityId = info.getFacilityId();
                    m_textScope.setText(HinemosMessage.replace(m_facilityPath));
                    update();
                }
            }
        });

        label = new Label(groupScope, SWT.NONE);
        WidgetTestUtil.setTestId(this, null, label);
        gridData = new GridData();
        gridData.horizontalSpan = 5;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);

        // 
        label = new Label(groupInfra, SWT.NONE);
        WidgetTestUtil.setTestId(this, "space1", label);
        gridData = new GridData();
        gridData.horizontalSpan = 15;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);

        /*
         * ?? ???
         */
        // ??
        label = new Label(groupInfra, SWT.NONE);
        WidgetTestUtil.setTestId(this, "priority", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_PRIORITY;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("priority"));

        // ?
        label = new Label(groupInfra, SWT.NONE);
        WidgetTestUtil.setTestId(this, "run", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_INFRA_RUN;
        gridData.horizontalAlignment = GridData.CENTER;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("notify.attribute"));

        // ID
        label = new Label(groupInfra, SWT.NONE);
        WidgetTestUtil.setTestId(this, "infraid", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_INFRA_ID;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("infra.management.id"));

        // 
        label = new Label(groupInfra, SWT.NONE);
        WidgetTestUtil.setTestId(this, "failurecallvalue", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_FAILURE_PRIORITY;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("failure.call.value"));

        //  ??
        label = this.getLabelPriority(groupInfra, Messages.getString("info"), PriorityColorConstant.COLOR_INFO);
        this.m_checkInfraRunInfo = this.getCheckInfraRun(groupInfra);
        WidgetTestUtil.setTestId(this, "infraruninfo", m_checkInfraRunInfo);
        this.m_comboInfraIdInfo = this.getComboInfraId(groupInfra);
        WidgetTestUtil.setTestId(this, "infraidinfo", m_comboInfraIdInfo);
        this.m_comboFailurePriorityInfo = this.getComboPriority(groupInfra);
        WidgetTestUtil.setTestId(this, "failurepriority", m_comboFailurePriorityInfo);
        this.m_checkInfraRunInfo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkInfraRunInfo.getSelection(), m_comboInfraIdInfo, m_comboFailurePriorityInfo);
                update();
            }
        });
        this.m_comboInfraIdInfo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                update();
            }
        });
        setEnabled(false, m_comboInfraIdInfo, m_comboFailurePriorityInfo);

        //  ??
        label = this.getLabelPriority(groupInfra, Messages.getString("warning"),
                PriorityColorConstant.COLOR_WARNING);
        this.m_checkInfraRunWarning = this.getCheckInfraRun(groupInfra);
        WidgetTestUtil.setTestId(this, "infrarunwarning", m_checkInfraRunWarning);
        this.m_comboInfraIdWarning = this.getComboInfraId(groupInfra);
        WidgetTestUtil.setTestId(this, "infraidwarnitng", m_comboInfraIdWarning);
        this.m_comboFailurePriorityWarning = this.getComboPriority(groupInfra);
        WidgetTestUtil.setTestId(this, "failureprioritywarning", m_comboFailurePriorityWarning);
        this.m_checkInfraRunWarning.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkInfraRunWarning.getSelection(), m_comboInfraIdWarning,
                        m_comboFailurePriorityWarning);
                update();
            }
        });
        this.m_comboInfraIdWarning.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                update();
            }
        });
        setEnabled(false, m_comboInfraIdWarning, m_comboFailurePriorityWarning);

        //  ???
        label = this.getLabelPriority(groupInfra, Messages.getString("critical"),
                PriorityColorConstant.COLOR_CRITICAL);
        this.m_checkInfraRunCritical = this.getCheckInfraRun(groupInfra);
        WidgetTestUtil.setTestId(this, "criticalcheck", m_checkInfraRunCritical);
        this.m_comboInfraIdCritical = this.getComboInfraId(groupInfra);
        WidgetTestUtil.setTestId(this, "infraidcritical", m_comboInfraIdCritical);
        this.m_comboFailurePriorityCritical = this.getComboPriority(groupInfra);
        WidgetTestUtil.setTestId(this, "failureprioritycritical", m_comboFailurePriorityCritical);
        this.m_checkInfraRunCritical.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkInfraRunCritical.getSelection(), m_comboInfraIdCritical,
                        m_comboFailurePriorityCritical);
                update();
            }
        });
        this.m_comboInfraIdCritical.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                update();
            }
        });
        setEnabled(false, m_comboInfraIdCritical, m_comboFailurePriorityCritical);

        //  ???
        label = this.getLabelPriority(groupInfra, Messages.getString("unknown"),
                PriorityColorConstant.COLOR_UNKNOWN);
        this.m_checkInfraRunUnknown = this.getCheckInfraRun(groupInfra);
        WidgetTestUtil.setTestId(this, "infrarununknown", m_checkInfraRunUnknown);
        this.m_comboInfraIdUnknown = this.getComboInfraId(groupInfra);
        WidgetTestUtil.setTestId(this, "infraidunknown", m_comboInfraIdUnknown);
        this.m_comboFailurePriorityUnknown = this.getComboPriority(groupInfra);
        WidgetTestUtil.setTestId(this, "failurepriorityunknown", m_comboFailurePriorityUnknown);
        this.m_checkInfraRunUnknown.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkInfraRunUnknown.getSelection(), m_comboInfraIdUnknown,
                        m_comboFailurePriorityUnknown);
                update();
            }
        });
        this.m_comboInfraIdUnknown.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                update();
            }
        });
        setEnabled(false, m_comboInfraIdUnknown, m_comboFailurePriorityUnknown);

        if (!this.updateFlg) {
            // ???????
            getComboManagerName().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    String managerNames = getComboManagerName().getText();
                    managerName = managerNames;
                    refreshComboInfraId();
                    update();
                }
            });

            // ID??????
            getComboOwnerRoleId().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    refreshComboInfraId();
                    update();
                }
            });
        }
    }

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

        // 
        if (this.m_radioFixedValue.getSelection() && "".equals(this.m_textScope.getText())) {
            this.m_textScope.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_textScope.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }

        // 
        if (this.m_checkInfraRunInfo.getSelection() && "".equals(this.m_comboInfraIdInfo.getText())) {
            this.m_comboInfraIdInfo.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_comboInfraIdInfo.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        // 
        if (this.m_checkInfraRunWarning.getSelection() && "".equals(this.m_comboInfraIdWarning.getText())) {
            this.m_comboInfraIdWarning.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_comboInfraIdWarning.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        // ?
        if (this.m_checkInfraRunCritical.getSelection() && "".equals(this.m_comboInfraIdCritical.getText())) {
            this.m_comboInfraIdCritical.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_comboInfraIdCritical.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        // ?
        if (this.m_checkInfraRunUnknown.getSelection() && "".equals(this.m_comboInfraIdUnknown.getText())) {
            this.m_comboInfraIdUnknown.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_comboInfraIdUnknown.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
    }

    /**
     * ???????
     *
     * @return 
     */
    @Override
    public NotifyInfo getInputData() {
        return this.inputData;
    }

    /**
     * ??????????
     *
     * @param notify ????
     */
    @Override
    protected void setInputData(NotifyInfo notify) {
        super.setInputData(notify);

        // ID???
        refreshComboInfraId();

        // 
        NotifyInfraInfo info = notify.getNotifyInfraInfo();
        if (info != null) {
            this.setInputDatal(info);
        } else {
            // ???
            this.m_radioGenerationNodeValue.setSelection(true);
            this.m_scopeSelect.setEnabled(false);
        }
        update();
    }

    private void setInputDatal(NotifyInfraInfo infra) {
        if (infra.getInfraExecFacility() != null) {
            this.m_facilityId = infra.getInfraExecFacility();
            this.m_textScope.setText(HinemosMessage.replace(infra.getInfraExecScope()));
        }
        if (infra.getInfraExecFacilityFlg() != null
                && infra.getInfraExecFacilityFlg() == ExecFacilityConstant.TYPE_GENERATION) {
            this.m_radioGenerationNodeValue.setSelection(true);
            this.m_scopeSelect.setEnabled(false);
        } else {
            this.m_radioFixedValue.setSelection(true);
            this.m_scopeSelect.setEnabled(true);
        }

        Boolean[] validFlgs = getValidFlgs(infra);
        Button[] checkInfraRuns = new Button[] { this.m_checkInfraRunInfo, this.m_checkInfraRunWarning,
                this.m_checkInfraRunCritical, this.m_checkInfraRunUnknown };
        String[] infraIds = new String[] { infra.getInfoInfraId(), infra.getWarnInfraId(),
                infra.getCriticalInfraId(), infra.getUnknownInfraId() };
        Combo[] comboInfraIds = new Combo[] { this.m_comboInfraIdInfo, this.m_comboInfraIdWarning,
                this.m_comboInfraIdCritical, this.m_comboInfraIdUnknown };
        Integer[] infraFailurePriorities = new Integer[] { infra.getInfoInfraFailurePriority(),
                infra.getWarnInfraFailurePriority(), infra.getCriticalInfraFailurePriority(),
                infra.getUnknownInfraFailurePriority() };
        Combo[] comboFailurePriorities = new Combo[] { this.m_comboFailurePriorityInfo,
                this.m_comboFailurePriorityWarning, this.m_comboFailurePriorityCritical,
                this.m_comboFailurePriorityUnknown };

        for (int i = 0; i < validFlgs.length; i++) {
            boolean valid = validFlgs[i].booleanValue();
            checkInfraRuns[i].setSelection(valid);
            WidgetTestUtil.setTestId(this, "checkInfraRuns" + i, checkInfraRuns[i]);

            // ID
            if (infraIds[i] != null) {
                setInfraId(comboInfraIds[i], infraIds[i]);
                WidgetTestUtil.setTestId(this, "textInfraIds" + i, comboInfraIds[i]);
            }

            // ???
            if (infraFailurePriorities[i] != null) {
                comboFailurePriorities[i].setText(PriorityMessage.typeToString(infraFailurePriorities[i]));
                WidgetTestUtil.setTestId(this, "comboFailurePriorities" + i, comboFailurePriorities[i]);
            }

            setEnabled(valid, comboInfraIds[i], comboFailurePriorities[i]);
        }
    }

    /**
     * ??????????
     *
     * @param info ????
     * @param checkInfraRun ?
     * @param textInfraId ID
     * @param checkInhibition ?
     * @param comboFailurePriority ???
     */
    protected void setInputDataForInfra(NotifyInfraInfo info, Button checkInfraRun, Text textInfraunitId,
            Text textInfraId, Combo comboFailurePriority) {
    }

    /**
     * ?????<BR>
     * ???????<code>null</code>???
     *
     * @return 
     *
     * @see #createInputDataForInfra(ArrayList, int, Button, Text, Button, Combo)
     */
    @Override
    protected NotifyInfo createInputData() {
        NotifyInfo info = super.createInputData();

        // ?
        info.setNotifyType(TYPE_INFRA);

        // 
        NotifyInfraInfo notifyInfraInfo = createNotifyInfoDetail();
        info.setNotifyInfraInfo(notifyInfraInfo);
        return info;
    }

    private NotifyInfraInfo createNotifyInfoDetail() {
        // 
        NotifyInfraInfo infra = new NotifyInfraInfo();

        //
        infra.setInfoValidFlg(m_checkInfraRunInfo.getSelection());
        infra.setWarnValidFlg(m_checkInfraRunWarning.getSelection());
        infra.setCriticalValidFlg(m_checkInfraRunCritical.getSelection());
        infra.setUnknownValidFlg(m_checkInfraRunUnknown.getSelection());

        // infraId
        if (isNotNullAndBlank(m_comboInfraIdInfo.getText())) {
            infra.setInfoInfraId(getInfraId(m_comboInfraIdInfo));
        }
        if (isNotNullAndBlank(m_comboInfraIdWarning.getText())) {
            infra.setWarnInfraId(getInfraId(m_comboInfraIdWarning));
        }
        if (isNotNullAndBlank(m_comboInfraIdCritical.getText())) {
            infra.setCriticalInfraId(getInfraId(m_comboInfraIdCritical));
        }
        if (isNotNullAndBlank(m_comboInfraIdUnknown.getText())) {
            infra.setUnknownInfraId(getInfraId(m_comboInfraIdUnknown));
        }

        // 
        if (isNotNullAndBlank(m_comboFailurePriorityInfo.getText())) {
            infra.setInfoInfraFailurePriority(PriorityMessage.stringToType(m_comboFailurePriorityInfo.getText()));
        }
        if (isNotNullAndBlank(m_comboFailurePriorityWarning.getText())) {
            infra.setWarnInfraFailurePriority(
                    PriorityMessage.stringToType(m_comboFailurePriorityWarning.getText()));
        }
        if (isNotNullAndBlank(m_comboFailurePriorityCritical.getText())) {
            infra.setCriticalInfraFailurePriority(
                    PriorityMessage.stringToType(m_comboFailurePriorityCritical.getText()));
        }
        if (isNotNullAndBlank(m_comboFailurePriorityUnknown.getText())) {
            infra.setUnknownInfraFailurePriority(
                    PriorityMessage.stringToType(m_comboFailurePriorityUnknown.getText()));
        }

        // 
        // ID
        if (isNotNullAndBlank(this.m_textScope.getText())) {
            infra.setInfraExecFacility(this.m_facilityId);
            infra.setInfraExecScope(this.m_textScope.getText());
        }
        // 
        if (this.m_radioGenerationNodeValue.getSelection()) {
            infra.setInfraExecFacilityFlg(ExecFacilityConstant.TYPE_GENERATION);
        } else if (this.m_radioFixedValue.getSelection()) {
            infra.setInfraExecFacilityFlg(ExecFacilityConstant.TYPE_FIX);
        }

        return infra;
    }

    /**
     * ????
     *
     * @return ?
     */
    @Override
    protected ValidateResult validate() {
        // ?
        this.inputData = this.createInputData();

        return super.validate();
    }

    /**
     * ?????
     *
     * @return true?false
     *
     * @see com.clustercontrol.dialog.CommonDialog#action()
     */
    @Override
    protected boolean action() {
        boolean result = false;

        NotifyInfo info = this.getInputData();
        if (info != null) {
            if (!this.updateFlg) {
                // ???
                result = new AddNotify().add(this.getInputManagerName(), info);
            } else {
                // ??
                result = new ModifyNotify().modify(this.getInputManagerName(), info);
            }
        }

        return result;
    }

    /**
     * ????
     *
     * @return ?
     */
    @Override
    protected String getOkButtonText() {
        return Messages.getString("ok");
    }

    /**
     * ????
     *
     * @return ?
     */
    @Override
    protected String getCancelButtonText() {
        return Messages.getString("cancel");
    }

    /**
     * ?????
     *
     * @param id ID
     * @param message 
     */
    @Override
    protected void setValidateResult(String id, String message) {

        this.validateResult = new ValidateResult();
        this.validateResult.setValid(false);
        this.validateResult.setID(id);
        this.validateResult.setMessage(message);
    }

    /**
     * ????<BR>
     * ??<code> true </code>???????<code> false </code>?????????
     *
     * @param parent ??
     *
     * @see #createButtonsForButtonBar(Composite)
     */
    @Override
    protected void createButtonsForButtonBar(Composite parent) {

        if (!this.referenceFlg) {
            super.createButtonsForButtonBar(parent);
        } else {
            // ?
            // TODO Remove the following hard-code. IDialogConstants.*_LABEL will causes IncompatibleClassChangeError on RAP
            this.createButton(parent, IDialogConstants.CANCEL_ID, "Close", false);
        }
    }

    /**
     * ????/?????
     *
     * @param enable ?????<code> true </code>
     */
    @Override
    protected void setEnabled(boolean enable) {
        super.m_notifyBasic.setEnabled(enable);
        super.m_notifyInhibition.setEnabled(enable);
    }

    private void setEnabled(boolean enable, Combo comboInfraId, Combo comboFailurePriority) {
        comboInfraId.setEnabled(enable);
        comboFailurePriority.setEnabled(enable);
    }

    /**
     * ??????
     *
     * @param parent ??
     * @param text ??
     * @param background ?
     * @return ???
     */
    private Label getLabelPriority(Composite parent, String text, Color background) {

        // ??
        Label label = new Label(parent, SWT.NONE);
        WidgetTestUtil.setTestId(this, "labelpriority", label);
        GridData gridData = new GridData();
        gridData.horizontalSpan = WIDTH_PRIORITY;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(text + " : ");
        label.setBackground(background);

        return label;
    }

    /**
     * ?????
     *
     * @param parent ??
     * @return ????
     */
    private Button getCheckInfraRun(Composite parent) {

        // ?
        Button button = new Button(parent, SWT.CHECK);
        WidgetTestUtil.setTestId(this, null, button);
        GridData gridData = new GridData();
        gridData.horizontalSpan = WIDTH_INFRA_RUN;
        gridData.horizontalAlignment = GridData.CENTER;
        gridData.grabExcessHorizontalSpace = true;
        button.setLayoutData(gridData);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                update();
            }
        });

        return button;
    }

    private String putMap(String infraId, String infraName) {
        String disp = null;
        if (infraId.length() == 0) {
            disp = "";
        } else {
            int maxLength = 32;
            if (maxLength < infraName.length()) {
                infraName = infraName.substring(0, maxLength) + "...";
            }
            disp = infraName + "(" + infraId + ")";
        }
        dispMap.put(infraId, disp);
        m_comboInfraIdInfo.add(disp);
        m_comboInfraIdWarning.add(disp);
        m_comboInfraIdCritical.add(disp);
        m_comboInfraIdUnknown.add(disp);
        return disp;
    }

    /** 
     * ID????
     * 
     * ???????ID??????????
     * @param comboInfraId
     */
    private void refreshComboInfraId() {
        dispMap.clear();
        m_comboInfraIdInfo.removeAll();
        m_comboInfraIdWarning.removeAll();
        m_comboInfraIdCritical.removeAll();
        m_comboInfraIdUnknown.removeAll();

        try {
            InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName);
            m_infraList = wrapper.getInfraManagementListByOwnerRole(getOwnerRoleId());
        } catch (Exception e) {
            MessageDialog.openError(getShell(), MessageConstant.MESSAGE.getMessage(), e.getMessage());
            return;
        }

        putMap("", "");

        for (InfraManagementInfo infra : m_infraList) {
            putMap(infra.getManagementId(), infra.getName());
        }
    }

    private String getInfraId(Combo comboInfraId) {
        String selectedText = comboInfraId.getText();
        if (selectedText == null || selectedText.isEmpty()) {
            return "";
        }
        for (Map.Entry<String, String> tmpId : dispMap.entrySet()) {
            if (tmpId.getValue().equals(selectedText)) {
                return tmpId.getKey();
            }
        }
        return null;
    }

    private void setInfraId(Combo comboInfraId, String infraManagementId) {
        if (infraManagementId == null) {
            return;
        }
        // ??????????(setText)???????
        // ????
        if (!dispMap.keySet().contains(infraManagementId)) {
            // ???????????????
            // ????????ID??????
            putMap(infraManagementId, "");
        }

        // ??
        comboInfraId.setText(dispMap.get(infraManagementId));
    }

    /**
     * ID???
     *
     * @param parent ??
     * @return ????
     */
    private Combo getComboInfraId(Composite parent) {
        // ID
        Combo notifyInfraCreateInfraIdCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
        WidgetTestUtil.setTestId(this, "infra", notifyInfraCreateInfraIdCombo);
        GridData gridData = new GridData();
        gridData.horizontalSpan = WIDTH_INFRA_ID;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        notifyInfraCreateInfraIdCombo.setLayoutData(gridData);

        return notifyInfraCreateInfraIdCombo;
    }

    /**
     * ???????
     *
     * @param parent ??
     * @param horizontalSpan ?
     * @return 
     */
    private Combo getComboPriority(Composite parent) {
        Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
        WidgetTestUtil.setTestId(this, null, combo);
        GridData gridData = new GridData();
        gridData.horizontalSpan = WIDTH_FAILURE_PRIORITY;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        combo.setLayoutData(gridData);
        combo.add(PriorityMessage.STRING_CRITICAL);
        combo.add(PriorityMessage.STRING_WARNING);
        combo.add(PriorityMessage.STRING_INFO);
        combo.add(PriorityMessage.STRING_UNKNOWN);
        combo.setText(PriorityMessage.STRING_UNKNOWN);

        return combo;
    }

    @Override
    public void setOwnerRoleId(String ownerRoleId) {
        super.setOwnerRoleId(ownerRoleId);
        this.m_facilityPath = "";
        this.m_facilityId = "";
        this.m_textScope.setText(HinemosMessage.replace(m_facilityPath));

        refreshComboInfraId();
    }

}