List of usage examples for org.eclipse.jface.viewers StructuredSelection toList
@Override
public List toList()
From source file:com.clustercontrol.monitor.view.action.EventUnconfirmAction.java
License:Open Source License
/** * []???????????// w w w . j av a2 s . co m * <p> * <ol> * <li>[]??????????</li> * <li>?????????? </li> * <li>[]???</li> * </ol> * * @see org.eclipse.core.commands.IHandler#execute * @see com.clustercontrol.monitor.view.EventView * @see com.clustercontrol.monitor.view.EventView#update() */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { // ??? this.viewPart = HandlerUtil.getActivePart(event); EventView view = null; try { view = (EventView) this.viewPart.getAdapter(EventView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (view == null) { m_log.info("execute: view is null"); return null; } EventListComposite composite = (EventListComposite) view.getListComposite(); WidgetTestUtil.setTestId(this, null, composite); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = selection.toList(); Map<String, List<List<String>>> map = new ConcurrentHashMap<String, List<List<String>>>(); for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetEventListTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<List<String>>()); } } for (Object obj : list) { @SuppressWarnings("unchecked") List<String> objList = (List<String>) obj; String managerName = (String) objList.get(GetEventListTableDefine.MANAGER_NAME); map.get(managerName).add(objList); } // ???????????????? if (map.isEmpty()) { return null; } for (Map.Entry<String, List<List<String>>> entry : map.entrySet()) { String managerName = entry.getKey(); MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName); List<List<String>> records = entry.getValue(); ArrayList<EventDataInfo> eventInfoList = ConvertListUtil.listToEventLogDataList(records); if (eventInfoList != null && eventInfoList.size() > 0) { try { wrapper.modifyConfirm(eventInfoList, ConfirmConstant.TYPE_UNCONFIRMED); view.update(false); } catch (InvalidRole_Exception e) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (MonitorNotFound_Exception e) { MessageDialog.openError(null, Messages.getString("message"), Messages.getString("message.monitor.60") + ", " + HinemosMessage.replace(e.getMessage())); } catch (HinemosUnknown_Exception e) { MessageDialog.openError(null, Messages.getString("message"), Messages.getString("message.monitor.60") + ", " + HinemosMessage.replace(e.getMessage())); } catch (Exception e) { m_log.warn("run(), " + e.getMessage(), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } } } return null; }
From source file:com.clustercontrol.monitor.view.action.MonitorDeleteAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // ???/*from w ww . ja v a 2 s . c o m*/ this.viewPart = HandlerUtil.getActivePart(event); MonitorListView monitorListView = null; try { monitorListView = (MonitorListView) this.viewPart.getAdapter(MonitorListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (monitorListView == null) { m_log.info("execute: view is null"); return null; } MonitorListComposite composite = (MonitorListComposite) monitorListView.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (List<?>) selection.toList(); List<String[]> argsList = new ArrayList<String[]>(); if (list != null && list.size() > 0) { for (Object obj : list) { List<?> objList = (List<?>) obj; String[] args = new String[3]; args[0] = (String) objList.get(GetMonitorListTableDefine.MANAGER_NAME); args[1] = (String) objList.get(GetMonitorListTableDefine.MONITOR_TYPE_ID); args[2] = (String) objList.get(GetMonitorListTableDefine.MONITOR_ID); argsList.add(args); } } // ????????? if (argsList.isEmpty()) { return null; } // ??????? String msg = null; String[] msgArgs = new String[2]; if (argsList.isEmpty() == false) { if (argsList.size() == 1) { msgArgs[0] = argsList.get(0)[2] + "(" + argsList.get(0)[0] + ")"; msg = "message.monitor.39"; } else { msgArgs[0] = Integer.toString(argsList.size()); msg = "message.monitor.81"; } } if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, msgArgs))) { // OK?????? return null; } DeleteInterface deleteInterfaceAgent = null; DeleteInterface deleteInterfaceHttpN = null; DeleteInterface deleteInterfaceHttpS = null; DeleteInterface deleteInterfaceHttpScenario = null; DeleteInterface deleteInterfacePerformance = null; DeleteInterface deleteInterfacePing = null; DeleteInterface deleteInterfacePort = null; DeleteInterface deleteInterfaceProcess = null; DeleteInterface deleteInterfaceSnmpN = null; DeleteInterface deleteInterfaceSnmpS = null; DeleteInterface deleteInterfaceSqlN = null; DeleteInterface deleteInterfaceSqlS = null; DeleteInterface deleteInterfaceSystemLog = null; DeleteInterface deleteInterfaceLogfile = null; DeleteInterface deleteInterfaceCustomN = null; DeleteInterface deleteInterfaceCustomS = null; DeleteInterface deleteInterfaceSnmpTrap = null; DeleteInterface deleteInterfaceWinservice = null; DeleteInterface deleteInterfaceWinevent = null; DeleteInterface deleteInterfaceJmx = null; DeleteInterface deleteInterfaceExt = null; DeleteInterface deleteInterfaceCustomTrapN = null; DeleteInterface deleteInterfaceCustomTrapS = null; Map<String, List<String>> deleteMapAgent = null; Map<String, List<String>> deleteMapHttpN = null; Map<String, List<String>> deleteMapHttpS = null; Map<String, List<String>> deleteMapHttpScenario = null; Map<String, List<String>> deleteMapPerformance = null; Map<String, List<String>> deleteMapPing = null; Map<String, List<String>> deleteMapPort = null; Map<String, List<String>> deleteMapProcess = null; Map<String, List<String>> deleteMapSnmpN = null; Map<String, List<String>> deleteMapSnmpS = null; Map<String, List<String>> deleteMapSqlN = null; Map<String, List<String>> deleteMapSqlS = null; Map<String, List<String>> deleteMapSystemLog = null; Map<String, List<String>> deleteMapLogfile = null; Map<String, List<String>> deleteMapCustomN = null; Map<String, List<String>> deleteMapCustomS = null; Map<String, List<String>> deleteMapSnmpTrap = null; Map<String, List<String>> deleteMapWinservice = null; Map<String, List<String>> deleteMapWinevent = null; Map<String, List<String>> deleteMapJmx = null; Map<String, List<String>> deleteMapExt = null; Map<String, List<String>> deleteMapCustomTrapN = null; Map<String, List<String>> deleteMapCustomTrapS = null; for (String[] args : argsList) { String pluginId = args[1]; String managerName = args[0]; if (pluginId.equals(HinemosModuleConstant.MONITOR_AGENT)) { if (deleteMapAgent == null) { deleteMapAgent = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapAgent.get(managerName) == null) { deleteMapAgent.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_HTTP_N)) { if (deleteMapHttpN == null) { deleteMapHttpN = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapHttpN.get(managerName) == null) { deleteMapHttpN.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_HTTP_S)) { if (deleteMapHttpS == null) { deleteMapHttpS = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapHttpS.get(managerName) == null) { deleteMapHttpS.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_HTTP_SCENARIO)) { if (deleteMapHttpScenario == null) { deleteMapHttpScenario = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapHttpScenario.get(managerName) == null) { deleteMapHttpScenario.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PERFORMANCE)) { if (deleteMapPerformance == null) { deleteMapPerformance = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapPerformance.get(managerName) == null) { deleteMapPerformance.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PING)) { if (deleteMapPing == null) { deleteMapPing = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapPing.get(managerName) == null) { deleteMapPing.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PORT)) { if (deleteMapPort == null) { deleteMapPort = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapPort.get(managerName) == null) { deleteMapPort.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PROCESS)) { if (deleteMapProcess == null) { deleteMapProcess = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapProcess.get(managerName) == null) { deleteMapProcess.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SNMP_N)) { if (deleteMapSnmpN == null) { deleteMapSnmpN = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapSnmpN.get(managerName) == null) { deleteMapSnmpN.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SNMP_S)) { if (deleteMapSnmpS == null) { deleteMapSnmpS = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapSnmpS.get(managerName) == null) { deleteMapSnmpS.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SQL_N)) { if (deleteMapSqlN == null) { deleteMapSqlN = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapSqlN.get(managerName) == null) { deleteMapSqlN.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SQL_S)) { if (deleteMapSqlS == null) { deleteMapSqlS = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapSqlS.get(managerName) == null) { deleteMapSqlS.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SYSTEMLOG)) { if (deleteMapSystemLog == null) { deleteMapSystemLog = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapSystemLog.get(managerName) == null) { deleteMapSystemLog.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_LOGFILE)) { if (deleteMapLogfile == null) { deleteMapLogfile = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapLogfile.get(managerName) == null) { deleteMapLogfile.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOM_N)) { if (deleteMapCustomN == null) { deleteMapCustomN = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapCustomN.get(managerName) == null) { deleteMapCustomN.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOM_S)) { if (deleteMapCustomS == null) { deleteMapCustomS = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapCustomS.get(managerName) == null) { deleteMapCustomS.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SNMPTRAP)) { if (deleteMapSnmpTrap == null) { deleteMapSnmpTrap = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapSnmpTrap.get(managerName) == null) { deleteMapSnmpTrap.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_WINSERVICE)) { if (deleteMapWinservice == null) { deleteMapWinservice = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapWinservice.get(managerName) == null) { deleteMapWinservice.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_WINEVENT)) { if (deleteMapWinevent == null) { deleteMapWinevent = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapWinevent.get(managerName) == null) { deleteMapWinevent.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_JMX)) { if (deleteMapJmx == null) { deleteMapJmx = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapJmx.get(managerName) == null) { deleteMapJmx.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOMTRAP_N)) { if (deleteMapCustomTrapN == null) { deleteMapCustomTrapN = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapCustomTrapN.get(managerName) == null) { deleteMapCustomTrapN.put(managerName, new ArrayList<String>()); } } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOMTRAP_S)) { if (deleteMapCustomTrapS == null) { deleteMapCustomTrapS = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapCustomTrapS.get(managerName) == null) { deleteMapCustomTrapS.put(managerName, new ArrayList<String>()); } } else { if (deleteMapExt == null) { deleteMapExt = new ConcurrentHashMap<String, List<String>>(); } if (deleteMapExt.get(managerName) == null) { deleteMapExt.put(managerName, new ArrayList<String>()); } } } for (String[] args : argsList) { String managerName = args[0]; String pluginId = args[1]; String monitorId = args[2]; if (pluginId.equals(HinemosModuleConstant.MONITOR_AGENT)) { if (deleteInterfaceAgent == null) { deleteInterfaceAgent = new DeleteAgent(); } deleteMapAgent.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_HTTP_N)) { if (deleteInterfaceHttpN == null) { deleteInterfaceHttpN = new DeleteHttpNumeric(); } deleteMapHttpN.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_HTTP_S)) { if (deleteInterfaceHttpS == null) { deleteInterfaceHttpS = new DeleteHttpString(); } deleteMapHttpS.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_HTTP_SCENARIO)) { if (deleteInterfaceHttpScenario == null) { deleteInterfaceHttpScenario = new DeleteHttpScenario(); } deleteMapHttpScenario.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PERFORMANCE)) { if (deleteInterfacePerformance == null) { deleteInterfacePerformance = new DeletePerformance(); } deleteMapPerformance.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PING)) { if (deleteInterfacePing == null) { deleteInterfacePing = new DeletePing(); } deleteMapPing.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PORT)) { if (deleteInterfacePort == null) { deleteInterfacePort = new DeletePort(); } deleteMapPort.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_PROCESS)) { if (deleteInterfaceProcess == null) { deleteInterfaceProcess = new DeleteProcess(); } deleteMapProcess.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SNMP_N)) { if (deleteInterfaceSnmpN == null) { deleteInterfaceSnmpN = new DeleteSnmpNumeric(); } deleteMapSnmpN.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SNMP_S)) { if (deleteInterfaceSnmpS == null) { deleteInterfaceSnmpS = new DeleteSnmpString(); } deleteMapSnmpS.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SQL_N)) { if (deleteInterfaceSqlN == null) { deleteInterfaceSqlN = new DeleteSqlNumeric(); } deleteMapSqlN.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SQL_S)) { if (deleteInterfaceSqlS == null) { deleteInterfaceSqlS = new DeleteSqlString(); } deleteMapSqlS.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SYSTEMLOG)) { if (deleteInterfaceSystemLog == null) { deleteInterfaceSystemLog = new DeleteSystemlog(); } deleteMapSystemLog.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_LOGFILE)) { if (deleteInterfaceLogfile == null) { deleteInterfaceLogfile = new DeleteLogfile(); } deleteMapLogfile.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOM_N)) { if (deleteInterfaceCustomN == null) { deleteInterfaceCustomN = new DeleteCustomNumeric(); } deleteMapCustomN.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOM_S)) { if (deleteInterfaceCustomS == null) { deleteInterfaceCustomS = new DeleteCustomString(); } deleteMapCustomS.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_SNMPTRAP)) { if (deleteInterfaceSnmpTrap == null) { deleteInterfaceSnmpTrap = new DeleteSnmpTrap(); } deleteMapSnmpTrap.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_WINSERVICE)) { if (deleteInterfaceWinservice == null) { deleteInterfaceWinservice = new DeleteWinService(); } deleteMapWinservice.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_WINEVENT)) { if (deleteInterfaceWinevent == null) { deleteInterfaceWinevent = new DeleteWinEvent(); } deleteMapWinevent.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_JMX)) { if (deleteInterfaceJmx == null) { deleteInterfaceJmx = new DeleteJmx(); } deleteMapJmx.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOMTRAP_N)) { if (deleteInterfaceCustomTrapN == null) { deleteInterfaceCustomTrapN = new DeleteCustomTrapNumeric(); } deleteMapCustomTrapN.get(managerName).add(monitorId); } else if (pluginId.equals(HinemosModuleConstant.MONITOR_CUSTOMTRAP_S)) { if (deleteInterfaceCustomTrapS == null) { deleteInterfaceCustomTrapS = new DeleteCustomTrapString(); } deleteMapCustomTrapS.get(managerName).add(monitorId); } else { int i = 0; for (IMonitorPlugin extensionMonitor : LoadMonitorPlugin.getExtensionMonitorList()) { if (pluginId.equals(extensionMonitor.getMonitorPluginId())) { i++; if (deleteInterfaceExt == null) { deleteInterfaceExt = extensionMonitor.getDeleteMonitorClassObject(); } break; } } if (i == 0) { m_log.warn("unknown pluginId " + pluginId); break; } deleteMapExt.get(managerName).add(monitorId); } } String errMessage = ""; int errCount = 0; int successCount = 0; try { if (deleteInterfaceAgent != null) { for (Map.Entry<String, List<String>> map : deleteMapAgent.entrySet()) { try { deleteInterfaceAgent.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceHttpN != null) { for (Map.Entry<String, List<String>> map : deleteMapHttpN.entrySet()) { try { deleteInterfaceHttpN.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceHttpS != null) { for (Map.Entry<String, List<String>> map : deleteMapHttpS.entrySet()) { try { deleteInterfaceHttpS.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceHttpScenario != null) { for (Map.Entry<String, List<String>> map : deleteMapHttpScenario.entrySet()) { try { deleteInterfaceHttpScenario.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfacePerformance != null) { for (Map.Entry<String, List<String>> map : deleteMapPerformance.entrySet()) { try { deleteInterfacePerformance.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfacePing != null) { for (Map.Entry<String, List<String>> map : deleteMapPing.entrySet()) { try { deleteInterfacePing.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfacePort != null) { for (Map.Entry<String, List<String>> map : deleteMapPort.entrySet()) { try { deleteInterfacePort.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceProcess != null) { for (Map.Entry<String, List<String>> map : deleteMapProcess.entrySet()) { try { deleteInterfaceProcess.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceSnmpN != null) { for (Map.Entry<String, List<String>> map : deleteMapSnmpN.entrySet()) { try { deleteInterfaceSnmpN.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceSnmpS != null) { for (Map.Entry<String, List<String>> map : deleteMapSnmpS.entrySet()) { try { deleteInterfaceSnmpS.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceSqlN != null) { for (Map.Entry<String, List<String>> map : deleteMapSqlN.entrySet()) { try { deleteInterfaceSqlN.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceSqlS != null) { for (Map.Entry<String, List<String>> map : deleteMapSqlS.entrySet()) { try { deleteInterfaceSqlS.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceSystemLog != null) { for (Map.Entry<String, List<String>> map : deleteMapSystemLog.entrySet()) { try { deleteInterfaceSystemLog.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceLogfile != null) { for (Map.Entry<String, List<String>> map : deleteMapLogfile.entrySet()) { try { deleteInterfaceLogfile.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceCustomN != null) { for (Map.Entry<String, List<String>> map : deleteMapCustomN.entrySet()) { try { deleteInterfaceCustomN.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceCustomS != null) { for (Map.Entry<String, List<String>> map : deleteMapCustomS.entrySet()) { try { deleteInterfaceCustomS.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceSnmpTrap != null) { for (Map.Entry<String, List<String>> map : deleteMapSnmpTrap.entrySet()) { try { deleteInterfaceSnmpTrap.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceWinservice != null) { for (Map.Entry<String, List<String>> map : deleteMapWinservice.entrySet()) { try { deleteInterfaceWinservice.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceWinevent != null) { for (Map.Entry<String, List<String>> map : deleteMapWinevent.entrySet()) { try { deleteInterfaceWinevent.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceJmx != null) { for (Map.Entry<String, List<String>> map : deleteMapJmx.entrySet()) { try { deleteInterfaceJmx.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceExt != null) { for (Map.Entry<String, List<String>> map : deleteMapExt.entrySet()) { try { deleteInterfaceExt.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceCustomTrapN != null) { for (Map.Entry<String, List<String>> map : deleteMapCustomTrapN.entrySet()) { try { deleteInterfaceCustomTrapN.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } if (deleteInterfaceCustomTrapS != null) { for (Map.Entry<String, List<String>> map : deleteMapCustomTrapS.entrySet()) { try { deleteInterfaceCustomTrapS.delete(map.getKey(), map.getValue()); successCount = successCount + map.getValue().size(); } catch (InvalidRole_Exception e) { throw e; } catch (Exception e) { errCount = errCount + map.getValue().size(); errMessage = HinemosMessage.replace(e.getMessage()); } } } } catch (Exception e) { if (e instanceof InvalidRole_Exception) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); return null; } } String message = null; if (errCount > 0) { if (errCount == 1) { msgArgs[1] = errMessage; message = Messages.getString("message.monitor.38", msgArgs); } else { message = Messages.getString("message.monitor.83", new String[] { Integer.toString(errCount), errMessage }); } MessageDialog.openError(null, Messages.getString("failed"), message); } if (successCount > 0) { if (successCount == 1) { message = Messages.getString("message.monitor.37", msgArgs); } else { message = Messages.getString("message.monitor.82", new String[] { Integer.toString(successCount) }); } MessageDialog.openInformation(null, Messages.getString("successful"), message); monitorListView.update(); } return null; }
From source file:com.clustercontrol.monitor.view.action.StatusDeleteAction.java
License:Open Source License
/** * []?????????//from www . jav a 2 s. co m * <p> * <ol> * <li>[]??????????</li> * <li>?????? </li> * <li>[]???</li> * </ol> * * @see org.eclipse.core.commands.IHandler#execute * @see com.clustercontrol.monitor.view.StatusView * @see com.clustercontrol.monitor.view.StatusView#update() */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; } // ??? this.viewPart = HandlerUtil.getActivePart(event); StatusView statusView = null; try { statusView = (StatusView) this.viewPart.getAdapter(StatusView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (statusView == null) { m_log.info("execute: view is null"); return null; } StatusListComposite composite = (StatusListComposite) statusView.getListComposite(); WidgetTestUtil.setTestId(this, null, composite); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = selection.toList(); Map<String, List<List<String>>> map = new ConcurrentHashMap<String, List<List<String>>>(); for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetStatusListTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<List<String>>()); } } for (Object obj : list) { @SuppressWarnings("unchecked") List<String> objList = (List<String>) obj; String managerName = (String) objList.get(GetStatusListTableDefine.MANAGER_NAME); map.get(managerName).add(objList); } if (map.isEmpty()) { return null; } for (Map.Entry<String, List<List<String>>> entry : map.entrySet()) { String managerName = entry.getKey(); MonitorEndpointWrapper wrapper = MonitorEndpointWrapper.getWrapper(managerName); List<?> records = entry.getValue(); // ????????????? ArrayList<StatusDataInfo> statusList = ConvertListUtil.listToStatusInfoDataList(records); if (statusList != null && statusList.size() > 0) { try { wrapper.deleteStatus(statusList); statusView.update(false); } catch (InvalidRole_Exception e) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (MonitorNotFound_Exception e) { MessageDialog.openError(null, Messages.getString("message"), Messages.getString("message.monitor.61") + ", " + HinemosMessage.replace(e.getMessage())); } catch (HinemosUnknown_Exception e) { MessageDialog.openError(null, Messages.getString("message"), Messages.getString("message.monitor.61") + ", " + HinemosMessage.replace(e.getMessage())); } catch (Exception e) { m_log.warn("run(), " + e.getMessage(), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } } } return null; }
From source file:com.clustercontrol.notify.composite.NotifyListComposite.java
License:Open Source License
/** * ????ID??// w w w . j a va2 s .c o m * * @return */ public ArrayList<String> getSelectionData() { ArrayList<String> data = new ArrayList<String>(); //???? StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); List<?> list = selection.toList(); if (list != null) { for (int index = 0; index < list.size(); index++) { ArrayList<?> info = (ArrayList<?>) list.get(index); if (info != null && info.size() > 0) { String notifyId = (String) info.get(GetNotifyTableDefineCheckBox.NOTIFY_ID); data.add(notifyId); } } } return data; }
From source file:com.clustercontrol.notify.mail.view.action.MailTemplateDeleteAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // ???/*ww w . j av a 2 s . c o m*/ this.viewPart = HandlerUtil.getActivePart(event); MailTemplateListView view = null; try { view = (MailTemplateListView) this.viewPart.getAdapter(MailTemplateListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (view == null) { m_log.info("execute: view is null"); return null; } MailTemplateListComposite composite = (MailTemplateListComposite) view.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (List<?>) selection.toList(); Map<String, List<String>> deleteMap = new ConcurrentHashMap<String, List<String>>(); int size = 0; StringBuffer buf = new StringBuffer(); if (list != null && list.size() > 0) { for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetMailTemplateListTableDefine.MANAGER_NAME); if (deleteMap.get(managerName) != null) { continue; } deleteMap.put(managerName, new ArrayList<String>()); } for (Object obj : list) { List<?> objList = (List<?>) obj; String mailTemplateId = (String) objList.get(NotifyTableDefineNoCheckBox.NOTIFY_ID); String managerName = (String) objList.get(NotifyTableDefineNoCheckBox.MANAGER_NAME); if (size > 0) { buf.append(", "); } buf.append(mailTemplateId); deleteMap.get(managerName).add(mailTemplateId); size++; } } String[] args = { buf.toString() }; // ????????? if (size == 0) { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.notify.mail.8")); return null; } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.notify.mail.7", args)) == false) { return null; } boolean result = false; for (Map.Entry<String, List<String>> entry : deleteMap.entrySet()) { String managerName = entry.getKey(); for (String mailTemplateId : entry.getValue()) { result = result | new DeleteMailTemplate().delete(managerName, mailTemplateId); } } if (result) { composite.update(); } return null; }
From source file:com.clustercontrol.notify.view.action.NotifyDeleteAction.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // ???/*from www . j ava 2 s .c o m*/ this.viewPart = HandlerUtil.getActivePart(event); NotifyListView view = null; try { view = (NotifyListView) this.viewPart.getAdapter(NotifyListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (view == null) { m_log.info("execute: view is null"); return null; } NotifyListComposite composite = (NotifyListComposite) view.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (List<?>) selection.toList(); Map<String, List<String>> deleteMap = new ConcurrentHashMap<String, List<String>>(); int size = 0; if (list != null && list.size() > 0) { for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(NotifyTableDefineNoCheckBox.MANAGER_NAME); if (deleteMap.get(managerName) != null) { continue; } deleteMap.put(managerName, new ArrayList<String>()); } String notifyId = null; for (Object obj : list) { List<?> objList = (List<?>) obj; notifyId = (String) objList.get(NotifyTableDefineNoCheckBox.NOTIFY_ID); String managerName = (String) objList.get(NotifyTableDefineNoCheckBox.MANAGER_NAME); deleteMap.get(managerName).add(notifyId); size++; } String[] args = new String[1]; String msg = null; if (size > 0) { if (size == 1) { args[0] = notifyId; msg = "message.notify.7"; } else { args[0] = Integer.toString(size); msg = "message.notify.51"; } } // ????????? DeleteNotify deleteNotify = new DeleteNotify(); boolean check = true; for (Map.Entry<String, List<String>> map : deleteMap.entrySet()) { String managerName = map.getKey(); // ?ID????????? if (deleteNotify.useCheck(managerName, map.getValue()) != Window.OK) { check = false; } } if (check) { if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args)) == false) { return null; } boolean result = false; for (Map.Entry<String, List<String>> map : deleteMap.entrySet()) { result = result | deleteNotify.delete(map.getKey(), map.getValue()); } if (result) { composite.update(); } } } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.notify.9")); } return null; }
From source file:com.clustercontrol.repository.view.action.AgentRestartAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *///from www . j a v a 2 s. co m @Override public Object execute(ExecutionEvent event) throws ExecutionException { this.viewPart = HandlerUtil.getActivePart(event); AgentListView view = null; try { view = (AgentListView) this.viewPart.getAdapter(AgentListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (view == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = (StructuredSelection) view.getComposite().getTableViewer().getSelection(); List<?> selectionList = selection.toList(); if (selectionList.size() == 0) { return null; } Map<String, ArrayList<String>> map = new ConcurrentHashMap<String, ArrayList<String>>(); for (Object o : selectionList) { List<?> list = (List<?>) o; if (list == null) { continue; } String managerName = (String) list.get(GetAgentListTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<String>()); } } StringBuffer message = new StringBuffer(); boolean flag = true; for (Object o : selectionList) { List<?> list = (List<?>) o; String managerName = null; String facilityId = null; String facilityName = null; if (list != null) { managerName = (String) list.get(GetAgentListTableDefine.MANAGER_NAME); facilityId = (String) list.get(GetAgentListTableDefine.FACILITY_ID); facilityName = (String) list.get(GetAgentListTableDefine.FACILITY_NAME); map.get(managerName).add(facilityId); } // ID????????? if (facilityId == null) { return null; } else if ("".equals(facilityId)) { return null; } // ????????? if (flag) { flag = false; } else { message.append(", "); } message.append(facilityName + "(" + facilityId + ")"); } // ?? String[] args = { message.toString() }; if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.repository.44", args))) { m_log.debug("cancel"); return null; } Map<String, String> errorMsgs = new ConcurrentHashMap<>(); for (Map.Entry<String, ArrayList<String>> entry : map.entrySet()) { String managerName = entry.getKey(); ArrayList<String> facilityIdList = entry.getValue(); try { RepositoryEndpointWrapper wrapper = RepositoryEndpointWrapper.getWrapper(managerName); wrapper.restartAgent(facilityIdList, AgentCommandConstant.RESTART); } catch (InvalidRole_Exception e) { // ?????? Object[] arg = { managerName }; errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16", arg)); } 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); } return null; }
From source file:com.clustercontrol.repository.view.action.AgentUpdateAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *///from w w w. j a v a 2 s . c o m @Override public Object execute(ExecutionEvent event) throws ExecutionException { this.viewPart = HandlerUtil.getActivePart(event); AgentListView view = null; try { view = (AgentListView) this.viewPart.getAdapter(AgentListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (view == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = (StructuredSelection) view.getComposite().getTableViewer().getSelection(); List<?> selectionList = selection.toList(); if (selectionList.size() == 0) { return null; } Map<String, ArrayList<String>> map = new ConcurrentHashMap<String, ArrayList<String>>(); for (Object o : selectionList) { List<?> list = (List<?>) o; if (list == null) { continue; } String managerName = (String) list.get(GetAgentListTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<String>()); } } StringBuffer message = new StringBuffer(); boolean flag = true; for (Object o : selectionList) { List<?> list = (List<?>) o; String managerName = null; String facilityId = null; String facilityName = null; if (list != null) { facilityId = (String) list.get(GetAgentListTableDefine.FACILITY_ID); // ID????????? if (facilityId == null) { return null; } else if ("".equals(facilityId)) { return null; } managerName = (String) list.get(GetAgentListTableDefine.MANAGER_NAME); facilityName = (String) list.get(GetAgentListTableDefine.FACILITY_NAME); map.get(managerName).add(facilityId); } // ????????? if (flag) { flag = false; } else { message.append(", "); } message.append(facilityName + "(" + facilityId + ")"); } // ?? String[] args = { message.toString() }; if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.repository.45", args))) { m_log.debug("cancel"); return null; } Map<String, String> errorMsgs = new ConcurrentHashMap<>(); for (Map.Entry<String, ArrayList<String>> entry : map.entrySet()) { String managerName = entry.getKey(); ArrayList<String> facilityIdList = entry.getValue(); try { RepositoryEndpointWrapper wrapper = RepositoryEndpointWrapper.getWrapper(managerName); wrapper.restartAgent(facilityIdList, AgentCommandConstant.UPDATE); } catch (InvalidRole_Exception e) { // ?????? Object[] arg = { managerName }; errorMsgs.put(managerName, Messages.getString("message.accesscontrol.16", arg)); } 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); } return null; }
From source file:com.clustercontrol.repository.view.action.NodeDeleteAction.java
License:Open Source License
/** * @see org.eclipse.core.commands.IHandler#execute *///from ww w . ja va2s . co m @Override public Object execute(ExecutionEvent event) throws ExecutionException { this.viewPart = HandlerUtil.getActivePart(event); // ??????ID? NodeListView nodeListView = null; try { nodeListView = (NodeListView) this.viewPart.getAdapter(NodeListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (nodeListView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = (StructuredSelection) nodeListView.getComposite().getTableViewer() .getSelection(); List<?> sList = (List<?>) selection.toList(); Map<String, List<String>> map = new ConcurrentHashMap<String, List<String>>(); for (Object obj : sList) { List<?> list = (List<?>) obj; String managerName = null; if (list != null) { managerName = (String) list.get(GetNodeListTableDefine.MANAGER_NAME); if (map.get(managerName) == null) { map.put(managerName, new ArrayList<String>()); } } } int size = 0; String facilityName = null; String facilityId = null; for (Object obj : sList) { List<?> list = (List<?>) obj; String managerName = null; if (list != null) { managerName = (String) list.get(GetNodeListTableDefine.MANAGER_NAME); String id = (String) list.get(GetNodeListTableDefine.FACILITY_ID); facilityName = (String) list.get(GetNodeListTableDefine.FACILITY_NAME); facilityId = id; map.get(managerName).add(id); size++; } } if (size > 0) { // ??????????? String msg = ""; String[] args = new String[2]; if (size == 1) { args[0] = facilityName; args[1] = facilityId; msg = "message.repository.1"; } else { args[0] = Integer.toString(size); msg = "message.repository.51"; } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString(msg, args)) == false) { return null; } for (Map.Entry<String, List<String>> entry : map.entrySet()) { new DeleteNodeProperty().delete(entry.getKey(), entry.getValue()); } } // nodeListView.update(); return null; }
From source file:com.clustercontrol.repository.view.ScopeListView.java
License:Open Source License
public List<?> getSelectedScopeItems() { FacilityTreeComposite tree = this.getScopeTreeComposite(); ScopeListComposite list = (ScopeListComposite) this.getListComposite(); // tree.getTree().isFocusControl() is not working under RAP because of Toolbar focus List<?> items = null;/*from w ww.jav a 2 s . c o m*/ if (this.lastFocusComposite instanceof FacilityTreeComposite) { items = tree.getSelectionList(); } else if (this.lastFocusComposite instanceof ScopeListComposite) { StructuredSelection selection = (StructuredSelection) list.getTableViewer().getSelection(); items = selection.toList(); } // ????????? if (!(null == items || items.isEmpty())) { return items; } else { return null; } }