Example usage for org.eclipse.jface.dialogs MessageDialog openWarning

List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openWarning.

Prototype

public static void openWarning(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard warning dialog.

Usage

From source file:com.clustercontrol.maintenance.view.action.HinemosPropertyModifyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???//from   ww w  .  ja v a 2 s  . c o  m
    this.viewPart = HandlerUtil.getActivePart(event);
    HinemosPropertyView view = null;
    try {
        view = (HinemosPropertyView) this.viewPart.getAdapter(HinemosPropertyView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

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

    HinemosPropertyComposite composite = (HinemosPropertyComposite) view.getComposite();
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    @SuppressWarnings("rawtypes")
    List<?> list = (List) selection.getFirstElement();
    String key = null;
    int valueType = 0;
    String managerName = null;
    if (list != null && list.size() > 0) {
        key = (String) list.get(GetHinemosPropertyTableDefine.KEY);
        managerName = (String) list.get(GetHinemosPropertyTableDefine.MANAGER_NAME);
        String valueTypeStr = (String) list.get(GetHinemosPropertyTableDefine.VALUE_TYPE);
        valueType = HinemosPropertyTypeMessage.stringToType(valueTypeStr);
    }
    Table table = composite.getTableViewer().getTable();
    WidgetTestUtil.setTestId(this, null, table);

    //???????
    if (key != null) {

        try {
            HinemosPropertyInfo info = new HinemosPropertyInfo();
            info.setKey(key);
            info.setValueType(valueType);
            if (valueType == HinemosPropertyTypeConstant.TYPE_STRING) {
                String value = (String) list.get(GetHinemosPropertyTableDefine.VALUE);
                info.setValueString(value);
            } else if (valueType == HinemosPropertyTypeConstant.TYPE_NUMERIC) {
                long value = (Long) list.get(GetHinemosPropertyTableDefine.VALUE);
                info.setValueNumeric(value);
            } else {
                boolean value = Boolean.parseBoolean((String) list.get(GetHinemosPropertyTableDefine.VALUE));
                info.setValueBoolean(value);
            }
            info.setDescription((String) list.get(GetHinemosPropertyTableDefine.DESCRIPTION));

            // ?
            HinemosPropertyDialog dialog = new HinemosPropertyDialog(this.viewPart.getSite().getShell(),
                    managerName, valueType, PropertyDefineConstant.MODE_MODIFY, info);
            // ???????????
            if (dialog.open() == IDialogConstants.OK_ID) {
                int selectIndex = table.getSelectionIndex();
                view.update();
                table.setSelection(selectIndex);
            }
        } catch (Exception e1) {
            m_log.warn("run(), " + e1.getMessage(), e1);
        }
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.hinemos.property.11"));
    }
    return null;
}

From source file:com.clustercontrol.maintenance.view.action.MaintenanceCopyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???//from w ww.  j  ava 2  s  .  c  o  m
    this.viewPart = HandlerUtil.getActivePart(event);
    MaintenanceListView view = null;
    try {
        view = (MaintenanceListView) this.viewPart.getAdapter(MaintenanceListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

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

    MaintenanceListComposite composite = (MaintenanceListComposite) view.getListComposite();
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String maintenanceId = null;
    String managerName = null;
    if (list != null && list.size() > 0) {
        managerName = (String) list.get(GetMaintenanceListTableDefine.MANAGER_NAME);
        maintenanceId = (String) list.get(GetMaintenanceListTableDefine.MAINTENANCE_ID);
    }
    Table table = composite.getTableViewer().getTable();
    WidgetTestUtil.setTestId(this, null, table);

    //???????
    if (maintenanceId != null) {

        try {
            // ?
            MaintenanceDialog dialog = new MaintenanceDialog(this.viewPart.getSite().getShell(), managerName,
                    maintenanceId, PropertyDefineConstant.MODE_ADD);
            // MaintenanceSchedule scheduleList = new GetSchedule().getSchedule(maintenanceId);
            // dialog.setSchedule(scheduleList);
            // ???????????
            if (dialog.open() == IDialogConstants.OK_ID) {
                int selectIndex = table.getSelectionIndex();
                view.update();
                table.setSelection(selectIndex);
            }
        } catch (Exception e1) {
            m_log.warn("run(), " + e1.getMessage(), e1);
        }
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.maintenance.8"));
    }
    return null;
}

From source file:com.clustercontrol.maintenance.view.action.MaintenanceDeleteAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???//w w w. j a  v  a2s.c o  m
    this.viewPart = HandlerUtil.getActivePart(event);
    MaintenanceListView view = null;
    try {
        view = (MaintenanceListView) this.viewPart.getAdapter(MaintenanceListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

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

    MaintenanceListComposite composite = (MaintenanceListComposite) view.getListComposite();
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    List<?> list = (List<?>) selection.toList();

    Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>();
    for (Object obj : list) {
        List<?> objList = (List<?>) obj;
        String managerName = (String) objList.get(GetMaintenanceListTableDefine.MANAGER_NAME);
        if (map.get(managerName) == null) {
            map.put(managerName, new ArrayList<String>());
        }
    }

    StringBuffer maintenanceId = new StringBuffer();
    for (Object obj : list) {
        List<?> objList = (List<?>) obj;
        String managerName = (String) objList.get(GetMaintenanceListTableDefine.MANAGER_NAME);
        String id = (String) objList.get(GetMaintenanceListTableDefine.MAINTENANCE_ID);
        map.get(managerName).add(id);
        if (maintenanceId.length() > 0) {
            maintenanceId.append(", ");
        }
        maintenanceId.append(id + "(" + managerName + ")");
    }

    // ?????????
    if (map.isEmpty()) {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.maintenance.9"));
        return null;
    }

    String[] args = { maintenanceId.toString() };

    if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
            Messages.getString("message.maintenance.7", args)) == false) {

        return null;
    }

    Map<String, String> errorMsgs = new ConcurrentHashMap<>();
    for (Map.Entry<String, List<String>> entry : map.entrySet()) {
        String managerName = entry.getKey();
        MaintenanceEndpointWrapper wrapper = MaintenanceEndpointWrapper.getWrapper(managerName);
        for (String val : entry.getValue()) {
            try {
                wrapper.deleteMaintenance(val);
            } catch (InvalidRole_Exception e) {
                errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16"));
            } catch (Exception e) {
                m_log.warn("run(), " + e.getMessage(), e);
                errorMsgs.put(managerName, Messages.getString("message.hinemos.failure.unexpected")
                        + HinemosMessage.replace(e.getMessage()));
            }
        }
    }

    //
    if (0 < errorMsgs.size()) {
        UIManager.showMessageBox(errorMsgs, true);
    } else {
        MessageDialog.openInformation(null, Messages.getString("successful"),
                Messages.getString("message.maintenance.5", args));
    }

    composite.update();
    return null;
}

From source file:com.clustercontrol.maintenance.view.action.MaintenanceModifyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???/*from   www . j av  a 2s.com*/
    this.viewPart = HandlerUtil.getActivePart(event);
    MaintenanceListView view = null;
    try {
        view = (MaintenanceListView) this.viewPart.getAdapter(MaintenanceListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

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

    MaintenanceListComposite composite = (MaintenanceListComposite) view.getListComposite();
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String managerName = null;
    String maintenanceId = null;
    if (list != null && list.size() > 0) {
        managerName = (String) list.get(GetMaintenanceListTableDefine.MANAGER_NAME);
        maintenanceId = (String) list.get(GetMaintenanceListTableDefine.MAINTENANCE_ID);
    }
    Table table = composite.getTableViewer().getTable();
    WidgetTestUtil.setTestId(this, null, table);

    //???????
    if (maintenanceId != null) {

        try {
            // ?
            MaintenanceDialog dialog = new MaintenanceDialog(this.viewPart.getSite().getShell(), managerName,
                    maintenanceId, PropertyDefineConstant.MODE_MODIFY);
            // MaintenanceSchedule scheduleList = new GetSchedule().getSchedule(maintenanceId);
            // dialog.setSchedule(scheduleList);
            // ???????????
            if (dialog.open() == IDialogConstants.OK_ID) {
                int selectIndex = table.getSelectionIndex();
                view.update();
                table.setSelection(selectIndex);
            }
        } catch (Exception e1) {
            m_log.warn("run(), " + e1.getMessage(), e1);
        }
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.maintenance.8"));
    }
    return null;
}

From source file:com.clustercontrol.monitor.run.composite.StringValueInfoComposite.java

License:Open Source License

/**
 * ?????/*  w  w  w  . j  a v  a2s  .c  o  m*/
 */
private void initialize(ArrayList<TableColumnInfo> tableDefine) {

    // ????
    GridData gridData = null;

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

    /*
     * 
     */
    this.m_infoList = new StringValueListComposite(this, SWT.BORDER, tableDefine);
    WidgetTestUtil.setTestId(this, "stringvaluelist", m_infoList);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = CommonMonitorDialog.LONG_UNIT;
    this.m_infoList.setLayoutData(gridData);

    /*
     * ?
     */
    Composite composite = new Composite(this, SWT.NONE);
    WidgetTestUtil.setTestId(this, "button", composite);
    layout = new GridLayout(1, true);
    layout.numColumns = 1;
    composite.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = CommonMonitorDialog.SHORT_UNIT;
    composite.setLayoutData(gridData);

    // 
    this.m_buttonAdd = this.createButton(composite, Messages.getString("add"));
    WidgetTestUtil.setTestId(this, "add", m_buttonAdd);
    this.m_buttonAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            // ?
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

            StringValueInfoCreateDialog dialog = new StringValueInfoCreateDialog(shell, logLineFlag);
            if (dialog.open() == IDialogConstants.OK_ID) {
                m_infoList.getMonitorStringValueInfoList().add(dialog.getInputData());
                m_infoList.update();
            }
        }
    });

    // 
    this.m_buttonModify = this.createButton(composite, Messages.getString("modify"));
    WidgetTestUtil.setTestId(this, "modify", m_buttonModify);
    this.m_buttonModify.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int order = m_infoList.getTableViewer().getTable().getSelectionIndex();
            if (order >= 0) {
                // ?
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                StringValueInfoCreateDialog dialog = new StringValueInfoCreateDialog(shell,
                        m_infoList.getMonitorStringValueInfoList().get(order));
                if (dialog.open() == IDialogConstants.OK_ID) {
                    m_infoList.getMonitorStringValueInfoList().remove(order);
                    m_infoList.getMonitorStringValueInfoList().add(order, dialog.getInputData());
                    m_infoList.setSelection();
                    m_infoList.update();
                }
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // 
    this.m_buttonDelete = this.createButton(composite, Messages.getString("delete"));
    WidgetTestUtil.setTestId(this, "delete", m_buttonDelete);
    this.m_buttonDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int order = m_infoList.getTableViewer().getTable().getSelectionIndex();

            if (order >= 0) {
                String detail = m_infoList.getFilterItem().getDescription();
                if (detail == null) {
                    detail = "";
                }

                String[] args = { detail };
                if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                        Messages.getString("message.monitor.31", args))) {
                    m_infoList.getMonitorStringValueInfoList().remove(order);
                    m_infoList.update();
                }
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // 
    this.m_buttonCopy = this.createButton(composite, Messages.getString("copy"));
    WidgetTestUtil.setTestId(this, "copy", m_buttonCopy);
    this.m_buttonCopy.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int order = m_infoList.getTableViewer().getTable().getSelectionIndex();
            if (order >= 0) {

                // ?
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                StringValueInfoCreateDialog dialog = new StringValueInfoCreateDialog(shell,
                        m_infoList.getMonitorStringValueInfoList().get(order));
                if (dialog.open() == IDialogConstants.OK_ID) {
                    Table table = m_infoList.getTableViewer().getTable();
                    WidgetTestUtil.setTestId(this, "modify", table);
                    int selectIndex = table.getSelectionIndex();
                    m_infoList.getMonitorStringValueInfoList().add(dialog.getInputData());
                    m_infoList.update();
                    table.setSelection(selectIndex);
                }
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // ?
    Label label = new Label(composite, SWT.NONE); // 
    WidgetTestUtil.setTestId(this, "up", label);
    this.m_buttonUp = this.createButton(composite, Messages.getString("up"));
    WidgetTestUtil.setTestId(this, "up", m_buttonUp);
    this.m_buttonUp.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int order = m_infoList.getTableViewer().getTable().getSelectionIndex();
            if (order >= 0) {
                m_infoList.up();
                m_infoList.update();
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });

    // ?
    this.m_buttonDown = this.createButton(composite, Messages.getString("down"));
    WidgetTestUtil.setTestId(this, "down", m_buttonDown);
    this.m_buttonDown.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int order = m_infoList.getTableViewer().getTable().getSelectionIndex();
            if (order >= 0) {
                m_infoList.down();
                m_infoList.update();
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.monitor.30"));
            }
        }
    });
}

