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.monitor.action.CommentEvent.java

License:Open Source License

/**
 * ??SessionBean??????????<BR>/*from   www  .jav a  2s .c  o  m*/
 * <p>???????{@link ArrayList}???????
 * ????????????
 * EventLogData{@link com.clustercontrol.monitor.ejb.entity.EventLogData}??????????
 *
 * ???????????????????
 * <p>
 * <dl>
 *  <dt>EventLogData?</dt>
 * </dl>
 *
 * @param list ?EventLogData?
 * @return ??????</code> true </code>
 *
 */
public boolean updateComment(String managerName, Property property) {

    ArrayList<?> value = null;

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.MONITOR_ID);
    String monitorId = "";
    if (!"".equals(value.get(0))) {
        monitorId = (String) value.get(0);
    }

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.MONITOR_DETAIL_ID);
    String monitorDetailId = "";
    if (!"".equals(value.get(0))) {
        monitorDetailId = (String) value.get(0);
    }

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.PLUGIN_ID);
    String pluginId = "";
    if (!"".equals(value.get(0))) {
        pluginId = (String) value.get(0);
    }

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.FACILITY_ID);
    String facilityId = "";
    if (!"".equals(value.get(0))) {
        facilityId = (String) value.get(0);
    }

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.OUTPUT_DATE);
    Long outputDate = null;
    if (!"".equals(value.get(0)) && value.get(0) != null) {
        outputDate = ((Date) value.get(0)).getTime();
    }

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.COMMENT);
    String comment = null;

    if (!"".equals(value.get(0))) {
        comment = (String) value.get(0);
    } else {
        comment = "";
    }

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.COMMENT_DATE);
    Long commentDate = null;
    if (!"".equals(value.get(0)) && value.get(0) != null) {
        commentDate = ((Date) value.get(0)).getTime();
    }

    value = PropertyUtil.getPropertyValue(property, EventInfoConstant.COMMENT_USER);
    String commentUser = null;
    if (!"".equals(value.get(0))) {
        commentUser = (String) value.get(0);
    }

    try {
        MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName);
        wrapper.modifyComment(monitorId, monitorDetailId, pluginId, facilityId, outputDate, comment,
                commentDate, commentUser);
        return true;

    } catch (InvalidRole_Exception e) {
        // ??????
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
    } catch (HinemosUnknown_Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.monitor.58") + ", " + HinemosMessage.replace(e.getMessage()));
    } catch (EventLogNotFound_Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.monitor.59") + ", " + HinemosMessage.replace(e.getMessage()));
    } catch (Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.monitor.58") + ", " + HinemosMessage.replace(e.getMessage()));
    }
    return false;
}

From source file:com.clustercontrol.monitor.composite.ScopeListComposite.java

License:Open Source License

public void update(String managerName, String facilityId) {
    super.update();

    ArrayList<?> infoList = null;
    if (facilityId == null) {
        facilityId = ReservedFacilityIdConstant.ROOT_SCOPE;
    }//from   www  .  ja  va  2s.  c  om
    try {
        m_log.debug("managerName=" + managerName + ", faciiltyID=" + facilityId);
        List<ScopeDataInfo> records = null;
        MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName);
        records = wrapper.getScopeList(facilityId, true, true, false);
        infoList = ConvertListUtil.scopeInfoDataListToArrayList(managerName, records);
    } catch (InvalidRole_Exception e) {
        if (ClientSession.isDialogFree()) {
            ClientSession.occupyDialog();
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
            ClientSession.freeDialog();
        }
    } catch (MonitorNotFound_Exception e) {
        MessageDialog.openError(null, Messages.getString("message"),
                Messages.getString("message.monitor.64") + ", " + HinemosMessage.replace(e.getMessage()));
    } catch (FacilityNotFound_Exception e) {
        MessageDialog.openError(null, Messages.getString("message"),
                Messages.getString("message.monitor.64") + ", " + HinemosMessage.replace(e.getMessage()));
    } catch (HinemosUnknown_Exception e) {
        MessageDialog.openError(null, Messages.getString("message"),
                Messages.getString("message.monitor.64") + ", " + HinemosMessage.replace(e.getMessage()));
    } catch (Exception e) {
        if (ClientSession.isDialogFree()) {
            ClientSession.occupyDialog();
            if (e instanceof ClientTransportException) {
                m_log.info("update() getEventList, " + e.getMessage());
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.hinemos.failure.transfer") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            } else {
                m_log.warn("update() getScopeList, " + e.getMessage(), e);
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.hinemos.failure.unexpected") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            }
            ClientSession.freeDialog();
        }
    }

    if (infoList == null) {
        infoList = new ArrayList<Object>();
    }

    //???
    this.updateStatus(infoList);

    tableViewer.setInput(infoList);
}

