public ImageResource getIcon() { return SmallIcons.INSTANCE.addIcon(); }
/** * Returns widget with authors management for publication * * @return widget */ private Widget loadAuthorsSubTab() { DisclosurePanel dp = new DisclosurePanel(); dp.setWidth("100%"); dp.setOpen(true); VerticalPanel vp = new VerticalPanel(); vp.setSize("100%", "100%"); dp.setContent(vp); FlexTable header = new FlexTable(); header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.userGreenIcon())); header.setHTML(0, 1, "<h3>Authors / Reported by</h3>"); dp.setHeader(header); // menu TabMenu menu = new TabMenu(); // callback final FindAuthorsByPublicationId call = new FindAuthorsByPublicationId(publication.getId()); call.setCheckable(false); if (!publication.getLocked()) { // editable if not locked vp.add(menu); vp.setCellHeight(menu, "30px"); call.setCheckable(true); } final CustomButton addButton = new CustomButton( "Add myself", "Add you as author of publication", SmallIcons.INSTANCE.addIcon()); addButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(call); CreateAuthorship request = new CreateAuthorship(JsonCallbackEvents.disableButtonEvents(addButton, events)); request.createAuthorship(publicationId, session.getActiveUser().getId()); } }); menu.addWidget(addButton); CustomButton addOthersButton = new CustomButton("Add others", "Add more authors", SmallIcons.INSTANCE.addIcon()); addOthersButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { session .getTabManager() .addTabToCurrentTab( new AddAuthorTabItem(publication, JsonCallbackEvents.refreshTableEvents(call)), true); } }); menu.addWidget(addOthersButton); // fill table CellTable<Author> table = call.getEmptyTable(); call.retrieveData(); final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove select author(s) from publication"); removeButton.setEnabled(false); JsonUtils.addTableManagedButton(call, table, removeButton); menu.addWidget(removeButton); removeButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { final ArrayList<Author> list = call.getTableSelectedList(); String text = "Following users will be removed from publication's authors. They will lose any benefit granted by publication's rank."; UiElements.showDeleteConfirm( list, text, new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE for (int i = 0; i < list.size(); i++) { // calls the request if (i == list.size() - 1) { DeleteAuthorship request = new DeleteAuthorship( JsonCallbackEvents.disableButtonEvents( removeButton, JsonCallbackEvents.refreshTableEvents(call))); request.deleteAuthorship(publicationId, list.get(i).getId()); } else { DeleteAuthorship request = new DeleteAuthorship(); request.deleteAuthorship(publicationId, list.get(i).getId()); } } } }); } }); ScrollPanel sp = new ScrollPanel(); sp.add(table); table.addStyleName("perun-table"); sp.addStyleName("perun-tableScrollPanel"); vp.add(sp); return dp; }