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.jobmanagement.view.action.StopJobAction.java

License:Open Source License

/**
 * ??// w  ww  .  j  av  a  2 s .c o  m
 *
 * @param managerName ???
 * @param sessionId ID
 * @param jobunitId ?ID
 * @param jobId ID
 * @param facilityId ID
 * @return ??
 *
 */
private Property getStopProperty(String managerName, String sessionId, String jobunitId, String jobId,
        String facilityId) {
    Locale locale = Locale.getDefault();

    //ID
    Property session = new Property(JobOperationConstant.SESSION, Messages.getString("session.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    session.setValue(sessionId);

    //ID
    Property jobUnit = new Property(JobOperationConstant.JOB_UNIT, Messages.getString("jobunit.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    jobUnit.setValue(jobunitId);

    //ID
    Property job = new Property(JobOperationConstant.JOB, Messages.getString("job.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    job.setValue(jobId);

    //ID
    Property facility = new Property(JobOperationConstant.FACILITY, Messages.getString("facility.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    ArrayList<Property> endList = new ArrayList<Property>();
    if (facilityId != null && facilityId.length() > 0) {
        facility.setValue(facilityId);
    } else {
        facility.setValue("");
    }

    //
    Property endStatus = null;
    if (facilityId == null) {
        endStatus = new Property(JobOperationConstant.END_STATUS, Messages.getString("end.status", locale),
                PropertyDefineConstant.EDITOR_SELECT);
        Object endStatusList[][] = {
                { "", EndStatusMessage.STRING_NORMAL, EndStatusMessage.STRING_WARNING,
                        EndStatusMessage.STRING_ABNORMAL },
                { "", EndStatusConstant.TYPE_NORMAL, EndStatusConstant.TYPE_WARNING,
                        EndStatusConstant.TYPE_ABNORMAL } };
        endStatus.setSelectValues(endStatusList);
        endStatus.setValue("");
        endList.add(endStatus);
    }

    //
    Property endValue = new Property(JobOperationConstant.END_VALUE, Messages.getString("end.value", locale),
            PropertyDefineConstant.EDITOR_NUM, DataRangeConstant.SMALLINT_HIGH, DataRangeConstant.SMALLINT_LOW);
    endValue.setValue("");
    endList.add(endValue);

    //
    Property control = new Property(JobOperationConstant.CONTROL, Messages.getString("control", locale),
            PropertyDefineConstant.EDITOR_SELECT);
    HashMap<String, Object> mainteEndMap = new HashMap<String, Object>();
    mainteEndMap.put("value", OperationMessage.STRING_STOP_MAINTENANCE);
    mainteEndMap.put("property", endList);
    HashMap<String, Object> forceEndMap = new HashMap<String, Object>();
    forceEndMap.put("value", OperationMessage.STRING_STOP_FORCE);
    forceEndMap.put("property", endList);
    List<Integer> values1 = null;
    try {
        JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(managerName);
        values1 = wrapper.getAvailableStopOperation(sessionId, jobunitId, jobId, facilityId);
    } catch (InvalidRole_Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
        throw new InternalError("values1 is null");
    } catch (Exception e) {
        m_log.warn("getStopProperty(), " + e.getMessage(), e);
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
        throw new InternalError("values1 is null");
    }
    ArrayList<Object> values2 = new ArrayList<Object>();
    if (values1.contains(OperationConstant.TYPE_STOP_AT_ONCE)) {
        values2.add(OperationMessage.STRING_STOP_AT_ONCE);
    }
    if (values1.contains(OperationConstant.TYPE_STOP_SUSPEND)) {
        values2.add(OperationMessage.STRING_STOP_SUSPEND);
    }
    if (values1.contains(OperationConstant.TYPE_STOP_WAIT)) {
        values2.add(OperationMessage.STRING_STOP_WAIT);
    }
    if (values1.contains(OperationConstant.TYPE_STOP_SKIP)) {
        values2.add(OperationMessage.STRING_STOP_SKIP);
    }
    if (values1.contains(OperationConstant.TYPE_STOP_MAINTENANCE)) {
        values2.add(mainteEndMap);
    }
    if (values1.contains(OperationConstant.TYPE_STOP_FORCE)) {
        values2.add(forceEndMap);
    }

    List<String> stringValues = new ArrayList<String>();
    for (Integer type : values1) {
        stringValues.add(OperationMessage.typeToString(type));
    }
    Object controlValues[][] = { stringValues.toArray(), values2.toArray() };
    control.setSelectValues(controlValues);
    if (stringValues.size() >= 1) {
        control.setValue(stringValues.get(0));
    } else {
        control.setValue("");
    }

    //??/??
    session.setModify(PropertyDefineConstant.MODIFY_NG);
    jobUnit.setModify(PropertyDefineConstant.MODIFY_NG);
    job.setModify(PropertyDefineConstant.MODIFY_NG);
    facility.setModify(PropertyDefineConstant.MODIFY_NG);
    control.setModify(PropertyDefineConstant.MODIFY_OK);
    if (endStatus != null) {
        endStatus.setModify(PropertyDefineConstant.MODIFY_OK);
    }
    endValue.setModify(PropertyDefineConstant.MODIFY_OK);

    // ??
    Property property = new Property(null, null, "");
    property.removeChildren();
    property.addChildren(session);
    property.addChildren(jobUnit);
    property.addChildren(job);
    if (facilityId != null) {
        property.addChildren(facility);
    }
    property.addChildren(control);

    String controlStr = (String) control.getValue();
    if (OperationMessage.STRING_STOP_MAINTENANCE.equals(controlStr)
            || OperationMessage.STRING_STOP_FORCE.equals(controlStr)) {
        if (endStatus != null) {
            control.addChildren(endStatus);
        }
        control.addChildren(endValue);
    }

    return property;
}

From source file:com.clustercontrol.maintenance.action.GetMaintenance.java

License:Open Source License

/**
 * ???/* w  w  w.j  a v a  2s .c om*/
 *
 * @param maintenanceId
 * @return
 */
public MaintenanceInfo getMaintenanceInfo(String managerName, String maintenanceId) {

    MaintenanceInfo info = null;
    try {
        MaintenanceEndpointWrapper wrapper = MaintenanceEndpointWrapper.getWrapper(managerName);
        info = wrapper.getMaintenanceInfo(maintenanceId);
    } catch (InvalidRole_Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
    } catch (Exception e) {
        m_log.warn("getMaintenanceInfo(), " + e.getMessage(), e);
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
    }
    return info;
}

From source file:com.clustercontrol.maintenance.action.ModifyHinemosProperty.java

License:Open Source License

/**
 * ???DB???//from  www  . j a  v a  2 s  .  c o  m
 * @param managerName ???
 * @param info ?
 * @return ???
 */
public boolean modify(String managerName, HinemosPropertyInfo info) {
    boolean ret = false;

    String[] args = { info.getKey(), managerName };
    try {
        HinemosPropertyEndpointWrapper wrapper = HinemosPropertyEndpointWrapper.getWrapper(managerName);
        wrapper.modifyHinemosProperty(info);

        MessageDialog.openInformation(null, Messages.getString("successful"),
                Messages.getString("message.hinemos.property.4", args));

        ret = true;

    } catch (HinemosUnknown_Exception e) {
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.property.5", args) + ", "
                        + HinemosMessage.replace(e.getMessage()));
    } 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.hinemos.property.5", args) + errMessage);
    }

    return ret;
}

From source file:com.clustercontrol.maintenance.action.ModifyMaintenance.java

License:Open Source License

public boolean modify(String managerName, MaintenanceInfo info) {
    boolean ret = false;

    String[] args = { info.getMaintenanceId(), managerName };
    try {//from  ww w .j  a  va 2s. c  o m
        MaintenanceEndpointWrapper wrapper = MaintenanceEndpointWrapper.getWrapper(managerName);
        wrapper.modifyMaintenance(info);

        MessageDialog.openInformation(null, Messages.getString("successful"),
                Messages.getString("message.maintenance.3", args));

        ret = true;

    } catch (HinemosUnknown_Exception e) {
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.maintenance.2", args) + ", "
                        + HinemosMessage.replace(e.getMessage()));
    } 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.maintenance.4", args) + errMessage);
    }

    return ret;
}

From source file:com.clustercontrol.maintenance.dialog.HinemosPropertyDialog.java

License:Open Source License

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

    if (HinemosPropertyInfo == null) {
        this.HinemosPropertyInfo = new HinemosPropertyInfo();
    }
    HinemosPropertyInfo.setKey(m_key.getText());
    HinemosPropertyInfo.setValueType(valueType);

    if (valueType == HinemosPropertyTypeConstant.TYPE_STRING) {
        HinemosPropertyInfo.setValueString(m_value.getText());
    } else if (valueType == HinemosPropertyTypeConstant.TYPE_NUMERIC) {
        if (m_value.getText() == null || m_value.getText().trim().length() == 0) {
            HinemosPropertyInfo.setValueNumeric(null);
        } else {
            try {
                HinemosPropertyInfo.setValueNumeric(Long.parseLong(m_value.getText().trim()));
            } catch (NumberFormatException e) {
                m_log.info("action() setValueNumeric, " + e.getMessage());
                Object[] args = { Messages.getString("hinemos.property.value"), Long.MIN_VALUE,
                        Long.MAX_VALUE };
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.common.4", args));

                return false;
            }
        }
    } else {
        HinemosPropertyInfo.setValueBoolean(Boolean.parseBoolean(m_blCombo.getText()));
    }

    HinemosPropertyInfo.setDescription(m_textDescription.getText());
    HinemosPropertyInfo.setOwnerRoleId(RoleIdConstant.ADMINISTRATORS);

    if (this.mode == PropertyDefineConstant.MODE_ADD) {
        // ???
        String managerName = this.m_managerComposite.getText();
        String[] args = { HinemosPropertyInfo.getKey(), managerName };
        try {
            HinemosPropertyEndpointWrapper wrapper = HinemosPropertyEndpointWrapper.getWrapper(managerName);
            wrapper.addHinemosProperty(HinemosPropertyInfo);
            MessageDialog.openInformation(null, Messages.getString("successful"),
                    Messages.getString("message.hinemos.property.2", args));

            result = true;
        } catch (HinemosPropertyDuplicate_Exception e) {
            // ????????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.hinemos.property.10", 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.hinemos.property.3", args) + errMessage);
        }

    } else if (this.mode == PropertyDefineConstant.MODE_MODIFY) {
        // ??
        result = new ModifyHinemosProperty().modify(m_managerComposite.getText(), HinemosPropertyInfo);
    }

    return result;
}

From source file:com.clustercontrol.maintenance.dialog.MaintenanceDialog.java

License:Open Source License

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

    if (this.maintenanceInfo != null) {
        if (this.mode == PropertyDefineConstant.MODE_ADD) {
            // ???
            String managerName = this.m_managerComposite.getText();
            String[] args = { maintenanceInfo.getMaintenanceId(), managerName };
            try {
                MaintenanceEndpointWrapper wrapper = MaintenanceEndpointWrapper.getWrapper(managerName);
                wrapper.addMaintenance(maintenanceInfo);

                MessageDialog.openInformation(null, Messages.getString("successful"),
                        Messages.getString("message.maintenance.1", args));

                result = true;

            } catch (MaintenanceDuplicate_Exception e) {
                // ID????????
                MessageDialog.openInformation(null, Messages.getString("message"),
                        Messages.getString("message.maintenance.11", 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.maintenance.2", args) + errMessage);
            }

        } else if (this.mode == PropertyDefineConstant.MODE_MODIFY) {
            // ??
            result = new ModifyMaintenance().modify(this.m_managerComposite.getText(), maintenanceInfo);
        }
    }

    return result;
}

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

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???/*ww w . ja va2s.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();

    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(GetHinemosPropertyTableDefine.MANAGER_NAME);
        if (map.get(managerName) == null) {
            map.put(managerName, new ArrayList<String>());
        }
    }

    int size = 0;
    StringBuilder key = new StringBuilder();
    for (Object obj : list) {
        List<?> objList = (List<?>) obj;
        String managerName = (String) objList.get(GetHinemosPropertyTableDefine.MANAGER_NAME);
        String k = (String) objList.get(GetHinemosPropertyTableDefine.KEY);
        map.get(managerName).add(k);
        if (size > 0) {
            key.append(", ");
        }
        key.append(k + "(" + managerName + ")");
        size++;
    }

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

    String[] args = { key.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();
        HinemosPropertyEndpointWrapper wrapper = HinemosPropertyEndpointWrapper.getWrapper(managerName);
        for (String val : entry.getValue()) {
            try {
                wrapper.deleteHinemosProperty(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.hinemos.property.6", args));
    }

    composite.update();
    return null;
}

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

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???//from  www  .  j a v a  2  s.  co  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.MaintenanceDisableAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    // ???//from   w w w.ja v a 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();

    Object[] objs = selection.toArray();

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

    // 1??????
    String[] args;
    StringBuffer targetList = new StringBuffer();
    StringBuffer successList = new StringBuffer();
    StringBuffer failureList = new StringBuffer();
    Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>();
    for (Object o : objs) {
        if (targetList.length() != 0) {
            targetList.append(", ");
        }
        String managerName = (String) ((ArrayList<?>) o).get(GetMaintenanceListTableDefine.MANAGER_NAME);
        if (map.get(managerName) == null) {
            map.put(managerName, new ArrayList<String>());
        }
    }
    for (Object o : objs) {
        if (targetList.length() != 0) {
            targetList.append(", ");
        }
        String managerName = (String) ((ArrayList<?>) o).get(GetMaintenanceListTableDefine.MANAGER_NAME);
        String maintenanceId = (String) ((ArrayList<?>) o).get(GetMaintenanceListTableDefine.MAINTENANCE_ID);
        targetList.append(maintenanceId);
        map.get(managerName).add(maintenanceId);
    }

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

    boolean hasRole = true;
    // 
    for (Map.Entry<String, List<String>> entry : map.entrySet()) {
        String managerName = entry.getKey();
        MaintenanceEndpointWrapper wrapper = MaintenanceEndpointWrapper.getWrapper(managerName);
        for (String maintenanceId : entry.getValue()) {
            try {
                wrapper.setMaintenanceStatus(maintenanceId, false);
                successList.append(maintenanceId + "(" + managerName + ")" + "\n");
            } catch (InvalidRole_Exception e) {
                failureList.append(maintenanceId + "\n");
                m_log.warn("run() setNotifyStatus targetId=" + maintenanceId + ", " + e.getMessage(), e);
                hasRole = false;
            } catch (Exception e) {
                failureList.append(maintenanceId + "\n");
                m_log.warn("run() setMaintenanceStatus maintenanceId=" + maintenanceId + ", " + 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.maintenance.20", args));
    }

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

    // ?
    composite.update();

    return null;
}

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

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

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

    Object[] objs = selection.toArray();

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

    // 1??????
    String[] args;
    StringBuffer targetList = new StringBuffer();
    StringBuffer successList = new StringBuffer();
    StringBuffer failureList = new StringBuffer();
    Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>();
    for (Object o : objs) {
        if (targetList.length() != 0) {
            targetList.append(", ");
        }
        String managerName = (String) ((ArrayList<?>) o).get(GetMaintenanceListTableDefine.MANAGER_NAME);
        if (map.get(managerName) == null) {
            map.put(managerName, new ArrayList<String>());
        }
    }
    for (Object o : objs) {
        if (targetList.length() != 0) {
            targetList.append(", ");
        }
        String managerName = (String) ((ArrayList<?>) o).get(GetMaintenanceListTableDefine.MANAGER_NAME);
        String maintenanceId = (String) ((ArrayList<?>) o).get(GetMaintenanceListTableDefine.MAINTENANCE_ID);
        targetList.append(maintenanceId);
        map.get(managerName).add(maintenanceId);
    }

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

    boolean hasRole = true;
    // 
    for (Map.Entry<String, List<String>> entry : map.entrySet()) {
        String managerName = entry.getKey();
        MaintenanceEndpointWrapper wrapper = MaintenanceEndpointWrapper.getWrapper(managerName);
        for (String maintenanceId : entry.getValue()) {
            try {
                wrapper.setMaintenanceStatus(maintenanceId, true);
                successList.append(maintenanceId + "(" + managerName + ")" + "\n");
            } catch (InvalidRole_Exception e) {
                failureList.append(maintenanceId + "\n");
                m_log.warn("run() setMaintenanceStatus maintenanceId=" + maintenanceId + ", " + e.getMessage(),
                        e);
                hasRole = false;
            } catch (Exception e) {
                failureList.append(maintenanceId + "\n");
                m_log.warn("run() setMaintenanceStatus maintenanceId=" + maintenanceId + ", " + 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.maintenance.18", args));
    }

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

    // ?
    composite.update();

    return null;
}