From source file:com.clustercontrol.monitor.dialog.EventInfoDialog.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) {
    Shell shell = this.getShell();

    // 
    shell.setText(Messages.getString("dialog.monitor.info.events"));

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

    /*
     * 
     */

    // 
    Label label = new Label(parent, SWT.LEFT);
    WidgetTestUtil.setTestId(this, "attribute", label);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 1;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("attribute") + " : ");

    // 
    Tree table = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER);
    WidgetTestUtil.setTestId(this, null, table);

    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 1;
    table.setLayoutData(gridData);

    this.propertySheet = new PropertySheet(table);
    this.propertySheet.setSize(170, 280);

    // ???
    eventCommentProperty = null;
    if (m_list != null) {
        String managerName = (String) m_list.get(GetEventListTableDefine.MANAGER_NAME);
        String monitorId = (String) m_list.get(GetEventListTableDefine.MONITOR_ID);
        String monitorDetailId = (String) m_list.get(GetEventListTableDefine.MONITOR_DETAIL_ID);
        String pluginId = (String) m_list.get(GetEventListTableDefine.PLUGIN_ID);
        String facilityId = (String) m_list.get(GetEventListTableDefine.FACILITY_ID);
        Date receiveTime = (Date) m_list.get(GetEventListTableDefine.RECEIVE_TIME);

        try {
            MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName);
            EventDataInfo info = wrapper.getEventInfo(monitorId, monitorDetailId, pluginId, facilityId,
                    receiveTime.getTime());
            eventCommentProperty = EventDataPropertyUtil.dto2property(info, Locale.getDefault());
            this.propertySheet.setInput(eventCommentProperty);
        } catch (InvalidRole_Exception e) {
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
        } catch (Exception e) {
            m_log.warn("customizeDialog() getEventInfo, " + e.getMessage(), e);
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
        }
    }

    // ??
    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 = 1;
    line.setLayoutData(gridData);

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

From source file:com.clustercontrol.monitor.dialog.EventReportDialog.java

License:Open Source License

protected boolean output() {
    boolean flag = false;
    // Write event file
    File file = new File(this.filePath);
    FileOutputStream fOut = null;
    try {//from ww w . j a v a2  s .com
        if (!file.createNewFile()) {
            m_log.warn("file is already exist.");
        }

        fOut = new FileOutputStream(file);

        DataHandler handler = null;

        Property condition = this.getInputData();

        // ?
        PropertyUtil.deletePropertyDefine(condition);
        EventFilterInfo filter = EventFilterPropertyUtil.property2dto(condition);
        MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(this.managerName);
        String language = Locale.getDefault().getLanguage();
        handler = wrapper.downloadEventFile(this.facilityId, filter, this.fileName, language);
        handler.writeTo(fOut);

        // Start download file
        if (ClusterControlPlugin.isRAP()) {
            FileDownloader.openBrowser(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    this.filePath, this.fileName);
        }

        flag = true;
    } catch (InvalidRole_Exception e) {
        // ??????
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
    } catch (MonitorNotFound_Exception e) {
        MessageDialog.openError(null, Messages.getString("message"),
                Messages.getString("message.monitor.66") + ", " + HinemosMessage.replace(e.getMessage()));
    } catch (HinemosUnknown_Exception e) {
        MessageDialog.openError(null, Messages.getString("message"),
                Messages.getString("message.monitor.66") + ", " + HinemosMessage.replace(e.getMessage()));
    } catch (Exception e) {
        m_log.warn("run() downloadEventFile, " + e.getMessage(), e);
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
    } finally {
        try {
            if (fOut != null) {
                fOut.close();
            }
            if (ClusterControlPlugin.isRAP()) {
                // Clean up temporary file
                FileDownloader.cleanup(this.filePath);
            }
        } catch (IOException e) {
            m_log.warn("output() fileOutputStream.close(), " + e.getMessage(), e);
        }
        try {
            MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(this.managerName);
            wrapper.deleteEventFile(this.fileName);
        } catch (Exception e) {
            m_log.warn("output() deleteEventFile, " + e.getMessage(), e);
        }
    }
    return flag;
}