From source file:com.clustercontrol.monitor.run.composite.TableItemInfoComposite.java

License:Open Source License

/**
 * ?????//w w  w .  j a  va2s . c om
 */
protected void initialize() {

    // ????
    GridData gridData = null;

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

    /*
     * 
     */
    this.m_infoList = new TableItemListComposite<T>(this, SWT.BORDER, this.m_define);
    WidgetTestUtil.setTestId(this, "pagelist", m_infoList);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 11;
    this.m_infoList.setLayoutData(gridData);

    /*
     * ?
     */
    Composite composite = new Composite(this, SWT.NONE);
    WidgetTestUtil.setTestId(this, "button", composite);
    layout = new GridLayout(1, true);
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.MULTI) != 0) {
        layout.numColumns = 2;
    }
    composite.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 4;
    composite.setLayoutData(gridData);

    // 
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.ADD) != 0) {
        this.m_buttonAdd = this.createButton(composite, Messages.getString("add"));
        WidgetTestUtil.setTestId(this, "add", m_buttonAdd);
        this.m_buttonAdd.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {

                // ?
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                CommonDialog dialog = m_define.createDialog(shell);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    m_define.getTableItemInfoManager().add(m_define.getCurrentCreatedItem());
                    m_infoList.update();
                }
            }
        });
    }
    // 
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.MODIFY) != 0) {
        this.m_buttonModify = this.createButton(composite, Messages.getString("modify"));
        WidgetTestUtil.setTestId(this, "modify", m_buttonModify);
        this.m_buttonModify.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                T item = getSelectedItem();
                if (item != null) {

                    // ?
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                    CommonDialog dialog = m_define.createDialog(shell, item);
                    if (dialog.open() == IDialogConstants.OK_ID) {
                        Table table = m_infoList.getTableViewer().getTable();
                        WidgetTestUtil.setTestId(this, "modify", table);
                        int selectIndex = table.getSelectionIndex();
                        m_define.getTableItemInfoManager().modify(item, m_define.getCurrentCreatedItem());
                        m_infoList.update();
                        table.setSelection(selectIndex);
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }

    // 
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.DELETE) != 0) {
        this.m_buttonDelete = this.createButton(composite, Messages.getString("delete"));
        WidgetTestUtil.setTestId(this, "delete", m_buttonDelete);
        this.m_buttonDelete.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                T item = m_infoList.getTableItem();

                if (item != null) {
                    String detail = m_define.getItemsIdentifier(item);

                    String[] args = { detail };
                    if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                            Messages.getString("message.monitor.31", args))) {

                        m_define.getTableItemInfoManager().delete(getSelectedItem());
                        m_infoList.update();
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }

    // 
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.COPY) != 0) {
        this.m_buttonCopy = this.createButton(composite, Messages.getString("copy"));
        WidgetTestUtil.setTestId(this, "copy", m_buttonCopy);
        this.m_buttonCopy.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                T item = m_infoList.getTableItem();
                if (item != null) {

                    // ?
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                    CommonDialog dialog = m_define.createDialog(shell, item);
                    if (dialog.open() == IDialogConstants.OK_ID) {
                        Table table = m_infoList.getTableViewer().getTable();
                        WidgetTestUtil.setTestId(this, "modify", table);
                        int selectIndex = table.getSelectionIndex();
                        m_define.getTableItemInfoManager().add(m_define.getCurrentCreatedItem());
                        m_infoList.update();
                        table.setSelection(selectIndex);
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }

    // 
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.SPACE) != 0) {
        Label label = new Label(composite, SWT.NONE); // 
        WidgetTestUtil.setTestId(this, "space", label);
    }

    // ?
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.UP) != 0) {
        this.m_buttonUp = this.createButton(composite, Messages.getString("up"));
        WidgetTestUtil.setTestId(this, "up", m_buttonUp);
        this.m_buttonUp.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                T item = m_infoList.getTableItem();
                if (item != null) {
                    if (m_define.getTableItemInfoManager().upOrder(item)) {
                        m_infoList.update();
                        selectItem(item);
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }

    // ?
    if ((this.m_define.getButtonOptions() & ITableItemCompositeDefine.DOWN) != 0) {
        this.m_buttonDown = this.createButton(composite, Messages.getString("down"));
        WidgetTestUtil.setTestId(this, "down", m_buttonDown);
        this.m_buttonDown.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                T item = m_infoList.getTableItem();
                if (item != null) {
                    if (m_define.getTableItemInfoManager().downOrder(item)) {
                        m_infoList.update();
                        selectItem(item);
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }
}

From source file:com.clustercontrol.notify.dialog.NotifyListDialog.java

License:Open Source License

/**
 * ????//from w w  w.j a v  a2 s . co  m
 *
 * @param parent ??
 *
 * @see com.clustercontrol.notify.composite.NotifyListComposite
 */
@Override
protected void customizeDialog(Composite parent) {
    Shell shell = this.getShell();

    // 
    shell.setText(Messages.getString("dialog.notify.list"));

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

    /*
     * 
     */
    this.notifyListComposite = new NotifyListComposite(parent, SWT.BORDER, isSelect, this.ownerRoleId);
    this.notifyListComposite.setManagerName(this.managerName);
    WidgetTestUtil.setTestId(this, "notifylist", notifyListComposite);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 7;
    gridData.heightHint = SWT.MIN;
    this.notifyListComposite.setLayoutData(gridData);
    this.notifyListComposite.setSelectNotify(this.notify);
    this.notifyListComposite.update();
    // ???????????????????
    if (!this.notifyListComposite.isShowFlg()) {
        this.close();
        return;
    }

    /*
     * ?
     */

    Composite composite = new Composite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, "button", composite);
    layout = new GridLayout(1, true);
    layout.numColumns = 1;
    composite.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 1;
    composite.setLayoutData(gridData);

    // 
    this.buttonAdd = this.createButton(composite, Messages.getString("add"));
    WidgetTestUtil.setTestId(this, "add", buttonAdd);
    this.buttonAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            NotifyTypeDialog dialog = new NotifyTypeDialog(getParentShell(), notifyListComposite, managerName);
            dialog.open();
        }
    });

    // 
    Label dummy = new Label(composite, SWT.NONE);
    WidgetTestUtil.setTestId(this, "dummy", dummy);
    this.buttonModify = this.createButton(composite, Messages.getString("modify"));
    WidgetTestUtil.setTestId(this, "modify", buttonModify);
    this.buttonModify.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            String notifyId = null;
            Integer notifyType = null;

            Table notifyListModifyTable = notifyListComposite.getTableViewer().getTable();
            WidgetTestUtil.setTestId(this, "modify", notifyListModifyTable);
            TableItem[] item = notifyListModifyTable.getSelection();

            if (item != null && item.length > 0) {
                try {
                    notifyId = (String) ((ArrayList<?>) item[0].getData())
                            .get(GetNotifyTableDefineCheckBox.NOTIFY_ID);
                    notifyType = (Integer) ((ArrayList<?>) item[0].getData())
                            .get(GetNotifyTableDefineCheckBox.NOTIFY_TYPE);
                } catch (Exception ex) {
                    Logger.getLogger(this.getClass()).debug(ex.getMessage(), ex);
                }
            }

            if (notifyId != null && notifyType != null) {
                NotifyModifyAction action = new NotifyModifyAction();
                if (action.openDialog(getParentShell(), NotifyListDialog.this.managerName, notifyId,
                        notifyType) == IDialogConstants.OK_ID) {
                    int selectIndex = notifyListModifyTable.getSelectionIndex();
                    notifyListComposite.update();
                    notifyListModifyTable.setSelection(selectIndex);
                }
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.notify.8"));
            }
        }
    });

    // 
    dummy = new Label(composite, SWT.NONE);
    WidgetTestUtil.setTestId(this, "dummydelete", dummy);
    this.buttonDelete = this.createButton(composite, Messages.getString("delete"));
    WidgetTestUtil.setTestId(this, "delete", buttonDelete);
    this.buttonDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            String notifyId = null;

            Table notifyListDeleteTable = notifyListComposite.getTableViewer().getTable();
            WidgetTestUtil.setTestId(this, "delete", notifyListDeleteTable);
            TableItem[] item = notifyListDeleteTable.getSelection();
            List<String> notifyIdList = new ArrayList<String>();

            if (item == null || item.length == 0) {
                return;
            }

            for (int i = 0; i < item.length; i++) {
                WidgetTestUtil.setTestId(this, "item" + i, item[i]);
                notifyId = (String) ((ArrayList<?>) item[i].getData())
                        .get(GetNotifyTableDefineCheckBox.NOTIFY_ID);
                notifyIdList.add(notifyId);
            }

            String[] args = new String[1];
            String msg = null;
            if (notifyIdList.isEmpty() == false) {
                if (notifyIdList.size() == 1) {
                    args[0] = notifyIdList.get(0);
                    msg = "message.notify.7";
                } else {
                    args[0] = Integer.toString(notifyIdList.size());
                    msg = "message.notify.51";
                }

                DeleteNotify deleteNotify = new DeleteNotify();

                if (deleteNotify.useCheck(managerName, notifyIdList) == Window.OK) { // ?ID?????????
                    if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                            Messages.getString(msg, args))) {

                        boolean result = deleteNotify.delete(managerName, notifyIdList);
                        if (result) {
                            notifyListComposite.update();
                        }
                        //                     else{
                        //                           MessageDialog.openError(
                        //                                 null,
                        //                                 Messages.getString("failed"),
                        //                                 Messages.getString("message.notify.6", args));
                        //                     }
                    }
                }
            } else {
                MessageDialog.openWarning(null, Messages.getString("warning"),
                        Messages.getString("message.notify.9"));
            }
        }
    });

    // 
    dummy = new Label(composite, SWT.NONE);
    WidgetTestUtil.setTestId(this, "dummy1", dummy);
    dummy = new Label(composite, SWT.NONE);
    WidgetTestUtil.setTestId(this, "dummy2", dummy);
    this.buttonValid = this.createButton(composite, Messages.getString("valid"));
    WidgetTestUtil.setTestId(this, "valid", buttonValid);
    this.buttonValid.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            //??
            setValid(true);
        }
    });

    // 
    this.buttonInvalid = this.createButton(composite, Messages.getString("invalid"));
    WidgetTestUtil.setTestId(this, "invalid", buttonInvalid);
    this.buttonInvalid.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            //??
            setValid(false);
        }
    });

    // ??
    Label line = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    WidgetTestUtil.setTestId(this, "line", line);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 8;
    line.setLayoutData(gridData);

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

    //?pack:resize to be its preferred size
    shell.pack();
    shell.setSize(new Point(sizeX, sizeY));

}

