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);
}
}
});
}
};
disableBtn = new ToolButton(Console.CONSTANTS.common_label_enOrDisable());
disableBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_enOrDisable_xADataSourceDetails());
disableBtn.addClickHandler(disableHandler);
topLevelTools.addToolButtonRight(disableBtn);
// -----
TabPanel bottomPanel = new TabPanel();
bottomPanel.setStyleName("default-tabpanel");
bottomPanel.add(details.asWidget(), "Attributes");
details.getForm().bind(dataSourceTable);
final FormToolStrip.FormCallback<XADataSource> xaCallback = new FormToolStrip.FormCallback<XADataSource>() {
@Override
public void onSave(Map<String, Object> changeset) {
DataSource ds = getCurrentSelection();
presenter.onSaveXADetails(ds.getName(), changeset);
}
@Override
public void onDelete(XADataSource entity) {
// n/a
}
};
final FormToolStrip.FormCallback<DataSource> dsCallback = new FormToolStrip.FormCallback<DataSource>() {
@Override
public void onSave(Map<String, Object> changeset) {
DataSource ds = getCurrentSelection();
presenter.onSaveXADetails(ds.getName(), changeset);
}
@Override
public void onDelete(DataSource entity) {
// n/a
}
};
connectionEditor = new XADataSourceConnection(presenter, xaCallback);
connectionEditor.getForm().bind(dataSourceTable);
bottomPanel.add(connectionEditor.asWidget(), "Connection");
securityEditor = new DataSourceSecurityEditor(dsCallback);
securityEditor.getForm().bind(dataSourceTable);
bottomPanel.add(securityEditor.asWidget(), "Security");
bottomPanel.add(propertyEditor.asWidget(), "Properties");
propertyEditor.setAllowEditProps(false);
poolConfig = new PoolConfigurationView(new PoolManagement() {
@Override
public void onSavePoolConfig(String parentName, Map<String, Object> changeset) {
presenter.onSavePoolConfig(parentName, changeset, true);
}
@Override
public void onResetPoolConfig(String parentName, PoolConfig entity) {
presenter.onDeletePoolConfig(parentName, entity, true);
}
@Override
public void onDoFlush(String editedName) {
presenter.onDoFlush(true, editedName);
}
});
bottomPanel.add(poolConfig.asWidget(), "Pool");
poolConfig.getForm().bind(dataSourceTable);
validationEditor = new DataSourceValidationEditor(dsCallback);
validationEditor.getForm().bind(dataSourceTable);
bottomPanel.add(validationEditor.asWidget(), "Validation");
bottomPanel.selectTab(0);
vpanel.add(new ContentGroupLabel(Console.CONSTANTS.common_label_selection()));
vpanel.add(bottomPanel);
return layout;
}