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

Java tutorial

Introduction

Here is the source code for com.clustercontrol.notify.dialog.NotifyCommandCreateDialog.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 org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
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.bean.PriorityColorConstant;
import com.clustercontrol.bean.RequiredFieldColorConstant;
import com.clustercontrol.composite.TextWithParameterComposite;
import com.clustercontrol.dialog.ValidateResult;
import com.clustercontrol.notify.action.AddNotify;
import com.clustercontrol.notify.action.GetNotify;
import com.clustercontrol.notify.action.ModifyNotify;
import com.clustercontrol.util.Messages;
import com.clustercontrol.util.WidgetTestUtil;
import com.clustercontrol.ws.notify.NotifyCommandInfo;
import com.clustercontrol.ws.notify.NotifyInfo;

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

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

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

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

    /**  */
    private static final int WIDTH_COMMAND_TEXT = 9;

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

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

    /**
     * 
     *
     * @see com.clustercontrol.bean.NotifyTypeConstant
     */
    private static final int TYPE_COMMAND = 5;

    /** command*/
    public static final int TIMEOUT_SEC_COMMAND = 15000;

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

    /** ?? ? */
    private Button m_checkExecInfo = null;
    /** ?? ? */
    private Button m_checkExecWarning = null;
    /** ??? ? */
    private Button m_checkExecCritical = null;
    /** ??? ? */
    private Button m_checkExecUnknown = null;

    /** ??  */
    private Text m_textUserInfo = null;
    /** ??  */
    private Text m_textUserWarning = null;
    /** ???  */
    private Text m_textUserCritical = null;
    /** ???  */
    private Text m_textUserUnknown = null;

    /** ??  */
    private TextWithParameterComposite m_textCommandInfo = null;
    /** ??  */
    private TextWithParameterComposite m_textCommandWarning = null;
    /** ???  */
    private TextWithParameterComposite m_textCommandCritical = null;
    /** ???  */
    private TextWithParameterComposite m_textCommandUnknown = null;

    /**  */
    private Text m_textTimeout = null;

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

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

    /**
     * ????
     *
     * @param parent
     *            ?
     * @param managerName
     *            ???
     * @param notifyId
     *            ??ID
     * @param updateFlg
     *            true:?
     */
    public NotifyCommandCreateDialog(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.command.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 groupComamnd = new Group(parent, SWT.NONE);
        WidgetTestUtil.setTestId(this, "command", groupComamnd);
        layout = new GridLayout(1, true);
        layout.marginWidth = 5;
        layout.marginHeight = 5;
        layout.numColumns = 15;
        groupComamnd.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalSpan = 15;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        groupComamnd.setLayoutData(gridData);
        groupComamnd.setText(Messages.getString("notifies.command"));

        /*
         * ?? ???
         */
        // ??
        label = new Label(groupComamnd, 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(groupComamnd, SWT.NONE);
        WidgetTestUtil.setTestId(this, "notifyattribute", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_CHECK;
        gridData.horizontalAlignment = GridData.CENTER;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("notify.attribute"));

        // 
        label = new Label(groupComamnd, SWT.NONE);
        WidgetTestUtil.setTestId(this, "effectiveuser", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_COMMAND_USER;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("effective.user"));

        // 
        label = new Label(groupComamnd, SWT.NONE);
        WidgetTestUtil.setTestId(this, "command", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_COMMAND_TEXT;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("command"));

        // ??
        label = this.getLabelPriority(groupComamnd, Messages.getString("info"), PriorityColorConstant.COLOR_INFO);
        this.m_checkExecInfo = this.getCheckBox(groupComamnd);
        WidgetTestUtil.setTestId(this, "execinfo", m_checkExecInfo);
        this.m_textUserInfo = this.getTextUser(groupComamnd);
        WidgetTestUtil.setTestId(this, "userinfo", m_textUserInfo);
        this.m_textCommandInfo = this.getTextCommand(groupComamnd);
        WidgetTestUtil.setTestId(this, "commandinfo", m_textCommandInfo);
        this.m_checkExecInfo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkExecInfo.getSelection(), m_textUserInfo, m_textCommandInfo);
                update();
            }
        });
        setEnabled(false, m_textUserInfo, m_textCommandInfo);

        // ??
        label = this.getLabelPriority(groupComamnd, Messages.getString("warning"),
                PriorityColorConstant.COLOR_WARNING);
        this.m_checkExecWarning = this.getCheckBox(groupComamnd);
        WidgetTestUtil.setTestId(this, "execwarning", m_checkExecWarning);
        this.m_textUserWarning = this.getTextUser(groupComamnd);
        WidgetTestUtil.setTestId(this, "userwarning", m_textUserWarning);
        this.m_textCommandWarning = this.getTextCommand(groupComamnd);
        WidgetTestUtil.setTestId(this, "commandwarning", m_textCommandWarning);
        this.m_checkExecWarning.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkExecWarning.getSelection(), m_textUserWarning, m_textCommandWarning);
                update();
            }
        });
        setEnabled(false, m_textUserWarning, m_textCommandWarning);

        // ???
        label = this.getLabelPriority(groupComamnd, Messages.getString("critical"),
                PriorityColorConstant.COLOR_CRITICAL);
        this.m_checkExecCritical = this.getCheckBox(groupComamnd);
        WidgetTestUtil.setTestId(this, "execcritical", m_checkExecCritical);
        this.m_textUserCritical = this.getTextUser(groupComamnd);
        WidgetTestUtil.setTestId(this, "usercritical", m_textUserCritical);
        this.m_textCommandCritical = this.getTextCommand(groupComamnd);
        WidgetTestUtil.setTestId(this, "commandcritical", m_textCommandCritical);
        this.m_checkExecCritical.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkExecCritical.getSelection(), m_textUserCritical, m_textCommandCritical);
                update();
            }
        });
        setEnabled(false, m_textUserCritical, m_textCommandCritical);

        // ???
        label = this.getLabelPriority(groupComamnd, Messages.getString("unknown"),
                PriorityColorConstant.COLOR_UNKNOWN);
        this.m_checkExecUnknown = this.getCheckBox(groupComamnd);
        WidgetTestUtil.setTestId(this, "execunknown", m_checkExecUnknown);
        this.m_textUserUnknown = this.getTextUser(groupComamnd);
        WidgetTestUtil.setTestId(this, "userunknown", m_textUserUnknown);
        this.m_textCommandUnknown = this.getTextCommand(groupComamnd);
        WidgetTestUtil.setTestId(this, "commandunknown", m_textCommandUnknown);
        this.m_checkExecUnknown.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setEnabled(m_checkExecUnknown.getSelection(), m_textUserUnknown, m_textCommandUnknown);
                update();
            }
        });
        setEnabled(false, m_textUserUnknown, m_textCommandUnknown);

        /*
         * 
         */
        // 
        label = new Label(groupComamnd, SWT.NONE);
        WidgetTestUtil.setTestId(this, "timeout", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_TIME_OUT;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("time.out") + " : ");

        // 
        this.m_textTimeout = new Text(groupComamnd, SWT.BORDER);
        WidgetTestUtil.setTestId(this, "timeout", m_textTimeout);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_TIME_OUT;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        this.m_textTimeout.setLayoutData(gridData);
        this.m_textTimeout.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });

        // ??
        label = new Label(groupComamnd, SWT.NONE);
        WidgetTestUtil.setTestId(this, "millisec", label);
        gridData = new GridData();
        gridData.horizontalSpan = WIDTH_TIME_OUT;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
        label.setText(Messages.getString("milli.sec"));
    }

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

        // 
        if (this.m_checkExecInfo.getSelection()) {
            // 
            if ("".equals(this.m_textUserInfo.getText())) {
                this.m_textUserInfo.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textUserInfo.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
            // 
            if ("".equals(this.m_textCommandInfo.getText())) {
                this.m_textCommandInfo.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textCommandInfo.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
        } else {
            // ??setEnabled?????????????
            this.m_textUserInfo.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }

        // 
        if (this.m_checkExecWarning.getSelection()) {
            // 
            if ("".equals(this.m_textUserWarning.getText())) {
                this.m_textUserWarning.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textUserWarning.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
            // 
            if ("".equals(this.m_textCommandWarning.getText())) {
                this.m_textCommandWarning.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textCommandWarning.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
        } else {
            this.m_textUserWarning.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }

        // ?
        if (this.m_checkExecCritical.getSelection()) {
            // 
            if ("".equals(this.m_textUserCritical.getText())) {
                this.m_textUserCritical.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textUserCritical.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
            // 
            if ("".equals(this.m_textCommandCritical.getText())) {
                this.m_textCommandCritical.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textCommandCritical.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
        } else {
            this.m_textUserCritical.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }

        // ?
        if (m_checkExecUnknown.getSelection()) {
            // 
            if ("".equals(this.m_textUserUnknown.getText())) {
                this.m_textUserUnknown.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textUserUnknown.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
            // 
            if ("".equals(this.m_textCommandUnknown.getText())) {
                this.m_textCommandUnknown.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
            } else {
                this.m_textCommandUnknown.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
            }
        } else {
            this.m_textUserUnknown.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }

        // 
        if ("".equals(this.m_textTimeout.getText())) {
            this.m_textTimeout.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_textTimeout.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
    }

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

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

        // 
        NotifyCommandInfo info = notify.getNotifyCommandInfo();
        if (info != null) {
            this.setInputData(info);
        } else {
            // 
            this.m_textTimeout.setText(Integer.toString(TIMEOUT_SEC_COMMAND));
        }

        // ?
        this.update();
    }

    /**
     * ??????????
     *
     * @param info
     *            ????
     */
    private void setInputData(NotifyCommandInfo info) {
        Button[] checkExecs = getCheckExecs();
        Text[] textUsers = getTextUsers();
        TextWithParameterComposite[] textCommands = getTextCommands();

        String[] effectiveUsers = new String[] { info.getInfoEffectiveUser(), info.getWarnEffectiveUser(),
                info.getCriticalEffectiveUser(), info.getUnknownEffectiveUser() };
        String[] commands = new String[] { info.getInfoCommand(), info.getWarnCommand(), info.getCriticalCommand(),
                info.getUnknownCommand() };

        Boolean[] validFlgs = getValidFlgs(info);
        for (int i = 0; i < validFlgs.length; i++) {
            boolean valid = validFlgs[i].booleanValue();
            checkExecs[i].setSelection(valid);
            setEnabled(valid, textUsers[i], textCommands[i]);
            WidgetTestUtil.setTestId(this, "textusers" + i, textUsers[i]);
            if (effectiveUsers[i] != null) {
                textUsers[i].setText(effectiveUsers[i]);
            }
            if (commands[i] != null) {
                textCommands[i].setText(commands[i]);
            }
        }
        this.m_textTimeout.setText(Integer.toString(info.getTimeout()));
    }

    private TextWithParameterComposite[] getTextCommands() {
        TextWithParameterComposite[] textCommands = new TextWithParameterComposite[] { this.m_textCommandInfo,
                this.m_textCommandWarning, this.m_textCommandCritical, this.m_textCommandUnknown };
        return textCommands;
    }

    private Text[] getTextUsers() {
        Text[] textUsers = new Text[] { this.m_textUserInfo, this.m_textUserWarning, this.m_textUserCritical,
                this.m_textUserUnknown };
        return textUsers;
    }

    private Button[] getCheckExecs() {
        Button[] checkExecs = new Button[] { this.m_checkExecInfo, this.m_checkExecWarning,
                this.m_checkExecCritical, this.m_checkExecUnknown };
        return checkExecs;
    }

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

        // ?
        info.setNotifyType(TYPE_COMMAND);

        // 
        NotifyCommandInfo notifyCommandInfo = this.createNotifyInfoDetail();
        if (notifyCommandInfo != null) {
            info.setNotifyCommandInfo(notifyCommandInfo);
        } else {
            return null;
        }

        return info;
    }

    /**
     * ?????<BR>
     * ???????<code>null</code>???
     *
     * @return 
     *
     */
    private NotifyCommandInfo createNotifyInfoDetail() {
        NotifyCommandInfo command = new NotifyCommandInfo();
        // ????????
        command.setSetEnvironment(true);

        // ?
        command.setInfoValidFlg(m_checkExecInfo.getSelection());
        command.setWarnValidFlg(m_checkExecWarning.getSelection());
        command.setCriticalValidFlg(m_checkExecCritical.getSelection());
        command.setUnknownValidFlg(m_checkExecUnknown.getSelection());

        // 
        if (isNotNullAndBlank(m_textUserInfo.getText())) {
            command.setInfoEffectiveUser(m_textUserInfo.getText());
        }
        if (isNotNullAndBlank(m_textUserWarning.getText())) {
            command.setWarnEffectiveUser(m_textUserWarning.getText());
        }
        if (isNotNullAndBlank(m_textUserCritical.getText())) {
            command.setCriticalEffectiveUser(m_textUserCritical.getText());
        }
        if (isNotNullAndBlank(m_textUserUnknown.getText())) {
            command.setUnknownEffectiveUser(m_textUserUnknown.getText());
        }

        // 
        if (isNotNullAndBlank(m_textCommandInfo.getText())) {
            command.setInfoCommand(m_textCommandInfo.getText());
        }
        if (isNotNullAndBlank(m_textCommandWarning.getText())) {
            command.setWarnCommand(m_textCommandWarning.getText());
        }
        if (isNotNullAndBlank(m_textCommandCritical.getText())) {
            command.setCriticalCommand(m_textCommandCritical.getText());
        }
        if (isNotNullAndBlank(m_textCommandUnknown.getText())) {
            command.setUnknownCommand(m_textCommandUnknown.getText());
        }

        // 
        try {
            command.setTimeout(Integer.parseInt(m_textTimeout.getText()));
        } catch (NumberFormatException e) {
            this.setValidateResult(Messages.getString("message.hinemos.1"),
                    Messages.getString("message.monitor.custom.msg.timeout.invalid"));
            return null;
        }

        return command;
    }

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

        if (this.inputData != null) {
            return super.validate();
        } else {
            return validateResult;
        }
    }

    /**
     * ?????
     *
     * @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 enable
     *            ?????<code> true </code>
     */
    @Override
    protected void setEnabled(boolean enable) {

        super.m_notifyBasic.setEnabled(enable);
        super.m_notifyInhibition.setEnabled(enable);

        this.setEnabledDetails(enable);
    }

    /**
     * ?????/?????
     *
     * @param enable
     *            ?????<code> true </code>
     *
     * @see #setEnabledDetail(boolean, Button, Text, Button)
     */
    protected void setEnabledDetails(boolean enable) {

        // 
        this.setEnabledDetail(enable, this.m_checkExecInfo, this.m_textUserInfo, this.m_textCommandInfo);
        this.setEnabledDetail(enable, this.m_checkExecWarning, this.m_textUserWarning, this.m_textCommandWarning);
        this.setEnabledDetail(enable, this.m_checkExecCritical, this.m_textUserCritical,
                this.m_textCommandCritical);
        this.setEnabledDetail(enable, this.m_checkExecUnknown, this.m_textUserUnknown, this.m_textCommandUnknown);
    }

    /**
     * ?????/?????
     *
     * @param enable
     *            ?????<code> true </code>
     * @param checkBox
     *            ?
     * @param textCommand
     *            
     * @param checkExecInhibition
     *            ?
     */
    protected void setEnabledDetail(boolean enable, Button checkBox, Text textUser,
            TextWithParameterComposite textCommand) {

        if (enable) {
            checkBox.setEnabled(true);

            textUser.setEnabled(checkBox.getSelection());
            textCommand.setEnabled(checkBox.getSelection());

        } else {
            checkBox.setEnabled(false);

            textUser.setEnabled(false);
            textCommand.setEnabled(false);

        }
    }

    /**
     * ???????/?????
     *
     * @param enabled
     *            ?????</code> true </code>
     * @param textCommand
     *            ?
     * @param checkInhibitionFlg
     *            ??
     */
    private void setEnabled(boolean enabled, Text textUser, TextWithParameterComposite textCommand) {
        textUser.setEnabled(enabled);
        textCommand.setEnabled(enabled);
    }

    /**
     * ?????
     *
     * @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 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 getCheckBox(Composite parent) {
        // ?
        Button button = new Button(parent, SWT.CHECK);
        GridData gridData = new GridData();
        gridData.horizontalSpan = WIDTH_CHECK;
        gridData.horizontalAlignment = GridData.CENTER;
        gridData.grabExcessHorizontalSpace = true;
        button.setLayoutData(gridData);

        return button;
    }

    /**
     * ???? ?????????????
     *
     * @param parent
     *            ?
     * @return ???
     */
    private Text getTextUser(Composite parent) {
        // 
        Text text = new Text(parent, SWT.BORDER);
        WidgetTestUtil.setTestId(this, null, text);
        GridData gridData = new GridData();
        gridData.horizontalSpan = WIDTH_COMMAND_USER;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        text.setLayoutData(gridData);
        text.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });

        return text;
    }

    /**
     * ???? ?????????????
     *
     * @param parent
     *            ?
     * @return ???
     */
    private TextWithParameterComposite getTextCommand(Composite parent) {

        // 
        TextWithParameterComposite notifyCmdCreateTooltipTextWithParamComposite = new TextWithParameterComposite(
                parent, SWT.BORDER | SWT.SINGLE);
        GridData gridData = new GridData();
        gridData.horizontalSpan = WIDTH_COMMAND_TEXT;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        notifyCmdCreateTooltipTextWithParamComposite.setLayoutData(gridData);

        notifyCmdCreateTooltipTextWithParamComposite.setToolTipText(Messages.getString("notify.parameter.tooltip"));
        notifyCmdCreateTooltipTextWithParamComposite.setColor(new Color(parent.getDisplay(), new RGB(0, 0, 255)));
        notifyCmdCreateTooltipTextWithParamComposite.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });

        return notifyCmdCreateTooltipTextWithParamComposite;
    }
}