Search in sources :

Example 1 with RendererClickEvent

use of com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent in project catma by forTEXT.

the class TagsView method initActions.

private void initActions() {
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getColor(), new HtmlRenderer()).setCaption("Tagsets").setSortable(false).setWidth(200);
    tagsetGrid.setHierarchyColumn(tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getName()).setCaption("Tags").setSortable(false).setWidth(300));
    ButtonRenderer<TagsetTreeItem> propertySummaryRenderer = new ButtonRenderer<>(rendererClickEvent -> handlePropertySummaryClickEvent(rendererClickEvent));
    propertySummaryRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertySummary(), propertySummaryRenderer).setCaption("Properties").setSortable(false).setHidable(true).setWidth(300);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertyValue()).setCaption("Values").setSortable(false).setHidable(true).setWidth(300);
    ButtonRenderer<TagsetTreeItem> btRemovalRenderer = new ButtonRenderer<>(rendererClickEvent -> handleTagsetTreeItemRemovalRequest(rendererClickEvent));
    btRemovalRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getRemoveIcon()).setRenderer(btRemovalRenderer).setSortable(false).setHidable(false).setExpandRatio(1);
    tagsetGrid.setStyleGenerator(new StyleGenerator<TagsetTreeItem>() {

        @Override
        public String apply(TagsetTreeItem item) {
            return item.generateStyle();
        }
    });
    tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetTreeItem>() {

        @Override
        public SerializablePredicate<TagsetTreeItem> createSearchFilter(String searchInput) {
            return new TagsetSearchFilterProvider(searchInput, tagsetData);
        }
    });
    tagsetGrid.addExpandListener(expandEvent -> handleExpandCollapseTagset(expandEvent.getExpandedItem(), true));
    tagsetGrid.addCollapseListener(collapseEvent -> handleExpandCollapseTagset(collapseEvent.getCollapsedItem(), false));
    ContextMenu addContextMenu = tagsetGridComponent.getActionGridBar().getBtnAddContextMenu();
    addContextMenu.addItem("Add Tagset", clickEvent -> handleAddTagsetRequest());
    addContextMenu.addItem("Add Tag", clickEvent -> handleAddTagRequest());
    addContextMenu.addItem("Add Subtag", clickEvent -> handleAddSubtagRequest());
    addContextMenu.addItem("Add Property", clickEvent -> handleAddPropertyRequest());
    ContextMenu moreOptionsContextMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    moreOptionsContextMenu.addItem("Edit Tag", clickEvent -> handleEditTagRequest());
    moreOptionsContextMenu.addItem("Delete Tag", clickEvent -> handleDeleteTagRequest());
    moreOptionsContextMenu.addItem("Edit/Delete Properties", clickEvent -> handleEditPropertiesRequest());
    moreOptionsContextMenu.addItem("Edit Tagset", clickEvent -> handleEditTagsetRequest());
    moreOptionsContextMenu.addItem("Delete Tagset", clickEvent -> handleDeleteTagsetRequest());
    resourcePanel.setTagsetSelectionListener(selectedTagsets -> {
        tagsets.clear();
        tagsets.addAll(selectedTagsets);
        initData();
    });
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) PropertyDefinition(de.catma.tag.PropertyDefinition) UI(com.vaadin.ui.UI) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) Multimap(com.google.common.collect.Multimap) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) ArrayList(java.util.ArrayList) EventBus(com.google.common.eventbus.EventBus) MaterialTheme(com.github.appreciated.material.MaterialTheme) Notification(com.vaadin.ui.Notification) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) SliderPanel(org.vaadin.sliderpanel.SliderPanel) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) Pair(de.catma.util.Pair) Version(de.catma.tag.Version) TreeGridFactory(de.catma.ui.component.TreeGridFactory) IDGenerator(de.catma.util.IDGenerator) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) TreeData(com.vaadin.data.TreeData) Project(de.catma.project.Project) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ContextMenu(com.vaadin.contextmenu.ContextMenu) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TagDefinition(de.catma.tag.TagDefinition) SerializablePredicate(com.vaadin.server.SerializablePredicate) Optional(java.util.Optional) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) SliderPanelBuilder(org.vaadin.sliderpanel.SliderPanelBuilder) SelectionMode(com.vaadin.ui.Grid.SelectionMode) StyleGenerator(com.vaadin.ui.StyleGenerator) RBACPermission(de.catma.rbac.RBACPermission) SliderMode(org.vaadin.sliderpanel.client.SliderMode) HugeCard(de.catma.ui.component.hugecard.HugeCard) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SerializablePredicate(com.vaadin.server.SerializablePredicate) ContextMenu(com.vaadin.contextmenu.ContextMenu) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 2 with RendererClickEvent

use of com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent in project cia by Hack23.

the class PageItemPropertyClickListenerTest method checkCorrectPageIdClickSuccessTest.

/**
 * Check correct page id click success test.
 */