From source file:com.clustercontrol.notify.dialog.NotifyListDialog.java

License:Open Source License

/**
 * ??????????/*  w ww. j  a va2 s .  co m*/
 * ???????????
 * <p>
 *
 * ?????????
 */
@Override
protected void cancelPressed() {
    //??????
    if (isSelect) {

        if (!notifyListComposite.makeNotifyData()) {
            MessageDialog.openWarning(null, Messages.getString("warning"),
                    Messages.getString("message.notify.25"));
            return;
        }

    }

    //??cancelPress?
    super.cancelPressed();
}

From source file:com.clustercontrol.notify.dialog.NotifyListDialog.java

License:Open Source License

/**
 * ?//from   ww w  .jav  a  2s  . com
 *
 * @param valid
 */
public void setValid(boolean valid) {

    //???ID?
    ArrayList<String> list = notifyListComposite.getSelectionData();
    if (list != null && list.size() > 0) {

        StringBuilder notifyIds = new StringBuilder();
        for (int i = 0; i < list.size(); i++) {
            if (i > 0) {
                notifyIds.append(", ");
            }
            notifyIds.append(list.get(i));
        }

        String[] confirmArgs = { notifyIds.toString() };
        String message;
        if (valid)
            message = Messages.getString("message.notify.34", confirmArgs);
        else
            message = Messages.getString("message.notify.37", confirmArgs);
        if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), message)) {
            return;
        }

        for (int i = 0; i < list.size(); i++) {
            String notifyId = list.get(i);

            if (notifyId != null && !notifyId.equals("")) {
                //?
                NotifyInfo info = new GetNotify().getNotify(this.managerName, notifyId);

                //
                info.setValidFlg(valid);

                //
                new ModifyNotify().modify(this.managerName, info);
            }
        }

        int selectIndex = notifyListComposite.getTableViewer().getTable().getSelectionIndex();
        notifyListComposite.update();
        notifyListComposite.getTableViewer().getTable().setSelection(selectIndex);
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.notify.10"));
    }
}

