com.clustercontrol.calendar.dialog.CalendarDialog.java Source code

Java tutorial

Introduction

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

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.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.Text;

import com.clustercontrol.bean.PropertyDefineConstant;
import com.clustercontrol.bean.RequiredFieldColorConstant;
import com.clustercontrol.util.Messages;
import com.clustercontrol.util.TimezoneUtil;
import com.clustercontrol.util.WidgetTestUtil;
import com.clustercontrol.ws.calendar.CalendarDetailInfo;
import com.clustercontrol.ws.calendar.CalendarInfo;
import com.clustercontrol.calendar.action.AddCalendar;
import com.clustercontrol.calendar.action.GetCalendar;
import com.clustercontrol.calendar.action.GetCalendarDetailTableDefine;
import com.clustercontrol.calendar.action.ModifyCalendar;
import com.clustercontrol.calendar.composite.CalendarDetailInfoComposite;
import com.clustercontrol.composite.ManagerListComposite;
import com.clustercontrol.composite.RoleIdListComposite;
import com.clustercontrol.composite.RoleIdListComposite.Mode;
import com.clustercontrol.dialog.CommonDialog;
import com.clustercontrol.dialog.DateTimeDialog;
import com.clustercontrol.fault.HinemosUnknown;

/**
 * ?<BR>
 *
 * @version 4.1.0
 * @since 2.0.0
 */
public class CalendarDialog extends CommonDialog {

    // 
    private static Log m_log = LogFactory.getLog(CalendarDialog.class);
    /** ID */
    private String calendarId = "";

    /**  */
    private Long calTimeFrom = -1l;
    /**  */
    private Long calTimeTo = -1l;
    /**  */
    private int mode;
    /** ID */
    private Text calIdText = null;
    /** ?? */
    private Text calNameText = null;
    /**  */
    private Text calTimeFromText = null;
    /**  */
    private Text calTimeToText = null;
    /** ??? */
    private CalendarInfo inputData = null;
    /**  */
    private CalendarDetailInfoComposite calDetailComposite = null;
    /** ID */
    private RoleIdListComposite calRoleIdListComposite = null;
    private String ownerRoleId = null;
    /** ??? */
    private String managerName = null;
    /** ???? */
    private ManagerListComposite m_managerComposite = null;

    // ----- ? ----- //
    private Shell shell = null;
    private Group calGroup = null; //
    private Group calDetailGroup = null;// 
    private Text calDescription = null;
    private Button calTimeFromButton = null;
    private Button calTimeToButton = null;

    // -----  ----- //
    /**
     * ?????
     *
     * @param parent
     *            ?
     */
    public CalendarDialog(Shell parent, String managerName, String id, int mode) {
        super(parent);
        this.managerName = managerName;
        this.calendarId = id;
        this.mode = mode;
    }

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

        // 
        shell.setText(Messages.getString("dialog.calendar.calendar.create.modify"));
        GridData gridData = new GridData();
        GridLayout layout = new GridLayout(1, true);
        layout.marginWidth = 10;
        layout.marginHeight = 10;
        parent.setLayout(layout);
        /*
         * 
         */
        calGroup = new Group(parent, SWT.NONE);
        WidgetTestUtil.setTestId(this, "setting", calGroup);
        layout = new GridLayout(1, true);
        layout.marginWidth = 5;
        layout.marginHeight = 5;
        layout.numColumns = 15;
        calGroup.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalSpan = 15;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calGroup.setLayoutData(gridData);
        calGroup.setText(Messages.getString("calendar.create"));

