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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a standard information dialog.

Usage

From source file:com.clustercontrol.notify.view.action.NotifyEnableAction.java

License:Open Source License

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

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

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

    Object[] objs = selection.toArray();

    // 1????????
    if (objs.length == 0) {
        MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                Messages.getString("message.notify.8"));
        return null;
    }

    // 1??????
    String notifyId = null;
    String[] args;
    StringBuffer targetList = new StringBuffer();
    StringBuffer successList = new StringBuffer();
    StringBuffer failureList = new StringBuffer();

    Map<String, List<String>> enableMap = new ConcurrentHashMap<String, List<String>>();
    for (int i = 0; i < objs.length; i++) {
        String managerName = (String) ((ArrayList<?>) objs[i]).get(NotifyTableDefineNoCheckBox.MANAGER_NAME);
        enableMap.put(managerName, new ArrayList<String>());
    }
    for (int i = 0; i < objs.length; i++) {
        notifyId = (String) ((ArrayList<?>) objs[i]).get(NotifyTableDefineNoCheckBox.NOTIFY_ID);
        String managerName = (String) ((ArrayList<?>) objs[i]).get(NotifyTableDefineNoCheckBox.MANAGER_NAME);
        enableMap.get(managerName).add(notifyId);
        targetList.append(notifyId + "\n");
    }

    // ?(NG)
    args = new String[] { targetList.toString() };
    if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"),
            Messages.getString("message.notify.34", args))) {
        return null;
    }

    boolean hasRole = true;
    // 
    for (Map.Entry<String, List<String>> map : enableMap.entrySet()) {
        String managerName = map.getKey();
        NotifyEndpointWrapper wrapper = NotifyEndpointWrapper.getWrapper(map.getKey());
        for (String targetId : map.getValue()) {
            try {
                wrapper.setNotifyStatus(targetId, true);
                successList.append(targetId + "(" + managerName + ")" + "\n");
            } catch (InvalidRole_Exception e) {
                failureList.append(targetId + "\n");
                m_log.warn("run() setNotifyStatus targetId=" + targetId + ", " + e.getMessage(), e);
                hasRole = false;
            } catch (Exception e) {
                failureList.append(targetId + "\n");
                m_log.warn("run() setNotifyStatus targetId=" + targetId + ", " + e.getMessage(), e);
            }
        }
    }

    if (!hasRole) {
        // ????????
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
    }

    // ?
    if (successList.length() != 0) {
        args = new String[] { successList.toString() };
        MessageDialog.openInformation(null, Messages.getString("successful"),
                Messages.getString("message.notify.35", args));
    }

    // 
    if (failureList.length() != 0) {
        args = new String[] { failureList.toString() };
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.notify.36", args));
    }

    // ?
    composite.update();
    return null;
}

From source file:com.clustercontrol.performance.monitor.composite.CollectorItemComboComposite.java

License:Open Source License

/**
 * ???????/*from w  w w.ja  va 2s.co m*/
 *
 * @param facilityId ID
 */
public void setCollectorItemCombo(String managerName, String facilityId) {
    // ???
    List<CollectorItemInfo> itemInfoList = null;

    try {
        MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName);
        itemInfoList = wrapper.getAvailableCollectorItemList(facilityId);
    } catch (InvalidRole_Exception e) {
        // ??????
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
    } catch (Exception e) {
        // ?
        m_log.warn("setCollectorItemCombo() getAvailableCollectorItemList, " + e.getMessage(), e);
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
    }
    if (itemInfoList == null) {
        itemInfoList = new ArrayList<CollectorItemInfo>();
    }

    // ?????
    m_comboCollectorItem.removeAll();

    // ??
    m_comboCollectorItem.add("");
    m_comboCollectorItem.setData("", null);

    Iterator<CollectorItemInfo> itr = itemInfoList.iterator();
    while (itr.hasNext()) {
        CollectorItemInfo itemInfo = itr.next();

        String itemName = CollectorItemCodeFactory.getFullItemName(managerName, itemInfo);
        itemName = HinemosMessage.replace(itemName);
        m_comboCollectorItem.add(itemName);
        m_comboCollectorItem.setData(itemName, itemInfo);
    }
}

