/** * {@inheritDoc} */ @Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { if (returnButton.getSelection()) { contextCapture = new ReturnContextCapture(); } else if (parameterButton.getSelection()) { ParameterContextCapture capture = new ParameterContextCapture(); capture.setIndex(Integer.parseInt(indexText.getText())); contextCapture = capture; } else if (fieldButton.getSelection()) { FieldContextCapture capture = new FieldContextCapture(); capture.setFieldName(fieldText.getText()); contextCapture = capture; } contextCapture.setDisplayName(nameText.getText()); if (CollectionUtils.isNotEmpty(paths)) { contextCapture.setPaths(paths); } } super.buttonPressed(buttonId); }
/** * {@inheritDoc} */ @Override public String getAgentStringNotation() { StringBuffer stringBuffer = new StringBuffer("f="); stringBuffer.append(getDisplayName()); stringBuffer.append(';'); stringBuffer.append(fieldName); if (CollectionUtils.isNotEmpty(getPaths())) { for (String path : getPaths()) { stringBuffer.append('.'); stringBuffer.append(path); } } return stringBuffer.toString(); }
public static TimerMethodSensorAssignment getTimerMethodSensorAssignment() { TimerMethodSensorAssignment assignment = new TimerMethodSensorAssignment(); populateMethodSensorAssignment(assignment); List<AbstractContextCapture> contextCaptures = new ArrayList<>(); if (RandomUtils.nextBoolean()) { ReturnContextCapture returnContextCapture = new ReturnContextCapture(); returnContextCapture.setDisplayName("myReturn"); contextCaptures.add(returnContextCapture); } if (RandomUtils.nextBoolean() && CollectionUtils.isNotEmpty(assignment.getParameters())) { ParameterContextCapture parameterContextCapture = new ParameterContextCapture(); parameterContextCapture.setDisplayName("myParam"); parameterContextCapture.setIndex(0); List<String> paths = new ArrayList<>(); paths.add("user"); paths.add("surname"); parameterContextCapture.setPaths(paths); contextCaptures.add(parameterContextCapture); } if (RandomUtils.nextBoolean()) { FieldContextCapture fieldContextCapture = new FieldContextCapture(); fieldContextCapture.setDisplayName("myField"); fieldContextCapture.setFieldName("message"); } assignment.setCharting(RandomUtils.nextBoolean()); if (CollectionUtils.isNotEmpty(contextCaptures)) { assignment.setContextCaptures(contextCaptures); } return assignment; }
/** * {@inheritDoc} */ @Override public PropertyPathStart getPropertyPathStart() { PropertyPathStart propertyPathStart = new PropertyPathStart(); propertyPathStart.setName(getDisplayName()); propertyPathStart.setContentType(ParameterContentType.FIELD); // create field navigation PropertyPath fieldPath = new PropertyPath(); fieldPath.setName(fieldName); addPaths(fieldPath); // connect to the start and return propertyPathStart.setPathToContinue(fieldPath); return propertyPathStart; }
indexText.setText(String.valueOf(((ParameterContextCapture) contextCapture).getIndex())); } else if (contextCapture instanceof FieldContextCapture) { fieldText.setText(((FieldContextCapture) contextCapture).getFieldName());