From source file:com.clustercontrol.monitor.view.action.CollectorDisableAction.java

License:Open Source License

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

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

    MonitorListComposite composite = (MonitorListComposite) 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.monitor.1"));
        return null;
    }

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

    Map<String, List<String[]>> dataMap = new ConcurrentHashMap<String, List<String[]>>();
    for (int i = 0; i < objs.length; i++) {
        managerName = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MANAGER_NAME);
        if (dataMap.get(managerName) == null) {
            dataMap.put(managerName, new ArrayList<String[]>());
        }
    }

    for (int i = 0; i < objs.length; i++) {
        managerName = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MANAGER_NAME);
        monitorId = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MONITOR_ID);
        monitorTypeId = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MONITOR_TYPE_ID);

        String[] arg = { monitorId, monitorTypeId };
        dataMap.get(managerName).add(arg);

        if (targetList.length() > 0) {
            targetList.append(", ");

        }
        targetList.append(monitorId);
    }

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

    boolean hasRole = true; //?????????
    // 
    for (Map.Entry<String, List<String[]>> map : dataMap.entrySet()) {
        String mgrName = map.getKey();
        MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(mgrName);

        for (String[] strArgs : map.getValue()) {
            monitorId = strArgs[0];
            monitorTypeId = strArgs[1];

            try {
                wrapper.setStatusCollector(monitorId, monitorTypeId, false);
                if (successList.length() > 0) {
                    successList.append(", ");
                }
                successList.append(monitorId + "(" + mgrName + ")");
            } catch (InvalidRole_Exception e) {
                if (failureList.length() > 0) {
                    failureList.append(", ");
                }
                failureList.append(monitorId + "(" + HinemosMessage.replace(e.getMessage()) + ")");
                m_log.warn("run() setStatusCollector monitorId=" + monitorId + ", " + e.getMessage(), e);
                hasRole = false;
            } catch (Exception e) {
                if (failureList.length() > 0) {
                    failureList.append(", ");
                }
                failureList.append(monitorId + "(" + HinemosMessage.replace(e.getMessage()) + ")");
                m_log.warn("run() setStatusCollector monitorId=" + monitorId + ", " + 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.monitor.78", args));
    }

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

    // ?
    composite.update();

    return null;
}

From source file:com.clustercontrol.monitor.view.action.CollectorEnableAction.java

License:Open Source License

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

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

    MonitorListComposite composite = (MonitorListComposite) 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.monitor.1"));
        return null;
    }

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

    Map<String, List<String[]>> dataMap = new ConcurrentHashMap<String, List<String[]>>();
    for (int i = 0; i < objs.length; i++) {
        managerName = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MANAGER_NAME);
        if (dataMap.get(managerName) == null) {
            dataMap.put(managerName, new ArrayList<String[]>());
        }
    }

    for (int i = 0; i < objs.length; i++) {
        managerName = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MANAGER_NAME);
        monitorId = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MONITOR_ID);
        monitorTypeId = (String) ((ArrayList<?>) objs[i]).get(GetMonitorListTableDefine.MONITOR_TYPE_ID);

        String[] arg = { monitorId, monitorTypeId };
        dataMap.get(managerName).add(arg);

        if (targetList.length() > 0) {
            targetList.append(", ");

        }
        targetList.append(monitorId);
    }

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

    boolean hasRole = true; //?????????
    // 
    for (Map.Entry<String, List<String[]>> map : dataMap.entrySet()) {
        String mgrName = map.getKey();
        MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(mgrName);

        for (String[] strArgs : map.getValue()) {
            monitorId = strArgs[0];
            monitorTypeId = strArgs[1];

            try {
                wrapper.setStatusCollector(monitorId, monitorTypeId, true);
                if (successList.length() > 0) {
                    successList.append(", ");
                }
                successList.append(monitorId + "(" + mgrName + ")");
            } catch (InvalidRole_Exception e) {
                if (failureList.length() > 0) {
                    failureList.append(", ");
                }
                failureList.append(monitorId + "(" + HinemosMessage.replace(e.getMessage()) + ")");
                m_log.warn("run() setStatusCollector monitorId=" + monitorId + ", "
                        + HinemosMessage.replace(e.getMessage()));
                hasRole = false;
            } catch (Exception e) {
                if (failureList.length() > 0) {
                    failureList.append(", ");
                }
                failureList.append(monitorId + "(" + HinemosMessage.replace(e.getMessage()) + ")");
                m_log.warn("run() setStatusCollector monitorId=" + monitorId + ", "
                        + HinemosMessage.replace(e.getMessage()));
            }
        }
    }

    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.monitor.72", args));
    }

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

    // ?
    composite.update();

    return null;
}