From source file:com.clustercontrol.performance.monitor.composite.CollectorItemComboComposite.java

License:Open Source License

/**
 * ??????/*from   w ww .  j  av a2  s  .  c  o  m*/
 * @param monitor
 */
public void select(String managerName, MonitorInfo monitor) {
    // 
    PerfCheckInfo perfCheckInfo = monitor.getPerfCheckInfo();

    // ??????????????
    if (perfCheckInfo == null) {
        return;
    }

    String facilityId = monitor.getFacilityId();

    setCollectorItemCombo(managerName, facilityId);

    int index = 0;

    List<CollectorItemInfo> itemInfoList = null;
    try {
        MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName);
        itemInfoList = wrapper.getAvailableCollectorItemList(facilityId);
    } catch (InvalidRole_Exception e) {
        // ??????
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
    } catch (Exception e) {
        // ?
        m_log.warn("select() getAvailableCollectorItemList, " + e.getMessage(), e);
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
    }
    if (itemInfoList == null) {
        itemInfoList = new ArrayList<CollectorItemInfo>();
    }

    Iterator<CollectorItemInfo> itr = itemInfoList.iterator();
    // getAvailableCollectorItemList?CPU????
    // ???????i=1???
    int i = 1;
    while (itr.hasNext()) {
        CollectorItemInfo itemInfo = itr.next();

        if (itemInfo.getItemCode().equals(perfCheckInfo.getItemCode())
                && itemInfo.getDisplayName().equals(perfCheckInfo.getDeviceDisplayName())) {
            index = i;
            break;
        }
        i++;
    }

    this.m_comboCollectorItem.select(index);
}

From source file:com.clustercontrol.performance.monitor.dialog.PerformanceCreateDialog.java

License:Open Source License

/**
 * ????/*  w  ww  . j a v a2s.co  m*/
 *
 * @param parent
 *            ?
 */
@Override
protected void customizeDialog(Composite parent) {
    // ?????
    item1 = Messages.getString("select.value");
    item2 = Messages.getString("select.value");

    super.customizeDialog(parent);
    itemName.setEditable(false);
    measure.setEditable(false);

    // 
    shell.setText(Messages.getString("dialog.performance.monitor.create.modify"));

    // ????
    GridData gridData = null;

    /*
     * ????
     */
    Group groupCheckRule = new Group(groupRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule);
    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    layout.numColumns = BASIC_UNIT;
    groupCheckRule.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalSpan = BASIC_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    groupCheckRule.setLayoutData(gridData);
    groupCheckRule.setText(Messages.getString("check.rule"));

    // 
    this.m_comboCollectorItem = new CollectorItemComboComposite(groupCheckRule, SWT.DROP_DOWN | SWT.READ_ONLY);
    WidgetTestUtil.setTestId(this, "collectoritem", m_comboCollectorItem);
    gridData = new GridData();
    gridData.horizontalSpan = BASIC_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_comboCollectorItem.setLayoutData(gridData);

    // ?????????
    m_comboCollectorItem.setCollectorItemCombo(this.m_monitorBasic.getManagerListComposite().getText(), null);

    m_monitorBasic.getButtonScope().addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            m_comboCollectorItem.setCollectorItemCombo(PerformanceCreateDialog.this.getManagerName(),
                    m_monitorBasic.getFacilityId());
        }
    });

    //????
    if (!updateFlg) {
        this.getMonitorBasicScope().getManagerListComposite().getComboManagerName()
                .addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        m_comboCollectorItem.setCollectorItemCombo(
                                PerformanceCreateDialog.this.getManagerName(), m_monitorBasic.getFacilityId());
                    }
                });
    }

    // 
    this.m_breakdownFlg = new Button(groupCheckRule, SWT.CHECK);
    WidgetTestUtil.setTestId(this, "breakdownflg", m_breakdownFlg);
    this.m_breakdownFlg.setText(Messages.getString("dialog.performance.monitor.collect.detail"));
    gridData = new GridData();
    gridData.horizontalSpan = BASIC_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_breakdownFlg.setLayoutData(gridData);

    // ???????
    m_comboCollectorItem.getCombo().addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            itemName.setText(m_comboCollectorItem.getCombo().getText());
            if (m_comboCollectorItem.getCollectorItem() != null) {
                measure.setText(HinemosMessage.replace(
                        CollectorItemCodeFactory.getMeasure(PerformanceCreateDialog.this.getManagerName(),
                                m_comboCollectorItem.getCollectorItem().getItemCode())));
                update();
            }
        }
    });

    // 
    this.adjustDialog();

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

