@Override protected void configureTable() { addTableAction( MSG.common_button_delete(), MSG.view_inventory_resources_deleteConfirm(), new AbstractTableAction(TableActionEnablement.ANY) { // only enabled if all selected are a deletable type and if the user has delete permission // on the resources. public boolean isEnabled(ListGridRecord[] selection) { boolean isEnabled = super.isEnabled(selection); if (isEnabled) { for (ListGridRecord record : selection) { ResourceComposite resComposite = (ResourceComposite) record.getAttributeAsObject("resourceComposite"); Resource res = resComposite.getResource(); if (!(isEnabled = res.getResourceType().isDeletable())) { break; } ResourcePermission resPermission = resComposite.getResourcePermission(); if (!(isEnabled = resPermission.isDeleteResource())) { break; } } } return isEnabled; } public void executeAction(ListGridRecord[] selection, Object actionValue) { int[] resourceIds = TableUtility.getIds(selection); ResourceGWTServiceAsync resourceManager = GWTServiceLookup.getResourceService(); resourceManager.deleteResources( resourceIds, new AsyncCallback<List<DeleteResourceHistory>>() { public void onFailure(Throwable caught) { if (caught instanceof CannotConnectToAgentException) { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_inventory_resources_deleteFailed2(), Severity.Warning)); } else { CoreGUI.getErrorHandler() .handleError(MSG.view_inventory_resources_deleteFailed(), caught); } } public void onSuccess(List<DeleteResourceHistory> result) { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_inventory_resources_deleteSuccessful(), Severity.Info)); refresh(true); // refresh the entire gui so it encompasses any relevant tree view. Don't just // call this.refresh(), // because CoreGUI.refresh is more comprehensive. CoreGUI.refresh(); } }); } }); addImportAndCreateButtons(false); super.configureTable(); }