Search in sources :

Example 1 with DataModelerEvent

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);
}
Also used : DataModelerEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent) DataObjectChangeEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectChangeEvent)

Example 2 with DataModelerEvent

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);
}
Also used : DataModelerEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent) DataObjectChangeEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectChangeEvent)

Example 3 with DataModelerEvent

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);
}
Also used : DataModelerEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent) DataObjectChangeEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectChangeEvent) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Example 4 with DataModelerEvent

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);
    }
}
Also used : DataModelerEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent) DataObjectChangeEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectChangeEvent)

Example 5 with DataModelerEvent

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));
}
Also used : DataModelerEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) DomainEditorBaseTest(org.kie.workbench.common.screens.datamodeller.client.widgets.DomainEditorBaseTest) Test(org.junit.Test)

Aggregations

DataModelerEvent (org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent)10 Test (org.junit.Test)5 DomainEditorBaseTest (org.kie.workbench.common.screens.datamodeller.client.widgets.DomainEditorBaseTest)5 DataObjectChangeEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectChangeEvent)5 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)5 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)3 HashMap (java.util.HashMap)2 Path (org.uberfire.backend.vfs.Path)2 DataModelerContext (org.kie.workbench.common.screens.datamodeller.client.DataModelerContext)1 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)1 AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)1