Example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Prototype

int OK_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Click Source Link

Document

Button id for an "Ok" button (value 0).

Usage

From source file:com.clustercontrol.calendar.composite.action.CalendarDoubleClickListener.java

License:Open Source License

/**
 * ?????<BR>/*from  w w  w  .ja  v  a 2s . c o m*/
 * []?????????????
 * <P>
 * <ol>
 * <li>???????ID????</li>
 * <li>ID????????</li>
 * </ol>
 *
 * @param event 
 *
 * @see com.clustercontrol.calendar.dialog.CalendarDialog
 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
 */
@Override
public void doubleClick(DoubleClickEvent event) {
    String managerName = null;
    String calendarId = null;

    //ID?
    if (((StructuredSelection) event.getSelection()).getFirstElement() != null) {
        ArrayList<?> info = (ArrayList<?>) ((StructuredSelection) event.getSelection()).getFirstElement();
        managerName = (String) info.get(GetCalendarListTableDefine.MANAGER_NAME);
        calendarId = (String) info.get(GetCalendarListTableDefine.CALENDAR_ID);
    }

    if (calendarId != null) {
        // ?
        CalendarDialog dialog = null;

        dialog = new CalendarDialog(m_composite.getShell(), managerName, calendarId,
                PropertyDefineConstant.MODE_MODIFY);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            m_composite.update();
        }
    }
}

From source file:com.clustercontrol.calendar.composite.action.CalendarPatternDoubleClickListener.java

License:Open Source License

/**
 * ?????<BR>/*from ww  w  . ja va  2s  .c o  m*/
 * []?????
 * ????????
 * <P>
 * <ol>
 * <li>???????ID????</li>
 * <li>ID?[]???????</li>
 * </ol>
 *
 * @param event 
 *
 * @see com.clustercontrol.calendar.dialog.CalendarPatternDialog
 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
 */
@Override
public void doubleClick(DoubleClickEvent event) {
    String managerName = null;
    String id = null;

    //ID?
    if (((StructuredSelection) event.getSelection()).getFirstElement() != null) {
        ArrayList<?> info = (ArrayList<?>) ((StructuredSelection) event.getSelection()).getFirstElement();
        managerName = (String) info.get(GetCalendarPatternTableDefine.MANAGER_NAME);
        id = (String) info.get(GetCalendarPatternTableDefine.CAL_PATTERN_ID);
    }

    if (id != null) {

        // ?
        CalendarPatternDialog dialog = null;

        dialog = new CalendarPatternDialog(m_composite.getShell(), managerName, id,
                PropertyDefineConstant.MODE_MODIFY);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            m_composite.update();
        }
    }
}

From source file:com.clustercontrol.calendar.composite.CalendarDetailInfoComposite.java

License:Open Source License

/**
 * ?????/*w w  w.  j  a  v a  2  s .  c  o  m*/
 */
