@SuppressWarnings("ConstantConditions") private void beginResourceSelection() { final Dialog dlg = new Dialog(getApplication(), createText(LABEL_SELECT_RESOURCES_FMT(), _terms.resources())); dlg.addClassName("resource-selector-dialog"); ResourceSelector selector = new ResourceSelector( _repositoryDAO.getOwnerOfRepositoryItem(getValue()), getResourcesFromValue(getValue())); selector.setOnSelect( context -> { ResourceRepositoryItem rri = context.getData(); if (rri != null) { RI val = addResourceToValue(rri.getResource(), getValue()); _repositoryDAO.mergeRepositoryItem(val); selector.setSelection(getResourcesFromValue(getValue())); populateListing(); context.getSearchUI().doAction(SearchUIAction.search); } return null; }); dlg.add(of(HTMLElement.section, "repo-item resource-selector", selector)); getWindowManager().add(dlg); dlg.setVisible(true); }
@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); }