use of org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.item.AnnotationListItem in project kie-wb-common by kiegroup.
the class AdvancedAnnotationListEditorTest method testExpandCollapseChanges.
@Test
public void testExpandCollapseChanges() {
// first load.
annotationListEditor.loadAnnotations(annotations, annotationSourcesMap);
// when loaded by the first time, all annotations are collapsed.
for (AnnotationListItem listItem : itemInstances) {
verify(listItem, times(1)).setCollapsed(true);
verify(listItem, never()).setCollapsed(false);
}
// emulate some expand/collapse actions coming from the UI
// annotation #0 is expanded
annotationListEditor.onCollapseChange(annotations.get(0), false);
// annotation #1 is expanded, and then collapsed again, so finally collapsed.
annotationListEditor.onCollapseChange(annotations.get(1), false);
annotationListEditor.onCollapseChange(annotations.get(1), true);
// annotation #2 is expanded
annotationListEditor.onCollapseChange(annotations.get(2), false);
// annotation #3 is un-touched. (the by default state is collapsed)
// reset the items prior the second load
setupItemInstances();
// second load.
annotationListEditor.loadAnnotations(annotations, annotationSourcesMap);
// after the reload we should have the following.
// annotation #0 should be expanded
verify(itemInstances.get(0), times(1)).setCollapsed(false);
verify(itemInstances.get(0), never()).setCollapsed(true);
// annotation #1 should be collapsed.
verify(itemInstances.get(1), times(1)).setCollapsed(true);
verify(itemInstances.get(1), never()).setCollapsed(false);
// annotation #2 should be expanded.
verify(itemInstances.get(2), times(1)).setCollapsed(false);
verify(itemInstances.get(2), never()).setCollapsed(true);
// annotation #3 should be collapsed.
verify(itemInstances.get(3), times(1)).setCollapsed(true);
verify(itemInstances.get(3), never()).setCollapsed(false);
}
use of org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.item.AnnotationListItem in project kie-wb-common by kiegroup.
the class AdvancedAnnotationListEditor method loadAnnotations.
public void loadAnnotations(List<Annotation> annotations, Map<String, AnnotationSource> annotationSources) {
view.clear();
clearListItems();
this.annotationSources = annotationSources;
if (annotations != null) {
for (Annotation annotation : annotations) {
final Annotation currentAnnotation = annotation;
final AnnotationListItem annotationListItem = createListItem();
annotationListItem.loadAnnotation(annotation, annotationSources != null ? annotationSources.get(annotation.getClassName()) : null);
annotationListItem.setCollapsed(!isExpanded(annotation.getClassName()));
annotationListItem.setDeleteAnnotationHandler(AdvancedAnnotationListEditor.this::onDeleteAnnotation);
annotationListItem.setClearValuePairHandler(AdvancedAnnotationListEditor.this::onClearValuePair);
annotationListItem.setEditValuePairHandler(AdvancedAnnotationListEditor.this::onEditValuePair);
annotationListItem.setCollapseChangeHandler(() -> AdvancedAnnotationListEditor.this.onCollapseChange(currentAnnotation, annotationListItem.isCollapsed()));
annotationListItem.setReadonly(readonly);
annotationItems.put(annotation, annotationListItem);
view.addItem(annotationListItem);
}
}
}
use of org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.item.AnnotationListItem in project kie-wb-common by kiegroup.
the class AdvancedAnnotationListEditor method removeAnnotation.
public void removeAnnotation(Annotation annotation) {
AnnotationListItem listItem = annotationItems.get(annotation);
if (listItem != null) {
view.removeItem(listItem);
annotationItems.remove(annotation);
dispose(listItem);
}
}
use of org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.item.AnnotationListItem in project kie-wb-common by kiegroup.
the class AdvancedAnnotationListEditor method setReadonly.
public void setReadonly(boolean readonly) {
this.readonly = readonly;
view.setReadonly(readonly);
for (AnnotationListItem annotationListItem : annotationItems.values()) {
annotationListItem.setReadonly(readonly);
}
}
use of org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.item.AnnotationListItem in project kie-wb-common by kiegroup.
the class AdvancedAnnotationListEditorTest method verifyAnnotationsLoaded.
private void verifyAnnotationsLoaded() {
verify(view, times(1)).clear();
// the items should have been properly created and initialized.
verify(itemInstance, times(itemInstances.size())).get();
// each item should have been properly loaded with the corresponding annotation.
Annotation annotation;
AnnotationListItem listItem;
for (int i = 0; i < annotations.size(); i++) {
annotation = annotations.get(i);
listItem = itemInstances.get(i);
verify(listItem, times(1)).loadAnnotation(annotation, annotationSourcesMap.get(annotation.getClassName()));
}
}
Aggregations