private void initialize() {

    // ????
    GridData gridData = null;

    GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 15;
    this.setLayout(layout);

    /*
     * 
     */
    this.calInfoListComposite = new CalendarDetailListComposite(this, SWT.BORDER, this.managerName);
    WidgetTestUtil.setTestId(this, "list", calInfoListComposite);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 13;
    this.calInfoListComposite.setLayoutData(gridData);
    /*
     * ?
     */
    Composite calDetailInfoButtonComposite = new Composite(this, SWT.NONE);
    WidgetTestUtil.setTestId(this, "button", calDetailInfoButtonComposite);
    layout = new GridLayout(1, true);
    layout.numColumns = 1;
    calDetailInfoButtonComposite.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 2;
    calDetailInfoButtonComposite.setLayoutData(gridData);

    // 
    this.calDetailInfoAddButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("add"));
    WidgetTestUtil.setTestId(this, "add", calDetailInfoAddButton);
    this.calDetailInfoAddButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // ?
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            //FIXME
            //CalendarDetailDialog dialog = new CalendarDetailDialog(shell, m_ownerRoleId);
            CalendarDetailDialog dialog = new CalendarDetailDialog(shell, calInfoListComposite.getManagerName(),
                    calInfoListComposite.getOwnerRoleId());
            if (dialog.open() == IDialogConstants.OK_ID) {
                calInfoListComposite.getDetailList().add(dialog.getInputData());
                calInfoListComposite.update();
            }
        }
    });

    // 
    this.calDetailInfoModifyButton = this.createButton(calDetailInfoButtonComposite,
            Messages.getString("modify"));
    WidgetTestUtil.setTestId(this, "modify", calDetailInfoModifyButton);
    this.calDetailInfoModifyButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Integer order = calInfoListComposite.getSelection();
            if (order != null) {
                // ?
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                //FIXME
                //CalendarDetailDialog dialog = new CalendarDetailDialog(shell,m_infoListComposite.getDetailList().get(order - 1), m_ownerRoleId);
                CalendarDetailDialog dialog = new CalendarDetailDialog(shell,
                        calInfoListComposite.getManagerName(),
                        calInfoListComposite.getDetailList().get(order - 1),
                        calInfoListComposite.getOwnerRoleId());
                if (dialog.open() == IDialogConstants.OK_ID) {
                    calInfoListComposite.getDetailList()
                            .remove(calInfoListComposite.getDetailList().get(order - 1));
                    calInfoListComposite.getDetailList().add(order - 1, dialog.getInputData());
                    calInfoListComposite.setSelection();
                }
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // 
    this.calDetailInfoDeleteButton = this.createButton(calDetailInfoButtonComposite,
            Messages.getString("delete"));
    WidgetTestUtil.setTestId(this, "delete", calDetailInfoDeleteButton);
    this.calDetailInfoDeleteButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Integer order = calInfoListComposite.getSelection();
            if (order != null) {
                calInfoListComposite.getDetailList().remove(order - 1);
                calInfoListComposite.update();
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // 
    this.calDetailInfoCopyButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("copy"));
    WidgetTestUtil.setTestId(this, "copy", calDetailInfoCopyButton);
    this.calDetailInfoCopyButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Integer order = calInfoListComposite.getSelection();
            if (order != null) {
                // ?
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                CalendarDetailDialog dialog = new CalendarDetailDialog(shell,
                        calInfoListComposite.getManagerName(),
                        calInfoListComposite.getDetailList().get(order - 1),
                        calInfoListComposite.getOwnerRoleId());
                if (dialog.open() == IDialogConstants.OK_ID) {
                    calInfoListComposite.getDetailList().add(dialog.getInputData());
                    calInfoListComposite.setSelection();
                }
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // ?
    this.calDetailInfoUpButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("up"));
    WidgetTestUtil.setTestId(this, "up", calDetailInfoUpButton);
    this.calDetailInfoUpButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Integer order = calInfoListComposite.getSelection();
            if (order != null) {
                calInfoListComposite.up();
                calInfoListComposite.update();
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // ?
    this.calDetailInfoDownButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("down"));
    WidgetTestUtil.setTestId(this, "down", calDetailInfoDownButton);
    this.calDetailInfoDownButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Integer order = calInfoListComposite.getSelection();
            if (order != null) {
                calInfoListComposite.down();
                calInfoListComposite.update();
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });
}

From source file:com.clustercontrol.calendar.composite.CalendarDetailListComposite.java

License:Open Source License

/**
 * ?????//  w w w  . ja  v a 2 s. com
 */
private void initialize() {
    /*
     * ?
     */
    //this.detailList = new ArrayList<CalendarDetailInfo>();

    GridLayout layout = new GridLayout(1, true);
    this.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    Table calDetialListTable = new Table(this, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    WidgetTestUtil.setTestId(this, null, calDetialListTable);
    calDetialListTable.setHeaderVisible(true);
    calDetialListTable.setLinesVisible(true);

    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    calDetialListTable.setLayoutData(gridData);

    // ??
    m_tableViewer = new CommonTableViewer(calDetialListTable);
    m_tableViewer.createTableColumn(GetCalendarDetailTableDefine.get(),
            GetCalendarDetailTableDefine.SORT_COLUMN_INDEX, GetCalendarDetailTableDefine.SORT_ORDER);
    m_tableViewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            Integer order = getSelection();
            List<CalendarDetailInfo> detailList = getDetailList();
            if (order != null) {
                // ?
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                //FIXME
                //CalendarDetailDialog dialog = new CalendarDetailDialog(shell,detailList.get(order - 1), m_calendarInfo.getOwnerRoleId());
                CalendarDetailDialog dialog = new CalendarDetailDialog(shell, m_managerName,
                        detailList.get(order - 1), m_ownerRoleId);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    detailList.remove(order - 1);
                    detailList.add(order - 1, dialog.getInputData());
                    setSelection();
                }
            }
        }
    });
}

