List<ListGridField> fields = getDataSource().getListGridFields();
ListGrid listGrid = getListGrid();
listGrid.setFields(fields.toArray(new ListGridField[fields.size()]));
listGrid.sort(FIELD_NAME, SortDirection.ASCENDING);
addTableAction(MSG.common_button_enable(), MSG.common_msg_areYouSure(), ButtonColor.BLUE, new AuthorizedTableAction(this,
TableActionEnablement.ANY, Permission.MANAGE_SETTINGS) {
public void executeAction(ListGridRecord[] selections, Object actionValue) {
int[] selectedIds = getSelectedIds(selections);
GWTServiceLookup.getPluginService().enableAgentPlugins(selectedIds,
new AsyncCallback<ArrayList<String>>() {
@Override
public void onSuccess(ArrayList<String> result) {
Message msg = new Message(MSG.view_admin_plugins_enabledAgentPlugins(result.toString()),
Severity.Info);
CoreGUI.getMessageCenter().notify(msg);
refresh();
}
@Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler()
.handleError(
MSG.view_admin_plugins_enabledAgentPluginsFailure() + " " + caught.getMessage(),
caught);
refreshTableInfo();
}
});
}
});
addTableAction(MSG.common_button_disable(), new AuthorizedTableAction(this, TableActionEnablement.ANY,
Permission.MANAGE_SETTINGS) {
public void executeAction(final ListGridRecord[] selections, Object actionValue) {
ArrayList<String> selectedNames = getSelectedNames(selections);
String message = MSG.view_admin_plugins_agentDisableConfirm(selectedNames.toString());
SC.ask(message, new BooleanCallback() {
public void execute(Boolean confirmed) {
if (confirmed) {
int[] selectedIds = getSelectedIds(selections);
GWTServiceLookup.getPluginService().disableAgentPlugins(selectedIds,
new AsyncCallback<ArrayList<String>>() {
@Override
public void onSuccess(ArrayList<String> result) {
Message msg = new Message(MSG.view_admin_plugins_disabledAgentPlugins(result
.toString()), Severity.Info);
CoreGUI.getMessageCenter().notify(msg);
refresh();
}
@Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
MSG.view_admin_plugins_disabledAgentPluginsFailure() + " "
+ caught.getMessage(), caught);
refreshTableInfo();
}
});
} else {
refreshTableInfo();
}
}
});
}
});
addTableAction(MSG.common_button_delete(), ButtonColor.RED, new AuthorizedTableAction(this, TableActionEnablement.ANY,
Permission.MANAGE_SETTINGS) {
public void executeAction(final ListGridRecord[] selections, Object actionValue) {
ArrayList<String> selectedNames = getSelectedNames(selections);
String message = MSG.view_admin_plugins_agentDeleteConfirm(selectedNames.toString());
SC.ask(message, new BooleanCallback() {