ClickHandler clickHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final XADataSource currentSelection = details.getCurrentSelection();
if(currentSelection!=null)
{
Feedback.confirm(
Console.MESSAGES.deleteTitle("XA Datasource"),
Console.MESSAGES.deleteConfirm("XA Datasource "+currentSelection.getName()),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.onDeleteXA(currentSelection);
}
}
});
}
}
};
ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete());
deleteBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_delete_xADataSourceEditor());
deleteBtn.addClickHandler(clickHandler);
topLevelTools.addToolButtonRight(deleteBtn);
// ----
VerticalPanel vpanel = new VerticalPanel();
vpanel.setStyleName("rhs-content-panel");
ScrollPanel scroll = new ScrollPanel(vpanel);
layout.add(scroll);
layout.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 100, Style.Unit.PCT);
// ---
vpanel.add(new ContentHeaderLabel("JDBC XA Datasources"));
vpanel.add(new ContentDescription(Console.CONSTANTS.subsys_jca_xadataSources_desc()));
dataSourceTable = new DefaultCellTable<XADataSource>(8,
new ProvidesKey<XADataSource>() {
@Override
public Object getKey(XADataSource item) {
return item.getJndiName();
}
});
dataSourceProvider = new ListDataProvider<XADataSource>();
dataSourceProvider.addDataDisplay(dataSourceTable);
TextColumn<DataSource> nameColumn = new TextColumn<DataSource>() {
@Override
public String getValue(DataSource record) {
return record.getName();
}
};
TextColumn<DataSource> jndiNameColumn = new TextColumn<DataSource>() {
@Override
public String getValue(DataSource record) {
return record.getJndiName();
}
};
Column<DataSource, ImageResource> statusColumn =
new Column<DataSource, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(DataSource dataSource) {
ImageResource res = null;
if(dataSource.isEnabled())
res = Icons.INSTANCE.status_good();
else
res = Icons.INSTANCE.status_bad();
return res;
}
};
dataSourceTable.addColumn(nameColumn, "Name");
dataSourceTable.addColumn(jndiNameColumn, "JNDI");
dataSourceTable.addColumn(statusColumn, "Enabled?");
vpanel.add(new ContentGroupLabel(Console.MESSAGES.available("XA Datasources")));
vpanel.add(topLevelTools.asWidget());
vpanel.add(dataSourceTable);
DefaultPager pager = new DefaultPager();
pager.setDisplay(dataSourceTable);
vpanel.add(pager);
// -----------
details = new XADataSourceDetails(presenter);
propertyEditor = new PropertyEditor(this, true);
propertyEditor.setHelpText(Console.CONSTANTS.subsys_jca_dataSource_xaprop_help());
final SingleSelectionModel<XADataSource> selectionModel = new SingleSelectionModel<XADataSource>();
selectionModel.addSelectionChangeHandler(
new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
XADataSource dataSource = selectionModel.getSelectedObject();
String nextState = dataSource.isEnabled() ? Console.CONSTANTS.common_label_disable():Console.CONSTANTS.common_label_enable();
disableBtn.setText(nextState);
presenter.loadXAProperties(dataSource.getName());
presenter.loadPoolConfig(true, dataSource.getName());
}
});
dataSourceTable.setSelectionModel(selectionModel);
ClickHandler disableHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final XADataSource selection = getCurrentSelection();
final boolean doEnable = !selection.isEnabled();
Feedback.confirm(Console.MESSAGES.modify("XA datasource"), Console.MESSAGES.modifyConfirm("XA datasource " + selection.getName()),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.onDisableXA(selection, doEnable);