From source file:com.clustercontrol.monitor.view.action.EventBatchConfirmAction.java

License:Open Source License

/**
 * [?]???????????//  www.j  av a 2 s.c om
 * <p>
 * <ol>
 * <li>[?]???</li>
 * <li>????????</li>
 * <li>??????ID????</li>
 * <li>ID????????? </li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.monitor.dialog.EventBatchConfirmDialog
 * @see com.clustercontrol.monitor.view.EventView#update()
 */
@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;
    }

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

    EventBatchConfirmDialog dialog = new EventBatchConfirmDialog(this.viewPart.getSite().getShell());

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

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

    FacilityTreeItem item = view.getScopeTreeComposite().getSelectItem();
    if (null == item || item.getData().getFacilityType() == FacilityConstant.TYPE_COMPOSITE) {
        MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.monitor.47"));
        return null;
    }

    String managerName;
    String facilityId;
    if (item.getData().getFacilityType() == FacilityConstant.TYPE_MANAGER) {
        facilityId = null;
        managerName = item.getData().getFacilityId();
    } else {
        facilityId = item.getData().getFacilityId();
        FacilityTreeItem manager = ScopePropertyUtil.getManager(item);
        managerName = manager.getData().getFacilityId();
    }

    if (dialog.open() == IDialogConstants.OK_ID) {
        Property condition = dialog.getInputData();
        PropertyUtil.deletePropertyDefine(condition);
        try {
            MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName);
            EventBatchConfirmInfo info = EventBatchConfirmPropertyUtil.property2dto(condition);
            wrapper.modifyBatchConfirm(ConfirmConstant.TYPE_CONFIRMED, facilityId, info);
            view.update(false);
        } catch (InvalidRole_Exception e) {
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
        } catch (HinemosUnknown_Exception e) {
            MessageDialog.openError(null, Messages.getString("message"),
                    Messages.getString("message.monitor.60") + ", " + HinemosMessage.replace(e.getMessage()));
        } catch (Exception e) {
            m_log.warn("run() modifyBatchConfirm, " + e.getMessage(), e);
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
        }
    }
    return null;
}

From source file:com.clustercontrol.monitor.view.action.EventCollectGraphOffAction.java

License:Open Source License

/**
 * []?????ON??????/*w ww .j av  a  2 s  .  co m*/
 * <p>
 * <ol>
 * <li>[]??????????</li>
 * <li>????ON???? </li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.monitor.view.EventView
 * @see com.clustercontrol.monitor.view.EventView#update()
 */
