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);
}
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);
}
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));
}
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());
}
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());
}
Aggregations