From source file:com.clustercontrol.notify.mail.view.action.MailTemplateCopyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???//ww  w  .  j a v a2  s. c om
    this.viewPart = HandlerUtil.getActivePart(event);

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

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

    MailTemplateListComposite composite = (MailTemplateListComposite) view.getListComposite();
    WidgetTestUtil.setTestId(this, null, composite);
    WidgetTestUtil.setTestId(this, null, composite);

    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String managerName = null;
    String mailTemplateId = null;
    if (list != null && list.size() > 0) {
        managerName = (String) list.get(GetMailTemplateListTableDefine.MANAGER_NAME);
        mailTemplateId = (String) list.get(GetMailTemplateListTableDefine.MAIL_TEMPLATE_ID);
    }

    Table table = composite.getTableViewer().getTable();
    WidgetTestUtil.setTestId(this, null, table);

    // ???????
    if (mailTemplateId != null) {
        MailTemplateCreateDialog dialog = new MailTemplateCreateDialog(view.getListComposite().getShell(),
                managerName, mailTemplateId, PropertyDefineConstant.MODE_ADD);
        if (dialog.open() == IDialogConstants.OK_ID) {
            int selectIndex = table.getSelectionIndex();
            composite.update();
            table.setSelection(selectIndex);
        }
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.notify.mail.8"));
    }
    return null;
}