@Test
public void checkCorrectPageIdClickSuccessTest() {
    final PageItemPropertyClickListener pageItemPropertyClickListener = new PageItemPropertyClickListener(UserViews.POLITICIAN_VIEW_NAME, "personId");
    final String personIdValue = "personId";
    final ViewRiksdagenPolitician riksdagenPolitician = new ViewRiksdagenPolitician().withPersonId(personIdValue);
    final String pageId = pageItemPropertyClickListener.getPageId(riksdagenPolitician);
    assertEquals(personIdValue, pageId);
    final UI uiMock = Mockito.mock(UI.class);
    UI.setCurrent(uiMock);
    final Navigator navigatorMock = Mockito.mock(Navigator.class);
    Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);
    pageItemPropertyClickListener.click(new RendererClickEvent(new Grid(), riksdagenPolitician, null, null) {

        /**
         */
        private static final long serialVersionUID = 1L;
    });
    Mockito.verify(navigatorMock, times(1)).navigateTo(UserViews.POLITICIAN_VIEW_NAME + "/personId");
}
Also used : UI(com.vaadin.ui.UI) Navigator(com.vaadin.navigator.Navigator) Grid(com.vaadin.ui.Grid) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) ViewRiksdagenPolitician(com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician) Test(org.junit.Test) AbstractUnitTest(com.hack23.cia.testfoundation.AbstractUnitTest)

Example 3 with RendererClickEvent

use of com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent in project cia by Hack23.

the class RuleViolationPageItemRendererClickListenerTest method clickPartyTest.

/**
 * Click party test.
 */
@Test
public void clickPartyTest() {
    final RuleViolationPageItemRendererClickListener listener = new RuleViolationPageItemRendererClickListener();
    final UI uiMock = Mockito.mock(UI.class);
    UI.setCurrent(uiMock);
    final Navigator navigatorMock = Mockito.mock(Navigator.class);
    Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);
    final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
    Mockito.when(event.getItem()).thenReturn(new RuleViolation("partyid", null, ResourceType.PARTY, null, null, null, null, null));
    listener.click(event);
    Mockito.verify(navigatorMock, times(1)).navigateTo("party/partyid");
}
Also used : UI(com.vaadin.ui.UI) Navigator(com.vaadin.navigator.Navigator) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) RuleViolation(com.hack23.cia.model.internal.application.data.rules.impl.RuleViolation) AbstractUnitTest(com.hack23.cia.testfoundation.AbstractUnitTest) Test(org.junit.Test)

Example 4 with RendererClickEvent

use of com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent in project cia by Hack23.

the class ComplianceCheckPageItemRendererClickListenerTest method clickPartyTest.

/**
 * Click party test.
 */
@Test
public void clickPartyTest() {
    final ComplianceCheckPageItemRendererClickListener listener = new ComplianceCheckPageItemRendererClickListener();
    final UI uiMock = Mockito.mock(UI.class);
    UI.setCurrent(uiMock);
    final Navigator navigatorMock = Mockito.mock(Navigator.class);
    Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);
    final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
    Mockito.when(event.getItem()).thenReturn(new PartyComplianceCheckImpl(new ViewRiksdagenPartySummary().withParty("partyid"), null, null, null));
    listener.click(event);
    Mockito.verify(navigatorMock, times(1)).navigateTo("party/partyid");
}
Also used : ViewRiksdagenPartySummary(com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary) UI(com.vaadin.ui.UI) Navigator(com.vaadin.navigator.Navigator) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PartyComplianceCheckImpl(com.hack23.cia.service.impl.rules.PartyComplianceCheckImpl) Test(org.junit.Test) AbstractUnitTest(com.hack23.cia.testfoundation.AbstractUnitTest)

Example 5 with RendererClickEvent

use of com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent in project cia by Hack23.

the class RuleViolationPageItemRendererClickListenerTest method clickPoliticianTest.

/**
 * Click politician test.
 */
@Test
public void clickPoliticianTest() {
    final RuleViolationPageItemRendererClickListener listener = new RuleViolationPageItemRendererClickListener();
    final UI uiMock = Mockito.mock(UI.class);
    UI.setCurrent(uiMock);
    final Navigator navigatorMock = Mockito.mock(Navigator.class);
    Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);
    final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
    Mockito.when(event.getItem()).thenReturn(new RuleViolation("personid", null, ResourceType.POLITICIAN, null, null, null, null, null));
    listener.click(event);
    Mockito.verify(navigatorMock, times(1)).navigateTo("politician/personid");
}
Also used : UI(com.vaadin.ui.UI) Navigator(com.vaadin.navigator.Navigator) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) RuleViolation(com.hack23.cia.model.internal.application.data.rules.impl.RuleViolation) AbstractUnitTest(com.hack23.cia.testfoundation.AbstractUnitTest) Test(org.junit.Test)

Aggregations

UI (com.vaadin.ui.UI)7 RendererClickEvent (com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent)7 AbstractUnitTest (com.hack23.cia.testfoundation.AbstractUnitTest)5 Navigator (com.vaadin.navigator.Navigator)5 Test (org.junit.Test)5 MaterialTheme (com.github.appreciated.material.MaterialTheme)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 Multimap (com.google.common.collect.Multimap)2 EventBus (com.google.common.eventbus.EventBus)2 ViewRiksdagenPolitician (com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician)2 RuleViolation (com.hack23.cia.model.internal.application.data.rules.impl.RuleViolation)2 ContextMenu (com.vaadin.contextmenu.ContextMenu)2 TreeData (com.vaadin.data.TreeData)2 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)2 SerializablePredicate (com.vaadin.server.SerializablePredicate)2 SelectionMode (com.vaadin.ui.Grid.SelectionMode)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Label (com.vaadin.ui.Label)2 Notification (com.vaadin.ui.Notification)2 Type (com.vaadin.ui.Notification.Type)2