From source file:com.clustercontrol.performance.monitor.dialog.PerformanceCreateDialog.java

License:Open Source License

/**
 * ?????//  w  w  w . j  a  v  a  2 s  .com
 *
 * @return true?false
 *
 * @see com.clustercontrol.dialog.CommonDialog#action()
 */
@Override
protected boolean action() {
    boolean result = false;

    MonitorInfo info = this.inputData;
    CollectorItemInfo itemInfo = (CollectorItemInfo) this.m_comboCollectorItem.getCombo()
            .getData(this.itemName.getText());
    String managerName = this.getManagerName();
    String[] args = { info.getMonitorId(), managerName };
    if (itemInfo == null || itemInfo.getItemCode().length() == 0) {
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.monitor.34", args));
        return false;
    }
    String itemCode = CollectorItemCodeFactory.getFullItemName(managerName, itemInfo);
    String itemName = itemCode.split("]")[0].concat("]");
    info.setItemName(itemName);
    String itemMeasure = CollectorItemCodeFactory.getMeasure(itemName, itemInfo.getItemCode());
    info.setMeasure(itemMeasure);

    MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName);
    if (!this.updateFlg) {
        // ???
        try {
            result = wrapper.addMonitor(info);

            if (result) {
                MessageDialog.openInformation(null, Messages.getString("successful"),
                        Messages.getString("message.monitor.33", args));
            } else {
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.monitor.34", args));
            }
        } catch (MonitorDuplicate_Exception e) {
            // ID????????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.monitor.53", args));

        } catch (Exception e) {
            String errMessage = "";
            if (e instanceof InvalidRole_Exception) {
                // ??????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.accesscontrol.16"));
            } else {
                errMessage = ", " + HinemosMessage.replace(e.getMessage());
            }

            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.monitor.34", args) + errMessage);
        }
    } else {
        // ??
        String errMessage = "";
        try {
            result = wrapper.modifyMonitor(info);
        } catch (InvalidRole_Exception e) {
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
        } catch (Exception e) {
            errMessage = ", " + HinemosMessage.replace(e.getMessage());
        }

        if (result) {
            MessageDialog.openInformation(null, Messages.getString("successful"),
                    Messages.getString("message.monitor.35", args));
        } else {
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.monitor.36", args) + errMessage);
        }
    }

    return result;
}

From source file:com.clustercontrol.ping.dialog.PingCreateDialog.java

License:Open Source License

/**
 * ????//from  w  w  w  .j  a  v a 2 s .  c  o m
 *
 * @param parent
 *            ?
 */