From source file:com.clustercontrol.calendar.dialog.CalendarDialog.java

License:Open Source License

/**
 * ????/*from  w  ww. j  a v a 2  s .  co  m*/
 *
 * @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();

}

From source file:com.clustercontrol.calendar.view.action.CalendarCopyAction.java

License:Open Source License

/**
 * Handler execution/*  w w  w.  jav  a2  s  .c  o  m*/
 */
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    this.window = HandlerUtil.getActiveWorkbenchWindow(event);
    // In case this action has been disposed
    if (null == this.window || !isEnabled()) {
        return null;
    }

    this.viewPart = HandlerUtil.getActivePart(event);

    // ?????ID?

    CalendarListView calendarListView = null;
    try {
        calendarListView = (CalendarListView) this.viewPart.getAdapter(CalendarListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (calendarListView == null) {
        m_log.info("execute: view is null");
        return null;
    }

    String managerName = calendarListView.getSelectedManagerNameList().get(0);
    String id = calendarListView.getSelectedIdList().get(0);

    if (id != null) {
        // ?
        CalendarDialog dialog = new CalendarDialog(this.viewPart.getSite().getShell(), managerName, id,
                PropertyDefineConstant.MODE_COPY);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            calendarListView.update();
        }
    }

    return null;
}

From source file:com.clustercontrol.calendar.view.action.CalendarModifyAction.java

License:Open Source License

/**
 * Handler execution//from ww w . j  av  a  2  s .c  om
 */
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    this.window = HandlerUtil.getActiveWorkbenchWindow(event);
    // In case this action has been disposed
    if (null == this.window || !isEnabled()) {
        return null;
    }

    this.viewPart = HandlerUtil.getActivePart(event);

    // ?????ID?
    CalendarListView calendarListView = null;
    try {
        calendarListView = (CalendarListView) this.viewPart.getAdapter(CalendarListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (calendarListView == null) {
        m_log.info("execute: view is null");
        return null;
    }

    String managerName = calendarListView.getSelectedManagerNameList().get(0);
    String id = calendarListView.getSelectedIdList().get(0);

    if (id != null) {
        // ?
        CalendarDialog dialog = new CalendarDialog(this.viewPart.getSite().getShell(), managerName, id,
                PropertyDefineConstant.MODE_MODIFY);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            calendarListView.update();
        }
    }

    return null;
}

From source file:com.clustercontrol.calendar.view.action.CalendarPatternCopyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    this.window = HandlerUtil.getActiveWorkbenchWindow(event);
    // In case this action has been disposed
    if (null == this.window || !isEnabled()) {
        return null;
    }//from   w ww.  ja v a  2s . co  m

    this.viewPart = HandlerUtil.getActivePart(event);
    // []?????ID?

    CalendarPatternView calendarPatternView = null;
    try {
        calendarPatternView = (CalendarPatternView) this.viewPart.getAdapter(CalendarPatternView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (calendarPatternView == null) {
        m_log.info("execute: view is null");
        return null;
    }

    String managerName = calendarPatternView.getSelectedManagerNameList().get(0);
    String id = calendarPatternView.getSelectedIdList().get(0);

    if (id != null) {
        // ?
        CalendarPatternDialog dialog = new CalendarPatternDialog(this.viewPart.getSite().getShell(),
                managerName, id, PropertyDefineConstant.MODE_COPY);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            calendarPatternView.update();
        }
    }
    return null;
}

