use of org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent in project kie-wb-common by kiegroup.
the class DataObjectAddNestedClassCommand method execute.
@Override
public void execute() {
dataObject.addNestedClass(nestedClass);
DataModelerEvent event = new DataObjectChangeEvent().withChangeType(ChangeType.NESTED_CLASS_ADD_CHANGE).withOldValue(null).withNewValue(nestedClass).withContextId(getContext().getContextId()).withSource(getSource()).withCurrentDataObject(getDataObject());
notifyChange(event);
}
use of org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent in project kie-wb-common by kiegroup.
the class DataObjectRemoveNestedClassCommand method execute.
@Override
public void execute() {
dataObject.removeNestedClass(nestedClass);
DataModelerEvent event = new DataObjectChangeEvent().withChangeType(ChangeType.NESTED_CLASS_REMOVE_CHANGE).withOldValue(nestedClass).withNewValue(null).withContextId(getContext().getContextId()).withSource(getSource()).withCurrentDataObject(getDataObject());
notifyChange(event);
}
use of org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent in project kie-wb-common by kiegroup.
the class MethodAddAnnotationCommand method execute.
@Override
public void execute() {
if (annotation == null) {
annotation = new AnnotationImpl(context.getAnnotationDefinition(annotationClassName));
if (valuePairs != null) {
for (ValuePair valuePair : valuePairs) {
annotation.setValue(valuePair.getName(), valuePair.getValue());
}
}
}
Annotation existingAnnotation = method.getAnnotation(annotation.getClassName());
if (existingAnnotation != null) {
method.removeAnnotation(annotation.getClassName());
}
method.addAnnotation(annotation);
DataModelerEvent event = new DataObjectChangeEvent().withChangeType(ChangeType.METHOD_ANNOTATION_ADD_CHANGE).withOldValue(null).withNewValue(this.annotation).withContextId(getContext().getContextId()).withSource(getSource()).withCurrentDataObject(getDataObject()).withCurrentMethod(method);
notifyChange(event);
}
use of org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent in project kie-wb-common by kiegroup.
the class RemoveMethodCommand method execute.
@Override
public void execute() {
if (method != null) {
dataObject.removeMethod(method);
DataModelerEvent event = new DataObjectChangeEvent().withChangeType(ChangeType.METHOD_REMOVE_CHANGE).withOldValue(method).withNewValue(null).withContextId(getContext().getContextId()).withSource(getSource()).withCurrentDataObject(getDataObject()).withCurrentMethod(method);
notifyChange(event);
}
}
use of org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent in project kie-wb-common by kiegroup.
the class DroolsDataObjectEditorTest method valuesChangeTest.
@Test
public void valuesChangeTest() {
// load the editor
objectEditor.onContextChange(context);
// emulate the user input
when(view.getTypeSafe()).thenReturn("false");
when(view.getPropertyReactive()).thenReturn(false);
when(view.getRole()).thenReturn(null);
when(view.getTimeStampField()).thenReturn(NEW_FIELD_NAME);
when(view.getDurationField()).thenReturn(NEW_FIELD_NAME);
// new timer expression
when(view.getExpires()).thenReturn("100d");
when(view.getRemotable()).thenReturn(false);
when(validationService.isTimerIntervalValid("100d")).thenReturn(true);
// notify the presenter about the changes in the UI
objectEditor.onTypeSafeChange();
objectEditor.onPropertyReactiveChange();
objectEditor.onRoleChange();
objectEditor.onTimeStampFieldChange();
objectEditor.onDurationFieldChange();
objectEditor.onExpiresChange();
objectEditor.onRemotableChange();
// After the changes has been processed by the presenter the dataObject should have been populated with the new values.
DataObject dataObject = context.getDataObject();
assertEquals("false", AnnotationValueHandler.getStringValue(dataObject, TypeSafe.class.getName(), "value"));
assertNull(dataObject.getAnnotation(PropertyReactive.class.getName()));
assertNull(dataObject.getAnnotation(Role.class.getName()));
assertEquals(NEW_FIELD_NAME, AnnotationValueHandler.getStringValue(dataObject, Timestamp.class.getName(), "value"));
assertEquals(NEW_FIELD_NAME, AnnotationValueHandler.getStringValue(dataObject, Duration.class.getName(), "value"));
assertEquals("100d", AnnotationValueHandler.getStringValue(dataObject, Expires.class.getName(), "value"));
assertNull(dataObject.getAnnotation(XmlRootElement.class.getName()));
assertNull(dataObject.getAnnotation(Remotable.class.getName()));
verify(dataModelerEvent, times(7)).fire(any(DataModelerEvent.class));
}
Aggregations