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