From source file:com.clustercontrol.calendar.view.action.CalendarPatternModifyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    this.window = HandlerUtil.getActiveWorkbenchWindow(event);
    // In case this action has been disposed
    if (null == this.window || !isEnabled()) {
        return null;
    }//  w  w  w.ja v  a 2 s. c  o m

    this.viewPart = HandlerUtil.getActivePart(event);
    // []?????ID?

    CalendarPatternView calendarPatternView = null;
    try {
        calendarPatternView = (CalendarPatternView) this.viewPart.getAdapter(CalendarPatternView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (calendarPatternView == null) {
        m_log.info("execute: view is null");
        return null;
    }

    String managerName = calendarPatternView.getSelectedManagerNameList().get(0);
    String id = calendarPatternView.getSelectedIdList().get(0);

    if (id != null) {
        // ?
        CalendarPatternDialog dialog = new CalendarPatternDialog(this.viewPart.getSite().getShell(),
                managerName, id, PropertyDefineConstant.MODE_MODIFY);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            calendarPatternView.update();
        }
    }
    return null;
}

From source file:com.clustercontrol.custom.dialog.MonitorCustomDialog.java

License:Open Source License

/**
 * ???<br/>//from   w  w  w .j  av a 2  s .  co  m
 *
 * @param parent ???
 */
