/** {@inheritDoc} */ @Override protected InputDefinition getInputDefinition( RepositoryDefinition repositoryDefinition, ExceptionSensorData exceptionSensorData) { InputDefinition inputDefinition = new InputDefinition(); inputDefinition.setRepositoryDefinition(repositoryDefinition); inputDefinition.setId(SensorTypeEnum.EXCEPTION_SENSOR_GROUPED); EditorPropertiesData editorPropertiesData = new EditorPropertiesData(); editorPropertiesData.setSensorImage(SensorTypeEnum.EXCEPTION_SENSOR_GROUPED.getImage()); editorPropertiesData.setSensorName(SensorTypeEnum.EXCEPTION_SENSOR_GROUPED.getDisplayName()); editorPropertiesData.setViewName(exceptionSensorData.getThrowableType()); editorPropertiesData.setPartNameFlag(PartType.SENSOR); inputDefinition.setEditorPropertiesData(editorPropertiesData); IdDefinition idDefinition = new IdDefinition(); idDefinition.setPlatformId(exceptionSensorData.getPlatformIdent()); inputDefinition.setIdDefinition(idDefinition); ExceptionTypeInputDefinitionExtra exceptionTypeInputDefinitionExtra = new ExceptionTypeInputDefinitionExtra(); exceptionTypeInputDefinitionExtra.setThrowableType(exceptionSensorData.getThrowableType()); inputDefinition.addInputDefinitonExtra( InputDefinitionExtrasMarkerFactory.EXCEPTION_TYPE_EXTRAS_MARKER, exceptionTypeInputDefinitionExtra); return inputDefinition; }
/** {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { StructuredSelection selection = (StructuredSelection) HandlerUtil.getCurrentSelectionChecked(event); AbstractRootEditor rootEditor = (AbstractRootEditor) HandlerUtil.getActiveEditor(event); RepositoryDefinition repositoryDefinition = rootEditor.getInputDefinition().getRepositoryDefinition(); Object selectedObject = selection.getFirstElement(); ExceptionSensorData dataToNavigateTo = null; if (selectedObject instanceof ExceptionSensorData) { dataToNavigateTo = (ExceptionSensorData) selectedObject; } else if (selectedObject instanceof InvocationSequenceData) { List<ExceptionSensorData> exceptions = ((InvocationSequenceData) selectedObject).getExceptionSensorDataObjects(); if ((null != exceptions) && !exceptions.isEmpty()) { for (ExceptionSensorData exSensorData : exceptions) { if (0 != exSensorData.getMethodIdent()) { dataToNavigateTo = exSensorData; break; } } } } if (null != dataToNavigateTo) { ExceptionSensorData exceptionSensorData = dataToNavigateTo; // exit if the object does not carry the methodIdent if (null == exceptionSensorData.getThrowableType()) { return null; } InputDefinition inputDefinition = getInputDefinition(repositoryDefinition, exceptionSensorData); // open the view via command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand(OpenViewHandler.COMMAND); ExecutionEvent executionEvent = handlerService.createExecutionEvent(command, new Event()); IEvaluationContext context = (IEvaluationContext) executionEvent.getApplicationContext(); context.addVariable(OpenViewHandler.INPUT, inputDefinition); try { command.executeWithChecks(executionEvent); } catch (NotDefinedException | NotEnabledException | NotHandledException e) { throw new ExecutionException("Error opening the exception type view.", e); } } return null; }