        /*
         * ?
         */
        Label labelManager = new Label(calGroup, SWT.LEFT);
        WidgetTestUtil.setTestId(this, "manager", labelManager);
        gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalSpan = 4;
        labelManager.setLayoutData(gridData);
        labelManager.setText(Messages.getString("facility.manager") + " : ");
        if (this.mode == PropertyDefineConstant.MODE_MODIFY) {
            this.m_managerComposite = new ManagerListComposite(calGroup, SWT.NONE, false);
        } else {
            this.m_managerComposite = new ManagerListComposite(calGroup, SWT.NONE, true);
            this.m_managerComposite.getComboManagerName().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (calDetailComposite.getDetailList() != null
                            && calDetailComposite.getDetailList().size() > 0) {
                        if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                                Messages.getString("message.calendar.55"))) {
                            m_managerComposite.setText(managerName);
                            return;
                        }
                        String managerName = m_managerComposite.getText();
                        calRoleIdListComposite.createRoleIdList(managerName);
                        calDetailComposite.changeManagerName(m_managerComposite.getText(), true);
                        String roleId = calRoleIdListComposite.getText();
                        calDetailComposite.changeOwnerRoleId(roleId);
                    } else {
                        String managerName = m_managerComposite.getText();
                        calRoleIdListComposite.createRoleIdList(managerName);
                        calDetailComposite.changeManagerName(m_managerComposite.getText(), false);
                        String roleId = calRoleIdListComposite.getText();
                        calDetailComposite.changeOwnerRoleId(roleId);
                    }
                    managerName = m_managerComposite.getText();
                }
            });
        }
        WidgetTestUtil.setTestId(this, "managerComposite", this.m_managerComposite);
        gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.horizontalSpan = 8;
        gridData.grabExcessHorizontalSpace = true;
        this.m_managerComposite.setLayoutData(gridData);

        if (this.managerName != null) {
            this.m_managerComposite.setText(this.managerName);
        }

        /*
         * ID
         */
        //
        Label lblCalID = new Label(calGroup, SWT.LEFT);
        WidgetTestUtil.setTestId(this, "calid", lblCalID);
        gridData = new GridData();
        gridData.horizontalSpan = 4;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        lblCalID.setLayoutData(gridData);
        lblCalID.setText(Messages.getString("calendar.id") + " : ");
        //
        calIdText = new Text(calGroup, SWT.BORDER | SWT.LEFT);
        WidgetTestUtil.setTestId(this, "calid", calIdText);
        gridData = new GridData();
        gridData.horizontalSpan = 8;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calIdText.setLayoutData(gridData);
        calIdText.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });
        /*
         * ??
         */
        //
        Label lblCalName = new Label(calGroup, SWT.LEFT);
        WidgetTestUtil.setTestId(this, "calendarname", lblCalName);
        gridData = new GridData();
        gridData.horizontalSpan = 4;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        lblCalName.setLayoutData(gridData);
        lblCalName.setText(Messages.getString("calendar.name") + " : ");
        //
        calNameText = new Text(calGroup, SWT.BORDER | SWT.LEFT);
        WidgetTestUtil.setTestId(this, "calName", calNameText);
        gridData = new GridData();
        gridData.horizontalSpan = 8;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calNameText.setLayoutData(gridData);
        calNameText.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });
        /*
         * 
         */
        //
        Label lblCalDescription = new Label(calGroup, SWT.LEFT);
        WidgetTestUtil.setTestId(this, "description", lblCalDescription);
        gridData = new GridData();
        gridData.horizontalSpan = 4;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        lblCalDescription.setLayoutData(gridData);
        lblCalDescription.setText(Messages.getString("description") + " : ");
        //
        calDescription = new Text(calGroup, SWT.BORDER | SWT.LEFT);
        WidgetTestUtil.setTestId(this, "caldescription", calDescription);
        gridData = new GridData();
        gridData.horizontalSpan = 8;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calDescription.setLayoutData(gridData);
        calDescription.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });

        /*
         * ID
         */
        Label labelRoleId = new Label(calGroup, SWT.LEFT);
        WidgetTestUtil.setTestId(this, "ownerroleid", labelRoleId);
        gridData = new GridData();
        gridData.horizontalSpan = 4;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        labelRoleId.setLayoutData(gridData);
        labelRoleId.setText(Messages.getString("owner.role.id") + " : ");
        if (this.mode == PropertyDefineConstant.MODE_ADD || this.mode == PropertyDefineConstant.MODE_COPY) {
            this.calRoleIdListComposite = new RoleIdListComposite(calGroup, SWT.NONE, this.managerName, true,
                    Mode.OWNER_ROLE);
            this.calRoleIdListComposite.getComboRoleId().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (calDetailComposite.getDetailList() != null
                            && calDetailComposite.getDetailList().size() > 0) {
                        if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                                Messages.getString("message.calendar.50"))) {
                            calRoleIdListComposite.setText(ownerRoleId);
                            return;
                        }
                    }
                    calDetailComposite.changeOwnerRoleId(calRoleIdListComposite.getText());
                    ownerRoleId = calRoleIdListComposite.getText();
                }
            });
        } else {
            this.calRoleIdListComposite = new RoleIdListComposite(calGroup, SWT.NONE, this.managerName, false,
                    Mode.OWNER_ROLE);
        }
        WidgetTestUtil.setTestId(this, "calroleidlist", calRoleIdListComposite);
        gridData = new GridData();
        gridData.horizontalSpan = 8;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calRoleIdListComposite.setLayoutData(gridData);

        /*
         * 
         */
        //
        Label lblCalTimeFrom = new Label(calGroup, SWT.LEFT);
        WidgetTestUtil.setTestId(this, "caltimefrom", lblCalTimeFrom);
        gridData = new GridData();
        gridData.horizontalSpan = 4;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        lblCalTimeFrom.setLayoutData(gridData);
        lblCalTimeFrom.setText(Messages.getString("valid.time") + "(" + Messages.getString("start") + ")" + " : ");
        //
        calTimeFromText = new Text(calGroup, SWT.BORDER | SWT.LEFT);
        WidgetTestUtil.setTestId(this, "timefrom", calTimeFromText);
        gridData = new GridData();
        gridData.horizontalSpan = 8;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calTimeFromText.setLayoutData(gridData);
        //?????????
        calTimeFromText.setEnabled(false);
        calTimeFromText.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });
        // 
        calTimeFromButton = new Button(calGroup, SWT.NONE);
        WidgetTestUtil.setTestId(this, "timefrom", calTimeFromButton);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calTimeFromButton.setLayoutData(gridData);
        calTimeFromButton.setText(Messages.getString("calendar.button"));
        calTimeFromButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                DateTimeDialog dialog = new DateTimeDialog(shell);
                if (calTimeFromText.getText().length() > 0) {
                    Date date = new Date(calTimeFrom);
                    dialog.setDate(date);
                }
                if (dialog.open() == IDialogConstants.OK_ID) {
                    //???Long???
                    calTimeFrom = dialog.getDate().getTime();
                    //???"yyyy/MM/dd HH:mm:ss"????
                    SimpleDateFormat sdf = TimezoneUtil.getSimpleDateFormat();
                    String tmp = sdf.format(dialog.getDate());
                    calTimeFromText.setText(tmp);
                    update();
                }
            }
        });
        /*
         * 
         */
        //
        Label lblCalTimeTo = new Label(calGroup, SWT.LEFT);
        WidgetTestUtil.setTestId(this, "caltimeto", lblCalTimeTo);
        gridData = new GridData();
        gridData.horizontalSpan = 4;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        lblCalTimeTo.setLayoutData(gridData);
        lblCalTimeTo.setText(Messages.getString("valid.time") + "(" + Messages.getString("end") + ")" + " : ");
        //
        calTimeToText = new Text(calGroup, SWT.BORDER | SWT.LEFT);
        WidgetTestUtil.setTestId(this, "timeto", calTimeToText);
        gridData = new GridData();
        gridData.horizontalSpan = 8;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calTimeToText.setLayoutData(gridData);
        //?????????
        calTimeToText.setEnabled(false);
        calTimeToText.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent arg0) {
                update();
            }
        });
        // 
        calTimeToButton = new Button(calGroup, SWT.NONE);
        WidgetTestUtil.setTestId(this, "timeto", calTimeToButton);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        calTimeToButton.setLayoutData(gridData);
        calTimeToButton.setText(Messages.getString("calendar.button"));
        calTimeToButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                DateTimeDialog dialog = new DateTimeDialog(shell);
                if (calTimeToText.getText().length() > 0) {
                    Date date = new Date(calTimeTo);
                    dialog.setDate(date);
                }
                if (dialog.open() == IDialogConstants.OK_ID) {
                    //???Long???
                    calTimeTo = dialog.getDate().getTime();
                    //???"yyyy/MM/dd HH:mm:ss"????
                    SimpleDateFormat sdf = TimezoneUtil.getSimpleDateFormat();
                    m_log.trace("CalendarDialog getTime" + dialog.getDate());
                    String tmp = sdf.format(dialog.getDate());
                    calTimeToText.setText(tmp);
                }
            }
        });

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

        /**
         *  
         */
        //?
        GetCalendarDetailTableDefine.get();
        this.calDetailComposite = new CalendarDetailInfoComposite(calDetailGroup, SWT.NONE, this.managerName);
        WidgetTestUtil.setTestId(this, "detail", calDetailComposite);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        gridData.heightHint = 220;
        calDetailComposite.setLayoutData(gridData);

        Display calDisplay = shell.getDisplay();
        shell.setLocation((calDisplay.getBounds().width - shell.getSize().x) / 2,
                (calDisplay.getBounds().height - shell.getSize().y) / 2);

        // 
        this.adjustDialog();
        //???
        this.reflectCalendar();
        //????
        //this.createCalendarInfo();
        // ?
        this.update();

    }

    /**
     * ???
     *
     */
    private void adjustDialog() {
        // ?
        // ????????????????????
        shell.pack();
        shell.setSize(new Point(600, shell.getSize().y));

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

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

        // ID?9
        if ("".equals(this.calIdText.getText())) {
            this.calIdText.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.calIdText.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        // ???9
        if ("".equals(this.calNameText.getText())) {
            this.calNameText.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.calNameText.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        // ?9
        if ("".equals(this.calTimeFromText.getText())) {
            this.calTimeFromText.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.calTimeFromText.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
        // ?9
        if ("".equals(this.calTimeToText.getText())) {
            this.calTimeToText.setBackground(RequiredFieldColorConstant.COLOR_REQUIRED);
        } else {
            this.calTimeToText.setBackground(RequiredFieldColorConstant.COLOR_UNREQUIRED);
        }
    }

    /**
     * ??????
     *
     * @return ??
     *
     * @see
     */
    private void createCalendarInfo() {

        this.inputData = new CalendarInfo();

        //ID?
        if (calIdText.getText().length() > 0) {
            inputData.setCalendarId(calIdText.getText());
        }
        m_log.trace("createCalendarInfo cal name = " + calNameText.getText());
        //???
        if (calNameText.getText().length() > 0 && !"".equals(calNameText.getText())) {
            m_log.trace("createCalendarInfo22 cal name = " + calNameText.getText());
            inputData.setCalendarName(calNameText.getText());
            m_log.trace("input cal name = " + inputData.getCalendarName());
        }
        //ID
        if (calRoleIdListComposite.getText().length() > 0) {
            inputData.setOwnerRoleId(calRoleIdListComposite.getText());
        }
        //?
        if (calDescription.getText().length() > 0) {
            inputData.setDescription(calDescription.getText());
        } else {
            inputData.setDescription("");
        }
        //?
        if (calTimeFromText.getText().length() > 0) {
            Date dateTimeFrom;
            try {
                dateTimeFrom = (TimezoneUtil.getSimpleDateFormat()).parse(calTimeFromText.getText());
                calTimeFrom = dateTimeFrom.getTime();
                inputData.setValidTimeFrom(calTimeFrom);
            } catch (ParseException e) {
                m_log.warn("createCalendarInfo : " + e.getMessage());
            }
        }
        //?
        if (calTimeToText.getText().length() > 0) {
            Date dateTimeTo;
            try {
                dateTimeTo = (TimezoneUtil.getSimpleDateFormat()).parse(calTimeToText.getText());
                calTimeTo = dateTimeTo.getTime();
                inputData.setValidTimeTo(calTimeTo);
            } catch (ParseException e) {
                m_log.warn("createCalendarInfo : " + e.getMessage());
            }
        }
        //?
        if (this.calDetailComposite.getDetailList() != null) {

            m_log.debug("Add CalendarDetailInfo : " + this.calDetailComposite.getDetailList().size());

            for (CalendarDetailInfo detailInfo : this.calDetailComposite.getDetailList()) {
                this.inputData.getCalendarDetailList().add(detailInfo);
            }
        }
    }

    /**
     * ??????
     *
     * @param detailList
     * @throws HinemosUnknown 
     */
    private void reflectCalendar() {
        // ?
        if (mode == PropertyDefineConstant.MODE_MODIFY || mode == PropertyDefineConstant.MODE_COPY) {
            // ?????
            inputData = new GetCalendar().getCalendar(this.m_managerComposite.getText(), this.calendarId);
        } else {
            // ???
            inputData = new CalendarInfo();
        }

        if (inputData == null)
            throw new InternalError("CalendarInfo is null");

        //?
        if (inputData.getCalendarId() != null) {
            this.calendarId = inputData.getCalendarId();
            this.calIdText.setText(inputData.getCalendarId());
            //???ID???
            if (this.mode == PropertyDefineConstant.MODE_MODIFY) {
                this.calIdText.setEnabled(false);
            }
        }
        if (inputData.getCalendarName() != null) {
            this.calNameText.setText(inputData.getCalendarName());
        }
        if (inputData.getDescription() != null) {
            this.calDescription.setText(inputData.getDescription());
        }
        if (inputData.getValidTimeFrom() != null) {
            SimpleDateFormat sdf = TimezoneUtil.getSimpleDateFormat();
            String tmp = sdf.format(inputData.getValidTimeFrom());
            this.calTimeFromText.setText(tmp);
            this.calTimeFrom = inputData.getValidTimeFrom();
        }
        if (inputData.getValidTimeTo() != null) {
            SimpleDateFormat sdf = TimezoneUtil.getSimpleDateFormat();
            String tmp = sdf.format(inputData.getValidTimeTo());
            this.calTimeToText.setText(tmp);
            this.calTimeTo = inputData.getValidTimeTo();
        }
        // ?
        calDetailComposite.setDetailList((ArrayList<CalendarDetailInfo>) inputData.getCalendarDetailList());

        // ID?
        if (inputData.getOwnerRoleId() != null) {
            this.calRoleIdListComposite.setText(inputData.getOwnerRoleId());
        }
        ownerRoleId = this.calRoleIdListComposite.getText();
        this.calDetailComposite.setOwnerRoleId(this.calRoleIdListComposite.getText());

        this.update();
    }

    /**
     * ?????
     *
     * @return true?false
     *
     * @see com.clustercontrol.dialog.CommonDialog#action()
     */

    @Override
    protected boolean action() {
        boolean result = false;
        createCalendarInfo();
        CalendarInfo info = this.inputData;
        String managerName = this.m_managerComposite.getText();
        if (info != null) {
            if (mode == PropertyDefineConstant.MODE_ADD) {
                // ???+
                result = new AddCalendar().add(managerName, info);
            } else if (mode == PropertyDefineConstant.MODE_MODIFY) {
                // ??
                info.setCalendarId(calIdText.getText());
                result = new ModifyCalendar().modify(managerName, info);
            } else if (mode == PropertyDefineConstant.MODE_COPY) {
                // ??
                info.setCalendarId(calIdText.getText());
                result = new AddCalendar().add(managerName, info);
            }
        } else {
            m_log.error("action() Calendarinfo is null");
        }
        return result;
    }
}