List of usage examples for org.eclipse.jface.viewers StructuredSelection toList
@Override
public List toList()
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; }/* www . j a v a 2s . c o m*/ // ??? 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; }//ww w . ja v a 2s.com // ??? 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 www . ja v a2 s . c om*/ // ??? 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; }//from w w w. j a va2 s .c om // ??? 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; }//from w w w. jav a 2s . c om // ??? 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; }
From source file:com.clustercontrol.infra.view.action.EnableInfraModuleAction.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 a va2 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(); } 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().getManagementId(); if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.infra.confirm.action", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.enable.setting"), strModuleIds })) == false) { return null; } InfraEndpointWrapper wrapper = InfraEndpointWrapper .getWrapper(infraModuleView.getComposite().getManagerName()); try { InfraManagementInfo info = wrapper.getInfraManagement(managerName); for (String moduleId : moduleIds) { for (InfraModuleInfo module : info.getModuleList()) { if (module.getModuleId().equals(moduleId)) { module.setValidFlg(true); 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.enable.setting"), Messages.getString("failed"), strModuleIds })); return null; } } catch (HinemosUnknown_Exception | InvalidRole_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.debug("execute getInfraManagement, " + e.getMessage()); } MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.infra.action.result", new Object[] { Messages.getString("infra.module.id"), Messages.getString("infra.enable.setting") + "(" + managerName + ")", Messages.getString("successful"), strModuleIds })); infraModuleView.update(infraModuleView.getComposite().getManagerName(), infraModuleView.getComposite().getManagementId()); return null; }
From source file:com.clustercontrol.infra.view.action.RunInfraManagementAction.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 . jav a 2s . c om*/ // ??? 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.run"), 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.run"), 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.runInfraModule(sessionId); 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.run.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.run"), 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.run"), 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.jobmanagement.composite.action.JobListSelectionChangedListener.java
License:Open Source License
/** * ??????<BR>/*www .j a v a2 s . c o m*/ * []???????????????? * <P> * <ol> * <li>????????ID????</li> * <li>[]???????</li> * <li>?????ID??????</li> * <li>[]????ID?????</li> * <li>[]?????</li> * </ol> * * @param event ? * * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ @Override public void selectionChanged(SelectionChangedEvent event) { //[]?? IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart viewPart = page.findView(JobListView.ID); //?? StructuredSelection selection = (StructuredSelection) event.getSelection(); if (viewPart != null && selection != null) { JobListView view = (JobListView) viewPart.getAdapter(JobListView.class); if (view == null) { m_log.info("selection changed: view is null"); return; } // Set last focus JobListComposite composite = view.getJobListComposite(); if (composite != null && composite.getTable().isFocusControl()) { view.setLastFocusComposite(composite); } JobTreeItem selectJobTreeItem = null; List<?> list = selection.toList(); List<JobTreeItem> itemList = new ArrayList<JobTreeItem>(); for (Object obj : list) { if (obj instanceof ArrayList) { ArrayList<?> item = (ArrayList<?>) obj; String jobId = (String) item.get(GetJobTableDefine.JOB_ID); if (m_list.getJobTreeItem() != null) { List<JobTreeItem> items = m_list.getJobTreeItem().getChildren(); for (int i = 0; i < items.size(); i++) { if (jobId.equals(items.get(i).getData().getId())) { selectJobTreeItem = items.get(i); break; } } itemList.add(selectJobTreeItem); } } } view.setEnabledAction(selectJobTreeItem, itemList, false); } }
From source file:com.clustercontrol.jobmanagement.composite.action.JobTreeSelectionChangedListener.java
License:Open Source License
/** * ??????<BR>// w w w. j av a2s . c om * []??????<BR> * ?????[]???<BR> * ?????[]????? * <P> * <ol> * <li>??????</li> * <li>[]????????</li> * <li>[]?????</li> * <li>[]??????</li> * </ol> * * @param event ? * * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ @Override public void selectionChanged(SelectionChangedEvent event) { JobTreeItem selectItem = null; //[]?? IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart viewPart = page.findView(JobListView.ID); //?? StructuredSelection selection = (StructuredSelection) event.getSelection(); if (viewPart != null && selection != null) { selectItem = (JobTreeItem) selection.getFirstElement(); List<?> list = selection.toList(); List<JobTreeItem> itemList = new ArrayList<JobTreeItem>(); for (Object obj : list) { if (obj instanceof JobTreeItem) { itemList.add((JobTreeItem) obj); } } JobListView view = (JobListView) viewPart.getAdapter(JobListView.class); if (view == null) { m_log.info("selection changed: view is null"); return; } // Set last focus JobTreeComposite composite = view.getJobTreeComposite(); if (composite != null && composite.getTree().isFocusControl()) { view.setLastFocusComposite(composite); } view.setEnabledAction(selectItem, itemList, true); } }
From source file:com.clustercontrol.jobmanagement.composite.JobTreeComposite.java
License:Open Source License
/** * ????// ww w . j a v a2 s . c om */ protected void initialize() { GridLayout layout = new GridLayout(1, true); this.setLayout(layout); layout.marginHeight = 0; layout.marginWidth = 0; // Add search bar Composite compSearch = new TreeSearchBarComposite(this, SWT.NONE, enableKeyPress); WidgetTestUtil.setTestId(this, "search", compSearch); compSearch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Tree tree = new Tree(this, SWT.MULTI | SWT.BORDER); WidgetTestUtil.setTestId(this, null, tree); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; tree.setLayoutData(gridData); m_viewer = new JobTreeViewer(tree); m_viewer.setContentProvider(new JobTreeContentProvider()); m_viewer.setLabelProvider(new JobTreeLabelProvider(m_useForView)); // ?? m_viewer.addSelectionChangedListener(new ISelectionChangedListener() { @SuppressWarnings("unchecked") @Override public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); m_selectItemList.clear(); m_selectItemList.addAll(selection.toList()); } }); // ???? if (m_useForView) { m_viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); JobTreeItem item = (JobTreeItem) selection.getFirstElement(); int type = item.getData().getType(); m_log.info("double click. type=" + type); if (type != JobConstant.TYPE_REFERJOB && type != JobConstant.TYPE_REFERJOBNET && type != JobConstant.TYPE_APPROVALJOB && type != JobConstant.TYPE_FILEJOB && type != JobConstant.TYPE_MONITORJOB && type != JobConstant.TYPE_JOB && type != JobConstant.TYPE_JOBUNIT && type != JobConstant.TYPE_JOBNET) { return; } String managerName = null; JobTreeItem mgrTree = JobTreeItemUtil.getManager(item); if (mgrTree == null) { managerName = item.getChildren().get(0).getData().getId(); } else { managerName = mgrTree.getData().getId(); } JobEditState jobEditState = JobEditStateUtil.getJobEditState(managerName); boolean readOnly = !jobEditState.isLockedJobunitId(item.getData().getJobunitId()); JobDialog dialog = new JobDialog(JobTreeComposite.this, JobTreeComposite.this.getShell(), managerName, readOnly); dialog.setJobTreeItem(item); // if (dialog.open() == IDialogConstants.OK_ID) { if (jobEditState.isLockedJobunitId(item.getData().getJobunitId())) { // ?????(??????? jobEditState.addEditedJobunit(item); if (item.getData().getType() == JobConstant.TYPE_JOBUNIT) { JobUtil.setJobunitIdAll(item, item.getData().getJobunitId()); } } m_viewer.sort(item.getParent()); m_viewer.refresh(item.getParent()); m_viewer.refresh(item); m_viewer.setSelection(new StructuredSelection(item), true); } } }); } updateTree(m_useForView); }