com.clustercontrol.jobmanagement.dialog.JobKickDialog.java Source code

Java tutorial

Introduction

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
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.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;

import com.clustercontrol.bean.DataRangeConstant;
import com.clustercontrol.bean.Property;
import com.clustercontrol.bean.PropertyDefineConstant;
import com.clustercontrol.bean.RequiredFieldColorConstant;
import com.clustercontrol.bean.ScheduleConstant;
import com.clustercontrol.bean.SizeConstant;
import com.clustercontrol.bean.ValidMessage;
import com.clustercontrol.calendar.composite.CalendarIdListComposite;
import com.clustercontrol.composite.ManagerListComposite;
import com.clustercontrol.composite.RoleIdListComposite;
import com.clustercontrol.composite.RoleIdListComposite.Mode;
import com.clustercontrol.composite.action.StringVerifyListener;
import com.clustercontrol.dialog.CommonDialog;
import com.clustercontrol.dialog.ValidateResult;
import com.clustercontrol.jobmanagement.action.GetJobKick;
import com.clustercontrol.jobmanagement.bean.JobConstant;
import com.clustercontrol.jobmanagement.bean.JobKickConstant;
import com.clustercontrol.jobmanagement.composite.JobKickFileCheckComposite;
import com.clustercontrol.jobmanagement.composite.JobKickParamComposite;
import com.clustercontrol.jobmanagement.composite.JobKickScheduleComposite;
import com.clustercontrol.jobmanagement.util.JobDialogUtil;
import com.clustercontrol.jobmanagement.util.JobEndpointWrapper;
import com.clustercontrol.util.HinemosMessage;
import com.clustercontrol.util.Messages;
import com.clustercontrol.util.WidgetTestUtil;
import com.clustercontrol.ws.jobmanagement.InvalidRole_Exception;
import com.clustercontrol.ws.jobmanagement.InvalidSetting_Exception;
import com.clustercontrol.ws.jobmanagement.InvalidUserPass_Exception;
import com.clustercontrol.ws.jobmanagement.JobFileCheck;
import com.clustercontrol.ws.jobmanagement.JobKick;
import com.clustercontrol.ws.jobmanagement.JobKickDuplicate_Exception;
import com.clustercontrol.ws.jobmanagement.JobSchedule;
import com.clustercontrol.ws.jobmanagement.JobTreeItem;

/**
 * [??]??
 *
 * @version 5.1.0
 */
public class JobKickDialog extends CommonDialog {

    // 
    private static Log m_log = LogFactory.getLog(JobKickDialog.class);

    /**  */
    private JobKick m_jobKick;

    /** 
     * 
     */
    /** ID */
    private Text m_txtJobKickId = null;
    /** ?? */
    private Text m_txtJobKickName = null;
    /** ID */
    private Text m_txtJobId = null;
    /** ?? */
    private Text m_txtJobName = null;
    /** ID */
    private CalendarIdListComposite m_cmpCalendarId = null;
    /** ? */
    private Button m_btnJobSelect = null;
    /**  */
    private Button m_btnValid = null;
    /**  */
    private Button m_btnInvalid = null;
    /** ID */
    private RoleIdListComposite m_cmpOwnerRoleId = null;
    /**  */
    private Shell m_shell = null;
    /** ???? */
    private ManagerListComposite m_managerComposite = null;
    /**
     * ?MODE_ADD = 0;
     * MODE_MODIFY = 1;
     * MODE_COPY = 3;
     * */
    private int m_mode = PropertyDefineConstant.MODE_ADD;

    /** ?ID */
    private String m_jobunitId = null;

    /** ID */
    private String m_jobkickId;

    /** ??? */
    private String m_managerName;

    /**  */
    private int m_jobkickType = JobKickConstant.TYPE_FILECHECK;

    /**  */
    private TabFolder m_tabFolder = null;

    /** Composite */
    private Composite m_detailComposite = null;

    /** Composite */
    private JobKickParamComposite m_jobKickParamComposite = null;