@Override
protected void customizeDialog(Composite parent) {
    // Local Variables
    Label label = null; // ????
    GridData gridData = null; // ????

    // MAIN

    // ???
    item1 = Messages.getString("select.value");
    item2 = Messages.getString("select.value");

    super.customizeDialog(parent);

    // ?
    shell.setText(Messages.getString("dialog.monitor.custom.edit"));

    // ??
    Group groupCheckRule = new Group(groupRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule);
    groupCheckRule.setText(Messages.getString("check.rule"));
    GridLayout layout = new GridLayout(15, true);
    layout.marginWidth = HALF_MARGIN;
    layout.marginHeight = HALF_MARGIN;
    groupCheckRule.setLayout(layout);

    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = BASIC_UNIT;
    groupCheckRule.setLayoutData(gridData);

    // checkbox?(???)
    this.checkSelected = new Button(groupCheckRule, SWT.CHECK);
    WidgetTestUtil.setTestId(this, "selectedCheck", checkSelected);
    this.checkSelected.setText(Messages.getString("monitor.custom.type.selected"));
    this.checkSelected.setToolTipText(Messages.getString("monitor.custom.type.selected.tips"));
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = 8;
    checkSelected.setLayoutData(gridData);
    checkSelected.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Button button = (Button) e.getSource();
            if (button.getSelection()) {
                textNode.setEnabled(true);
                buttonNode.setEnabled(true);
            } else {
                textNode.setEnabled(false);
                buttonNode.setEnabled(false);
            }
            update();
        }
    });

    // ???
    this.textNode = new Text(groupCheckRule, SWT.BORDER | SWT.CENTER | SWT.READ_ONLY);
    WidgetTestUtil.setTestId(this, "nodetext", textNode);
    this.textNode.setText("");
    this.textNode.setMessage(Messages.getString("monitor.custom.node.selected"));
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = 5;
    this.textNode.setLayoutData(gridData);
    this.textNode.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            update();
        }
    });
    ;

    this.buttonNode = new Button(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "node", buttonNode);
    this.buttonNode.setText(Messages.getString("refer"));
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = 2;
    this.buttonNode.setLayoutData(gridData);
    this.buttonNode.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // ?
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

            String managerName = getMonitorBasicScope().getManagerListComposite().getText();
            ScopeTreeDialog dialog = new ScopeTreeDialog(shell, managerName,
                    getMonitorBasicScope().getOwnerRoleId(), false, false);
            dialog.setSelectNodeOnly(true);
            if (dialog.open() == IDialogConstants.OK_ID) {
                FacilityTreeItem item = dialog.getSelectItem();
                FacilityInfo info = item.getData();
                nodeFacilityId = info.getFacilityId();
                if (info.getFacilityType() == FacilityConstant.TYPE_NODE) {
                    textNode.setText(info.getFacilityName());
                } else {
                    FacilityPath path = new FacilityPath(ClusterControlPlugin.getDefault().getSeparator());
                    textNode.setText(path.getPath(item));
                }
            }
        }
    });

    // ??
    Group groupEffectiveUser = new Group(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "effectiveuser", groupEffectiveUser);
    groupEffectiveUser.setText(Messages.getString("effective.user"));
    layout = new GridLayout(15, true);
    layout.marginWidth = HALF_MARGIN;
    layout.marginHeight = HALF_MARGIN;
    groupEffectiveUser.setLayout(layout);

    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = 15;
    groupEffectiveUser.setLayoutData(gridData);

    this.buttonAgentUser = new Button(groupEffectiveUser, SWT.RADIO);
    WidgetTestUtil.setTestId(this, "agentuser", buttonAgentUser);
    this.buttonAgentUser.setText(Messages.getString("agent.user"));
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = SMALL_UNIT;
    this.buttonAgentUser.setLayoutData(gridData);
    this.buttonAgentUser.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Button check = (Button) e.getSource();
            if (check.getSelection()) {
                buttonSpecifyUser.setSelection(false);
                textEffectiveUser.setEnabled(false);
            }
            update();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });

    this.buttonSpecifyUser = new Button(groupEffectiveUser, SWT.RADIO);
    WidgetTestUtil.setTestId(this, "specifyuser", buttonSpecifyUser);
    this.buttonSpecifyUser.setText(Messages.getString("specified.user"));
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = WIDTH_TEXT_SHORT;
    this.buttonSpecifyUser.setLayoutData(gridData);
    this.buttonSpecifyUser.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Button check = (Button) e.getSource();
            if (check.getSelection()) {
                buttonAgentUser.setSelection(false);
                textEffectiveUser.setEnabled(true);
            }
            update();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });

    this.textEffectiveUser = new Text(groupEffectiveUser, SWT.BORDER | SWT.LEFT);
    WidgetTestUtil.setTestId(this, "effectiveuser", textEffectiveUser);
    this.textEffectiveUser.setText("");
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = HALF_UNIT - (SMALL_UNIT + WIDTH_TEXT_SHORT);
    this.textEffectiveUser.setLayoutData(gridData);
    this.textEffectiveUser.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            update();
        }
    });

    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "customcommand", label);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    label.setText(Messages.getString("monitor.custom.command") + " : ");
    gridData.horizontalSpan = WIDTH_TITLE;
    label.setLayoutData(gridData);

    this.textCommand = new TextWithParameterComposite(groupCheckRule, SWT.BORDER | SWT.LEFT | SWT.SINGLE);
    WidgetTestUtil.setTestId(this, "commnad", textCommand);
    this.textCommand.setText("");
    this.textCommand.setToolTipText(Messages.getString("monitor.custom.commandline.tips"));
    this.textCommand.setColor(new Color(parent.getDisplay(), new RGB(0, 0, 255)));
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = 11;
    this.textCommand.setLayoutData(gridData);
    this.textCommand.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            update();
        }
    });
    ;

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

    // 
    this.m_textTimeout = new Text(groupCheckRule, SWT.BORDER);
    WidgetTestUtil.setTestId(this, "timeout", m_textTimeout);
    gridData = new GridData();
    gridData.horizontalSpan = 4;
    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(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "millisec", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_VALUE;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("milli.sec"));

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

    /*
     * ??
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("convert.value") + " : ");
    // 
    this.m_comboConvertValue = new Combo(groupCheckRule, SWT.DROP_DOWN | SWT.READ_ONLY);
    WidgetTestUtil.setTestId(this, "convertvalue", m_comboConvertValue);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TEXT_SHORT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_comboConvertValue.setLayoutData(gridData);
    this.m_comboConvertValue.add(ConvertValueMessage.STRING_NO);
    this.m_comboConvertValue.add(ConvertValueMessage.STRING_DELTA);

    // ???
    this.adjustDialog();

    // ?
    MonitorInfo info = null;
    if (this.monitorId == null) {
        // ????
        info = new MonitorInfo();
        this.setInfoInitialValue(info);
    } else {
        // ??
        try {
            MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName);
            info = wrapper.getMonitor(this.monitorId);
        } catch (InvalidRole_Exception e) {
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
            return;
        } catch (Exception e) {
            // ?
            m_log.warn("customizeDialog() getMonitor, " + HinemosMessage.replace(e.getMessage()), e);
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
            return;
        }
    }
    this.setInputData(info);
    update();
}