List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation
public static void openInformation(Shell parent, String title, String message)
From source file:com.clustercontrol.infra.dialog.FileTransferModuleDialog.java
License:Open Source License
@Override protected boolean action() { boolean result = false; createInputData();/*from w w w . j a v a2 s. c om*/ String action = null; if (infraInfo != null) { if (mode == PropertyDefineConstant.MODE_ADD | mode == PropertyDefineConstant.MODE_COPY) { // ??? action = Messages.getString("add"); } else if (mode == PropertyDefineConstant.MODE_MODIFY) { // ?? action = Messages.getString("modify"); } try { InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(this.m_managerName); wrapper.modifyInfraManagement(infraInfo); action += "(" + this.m_managerName + ")"; result = true; MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module"), action, Messages.getString("successful"), m_moduleId.getText() })); } catch (InfraManagementDuplicate_Exception e) { // ID? MessageDialog.openInformation(null, Messages.getString("message"), Messages .getString("message.infra.module.duplicate", new String[] { m_moduleId.getText() })); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (InfraManagementNotFound_Exception | NotifyDuplicate_Exception | NotifyNotFound_Exception | HinemosUnknown_Exception | InvalidUserPass_Exception | InvalidSetting_Exception e) { m_log.info( "action() modifyInfraManagement : " + e.getMessage() + " (" + e.getClass().getName() + ")"); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module"), action, Messages.getString("failed"), m_moduleId.getText() + "\n" + HinemosMessage.replace(e.getMessage()) })); } catch (Exception e) { m_log.info( "action() modifyInfraManagement : " + e.getMessage() + " (" + e.getClass().getName() + ")"); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module"), action, Messages.getString("failed"), m_moduleId.getText() + "\n" + HinemosMessage.replace(e.getMessage()) })); } } else { m_log.error("inputData InfraManagerInfo is null"); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module"), action, Messages.getString("failed"), m_moduleId.getText() })); } return result; }
From source file:com.clustercontrol.infra.dialog.InfraManagementDialog.java
License:Open Source License
@Override protected boolean action() { boolean result = false; InfraManagementInfo info = createInputData(); String action = null;// w w w.jav a2 s . c o m String errMsg = null; InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(this.m_managerComposite.getText()); if (mode == PropertyDefineConstant.MODE_MODIFY) { // ?? action = Messages.getString("modify"); try { wrapper.modifyInfraManagement(info); result = true; } catch (InvalidRole_Exception e) { m_log.info("action() modifyInfraManagement, " + e.getMessage()); errMsg = Messages.getString("message.accesscontrol.16"); } catch (InfraManagementDuplicate_Exception e) { // ID? MessageDialog.openInformation(null, Messages.getString("message"), Messages .getString("message.infra.module.duplicate", new String[] { m_managementId.getText() })); } catch (InfraManagementNotFound_Exception | HinemosUnknown_Exception | InvalidUserPass_Exception | InvalidSetting_Exception | NotifyDuplicate_Exception | NotifyNotFound_Exception e) { m_log.info("action() modifyInfraManagement, " + e.getMessage()); errMsg = HinemosMessage.replace(e.getMessage()); } catch (Exception e) { m_log.info("action() modifyInfraManagement, " + e.getMessage()); errMsg = HinemosMessage.replace(e.getMessage()); } } else if (mode == PropertyDefineConstant.MODE_ADD | mode == PropertyDefineConstant.MODE_COPY) { // ,??? action = Messages.getString("add"); try { wrapper.addInfraManagement(info); result = true; } catch (InvalidRole_Exception e) { m_log.info("action() addInfraManagement, " + e.getMessage()); errMsg = Messages.getString("message.accesscontrol.16"); } catch (InfraManagementDuplicate_Exception e) { m_log.info("action(); addInfraManagement, " + e.getMessage()); errMsg = Messages.getString("message.infra.module.duplicate", new String[] { m_managementId.getText() }); } catch (NotifyDuplicate_Exception | HinemosUnknown_Exception | InvalidUserPass_Exception | InvalidSetting_Exception e) { m_log.info("action() addInfraManagement, " + e.getMessage()); errMsg = HinemosMessage.replace(e.getMessage()); } catch (Exception e) { m_log.info("action() addInfraManagement, " + e.getMessage()); errMsg = HinemosMessage.replace(e.getMessage()); } } if (result) { action += "(" + this.m_managerComposite.getText() + ")"; MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), action, Messages.getString("successful"), m_managementId.getText() })); } else { MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), action, Messages.getString("failed"), m_managementId.getText() + "\n" + (errMsg != null ? errMsg : "") })); } return result; }
From source file:com.clustercontrol.infra.util.InfraFileUtil.java
License:Open Source License
public static void showSuccessDialog(String action, String extraArg) { MessageDialog.openInformation(null, Messages.getString("confirmed"), Messages.getString( "message.infra.action.result", new Object[] { Messages.getString("file"), action, Messages.getString("successful"), extraArg })); }
From source file:com.clustercontrol.infra.view.action.CheckInfraManagementAction.java
License:Open Source License
/** * ?????????????// w w w .ja va2s. c o m * * @param view ? * * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @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); if (!(viewPart instanceof InfraManagementView)) { return null; } InfraManagementView infraManagementView = null; try { infraManagementView = (InfraManagementView) viewPart.getAdapter(InfraManagementView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraManagementView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = null; if (!(infraManagementView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection)) { return null; } selection = (StructuredSelection) infraManagementView.getComposite().getTableViewer().getSelection(); if (selection == null) { return null; } List<?> sList = (List<?>) selection.toList(); Map<String, List<String>> managementIdMap = new ConcurrentHashMap<String, List<String>>(); for (Object obj : sList) { List<?> list = (List<?>) obj; String managerName = null; if (list == null) { continue; } managerName = (String) list.get(GetInfraManagementTableDefine.MANAGER_NAME); if (managementIdMap.get(managerName) == null) { managementIdMap.put(managerName, new ArrayList<String>()); } } for (Object obj : sList) { List<?> list = (List<?>) obj; String managementId = null; String managerName = null; if (list != null) { managementId = (String) list.get(GetInfraManagementTableDefine.MANAGEMENT_ID); managerName = (String) list.get(GetInfraManagementTableDefine.MANAGER_NAME); managementIdMap.get(managerName).add(managementId); } } Map<String, List<InfraManagementInfo>> managementMap = new ConcurrentHashMap<String, List<InfraManagementInfo>>(); Map<String, String> errorMsgs = new ConcurrentHashMap<>(); StringBuffer idbuf = new StringBuffer(); int size = 0; for (Map.Entry<String, List<String>> entry : managementIdMap.entrySet()) { String managerName = entry.getKey(); if (managementMap.get(managerName) == null) { managementMap.put(managerName, new ArrayList<InfraManagementInfo>()); } for (String managementId : entry.getValue()) { try { InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); InfraManagementInfo management = wrapper.getInfraManagement(managementId); managementMap.get(managerName).add(management); if (size > 0) { idbuf.append(", "); } idbuf.append(managementId); } catch (InvalidRole_Exception e) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.error("execute() : " + e.getClass().getName() + ", " + e.getMessage()); Object[] arg = new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.module.check"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) }; errorMsgs.put(managerName, Messages.getString("message.infra.action.result", arg)); } size++; } } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); return null; } boolean allRun = false; RunDialog dialog = new RunDialog(null, Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.management.id"), Messages.getString("infra.module.check"), idbuf.toString() })); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } allRun = dialog.isAllRun(); errorMsgs = new ConcurrentHashMap<>(); for (Map.Entry<String, List<InfraManagementInfo>> entry : managementMap.entrySet()) { String managerName = entry.getKey(); for (InfraManagementInfo management : entry.getValue()) { List<AccessInfo> accessInfoList = AccessUtil.getAccessInfoList(viewPart.getSite().getShell(), management.getFacilityId(), management.getOwnerRoleId(), managerName, infraManagementView.isUseNodeProp()); // ?????????null????? // ??????? if (accessInfoList == null) { continue; } List<String> moduleIdList = new ArrayList<String>(); for (InfraModuleInfo info : management.getModuleList()) { moduleIdList.add(info.getModuleId()); } String managementId = management.getManagementId(); try { InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); String sessionId = wrapper.createSession(managementId, moduleIdList, accessInfoList); while (true) { ModuleResult moduleResult = wrapper.checkInfraModule(sessionId, !allRun); if (!allRun && !ModuleUtil.displayResult(moduleResult.getModuleId(), moduleResult)) { break; } if (!moduleResult.isHasNext()) { break; } } wrapper.deleteSession(sessionId); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.infra.management.check.end")); } catch (InvalidRole_Exception e) { // ??? errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16")); continue; } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | InfraManagementNotFound_Exception | InfraModuleNotFound_Exception | SessionNotFound_Exception | FacilityNotFound_Exception | InvalidSetting_Exception e) { m_log.error("execute() : " + e.getClass().getName() + ", " + e.getMessage()); Object[] arg = new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.module.check"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) }; errorMsgs.put(managerName, Messages.getString("message.infra.action.result", arg)); continue; } catch (Exception e) { m_log.error("execute() : " + e.getClass().getName() + ", " + e.getMessage()); Object[] arg = new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.module.check"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) }; errorMsgs.put(managerName, Messages.getString("message.infra.action.result", arg)); continue; } } } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } infraManagementView.update(); return null; }
From source file:com.clustercontrol.infra.view.action.CheckInfraModuleAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }/* w w w . j ava 2 s. co m*/ // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraModuleView)) { return null; } InfraModuleView infraModuleView = null; try { infraModuleView = (InfraModuleView) viewPart.getAdapter(InfraModuleView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraModuleView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = null; if (infraModuleView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) infraModuleView.getComposite().getTableViewer().getSelection(); } InfraManagementInfo management = null; String managerName = infraModuleView.getComposite().getManagerName(); try { InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); management = wrapper.getInfraManagement(infraModuleView.getComposite().getManagementId()); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.16")); return null; } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.error("execute() : " + e.getClass().getName() + ", " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.module.check"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) })); return null; } if (selection == null || management == null) { return null; } String moduleId = (String) ((ArrayList<?>) selection.getFirstElement()) .get(GetInfraModuleTableDefine.MODULE_ID); boolean allRun = false; RunDialog dialog = new RunDialog(null, Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.module.check"), moduleId })); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } allRun = dialog.isAllRun(); List<AccessInfo> accessInfoList = AccessUtil.getAccessInfoList(viewPart.getSite().getShell(), management.getFacilityId(), management.getOwnerRoleId(), managerName, infraModuleView.isUseNodeProp()); // ?????????null????? // ??????? if (accessInfoList == null) { return null; } List<String> moduleIdList = new ArrayList<String>(); moduleIdList.add(moduleId); try { InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); String sessionId = wrapper.createSession(management.getManagementId(), moduleIdList, accessInfoList); while (true) { ModuleResult moduleResult = wrapper.checkInfraModule(sessionId, !allRun); if (!allRun && !ModuleUtil.displayResult(moduleResult.getModuleId(), moduleResult)) { break; } if (!moduleResult.isHasNext()) { break; } } MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.infra.management.check.end")); wrapper.deleteSession(sessionId); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.16")); return null; } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | InfraManagementNotFound_Exception | InfraModuleNotFound_Exception | SessionNotFound_Exception | FacilityNotFound_Exception | InvalidSetting_Exception e) { m_log.error("execute() : " + e.getClass().getName() + ", " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.module.run"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) })); return null; } catch (Exception e) { m_log.error("execute() : " + e.getClass().getName() + ", " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.module.run"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) })); return null; } infraModuleView.update(infraModuleView.getComposite().getManagerName(), infraModuleView.getComposite().getManagementId()); return null; }
From source file:com.clustercontrol.infra.view.action.DeleteInfraManagementAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }/* w ww . jav a2s. c om*/ // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraManagementView)) { return null; } InfraManagementView view = (InfraManagementView) viewPart; StructuredSelection selection = null; if (view.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) view.getComposite().getTableViewer().getSelection(); } StringBuffer strManagementIds = new StringBuffer(); String tmpManagementId = null; Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>(); if (selection != null) { for (Object object : selection.toList()) { String managerName = (String) ((ArrayList<?>) object) .get(GetInfraManagementTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<String>()); } } for (Object object : selection.toList()) { String managerName = (String) ((ArrayList<?>) object) .get(GetInfraManagementTableDefine.MANAGER_NAME); tmpManagementId = (String) ((ArrayList<?>) object).get(GetInfraManagementTableDefine.MANAGEMENT_ID); map.get(managerName).add(tmpManagementId); strManagementIds.append(tmpManagementId + ", "); } strManagementIds.setLength(strManagementIds.length() - 2); if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.management.id"), Messages.getString("delete"), strManagementIds }))) { Map<String, String> errMsg = new ConcurrentHashMap<String, String>(); for (Map.Entry<String, List<String>> entry : map.entrySet()) { String managerName = entry.getKey(); InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); List<String> managementIds = entry.getValue(); try { wrapper.deleteInfraManagement(managementIds); } catch (InvalidRole_Exception e) { // ??? errMsg.put(managerName, Messages.getString("message.accesscontrol.16")); } catch (InfraManagementNotFound_Exception | HinemosUnknown_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception e) { m_log.debug("execute() : " + e.getClass() + e.getMessage()); String arg = Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), Messages.getString("delete"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) }); errMsg.put(managerName, arg); } } if (errMsg.isEmpty()) { MessageDialog.openInformation(null, Messages.getString("confirmed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), Messages.getString("delete"), Messages.getString("successful"), strManagementIds })); } else { UIManager.showMessageBox(errMsg, true); } view.update(); } } return null; }
From source file:com.clustercontrol.infra.view.action.DeleteInfraModuleAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }/*from w w w .ja v a 2 s . c o m*/ // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraModuleView)) { return null; } InfraModuleView infraModuleView = null; try { infraModuleView = (InfraModuleView) viewPart.getAdapter(InfraModuleView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraModuleView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = null; if (infraModuleView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) infraModuleView.getComposite().getTableViewer().getSelection(); } List<String> moduleIds = new ArrayList<String>(); StringBuffer strModuleIds = new StringBuffer(); String tmpModuleId = null; if (selection != null) { for (Object object : selection.toList()) { tmpModuleId = (String) ((ArrayList<?>) object).get(GetInfraModuleTableDefine.MODULE_ID); moduleIds.add(tmpModuleId); strModuleIds.append(tmpModuleId + ", "); } strModuleIds.setLength(strModuleIds.length() - 2); } InfraManagementInfo info = null; try { InfraEndpointWrapper wrapper = InfraEndpointWrapper .getWrapper(infraModuleView.getComposite().getManagerName()); info = wrapper.getInfraManagement(infraModuleView.getComposite().getManagementId()); } catch (HinemosUnknown_Exception | InvalidRole_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.debug("execute getInfraManagement, " + e.getMessage()); } List<InfraModuleInfo> tmpDeleteList = new ArrayList<InfraModuleInfo>(); if (info != null && info.getModuleList() != null) { for (String moduleId : moduleIds) { for (InfraModuleInfo module : info.getModuleList()) { if (module.getModuleId().equals(moduleId)) { tmpDeleteList.add(module); break; } } } info.getModuleList().removeAll(tmpDeleteList); if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.module"), Messages.getString("delete"), strModuleIds }))) { try { InfraEndpointWrapper wrapper = InfraEndpointWrapper .getWrapper(infraModuleView.getComposite().getManagerName()); wrapper.modifyInfraManagement(info); MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module"), Messages.getString("delete") + "(" + infraModuleView.getComposite().getManagerName() + ")", Messages.getString("successful"), strModuleIds })); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.16")); return null; } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | InvalidSetting_Exception | NotifyDuplicate_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception | InfraManagementDuplicate_Exception e) { m_log.debug("execute modifyInfraManagement, " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.modlue"), Messages.getString("delete"), Messages.getString("failed"), HinemosMessage.replace(e.getMessage()) })); return null; } infraModuleView.update(infraModuleView.getComposite().getManagerName(), info.getManagementId()); } } return null; }
From source file:com.clustercontrol.infra.view.action.DisableInfraManagementAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }/*from ww w. j av a 2s. c o m*/ // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraManagementView)) { return null; } InfraManagementView infraManagementView = null; try { infraManagementView = (InfraManagementView) viewPart.getAdapter(InfraManagementView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraManagementView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = null; if (infraManagementView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) infraManagementView.getComposite().getTableViewer().getSelection(); } if (selection == null) { return null; } List<?> sList = (List<?>) selection.toList(); Map<String, List<String>> managementIdMap = new ConcurrentHashMap<String, List<String>>(); for (Object obj : sList) { List<?> list = (List<?>) obj; String managerName = null; if (list == null) { continue; } managerName = (String) list.get(GetInfraManagementTableDefine.MANAGER_NAME); if (managementIdMap.get(managerName) == null) { managementIdMap.put(managerName, new ArrayList<String>()); } } StringBuffer idbuf = new StringBuffer(); int size = 0; for (Object obj : sList) { List<?> list = (List<?>) obj; String managementId = null; String managerName = null; if (list != null) { managementId = (String) list.get(GetInfraManagementTableDefine.MANAGEMENT_ID); managerName = (String) list.get(GetInfraManagementTableDefine.MANAGER_NAME); managementIdMap.get(managerName).add(managementId); if (size > 0) { idbuf.append(", "); } idbuf.append(managementId); size++; } } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.management.id"), Messages.getString("infra.disable.setting"), idbuf.toString() })) == false) { return null; } StringBuffer sucManagementIds = new StringBuffer(); StringBuffer failManagementIds = new StringBuffer(); for (Map.Entry<String, List<String>> entry : managementIdMap.entrySet()) { String managerName = entry.getKey(); InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); for (String managementId : entry.getValue()) { try { InfraManagementInfo info = wrapper.getInfraManagement(managementId); info.setValidFlg(false); try { wrapper.modifyInfraManagement(info); sucManagementIds.append(managementId + "(" + managerName + "), "); } catch (InvalidSetting_Exception | NotifyDuplicate_Exception | HinemosUnknown_Exception | InvalidRole_Exception | InvalidUserPass_Exception | InfraManagementNotFound_Exception | InfraManagementDuplicate_Exception e) { m_log.debug("execute modifyInfraManagement, " + e.getMessage()); failManagementIds.append(managementId + ", "); } } catch (HinemosUnknown_Exception | InvalidRole_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.debug("execute getInfraManagement, " + e.getMessage()); failManagementIds.append(managementId + ", "); } } } //????? if (sucManagementIds.length() > 0) { sucManagementIds.setLength(sucManagementIds.length() - 2); MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), Messages.getString("infra.disable.setting"), Messages.getString("successful"), sucManagementIds })); } //???? if (failManagementIds.length() > 0) { failManagementIds.setLength(failManagementIds.length() - 2); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), Messages.getString("infra.disable.setting"), Messages.getString("failed"), failManagementIds })); } infraManagementView.update(); return null; }
From source file:com.clustercontrol.infra.view.action.DisableInfraModuleAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }/*ww w. j av a2s .c o m*/ // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraModuleView)) { return null; } InfraModuleView infraModuleView = null; try { infraModuleView = (InfraModuleView) viewPart.getAdapter(InfraModuleView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraModuleView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = null; if (infraModuleView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) infraModuleView.getComposite().getTableViewer().getSelection(); } StringBuffer strModuleIds = new StringBuffer(); List<String> moduleIds = new ArrayList<>(); if (selection != null) { for (Object object : selection.toList()) { String tmpModuleId = (String) ((ArrayList<?>) object).get(GetInfraModuleTableDefine.MODULE_ID); moduleIds.add(tmpModuleId); strModuleIds.append(tmpModuleId + ", "); } strModuleIds.setLength(strModuleIds.length() - 2); } String managerName = infraModuleView.getComposite().getManagerName(); if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.disable.setting"), strModuleIds })) == false) { return null; } InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); try { InfraManagementInfo info = wrapper.getInfraManagement(infraModuleView.getComposite().getManagementId()); for (String moduleId : moduleIds) { for (InfraModuleInfo module : info.getModuleList()) { if (module.getModuleId().equals(moduleId)) { module.setValidFlg(false); break; } } } try { wrapper.modifyInfraManagement(info); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.16")); return null; } catch (InvalidSetting_Exception | NotifyDuplicate_Exception | HinemosUnknown_Exception | InvalidUserPass_Exception | InfraManagementNotFound_Exception | InfraManagementDuplicate_Exception e) { m_log.debug("execute modifyInfraManagement, " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.disable.setting"), Messages.getString("failed"), strModuleIds })); return null; } } catch (InvalidRole_Exception e) { MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.16")); } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.debug("execute getInfraManagement, " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), HinemosMessage.replace(e.getMessage())); } MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.disable.setting") + "(" + managerName + ")", Messages.getString("successful"), strModuleIds })); infraModuleView.update(infraModuleView.getComposite().getManagerName(), infraModuleView.getComposite().getManagementId()); return null; }
From source file:com.clustercontrol.infra.view.action.EnableInfraManagementAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }// w ww .j ava2s.co m // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraManagementView)) { return null; } InfraManagementView infraManagementView = null; try { infraManagementView = (InfraManagementView) viewPart.getAdapter(InfraManagementView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraManagementView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = null; if (infraManagementView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) infraManagementView.getComposite().getTableViewer().getSelection(); } if (selection == null) { return null; } List<?> sList = (List<?>) selection.toList(); Map<String, List<String>> managementIdMap = new ConcurrentHashMap<String, List<String>>(); for (Object obj : sList) { List<?> list = (List<?>) obj; String managerName = null; if (list == null) { continue; } managerName = (String) list.get(GetInfraManagementTableDefine.MANAGER_NAME); if (managementIdMap.get(managerName) == null) { managementIdMap.put(managerName, new ArrayList<String>()); } } StringBuffer idbuf = new StringBuffer(); int size = 0; for (Object obj : sList) { List<?> list = (List<?>) obj; String managementId = null; String managerName = null; if (list != null) { managementId = (String) list.get(GetInfraManagementTableDefine.MANAGEMENT_ID); managerName = (String) list.get(GetInfraManagementTableDefine.MANAGER_NAME); managementIdMap.get(managerName).add(managementId); if (size > 0) { idbuf.append(", "); } idbuf.append(managementId); size++; } } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.management.id"), Messages.getString("infra.enable.setting"), idbuf.toString() })) == false) { return null; } StringBuffer sucManagementIds = new StringBuffer(); StringBuffer failManagementIds = new StringBuffer(); for (Map.Entry<String, List<String>> entry : managementIdMap.entrySet()) { String managerName = entry.getKey(); InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); for (String managementId : entry.getValue()) { try { InfraManagementInfo info = wrapper.getInfraManagement(managementId); info.setValidFlg(true); try { wrapper.modifyInfraManagement(info); sucManagementIds.append(managementId + "(" + managerName + ")" + ", "); } catch (InvalidSetting_Exception | NotifyDuplicate_Exception | HinemosUnknown_Exception | InvalidRole_Exception | InvalidUserPass_Exception | InfraManagementNotFound_Exception | InfraManagementDuplicate_Exception e) { m_log.debug("execute modifyInfraManagement, " + e.getMessage()); failManagementIds.append(managementId + ", "); } } catch (HinemosUnknown_Exception | InvalidRole_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.debug("execute getInfraManagement, " + e.getMessage()); failManagementIds.append(managementId + ", "); } } } //????? if (sucManagementIds.length() > 0) { sucManagementIds.setLength(sucManagementIds.length() - 2); MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), Messages.getString("infra.enable.setting"), Messages.getString("successful"), sucManagementIds })); } //???? if (failManagementIds.length() > 0) { failManagementIds.setLength(failManagementIds.length() - 2); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.management.id"), Messages.getString("infra.enable.setting"), Messages.getString("failed"), failManagementIds })); } infraManagementView.update(); return null; }