Search in sources :

Example 1 with MenuItemFactory

use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory in project drools-wb by kiegroup.

the class InsertMenuBuilderTest method setup.

@Before
public void setup() {
    model = new GuidedDecisionTable52();
    uiModel = new GuidedDecisionTableUiModel(mock(ModelSynchronizer.class));
    final MenuItemFactory menuItemFactory = new MenuItemFactory(menuItemViewProducer);
    when(dtPresenter.hasEditableColumns()).thenReturn(true);
    when(dtPresenter.getView()).thenReturn(dtPresenterView);
    when(dtPresenter.getModel()).thenReturn(model);
    when(dtPresenter.getAccess()).thenReturn(access);
    when(dtPresenterView.getModel()).thenReturn(uiModel);
    when(translationService.getTranslation(any(String.class))).thenReturn("i18n");
    when(menuItemViewProducer.select(any(Annotation.class))).thenReturn(menuItemViewProducer);
    when(menuItemViewProducer.get()).thenReturn(mock(MenuItemWithIconView.class));
    uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
    uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
    uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
    uiModel.appendRow(new BaseGridRow());
    uiModel.appendRow(new BaseGridRow());
    builder = spy(new InsertMenuBuilder(translationService, menuItemFactory, wizardManagedInstance));
    builder.setup();
    builder.setModeller(modeller);
}
Also used : MenuItemWithIconView(org.uberfire.ext.widgets.common.client.menu.MenuItemWithIconView) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) MenuItemFactory(org.uberfire.ext.widgets.common.client.menu.MenuItemFactory) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Annotation(java.lang.annotation.Annotation) Before(org.junit.Before)

Example 2 with MenuItemFactory

use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory in project drools-wb by kiegroup.

the class EditMenuBuilderTest method setup.

@Before
public void setup() {
    model = new GuidedDecisionTable52();
    uiModel = new GuidedDecisionTableUiModel(mock(ModelSynchronizer.class));
    clipboard = new DefaultClipboard();
    final MenuItemFactory menuItemFactory = new MenuItemFactory(menuItemViewProducer);
    when(dtPresenter.hasEditableColumns()).thenReturn(true);
    when(dtPresenter.getView()).thenReturn(dtPresenterView);
    when(dtPresenter.getModel()).thenReturn(model);
    when(dtPresenter.getAccess()).thenReturn(access);
    when(dtPresenterView.getModel()).thenReturn(uiModel);
    when(ts.getTranslation(any(String.class))).thenReturn("i18n");
    when(menuItemViewProducer.select(any(Annotation.class))).thenReturn(menuItemViewProducer);
    when(menuItemViewProducer.get()).thenReturn(menuItemWithIconView);
    when(menuItemWithIconView.getElement()).thenReturn(menuItemHTMLElement);
    uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
    uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
    uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
    uiModel.appendRow(new BaseGridRow());
    builder = spy(new EditMenuBuilder(clipboard, ts, menuItemFactory, popoverUtils));
    builder.setup();
}
Also used : DefaultClipboard(org.drools.workbench.screens.guided.dtable.client.editor.clipboard.impl.DefaultClipboard) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) MenuItemFactory(org.uberfire.ext.widgets.common.client.menu.MenuItemFactory) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Matchers.anyString(org.mockito.Matchers.anyString) Annotation(java.lang.annotation.Annotation) Before(org.junit.Before)

Example 3 with MenuItemFactory

use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorMenusTest method setup.

@Before
public void setup() {
    when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
    when(modeller.getView()).thenReturn(modellerView);
    when(versionRecordManager.newSaveMenuItem(any(Command.class))).thenReturn(saveMenuItem);
    when(versionRecordManager.buildMenu()).thenReturn(versionManagerMenuItem);
    when(ts.getTranslation(any(String.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
    when(menuItemViewProducer.select(any(Annotation.class))).thenAnswer((o) -> {
        final Annotation a = (Annotation) o.getArguments()[0];
        if (a.annotationType().equals(MenuItemHeader.class)) {
            return menuItemViewHeaderProducer;
        } else if (a.annotationType().equals(MenuItemWithIcon.class)) {
            return menuItemViewWithIconProducer;
        } else if (a.annotationType().equals(MenuItemDivider.class)) {
            return menuItemViewDividerProducer;
        }
        throw new IllegalArgumentException("Unexpected MenuItemView");
    });
    when(menuItemViewHeaderProducer.get()).thenReturn(mock(MenuItemHeaderView.class));
    when(menuItemViewDividerProducer.get()).thenReturn(mock(MenuItemDividerView.class));
    when(menuItemViewWithIconProducer.get()).thenReturn(menuItemWithIconView);
    when(menuItemWithIconView.getElement()).thenReturn(mock(HTMLElement.class));
    this.dtServiceCaller = new CallerMock<>(dtService);
    this.versionServiceCaller = new CallerMock<>(versionService);
    this.menuItemFactory = new MenuItemFactory(menuItemViewProducer);
    this.editMenuBuilder = new EditMenuBuilder(clipboard, ts, menuItemFactory, popoverUtils);
    this.editMenuBuilder.setup();
    this.insertMenuBuilder = new InsertMenuBuilder(ts, menuItemFactory, wizardManagedInstance);
    this.insertMenuBuilder.setup();
    this.insertMenuBuilder.setModeller(modeller);
    this.viewMenuBuilder = new ViewMenuBuilder(ts, menuItemFactory);
    this.viewMenuBuilder.setup();
    this.viewMenuBuilder.setModeller(modeller);
    this.radarMenuBuilder = new RadarMenuBuilder(radarMenuView);
    this.radarMenuBuilder.setup();
    final GuidedDecisionTableEditorPresenter wrapped = new GuidedDecisionTableEditorPresenter(view, dtServiceCaller, notification, decisionTableSelectedEvent, validationPopup, resourceType, editMenuBuilder, viewMenuBuilder, insertMenuBuilder, radarMenuBuilder, modeller, beanManager, placeManager, columnsPage, saveAndRenameCommandBuilder, alertsButtonMenuItemBuilder) {

        @Override
        protected Command getSaveAndRenameCommand() {
            return mock(Command.class);
        }
    };
    wrapped.setKieEditorWrapperView(kieEditorWrapperView);
    wrapped.setOverviewWidget(overviewWidget);
    wrapped.setSavePopUpPresenter(savePopUpPresenter);
    wrapped.setImportsWidget(importsWidget);
    wrapped.setNotificationEvent(notificationEvent);
    wrapped.setChangeTitleEvent(changeTitleEvent);
    wrapped.setWorkbenchContext(workbenchContext);
    wrapped.setVersionRecordManager(versionRecordManager);
    wrapped.setRegisteredDocumentsMenuBuilder(registeredDocumentsMenuBuilder);
    wrapped.setFileMenuBuilder(fileMenuBuilder);
    wrapped.setFileNameValidator(fileNameValidator);
    this.presenter = spy(wrapped);
    when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    presenter.init();
    presenter.setupMenuBar();
}
Also used : HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) MenuItemFactory(org.uberfire.ext.widgets.common.client.menu.MenuItemFactory) EditMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.EditMenuBuilder) RadarMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.RadarMenuBuilder) Annotation(java.lang.annotation.Annotation) MenuItemDividerView(org.uberfire.ext.widgets.common.client.menu.MenuItemDividerView) InsertMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.InsertMenuBuilder) ViewMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.ViewMenuBuilder) Command(org.uberfire.mvp.Command) MenuItemCommand(org.uberfire.workbench.model.menu.MenuItemCommand) MenuItemWithIcon(org.uberfire.ext.widgets.common.client.menu.MenuItemWithIcon) MenuItemHeaderView(org.uberfire.ext.widgets.common.client.menu.MenuItemHeaderView) Before(org.junit.Before)