@Override
protected void customizeDialog(Composite parent) {
    // ???(%)??
    item1 = Messages.getString("response.time.milli.sec");
    item2 = Messages.getString("ping.reach");

    // ?ping??????
    criterion1 = Messages.getString("less");
    criterion2 = Messages.getString("less");

    super.customizeDialog(parent);
    m_numericValueInfo.setInfoWarnText("1000", "1", "3000", "51");

    // 
    shell.setText(Messages.getString("dialog.ping.create.modify"));

    // ????
    Label label = null;
    // ????
    GridData gridData = null;

    /*
     * ????
     */
    Group groupCheckRule = new Group(groupRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule);
    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    layout.numColumns = BASIC_UNIT;
    groupCheckRule.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalSpan = BASIC_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    groupCheckRule.setLayoutData(gridData);
    groupCheckRule.setText(Messages.getString("check.rule"));

    /*
     * 
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "runcount", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("run.count") + " : ");

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

    // ??
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "count", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TEXT_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setText(Messages.getString("count"));
    label.setLayoutData(gridData);

    /*
     * 
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "runinterval", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("run.interval") + " : ");

    // 
    this.m_textRunInterval = new Text(groupCheckRule, SWT.BORDER);
    WidgetTestUtil.setTestId(this, "runinterval", m_textRunInterval);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_VALUE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_textRunInterval.setLayoutData(gridData);
    this.m_textRunInterval.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_TEXT_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setText(Messages.getString("milli.sec"));
    label.setLayoutData(gridData);

    /*
     * 
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "timeout", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    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 = WIDTH_VALUE_LONG;
    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, "labelmillisec", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_VALUE_LONG;
    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, "responsetime", label);
    gridData = new GridData();
    gridData.horizontalSpan = 14;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);

    // ????
    this.itemName.setText(Messages.getString("response.time"));

    // ????
    this.measure.setText(Messages.getString("time.msec"));

    // 
    this.adjustDialog();

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

}

From source file:com.clustercontrol.ping.dialog.PingCreateDialog.java

License:Open Source License

/**
 * ?????//from   ww  w . ja v  a  2 s . c  om
 *
 * @return true?false
 *
 * @see com.clustercontrol.dialog.CommonDialog#action()
 */
@Override
protected boolean action() {
    boolean result = false;

    MonitorInfo info = this.inputData;
    String managerName = this.getManagerName();
    MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName);
    if (info != null) {
        String[] args = { info.getMonitorId(), managerName };
        if (!this.updateFlg) {
            // ???
            try {
                result = wrapper.addMonitor(info);

                if (result) {
                    MessageDialog.openInformation(null, Messages.getString("successful"),
                            Messages.getString("message.monitor.33", args));
                } else {
                    MessageDialog.openError(null, Messages.getString("failed"),
                            Messages.getString("message.monitor.34", args));
                }
            } catch (MonitorDuplicate_Exception e) {
                // ID????????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.monitor.53", args));

            } catch (Exception e) {
                String errMessage = "";
                if (e instanceof InvalidRole_Exception) {
                    // ??????
                    MessageDialog.openInformation(null, Messages.getString("message"),
                            Messages.getString("message.accesscontrol.16"));
                } else {
                    errMessage = ", " + HinemosMessage.replace(e.getMessage());
                }

                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.monitor.34", args) + errMessage);

            }

        } else {
            // ??
            String errMessage = "";
            try {
                result = wrapper.modifyMonitor(info);
            } catch (InvalidRole_Exception e) {
                // ??????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.accesscontrol.16"));
            } catch (Exception e) {
                errMessage = ", " + HinemosMessage.replace(e.getMessage());
            }

            if (result) {
                MessageDialog.openInformation(null, Messages.getString("successful"),
                        Messages.getString("message.monitor.35", args));
            } else {
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.monitor.36", args) + errMessage);
            }
        }
    }

    return result;
}

From source file:com.clustercontrol.port.dialog.PortCreateDialog.java

License:Open Source License

/**
 * ????/*from w  ww .ja  v  a  2s  .  co m*/
 *
 * @param parent
 *            ?
 */