@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;
    }

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

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

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

    EventListComposite composite = (EventListComposite) eventView.getListComposite();
    WidgetTestUtil.setTestId(this, null, composite);
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

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

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

    for (Object obj : list) {
        @SuppressWarnings("unchecked")
        List<String> objList = (List<String>) obj;
        String managerName = (String) objList.get(GetEventListTableDefine.MANAGER_NAME);
        map.get(managerName).add(objList);
    }

    // ?????ON???????????
    if (map.isEmpty()) {
        return null;
    }

    for (Map.Entry<String, List<List<String>>> entry : map.entrySet()) {
        String managerName = entry.getKey();
        MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName);
        List<List<String>> records = entry.getValue();
        ArrayList<EventDataInfo> eventInfoList = ConvertListUtil.listToEventLogDataList(records);

        if (eventInfoList != null && eventInfoList.size() > 0) {
            try {
                wrapper.modifyCollectGraphFlg(eventInfoList, Boolean.FALSE);
                eventView.update(false);
            } catch (InvalidRole_Exception e) {
                // ??????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.accesscontrol.16"));
            } catch (MonitorNotFound_Exception e) {
                MessageDialog.openError(null, Messages.getString("message"),
                        Messages.getString("message.monitor.60") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            } catch (HinemosUnknown_Exception e) {
                MessageDialog.openError(null, Messages.getString("message"),
                        Messages.getString("message.monitor.60") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            } catch (Exception e) {
                m_log.warn("run(), " + e.getMessage(), e);
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.hinemos.failure.unexpected") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            }
        }
    }

    return null;
}

From source file:com.clustercontrol.monitor.view.action.EventCollectGraphOnAction.java

License:Open Source License

/**
 * []?????ON??????//from w  ww. j  a  va2  s .c  o  m
 * <p>
 * <ol>
 * <li>[]??????????</li>
 * <li>????ON???? </li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.monitor.view.EventView
 * @see com.clustercontrol.monitor.view.EventView#update()
 */
@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;
    }

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

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

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

    EventListComposite composite = (EventListComposite) eventView.getListComposite();
    WidgetTestUtil.setTestId(this, null, composite);
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

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

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

    for (Object obj : list) {
        @SuppressWarnings("unchecked")
        List<String> objList = (List<String>) obj;
        String managerName = (String) objList.get(GetEventListTableDefine.MANAGER_NAME);
        map.get(managerName).add(objList);
    }

    // ?????ON???????????
    if (map.isEmpty()) {
        return null;
    }

    for (Map.Entry<String, List<List<String>>> entry : map.entrySet()) {
        String managerName = entry.getKey();
        MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName);
        List<List<String>> records = entry.getValue();
        ArrayList<EventDataInfo> eventInfoList = ConvertListUtil.listToEventLogDataList(records);

        if (eventInfoList != null && eventInfoList.size() > 0) {
            try {
                wrapper.modifyCollectGraphFlg(eventInfoList, Boolean.TRUE);
                eventView.update(false);
            } catch (InvalidRole_Exception e) {
                // ??????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.accesscontrol.16"));
            } catch (MonitorNotFound_Exception e) {
                MessageDialog.openError(null, Messages.getString("message"),
                        Messages.getString("message.monitor.60") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            } catch (HinemosUnknown_Exception e) {
                MessageDialog.openError(null, Messages.getString("message"),
                        Messages.getString("message.monitor.60") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            } catch (Exception e) {
                m_log.warn("run(), " + e.getMessage(), e);
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.hinemos.failure.unexpected") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            }
        }
    }

    return null;
}

From source file:com.clustercontrol.monitor.view.action.EventConfirmAction.java

License:Open Source License

/**
 * []???????????/*from   w  w  w. j a v  a2  s.  com*/
 * <p>
 * <ol>
 * <li>[]??????????</li>
 * <li>??????????? </li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.monitor.view.EventView
 * @see com.clustercontrol.monitor.view.EventView#update()
 */
@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;
    }

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

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

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

    EventListComposite composite = (EventListComposite) eventView.getListComposite();
    WidgetTestUtil.setTestId(this, null, composite);
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

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

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

    for (Object obj : list) {
        @SuppressWarnings("unchecked")
        List<String> objList = (List<String>) obj;
        String managerName = (String) objList.get(GetEventListTableDefine.MANAGER_NAME);
        map.get(managerName).add(objList);
    }

    // ????????????????
    if (map.isEmpty()) {
        return null;
    }

    for (Map.Entry<String, List<List<String>>> entry : map.entrySet()) {
        String managerName = entry.getKey();
        MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName);
        List<List<String>> records = entry.getValue();
        ArrayList<EventDataInfo> eventInfoList = ConvertListUtil.listToEventLogDataList(records);

        if (eventInfoList != null && eventInfoList.size() > 0) {
            try {
                wrapper.modifyConfirm(eventInfoList, ConfirmConstant.TYPE_CONFIRMED);
                eventView.update(false);
            } catch (InvalidRole_Exception e) {
                // ??????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.accesscontrol.16"));
            } catch (MonitorNotFound_Exception e) {
                MessageDialog.openError(null, Messages.getString("message"),
                        Messages.getString("message.monitor.60") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            } catch (HinemosUnknown_Exception e) {
                MessageDialog.openError(null, Messages.getString("message"),
                        Messages.getString("message.monitor.60") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            } catch (Exception e) {
                m_log.warn("run(), " + e.getMessage(), e);
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.hinemos.failure.unexpected") + ", "
                                + HinemosMessage.replace(e.getMessage()));
            }
        }
    }

    return null;
}