Search in sources :

Example 1 with DataModelerContext

use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.

the class DataModellerDocksHandler method onContextChange.

public void onContextChange(@Observes DataModelerWorkbenchContextChangeEvent contextEvent) {
    DataModelerContext newContext = dataModelerWBContext.getActiveContext();
    /*
        Check if we should refresh the docks. The cases are:
        - if any context (lastActiveContext or newContext) are null we should refresh the docks and hide them
        - if there's a context change or there's a edition mode change we should refresh docks and show them.
        - if none of these cases we don't refresh the docks
        */
    boolean doRefresh;
    if (newContext == null) {
        doRefresh = true;
        dataModelerIsHidden = true;
    } else if (!newContext.equals(lastActiveContext) || (newContext.equals(lastActiveContext) && !newContext.getEditionMode().equals(lastEditionMode))) {
        doRefresh = true;
        dataModelerIsHidden = !isGraphicMode(newContext);
        lastEditionMode = newContext.getEditionMode();
    } else {
        doRefresh = false;
    }
    lastActiveContext = newContext;
    refreshDocks(doRefresh, dataModelerIsHidden);
}
Also used : DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext)

Example 2 with DataModelerContext

use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.

the class DataModellerDocksHandlerTest method testChangeDataModelerContextDifferentContextSourceMode.

@Test
public void testChangeDataModelerContextDifferentContextSourceMode() {
    DataModelerContext newContext = new DataModelerContext();
    newContext.setEditionMode(DataModelerContext.EditionMode.SOURCE_MODE);
    testChangeDataModelerEvent(true, true, newContext);
}
Also used : DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext) Test(org.junit.Test)

Example 3 with DataModelerContext

use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.

the class RemovePropertyCommandTest method execute.

@Test
public void execute() {
    DataObject dataObject = new DataObjectImpl("org.test", "TestDataObject");
    dataObject.addProperty(new ObjectPropertyImpl("testProperty", Integer.class.getName(), false));
    DataModelChangeNotifier notifier = mock(DataModelChangeNotifier.class);
    RemovePropertyCommand command = new RemovePropertyCommand(new DataModelerContext(), "source", dataObject, "testProperty", notifier);
    command.execute();
    assertNull(dataObject.getProperty("testProperty"));
    verify(notifier, times(1)).notifyChange(any(DataObjectFieldDeletedEvent.class));
}
Also used : DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) ObjectPropertyImpl(org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) DataObjectFieldDeletedEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectFieldDeletedEvent) DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext) Test(org.junit.Test)

Example 4 with DataModelerContext

use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.

the class DataObjectBrowserTest method removePropertyTest.

@Test
public void removePropertyTest() {
    DataObjectBrowser objectBrowser = createBrowser();
    DataModelerContext context = createContext();
    // the dataObject has fields: field1, field2 and field3
    DataObject dataObject = context.getDataObject();
    ObjectProperty objectProperty = dataObject.getProperty("field3");
    int count = dataObject.getProperties().size();
    context.getEditorModelContent().setPath(dummyPath);
    objectBrowser.setContext(context);
    when(assetsUsageService.getAssetPartUsages(any(), any(), any(), any())).thenReturn(new ArrayList<>());
    // field3 is on position 2 by construction.
    objectBrowser.onDeleteProperty(objectProperty, 2);
    verify(showAssetUsagesDisplayer).showAssetPartUsages(anyString(), any(), any(), any(), any(), any(), any());
    // if field3 was removed, then field2 should have been selected.
    verify(view).setSelectedRow(dataObject.getProperty("field2"), true);
    // an even should have been fired with the notification of the just removed property.
    verify(dataModelerEvent, times(1)).fire(any(DataModelerEvent.class));
    verify(view, times(1)).setTableHeight(DataObjectBrowser.DataObjectBrowserHelper.calculateTableHeight(count));
    verify(view, times(2)).setTableHeight(DataObjectBrowser.DataObjectBrowserHelper.calculateTableHeight(count - 1));
    // the dataObject should now have one less property.
    assertEquals((count - 1), dataObject.getProperties().size());
}
Also used : ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) DataModelerEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext) DomainEditorBaseTest(org.kie.workbench.common.screens.datamodeller.client.widgets.DomainEditorBaseTest) Test(org.junit.Test)

Example 5 with DataModelerContext

use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.

the class DataObjectBrowserTest method loadContextTest.

@Test
public void loadContextTest() {
    DataObjectBrowser objectBrowser = createBrowser();
    DataModelerContext context = createContext();
    objectBrowser.setContext(context);
    verify(view, times(1)).setReadonly(context.isReadonly());
    verify(view, times(1)).setObjectSelectorLabel("TestObject1Label (TestObject1)", context.getDataObject().getClassName());
}
Also used : DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext) DomainEditorBaseTest(org.kie.workbench.common.screens.datamodeller.client.widgets.DomainEditorBaseTest) Test(org.junit.Test)

Aggregations

DataModelerContext (org.kie.workbench.common.screens.datamodeller.client.DataModelerContext)15 Test (org.junit.Test)10 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)5 DomainEditorBaseTest (org.kie.workbench.common.screens.datamodeller.client.widgets.DomainEditorBaseTest)4 HashMap (java.util.HashMap)3 Pair (org.uberfire.commons.data.Pair)3 DataObjectFieldDeletedEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectFieldDeletedEvent)2 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)2 ObjectPropertyImpl (org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl)2 DataModelerEvent (org.kie.workbench.common.screens.datamodeller.events.DataModelerEvent)1 EditorModelContent (org.kie.workbench.common.screens.datamodeller.model.EditorModelContent)1 AnnotationDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition)1 DataObjectImpl (org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1