/** * {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); boolean confirmed = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Delete", "Are you sure you want to permanently delete the selected Agent(s)? Note that all monitoring data related to the Agent(s) will be deleted from the repository database."); if (confirmed) { for (Iterator<?> it = selection.iterator(); it.hasNext();) { Object selected = it.next(); if (selected instanceof AgentLeaf) { AgentLeaf agentLeaf = (AgentLeaf) selected; PlatformIdent platformIdent = agentLeaf.getPlatformIdent(); CmrRepositoryDefinition cmrRepositoryDefinition = agentLeaf.getCmrRepositoryDefinition(); try { cmrRepositoryDefinition.getGlobalDataAccessService().deleteAgent(platformIdent.getId()); InspectIT.getDefault().getCmrRepositoryManager().repositoryAgentDeleted(cmrRepositoryDefinition, platformIdent); } catch (BusinessException e) { throw new ExecutionException("Exception occurred trying to delete the Agent from the CMR.", e); } } } } return null; } }