}
}
private void uninventoryItems(ListGridRecord[] selection) {
int[] resourceIds = TableUtility.getIds(selection);
ResourceGWTServiceAsync resourceManager = GWTServiceLookup.getResourceService();
resourceManager.uninventoryResources(resourceIds, new AsyncCallback<List<Integer>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_uninventoryFailed(),
caught);
refreshTableInfo();
}
public void onSuccess(List<Integer> result) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_inventory_resources_uninventorySuccessful(), Severity.Info));
onActionSuccess();
}
});
}
private boolean containsStorageNodeOrItsResource(ListGridRecord[] selection) {
for (ListGridRecord record : selection) {
if (record.getAttribute(AncestryUtil.RESOURCE_ANCESTRY) == null
|| "RHQStorage".equals(record.getAttribute(PLUGIN.propertyName()))) {
// is a platform, storage node or child resource of storage node
return true;
}
}
return false;
}
});
addTableAction(MSG.common_button_disable(), MSG.view_inventory_resources_disableConfirm(),
new AvailabilityTypeResourceAuthorizedTableAction(ResourceSearchView.this, TableActionEnablement.ANY,
EnumSet.complementOf(EnumSet.of(AvailabilityType.DISABLED)), Permission.DELETE_RESOURCE,
new RecordExtractor<AvailabilityType>() {
public Collection<AvailabilityType> extract(Record[] records) {
List<AvailabilityType> result = new ArrayList<AvailabilityType>(records.length);
for (Record record : records) {
result.add(((Resource) record.getAttributeAsObject("resource")).getCurrentAvailability()
.getAvailabilityType());
}
return result;
}
}, //
new RecordExtractor<Integer>() {
public Collection<Integer> extract(Record[] records) {
List<Integer> result = new ArrayList<Integer>(records.length);
for (Record record : records) {
result.add(record.getAttributeAsInt("id"));
}
return result;
}
}) {
@Override
public boolean isEnabled(ListGridRecord[] records) {
boolean result = super.isEnabled(records);
if (result) {
for (Record record : records) {
if (record.getAttribute(ResourceDataSourceField.CATEGORY.propertyName()).equals(
ResourceCategory.PLATFORM.name())) {
result = false;
break;
}
}
}
return result;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
int[] resourceIds = TableUtility.getIds(selection);
ResourceGWTServiceAsync resourceManager = GWTServiceLookup.getResourceService();
resourceManager.disableResources(resourceIds, new AsyncCallback<List<Integer>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_disableFailed(), caught);
refreshTableInfo();
}
public void onSuccess(List<Integer> result) {
CoreGUI.getMessageCenter().notify(
new Message(
MSG.view_inventory_resources_disableSuccessful(String.valueOf(result.size())),
Severity.Info));
onActionSuccess();
}
});
}
});
addTableAction(MSG.common_button_enable(), MSG.view_inventory_resources_enableConfirm(), ButtonColor.BLUE,
new AvailabilityTypeResourceAuthorizedTableAction(ResourceSearchView.this, TableActionEnablement.ANY,
EnumSet.of(AvailabilityType.DISABLED), Permission.DELETE_RESOURCE,
new RecordExtractor<AvailabilityType>() {
public Collection<AvailabilityType> extract(Record[] records) {
List<AvailabilityType> result = new ArrayList<AvailabilityType>(records.length);
for (Record record : records) {
result.add(((Resource) record.getAttributeAsObject("resource")).getCurrentAvailability()
.getAvailabilityType());
}
return result;
}
}, //
new RecordExtractor<Integer>() {
public Collection<Integer> extract(Record[] records) {
List<Integer> result = new ArrayList<Integer>(records.length);
for (Record record : records) {
result.add(record.getAttributeAsInt("id"));
}
return result;
}
}) {
@Override
public boolean isEnabled(ListGridRecord[] records) {
boolean result = super.isEnabled(records);
if (result) {
for (Record record : records) {
if (record.getAttribute(ResourceDataSourceField.CATEGORY.propertyName()).equals(
ResourceCategory.PLATFORM.name())) {
result = false;
break;
}
}
}
return result;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
int[] resourceIds = TableUtility.getIds(selection);
ResourceGWTServiceAsync resourceManager = GWTServiceLookup.getResourceService();
resourceManager.enableResources(resourceIds, new AsyncCallback<List<Integer>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_enableFailed(), caught);
refreshTableInfo();
}