Search in sources :

Example 1 with AnnotationSource

use of org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource in project kie-wb-common by kiegroup.

the class AdvancedAnnotationListEditor method onEditValuePair.

protected void onEditValuePair(Annotation annotation, String valuePair) {
    ValuePairEditorPopup valuePairEditor = createValuePairEditor(annotation, valuePair);
    if (valuePairEditor.isGenericEditor()) {
        AnnotationSource annotationSource = annotationSources.get(annotation.getClassName());
        String valuePairSource = annotationSource != null ? annotationSource.getValuePairSource(valuePair) : null;
        valuePairEditor.setValue(valuePairSource);
    } else {
        valuePairEditor.setValue(annotation.getValue(valuePair));
    }
    valuePairEditor.show();
}
Also used : ValuePairEditorPopup(org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.valuepaireditor.ValuePairEditorPopup) AnnotationSource(org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource)

Example 2 with AnnotationSource

use of org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource in project kie-wb-common by kiegroup.

the class AdvancedAnnotationListEditorTest method setup.

@Before
public void setup() {
    yesCommandCaptor = ArgumentCaptor.forClass(Command.class);
    noCommandCaptor = ArgumentCaptor.forClass(Command.class);
    cancelCommandCaptor = ArgumentCaptor.forClass(Command.class);
    annotationCallbackCaptor = (ArgumentCaptor) ArgumentCaptor.forClass(Callback.class);
    Annotation annotation;
    AnnotationSource annotationSource;
    for (int i = 0; i < MAX_ITEMS; i++) {
        annotation = mock(Annotation.class);
        when(annotation.getClassName()).thenReturn("AnnotationClass" + i);
        annotations.add(annotation);
        annotationSource = mock(AnnotationSource.class);
        annotationSourcesMap.put(annotation.getClassName(), annotationSource);
    }
    setupItemInstances();
    annotationListEditor = new AdvancedAnnotationListEditor(view, new CallerMock(dataModelerService), valuePairEditorInstance, itemInstance) {

        @Override
        protected AnnotationListItem createListItem() {
            if (listItemsCount >= itemInstances.size()) {
                throw new RuntimeException("too many invocations");
            } else {
                super.createListItem();
                return itemInstances.get(listItemsCount++);
            }
        }

        @Override
        protected ValuePairEditorPopup createValuePairEditor() {
            super.createValuePairEditor();
            return valuePairEditor;
        }
    };
    annotationListEditor.addAddAnnotationHandler(addAnnotationHandler);
    annotationListEditor.addDeleteAnnotationHandler(deleteAnnotationHandler);
    annotationListEditor.addValuePairChangeHandler(valuePairChangeHandler);
    annotationListEditor.addClearValuePairHandler(clearValuePairHandler);
}
Also used : AnnotationListItem(org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.item.AnnotationListItem) Command(org.uberfire.mvp.Command) ValuePairEditorPopup(org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.valuepaireditor.ValuePairEditorPopup) AnnotationSource(org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Aggregations

ValuePairEditorPopup (org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.valuepaireditor.ValuePairEditorPopup)2 AnnotationSource (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationSource)2 Before (org.junit.Before)1 AnnotationListItem (org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.item.AnnotationListItem)1 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)1 CallerMock (org.uberfire.mocks.CallerMock)1 Command (org.uberfire.mvp.Command)1