@Override public void init() { super.init(); PushButton selectResources = new PushButton(createText(BUTTON_TEXT_SELECT_RESOURCES_FMT(), _terms.resources())); selectResources.addActionListener(ev -> beginResourceSelection()); selectResources.addClassName("select-resources"); populateListing(); if (_canEdit) { add(of("actions entity-actions", selectResources)); } add(_listing); }
private void populateListing() { _listing.removeAllComponents(); getResourcesFromValue(getValue()) .forEach( r -> { Optional<ResourceRepositoryItem> repoItem = _repositoryDAO.getRepoItemForResource(r); if (repoItem.isPresent()) { ResourceRepositoryItemValueViewer viewer = new ResourceRepositoryItemValueViewer(repoItem.get()); PushButton remove = CommonActions.REMOVE.push(); AppUtil.enableTooltip(remove); remove.addActionListener( ev -> { RI val = removeResourceFromValue(repoItem.get().getResource(), getValue()); _repositoryDAO.mergeRepositoryItem(val); populateListing(); }); _listing.add(of("resource", of("actions persistence-actions", remove), viewer)); } }); }