@Override
protected void customizeDialog(Composite parent) {
    // ????
    item1 = Messages.getString("response.time.milli.sec");
    item2 = Messages.getString("response.time.milli.sec");

    super.customizeDialog(parent);
    m_numericValueInfo.setInfoWarnText("0", "1000", "1000", "3000");

    // 
    shell.setText(Messages.getString("dialog.port.create.modify"));

    // ????
    Label label = null;
    // ????
    GridData gridData = null;

    /*
     * ????
     */
    Group groupCheckRule = new Group(groupRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule);
    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = HALF_MARGIN;
    layout.marginHeight = HALF_MARGIN;
    layout.numColumns = BASIC_UNIT;
    groupCheckRule.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalSpan = BASIC_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    groupCheckRule.setLayoutData(gridData);
    groupCheckRule.setText(Messages.getString("check.rule"));

    /*
     * 
     */
    // TCP??
    this.m_radioTCP = new Button(groupCheckRule, SWT.RADIO);
    WidgetTestUtil.setTestId(this, "tcp", m_radioTCP);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_radioTCP.setLayoutData(gridData);
    this.m_radioTCP.setText(Messages.getString("tcp.connect.only"));
    this.m_radioTCP.setSelection(true);

    // 
    this.m_radioService = new Button(groupCheckRule, SWT.RADIO);
    WidgetTestUtil.setTestId(this, "service", m_radioService);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_radioService.setLayoutData(gridData);
    this.m_radioService.setText(Messages.getString("service.protocol"));
    this.m_radioService.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            setEnabledComboService(m_radioService.getSelection());
        }
    });

    //
    this.m_comboService = new Combo(groupCheckRule, SWT.DROP_DOWN | SWT.READ_ONLY);
    WidgetTestUtil.setTestId(this, "service", m_comboService);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_VALUE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_comboService.setLayoutData(gridData);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_FTP);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_SMTP);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_SMTPS);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_POP3);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_POP3S);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_IMAP);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_IMAPS);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_NTP);
    this.m_comboService.add(ProtocolMessage.STRING_PROTOCOL_DNS);
    //this.m_comboService.setEnabled(false);

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

    /*
     * ??
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "portnumber", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("port.number") + " : ");
    // 
    this.m_textPortNo = new Text(groupCheckRule, SWT.BORDER);
    WidgetTestUtil.setTestId(this, "protno", m_textPortNo);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_VALUE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_textPortNo.setLayoutData(gridData);
    this.m_textPortNo.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            update();
        }
    });

    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "space2", label);
    gridData = new GridData();
    gridData.horizontalSpan = HALF_UNIT - (WIDTH_TITLE_LONG + WIDTH_VALUE_LONG);
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);

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

    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "labelruncount", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE + MIN_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("trial.run.count") + " : ");

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

    // ??
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "labelcount", label);
    gridData = new GridData();
    gridData.horizontalSpan = HALF_UNIT - (WIDTH_TITLE + WIDTH_VALUE + WIDTH_VALUE_LONG);
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("count"));

    /*
     * 
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "trialruninterval", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("trial.run.interval") + " : ");

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

    // ??
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "labelmillisec1", label);
    gridData = new GridData();
    gridData.horizontalSpan = HALF_UNIT - (WIDTH_TITLE_LONG + WIDTH_VALUE_LONG);
    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, "spacetimeout", label);
    gridData = new GridData();
    gridData.horizontalSpan = MIN_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "labeltimeout", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE + MIN_UNIT;
    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 = WIDTH_VALUE_LONG;
    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, "labelmillisec2", label);
    gridData = new GridData();
    gridData.horizontalSpan = HALF_UNIT - (WIDTH_TITLE + WIDTH_VALUE + WIDTH_VALUE_LONG);
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("milli.sec"));

    // ????
    this.itemName.setText(Messages.getString("response.time"));

    // ????
    this.measure.setText(Messages.getString("time.msec"));

    // 
    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(monitorId);
        } catch (InvalidRole_Exception e) {
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
            throw new InternalError(e.getMessage());
        } catch (Exception e) {
            // Manager???????????
            m_log.warn("customizeDialog(), " + HinemosMessage.replace(e.getMessage()), e);
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
            throw new InternalError(e.getMessage());
        }
    }
    this.setInputData(info);

}

From source file:com.clustercontrol.port.dialog.PortCreateDialog.java

License:Open Source License

/**
 * ?????/*from   www  .ja  va2 s. co m*/
 *
 * @return true?false
 *
 * @see com.clustercontrol.dialog.CommonDialog#action()
 */