    /**
     * 
     * ?
     * @param parent
     * @param jobkickId
     */
    public JobKickDialog(Shell parent, String managerName, String jobkickId, int jobkickType, int mode) {
        super(parent);
        this.m_managerName = managerName;
        this.m_jobkickId = jobkickId;
        this.m_jobkickType = jobkickType;
        this.m_mode = mode;
    }

    /**
     * ????
     *
     * @param parent ?
     */
    @Override
    protected void customizeDialog(Composite parent) {
        this.m_shell = this.getShell();

        Label label = null;

        String title = "";
        if (this.m_jobkickType == JobKickConstant.TYPE_SCHEDULE) {
            title = Messages.getString("dialog.job.add.modify.schedule");
        } else if (this.m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
            title = Messages.getString("dialog.job.add.modify.filecheck");
        } else if (this.m_jobkickType == JobKickConstant.TYPE_MANUAL) {
            title = Messages.getString("dialog.job.add.modify.manual");
        }
        parent.getShell().setText(title);

        /**
         * 
         * ?????
         */
        RowLayout layout = new RowLayout();
        layout.type = SWT.VERTICAL;
        layout.spacing = 0;
        layout.marginWidth = 10;
        layout.marginHeight = 10;
        layout.marginBottom = 0;
        layout.fill = true;
        parent.setLayout(layout);

        // Composite
        Composite jobKickComposite = new Composite(parent, SWT.NONE);
        jobKickComposite.setLayout(new GridLayout(3, false));

        // ?
        label = new Label(jobKickComposite, SWT.LEFT);
        label.setText(Messages.getString("facility.manager") + " : ");
        label.setLayoutData(new GridData(140, SizeConstant.SIZE_LABEL_HEIGHT));

        // ?
        if (this.m_mode == PropertyDefineConstant.MODE_MODIFY) {
            this.m_managerComposite = new ManagerListComposite(jobKickComposite, SWT.NONE, false);
        } else {
            this.m_managerComposite = new ManagerListComposite(jobKickComposite, SWT.NONE, true);
        }
        WidgetTestUtil.setTestId(this, "m_managerComposite", this.m_managerComposite);
        this.m_managerComposite.setLayoutData(new GridData());
        ((GridData) this.m_managerComposite.getLayoutData()).widthHint = 227;

        if (this.m_managerName != null) {
            this.m_managerComposite.setText(this.m_managerName);
        }
        if (this.m_mode != PropertyDefineConstant.MODE_MODIFY) {
            this.m_managerComposite.getComboManagerName().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    String managerName = m_managerComposite.getText();
                    m_cmpOwnerRoleId.createRoleIdList(managerName);
                    if (m_jobkickType != JobKickConstant.TYPE_MANUAL) {
                        updateCalendarId();
                        if (m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
                            ((JobKickFileCheckComposite) m_detailComposite)
                                    .setOwnerRoleId(m_managerComposite.getText(), m_cmpOwnerRoleId.getText());
                        }
                    }
                }
            });
        }

        // dummy
        new Label(jobKickComposite, SWT.NONE);

        // ID
        label = new Label(jobKickComposite, SWT.NONE);
        label.setText(Messages.getString("jobkick.id") + " : ");
        label.setLayoutData(new GridData(140, SizeConstant.SIZE_LABEL_HEIGHT));

        // ID
        this.m_txtJobKickId = new Text(jobKickComposite, SWT.BORDER);
        WidgetTestUtil.setTestId(this, "m_txtJobKickId", this.m_txtJobKickId);
        this.m_txtJobKickId.setLayoutData(new GridData(220, SizeConstant.SIZE_TEXT_HEIGHT));
        this.m_txtJobKickId.addVerifyListener(new StringVerifyListener(DataRangeConstant.VARCHAR_64));
        this.m_txtJobKickId.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });

        // dummy
        new Label(jobKickComposite, SWT.NONE);

        // ??
        label = new Label(jobKickComposite, SWT.NONE);
        label.setText(Messages.getString("jobkick.name") + " : ");
        label.setLayoutData(new GridData(140, SizeConstant.SIZE_LABEL_HEIGHT));

        // ??
        this.m_txtJobKickName = new Text(jobKickComposite, SWT.BORDER);
        WidgetTestUtil.setTestId(this, "m_txtJobKickName", this.m_txtJobKickName);
        this.m_txtJobKickName.setLayoutData(new GridData(220, SizeConstant.SIZE_TEXT_HEIGHT));
        this.m_txtJobKickName.addVerifyListener(new StringVerifyListener(DataRangeConstant.VARCHAR_64));
        this.m_txtJobKickName.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });

        // dummy
        new Label(jobKickComposite, SWT.NONE);

        // 
        label = new Label(jobKickComposite, SWT.NONE);
        label.setText(Messages.getString("owner.role.id") + " : ");
        label.setLayoutData(new GridData(140, SizeConstant.SIZE_LABEL_HEIGHT));

        // ID
        if (this.m_mode == PropertyDefineConstant.MODE_ADD || this.m_mode == PropertyDefineConstant.MODE_COPY) {
            this.m_cmpOwnerRoleId = new RoleIdListComposite(jobKickComposite, SWT.NONE, this.m_managerName, true,
                    Mode.OWNER_ROLE);
            this.m_cmpOwnerRoleId.getComboRoleId().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (m_jobkickType != JobKickConstant.TYPE_MANUAL) {
                        m_cmpCalendarId.createCalIdCombo(m_managerName, m_cmpOwnerRoleId.getText());
                        m_txtJobId.setText("");
                        m_txtJobName.setText("");
                        setJobunitId(null);
                        // ?????
                        if (m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
                            ((JobKickFileCheckComposite) m_detailComposite)
                                    .setOwnerRoleId(m_managerComposite.getText(), m_cmpOwnerRoleId.getText());
                        }
                    }
                }
            });
        } else {
            this.m_cmpOwnerRoleId = new RoleIdListComposite(jobKickComposite, SWT.NONE, this.m_managerName, false,
                    Mode.OWNER_ROLE);
        }
        WidgetTestUtil.setTestId(this, "m_cmpOwnerRoleId", this.m_cmpOwnerRoleId);
        this.m_cmpOwnerRoleId.setLayoutData(new GridData());
        ((GridData) this.m_cmpOwnerRoleId.getLayoutData()).widthHint = 227;

        // dummy
        new Label(jobKickComposite, SWT.NONE);

        // ID
        label = new Label(jobKickComposite, SWT.LEFT);
        label.setText(Messages.getString("job.id") + " : ");
        label.setLayoutData(new GridData(140, SizeConstant.SIZE_LABEL_HEIGHT));

        // ID
        this.m_txtJobId = new Text(jobKickComposite, SWT.READ_ONLY | SWT.BORDER);
        WidgetTestUtil.setTestId(this, "m_txtJobId", this.m_txtJobId);
        this.m_txtJobId.setLayoutData(new GridData(220, SizeConstant.SIZE_TEXT_HEIGHT));
        this.m_txtJobId.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });

        //
        this.m_btnJobSelect = new Button(jobKickComposite, SWT.NONE);
        WidgetTestUtil.setTestId(this, "m_btnJobSelect", this.m_btnJobSelect);
        this.m_btnJobSelect.setText(Messages.getString("refer"));
        this.m_btnJobSelect.setLayoutData(new GridData(40, SizeConstant.SIZE_BUTTON_HEIGHT));
        this.m_btnJobSelect.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                JobTreeDialog dialog = new JobTreeDialog(m_shell, m_managerComposite.getText(),
                        m_cmpOwnerRoleId.getText(), true);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    JobTreeItem selectItem = dialog.getSelectItem().isEmpty() ? null
                            : dialog.getSelectItem().get(0);
                    if (selectItem != null && selectItem.getData().getType() != JobConstant.TYPE_COMPOSITE) {
                        m_txtJobId.setText(selectItem.getData().getId());
                        m_txtJobName.setText(selectItem.getData().getName());
                        setJobunitId(selectItem.getData().getJobunitId());
                    } else {
                        m_txtJobId.setText("");
                        m_txtJobName.setText("");
                        setJobunitId(null);
                    }
                }
            }
        });

        // ??
        label = new Label(jobKickComposite, SWT.LEFT);
        label.setText(Messages.getString("job.name") + " : ");
        label.setLayoutData(new GridData(140, SizeConstant.SIZE_LABEL_HEIGHT));

        // ??
        this.m_txtJobName = new Text(jobKickComposite, SWT.BORDER | SWT.READ_ONLY);
        WidgetTestUtil.setTestId(this, "txtJobName", this.m_txtJobName);
        this.m_txtJobName.setLayoutData(new GridData(220, SizeConstant.SIZE_TEXT_HEIGHT));

        // dummy
        new Label(jobKickComposite, SWT.NONE);

        if (m_jobkickType != JobKickConstant.TYPE_MANUAL) {
            // ID
            label = new Label(jobKickComposite, SWT.LEFT);
            label.setText(Messages.getString("calendar.id") + " : ");
            label.setLayoutData(new GridData(140, SizeConstant.SIZE_LABEL_HEIGHT));

            // ID
            this.m_cmpCalendarId = new CalendarIdListComposite(jobKickComposite, SWT.NONE, false);
            WidgetTestUtil.setTestId(this, "cmpCalendarId", this.m_cmpCalendarId);
            this.m_cmpCalendarId.setLayoutData(new GridData());
            ((GridData) this.m_cmpCalendarId.getLayoutData()).widthHint = 227;

            // dummy
            new Label(jobKickComposite, SWT.NONE);
        }

        // separator
        JobDialogUtil.getSeparator(parent);

        // 
        this.m_tabFolder = new TabFolder(parent, SWT.NONE);

        if (this.m_jobkickType == JobKickConstant.TYPE_SCHEDULE) {
            // 
            this.m_detailComposite = new JobKickScheduleComposite(this.m_tabFolder, SWT.NONE);
            TabItem scheduleTabItem = new TabItem(this.m_tabFolder, SWT.NONE);
            WidgetTestUtil.setTestId(this, "scheduleTabItem", scheduleTabItem);
            scheduleTabItem.setText(Messages.getString("schedule.setting"));
            scheduleTabItem.setControl(this.m_detailComposite);
        } else if (this.m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
            // ?
            this.m_detailComposite = new JobKickFileCheckComposite(this.m_tabFolder, SWT.NONE);
            TabItem fileTabItem = new TabItem(this.m_tabFolder, SWT.NONE);
            WidgetTestUtil.setTestId(this, "fileTabItem", fileTabItem);
            fileTabItem.setText(Messages.getString("file.check.setting"));
            fileTabItem.setControl(this.m_detailComposite);
        } else if (this.m_jobkickType == JobKickConstant.TYPE_MANUAL) {
            // 
        } else {
            // ??
        }
        // 
        this.m_jobKickParamComposite = new JobKickParamComposite(this.m_tabFolder, SWT.NONE);
        TabItem paramTabItem = new TabItem(this.m_tabFolder, SWT.NONE);
        WidgetTestUtil.setTestId(this, "paramTabItem", paramTabItem);
        paramTabItem.setText(Messages.getString("job.parameter"));
        paramTabItem.setControl(this.m_jobKickParamComposite);

        if (this.m_jobkickType != JobKickConstant.TYPE_MANUAL) {
            // separator
            JobDialogUtil.getSeparator(parent);

            Group groupValidOrInvalid = new Group(parent, SWT.NONE);
            groupValidOrInvalid.setLayout(new RowLayout());
            groupValidOrInvalid.setText(Messages.getString("valid") + "/" + Messages.getString("invalid"));

            //
            this.m_btnValid = new Button(groupValidOrInvalid, SWT.RADIO);
            WidgetTestUtil.setTestId(this, "m_btnValid", this.m_btnValid);
            this.m_btnValid.setText(ValidMessage.STRING_VALID);
            this.m_btnValid.setLayoutData(new RowData(200, SizeConstant.SIZE_BUTTON_HEIGHT));
            this.m_btnValid.setSelection(true);

            //
            this.m_btnInvalid = new Button(groupValidOrInvalid, SWT.RADIO);
            WidgetTestUtil.setTestId(this, "m_btnInvalid", this.m_btnInvalid);
            this.m_btnInvalid.setText(ValidMessage.STRING_INVALID);
            this.m_btnInvalid.setLayoutData(new RowData(200, SizeConstant.SIZE_BUTTON_HEIGHT));
        }

        // 
        this.adjustDialog();

        //??
        if (this.m_jobkickType == JobKickConstant.TYPE_SCHEDULE) {
            reflectJobSchedule();
        } else if (this.m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
            reflectJobFileCheck();
        } else if (this.m_jobkickType == JobKickConstant.TYPE_MANUAL) {
            reflectJobManual();
        }

        // ?
        update();
    }

    /**
     * ???
     *
     */
    private void adjustDialog() {
        // ?
        // ????????????????????
        this.m_shell.pack();
        this.m_shell.setSize(new Point(590, m_shell.getSize().y));

        // ???
        Display display = this.m_shell.getDisplay();
        this.m_shell.setLocation((display.getBounds().width - this.m_shell.getSize().x) / 2,
                (display.getBounds().height - this.m_shell.getSize().y) / 2);
    }

    /**
     *  ?
     *
     */
    public void update() {
        // 
        if ("".equals(this.m_txtJobKickId.getText())) {
            this.m_txtJobKickId.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_txtJobKickId.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        if ("".equals(this.m_txtJobKickName.getText())) {
            this.m_txtJobKickName.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_txtJobKickName.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        if ("".equals(this.m_txtJobId.getText())) {
            this.m_txtJobId.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.m_txtJobId.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }

        // 
        if (this.m_detailComposite != null) {
            this.m_detailComposite.update();
        }
    }

    /**
     * ??????
     *
     */
    private void reflectJobKick() {

        // ID
        if (this.m_jobKick.getOwnerRoleId() != null) {
            this.m_cmpOwnerRoleId.setText(this.m_jobKick.getOwnerRoleId());
        }
        // Composite??ID?
        if (m_jobkickType != JobKickConstant.TYPE_MANUAL) {
            this.m_cmpCalendarId.createCalIdCombo(this.m_managerComposite.getText(),
                    this.m_cmpOwnerRoleId.getText());
        }

        //ID
        if (this.m_jobKick.getId() != null) {
            this.m_txtJobKickId.setText(this.m_jobKick.getId());
            this.m_jobkickId = this.m_jobKick.getId();
            if (this.m_mode == PropertyDefineConstant.MODE_MODIFY) {
                //???ID?????
                this.m_txtJobKickId.setEditable(false);
            }
        }
        //??
        if (this.m_jobKick.getName() != null) {
            this.m_txtJobKickName.setText(this.m_jobKick.getName());
        }
        //ID
        if (this.m_jobKick.getJobId() != null) {
            this.m_txtJobId.setText(this.m_jobKick.getJobId());
        }
        //??
        if (this.m_jobKick.getJobName() != null) {
            this.m_txtJobName.setText(this.m_jobKick.getJobName());
        }
        //ID
        if (this.m_jobKick.getJobunitId() != null) {
            String jobunitId = this.m_jobKick.getJobunitId();
            this.setJobunitId(jobunitId);
        }
        if (this.m_jobkickType != JobKickConstant.TYPE_MANUAL) {
            //ID
            if (this.m_jobKick.getCalendarId() != null) {
                this.m_cmpCalendarId.setText(this.m_jobKick.getCalendarId());
            }

            if (this.m_jobKick.isValid() != null) {
                ///
                Boolean effective = this.m_jobKick.isValid();
                this.m_btnValid.setSelection(effective.booleanValue());
                this.m_btnInvalid.setSelection(!effective.booleanValue());
            }
        }
        // 
        this.m_jobKickParamComposite.setJobRuntimeParamList(this.m_jobKick.getJobRuntimeParamList());
    }

    /**
     * ??????
     *
     */
    private void reflectJobSchedule() {

        //???
        if (this.m_mode == PropertyDefineConstant.MODE_MODIFY || this.m_mode == PropertyDefineConstant.MODE_COPY) {
            this.m_jobKick = GetJobKick.getJobSchedule(this.m_managerName, this.m_jobkickId);
        } else {
            this.m_jobKick = new JobSchedule();
        }
        if (this.m_jobKick == null) {
            throw new InternalError("JobSchedule is null");
        }

        // ???
        reflectJobKick();

        // ???
        JobKickScheduleComposite jobKickScheduleComposite = (JobKickScheduleComposite) this.m_detailComposite;
        JobSchedule jobSchedule = (JobSchedule) this.m_jobKick;
        jobKickScheduleComposite.setJobSchedule(jobSchedule.getScheduleType(), jobSchedule.getWeek(),
                jobSchedule.getHour(), jobSchedule.getMinute(), jobSchedule.getFromXminutes(),
                jobSchedule.getEveryXminutes());
    }

    /**
     * ???????
     *
     */
    private void reflectJobFileCheck() {

        //???
        if (this.m_mode == PropertyDefineConstant.MODE_MODIFY || this.m_mode == PropertyDefineConstant.MODE_COPY) {
            this.m_jobKick = GetJobKick.getJobFileCheck(this.m_managerName, this.m_jobkickId);
        } else {
            this.m_jobKick = new JobFileCheck();
        }
        if (this.m_jobKick == null) {
            throw new InternalError("JobFileCheck is null");
        }

        // ???
        reflectJobKick();

        // ????
        JobKickFileCheckComposite jobKickFileCheckComposite = (JobKickFileCheckComposite) this.m_detailComposite;
        JobFileCheck jobFileCheck = (JobFileCheck) this.m_jobKick;
        jobKickFileCheckComposite.setJobFileCheck(this.m_managerName, jobFileCheck.getOwnerRoleId(),
                jobFileCheck.getFacilityId(), jobFileCheck.getScope(), jobFileCheck.getDirectory(),
                jobFileCheck.getFileName(), jobFileCheck.getEventType(), jobFileCheck.getModifyType());
    }

    /**
     * ??????
     *
     */
    private void reflectJobManual() {

        //???
        if (this.m_mode == PropertyDefineConstant.MODE_MODIFY || this.m_mode == PropertyDefineConstant.MODE_COPY) {
            this.m_jobKick = GetJobKick.getJobManual(this.m_managerName, this.m_jobkickId);
        } else {
            this.m_jobKick = new JobKick();
        }
        if (this.m_jobKick == null) {
            throw new InternalError("JobManual is null");
        }

        // ???
        reflectJobKick();
    }

    /**
     * ??????
     *
     * @return ??
     */
    private ValidateResult createJobKick() {
        ValidateResult result = null;

        //ID?
        if (getJobunitId() != null) {
            this.m_jobKick.setJobunitId(getJobunitId());
        }

        //ID
        if (this.m_cmpOwnerRoleId.getText().length() > 0) {
            this.m_jobKick.setOwnerRoleId(this.m_cmpOwnerRoleId.getText());
        }

        //ID?
        if (this.m_txtJobKickId.getText().length() > 0) {
            this.m_jobKick.setId(this.m_txtJobKickId.getText());
            this.m_jobkickId = this.m_txtJobKickId.getText();
        } else {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.job.88"));
            return result;
        }

        //???
        if (this.m_txtJobKickName.getText().length() > 0) {
            this.m_jobKick.setName(this.m_txtJobKickName.getText());
        } else {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.job.89"));
            return result;
        }

        //ID?
        if (this.m_txtJobId.getText().length() > 0) {
            this.m_jobKick.setJobId(this.m_txtJobId.getText());
        } else {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.job.22"));
            return result;
        }

        //???
        if (this.m_txtJobName.getText().length() > 0) {
            this.m_jobKick.setJobName(this.m_txtJobName.getText());
        } else {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.job.23"));
            return result;
        }

        //ID
        if (this.m_jobkickType != JobKickConstant.TYPE_MANUAL && this.m_cmpCalendarId.getText().length() > 0) {
            this.m_jobKick.setCalendarId(this.m_cmpCalendarId.getText());
        } else {
            this.m_jobKick.setCalendarId(null);
        }

        ///?
        if (this.m_jobkickType != JobKickConstant.TYPE_MANUAL) {
            this.m_jobKick.setValid(this.m_btnValid.getSelection());
        } else {
            this.m_jobKick.setValid(true);
        }

        // 
        if (this.m_jobKickParamComposite.getJobRuntimeParamList() != null) {
            this.m_jobKick.getJobRuntimeParamList().addAll(this.m_jobKickParamComposite.getJobRuntimeParamList());
        }

        return result;
    }

    /**
     * ??????
     *
     * @return ??
     */
    private ValidateResult createJobSchedule() {
        ValidateResult result = null;

        this.m_jobKick = new JobSchedule();

        // ?
        result = createJobKick();
        if (result != null) {
            return result;
        }

        // 
        JobSchedule jobSchedule = (JobSchedule) this.m_jobKick;
        // Composite
        JobKickScheduleComposite jobKickScheduleComposite = (JobKickScheduleComposite) this.m_detailComposite;

        // 
        jobSchedule.setScheduleType(jobKickScheduleComposite.getScheduleType());

        if (jobKickScheduleComposite.getScheduleType() == ScheduleConstant.TYPE_DAY) {
            // ?
            // 
            jobSchedule.setHour(jobKickScheduleComposite.getHour());
            // 
            jobSchedule.setMinute(jobKickScheduleComposite.getMinute());

        } else if (jobKickScheduleComposite.getScheduleType() == ScheduleConstant.TYPE_WEEK) {
            //?
            // 
            if (jobKickScheduleComposite.getWeek() != null) {
                jobSchedule.setWeek(jobKickScheduleComposite.getWeek());
            } else {
                result = new ValidateResult();
                result.setValid(false);
                result.setID(Messages.getString("message.hinemos.1"));
                result.setMessage(Messages.getString("message.job.37"));
                return result;
            }
            // 
            jobSchedule.setHour(jobKickScheduleComposite.getHour());
            // 
            jobSchedule.setMinute(jobKickScheduleComposite.getMinute());

        } else if (jobKickScheduleComposite.getScheduleType() == ScheduleConstant.TYPE_REPEAT) {
            // 
            jobSchedule.setFromXminutes(jobKickScheduleComposite.getFromXminutes());
            // 
            jobSchedule.setEveryXminutes(jobKickScheduleComposite.getEveryXminutes());
        }

        return result;
    }

    /**
     * ???????
     *
     * @return ??
     */
    private ValidateResult createFileCheck() {
        ValidateResult result = null;

        this.m_jobKick = new JobFileCheck();

        // ?
        result = createJobKick();
        if (result != null) {
            return result;
        }

        // ?
        JobFileCheck jobFileCheck = (JobFileCheck) this.m_jobKick;
        // Composite
        JobKickFileCheckComposite jobKickFileCheckComposite = (JobKickFileCheckComposite) this.m_detailComposite;

        // ID
        if (jobKickFileCheckComposite.getFacilityId() != null) {
            jobFileCheck.setFacilityId(jobKickFileCheckComposite.getFacilityId());
            jobFileCheck.setScope(jobKickFileCheckComposite.getScope());
        } else {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.hinemos.3"));
            return result;
        }

        // 
        if (jobKickFileCheckComposite.getDirectory() != null) {
            jobFileCheck.setDirectory(jobKickFileCheckComposite.getDirectory());
        } else {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.job.92"));
            return result;
        }

        // ??
        if (jobKickFileCheckComposite.getFileName() != null) {
            jobFileCheck.setFileName(jobKickFileCheckComposite.getFileName());
        } else {
            result = new ValidateResult();
            result.setValid(false);
            result.setID(Messages.getString("message.hinemos.1"));
            result.setMessage(Messages.getString("message.job.90"));
            return result;
        }

        // ?
        jobFileCheck.setEventType(jobKickFileCheckComposite.getEventType());
        // 
        jobFileCheck.setModifyType(jobKickFileCheckComposite.getModifyType());

        return result;
    }

    /**
     * ??????
     *
     * @return ??
     */
    private ValidateResult createManual() {
        ValidateResult result = null;

        this.m_jobKick = new JobFileCheck();

        // ?
        result = createJobKick();

        return result;
    }

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

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

    /**
     * ???????<BR>
     * ????
     *
     * @return 
     *
     * @see com.clustercontrol.util.PropertyUtil#copy(Property)
     */
    @Override
    protected ValidateResult validate() {
        ValidateResult result = null;

        // 
        if (this.m_jobkickType == JobKickConstant.TYPE_SCHEDULE) {
            // 
            result = createJobSchedule();
            if (result != null) {
                return result;
            }
        } else if (this.m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
            // ?
            result = createFileCheck();
            if (result != null) {
                return result;
            }
        } else if (this.m_jobkickType == JobKickConstant.TYPE_MANUAL) {
            // 
            result = createManual();
            if (result != null) {
                return result;
            }
        }

        return null;
    }

    /**
     * ?ID???<BR>
     * @return ?ID
     */
    public String getJobunitId() {
        return this.m_jobunitId;
    }

    /**
     * ?ID???<BR>
     * @param jobunitId ?ID
     */
    public void setJobunitId(String jobunitId) {
        this.m_jobunitId = jobunitId;
    }

    @Override
    protected boolean action() {
        boolean result = false;
        try {
            String managerName = this.m_managerComposite.getText();

            JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(managerName);
            if (this.m_mode == PropertyDefineConstant.MODE_MODIFY) {
                if (this.m_jobkickType == JobKickConstant.TYPE_SCHEDULE) {
                    wrapper.modifySchedule((JobSchedule) this.m_jobKick);
                } else if (this.m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
                    wrapper.modifyFileCheck((JobFileCheck) this.m_jobKick);
                } else if (this.m_jobkickType == JobKickConstant.TYPE_MANUAL) {
                    wrapper.modifyJobManual(this.m_jobKick);
                }
                Object[] arg = { managerName };
                MessageDialog.openInformation(null, Messages.getString("successful"),
                        Messages.getString("message.job.77", arg));
            } else {//
                if (this.m_jobkickType == JobKickConstant.TYPE_SCHEDULE) {
                    wrapper.addSchedule((JobSchedule) this.m_jobKick);
                } else if (this.m_jobkickType == JobKickConstant.TYPE_FILECHECK) {
                    wrapper.addFileCheck((JobFileCheck) this.m_jobKick);
                } else if (this.m_jobkickType == JobKickConstant.TYPE_MANUAL) {
                    wrapper.addJobManual(this.m_jobKick);
                }

                Object[] arg = { managerName };
                MessageDialog.openInformation(null, Messages.getString("successful"),
                        Messages.getString("message.job.79", arg));
            }
            result = true;
        } catch (InvalidRole_Exception e) {
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
        } catch (JobKickDuplicate_Exception e) {
            String[] args = { this.m_jobKick.getId() };
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.job.83", args) + " " + HinemosMessage.replace(e.getMessage()));
        } catch (InvalidUserPass_Exception e) {
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.job.74") + " " + HinemosMessage.replace(e.getMessage()));
        } catch (InvalidSetting_Exception e) {
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.job.74") + " " + HinemosMessage.replace(e.getMessage()));
        } catch (Exception e) {
            m_log.warn("action(), " + e.getMessage(), e);
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
        }
        return result;
    }

    private void updateCalendarId() {
        this.m_cmpCalendarId.createCalIdCombo(this.m_managerComposite.getText(), this.m_cmpOwnerRoleId.getText());
        this.m_txtJobId.setText("");
        this.m_txtJobName.setText("");
        setJobunitId(null);
    }
}