Example 4 with MenuItemFactory

use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory in project drools-wb by kiegroup.

the class ViewMenuBuilderTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    menuItemFactory = new MenuItemFactory(menuItemViewProducer);
    menuItemFactoryViewMocks.clear();
    when(dtPresenter.getAccess()).thenReturn(access);
    when(ts.getTranslation(any(String.class))).thenReturn("i18n");
    when(menuItemViewProducer.select(any(Annotation.class))).thenAnswer((o) -> {
        final Annotation a = (Annotation) o.getArguments()[0];
        if (a.annotationType().equals(MenuItemHeader.class)) {
            return menuItemViewHeaderProducer;
        } else if (a.annotationType().equals(MenuItemWithIcon.class)) {
            return menuItemViewWithIconProducer;
        } else if (a.annotationType().equals(MenuItemDivider.class)) {
            return menuItemViewDividerProducer;
        }
        throw new IllegalArgumentException("Unexpected MenuItemView");
    });
    when(menuItemViewHeaderProducer.get()).then(invocation -> {
        final MenuItemHeaderView v = mock(MenuItemHeaderView.class);
        menuItemFactoryViewMocks.add(v);
        return v;
    });
    when(menuItemViewWithIconProducer.get()).then(invocation -> {
        final MenuItemWithIconView v = mock(MenuItemWithIconView.class);
        menuItemFactoryViewMocks.add(v);
        return v;
    });
    when(menuItemViewDividerProducer.get()).then(invocation -> {
        final MenuItemDividerView v = mock(MenuItemDividerView.class);
        menuItemFactoryViewMocks.add(v);
        return v;
    });
    builder = spy(new ViewMenuBuilder(ts, menuItemFactory));
    builder.setup();
    builder.setModeller(modeller);
}
Also used : MenuItemWithIconView(org.uberfire.ext.widgets.common.client.menu.MenuItemWithIconView) MenuItemDividerView(org.uberfire.ext.widgets.common.client.menu.MenuItemDividerView) MenuItemFactory(org.uberfire.ext.widgets.common.client.menu.MenuItemFactory) MenuItemWithIcon(org.uberfire.ext.widgets.common.client.menu.MenuItemWithIcon) MenuItemHeaderView(org.uberfire.ext.widgets.common.client.menu.MenuItemHeaderView) Annotation(java.lang.annotation.Annotation) Before(org.junit.Before)

Aggregations

Annotation (java.lang.annotation.Annotation)4 Before (org.junit.Before)4 MenuItemFactory (org.uberfire.ext.widgets.common.client.menu.MenuItemFactory)4 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 GuidedDecisionTableUiModel (org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel)2 MenuItemDividerView (org.uberfire.ext.widgets.common.client.menu.MenuItemDividerView)2 MenuItemHeaderView (org.uberfire.ext.widgets.common.client.menu.MenuItemHeaderView)2 MenuItemWithIcon (org.uberfire.ext.widgets.common.client.menu.MenuItemWithIcon)2 MenuItemWithIconView (org.uberfire.ext.widgets.common.client.menu.MenuItemWithIconView)2 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)2 DefaultClipboard (org.drools.workbench.screens.guided.dtable.client.editor.clipboard.impl.DefaultClipboard)1 EditMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.EditMenuBuilder)1 InsertMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.InsertMenuBuilder)1 RadarMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.RadarMenuBuilder)1 ViewMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.ViewMenuBuilder)1 HTMLElement (org.jboss.errai.common.client.dom.HTMLElement)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Command (org.uberfire.mvp.Command)1 MenuItemCommand (org.uberfire.workbench.model.menu.MenuItemCommand)1