@Override
protected boolean action() {
    boolean result = false;

    MonitorInfo info = this.inputData;
    if (info != null) {
        String[] args = { info.getMonitorId(), getManagerName() };
        MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(getManagerName());
        if (!this.updateFlg) {
            // ???
            try {
                result = wrapper.addMonitor(info);

                if (result) {
                    MessageDialog.openInformation(null, Messages.getString("successful"),
                            Messages.getString("message.monitor.33", args));
                } else {
                    MessageDialog.openError(null, Messages.getString("failed"),
                            Messages.getString("message.monitor.34", args));
                }
            } catch (MonitorDuplicate_Exception e) {
                // ID????????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.monitor.53", args));
            } catch (Exception e) {
                String errMessage = "";
                if (e instanceof InvalidRole_Exception) {
                    // ??????
                    MessageDialog.openInformation(null, Messages.getString("message"),
                            Messages.getString("message.accesscontrol.16"));
                } else {
                    errMessage = ", " + HinemosMessage.replace(e.getMessage());
                }

                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.monitor.34", args) + errMessage);
            }
        } else {
            // ??
            String errMessage = "";
            try {
                result = wrapper.modifyMonitor(info);
            } catch (InvalidRole_Exception e) {
                // ??????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.accesscontrol.16"));
            } catch (Exception e) {
                errMessage = ", " + HinemosMessage.replace(e.getMessage());
            }

            if (result) {
                MessageDialog.openInformation(null, Messages.getString("successful"),
                        Messages.getString("message.monitor.35", args));
            } else {
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.monitor.36", args) + errMessage);
            }
        }
    }

    return result;
}

From source file:com.clustercontrol.process.dialog.ProcessCreateDialog.java

License:Open Source License

/**
 * ????//w  w  w . j  a v a  2 s  .  co m
 *
 * @param parent
 *            ?
 */
@Override
protected void customizeDialog(Composite parent) {
    // ????
    item1 = Messages.getString("process.number");
    item2 = Messages.getString("process.number");

    super.customizeDialog(parent);
    m_numericValueInfo.setInfoWarnText("1", "99", "99", "99");

    // 
    shell.setText(Messages.getString("dialog.process.create.modify"));

    // ????
    Label label = null;
    // ????
    GridData gridData = null;

    /*
     * ????
     */
    Group groupCheckRule = new Group(groupRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule);
    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    layout.numColumns = BASIC_UNIT;
    groupCheckRule.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalSpan = BASIC_UNIT;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    groupCheckRule.setLayoutData(gridData);
    groupCheckRule.setText(Messages.getString("check.rule"));

    /*
     * 
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "command", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("command") + " : ");
    // 
    this.m_textCommand = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT);
    WidgetTestUtil.setTestId(this, "command", m_textCommand);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TEXT_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_textCommand.setLayoutData(gridData);
    this.m_textCommand.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent arg0) {
            update();
        }
    });

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

    /*
     * 
     */
    // 
    label = new Label(groupCheckRule, SWT.NONE);
    WidgetTestUtil.setTestId(this, "param", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("param") + " : ");
    // 
    this.m_textParam = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT);
    WidgetTestUtil.setTestId(this, "param", m_textParam);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TEXT_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_textParam.setLayoutData(gridData);
    this.m_textParam.setText(".*");

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

    // ?????
    this.m_checkCaseSensitive = new Button(groupCheckRule, SWT.CHECK);
    WidgetTestUtil.setTestId(this, "casesensitive", m_checkCaseSensitive);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TEXT_LONG;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.m_checkCaseSensitive.setLayoutData(gridData);
    this.m_checkCaseSensitive.setText(Messages.getString("case.sensitive"));

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

    // ????
    this.itemName.setText(Messages.getString("process.number"));

    // ????
    this.measure.setText(Messages.getString("process.measure"));

    // 
    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"));
            throw new InternalError(e.getMessage());
        } catch (Exception e) {
            // ?
            m_log.warn("customizeDialog(), " + HinemosMessage.replace(e.getMessage()), e);
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
            throw new InternalError(e.getMessage());
        }
    }
    this.setInputData(info);

}