ClickHandler clickHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ConnectionDefinition selection = getCurrentSelection();
if(selection!=null)
{
Feedback.confirm(
Console.MESSAGES.deleteTitle("Connection Definition"),
Console.MESSAGES.deleteConfirm("Connection Definition"+selection.getJndiName()),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.onDeleteConnection(selection);
}
}
});
}
}
};
ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete());
deleteBtn.addClickHandler(clickHandler);
topLevelTools.addToolButtonRight(deleteBtn);
disableBtn = new ToolButton(Console.CONSTANTS.common_label_disable(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ConnectionDefinition selection = getCurrentSelection();
if(selection!=null)
{
selection.setEnabled(!selection.isEnabled());
Feedback.confirm(
Console.MESSAGES.modify("Connection Definition"),
Console.MESSAGES.modifyConfirm("Connection Definition " + selection.getJndiName()),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.enOrDisbaleConnection(currentAdapter, selection);
}
}
});
}
}
});
topLevelTools.addToolButtonRight(disableBtn);
// -------
table = new DefaultCellTable<ConnectionDefinition>(10,
new ProvidesKey<ConnectionDefinition>() {
@Override
public Object getKey(ConnectionDefinition item) {
return item.getJndiName();
}
});
dataProvider = new ListDataProvider<ConnectionDefinition>();
dataProvider.addDataDisplay(table);
TextColumn<ConnectionDefinition> nameColumn = new TextColumn<ConnectionDefinition>() {
@Override
public String getValue(ConnectionDefinition record) {
return record.getJndiName();
}
};
Column<ConnectionDefinition, ImageResource> statusColumn =
new Column<ConnectionDefinition, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(ConnectionDefinition ra) {
ImageResource res = null;
if(ra.isEnabled())
res = Icons.INSTANCE.status_good();
else
res = Icons.INSTANCE.status_bad();
return res;
}
};
table.addColumn(nameColumn, "JNDI Name");
table.addColumn(statusColumn, "Enabled?");
table.setSelectionModel(new SingleSelectionModel<ConnectionDefinition>());
// -------
connectionDetails = new AdapterConnectionDetails(presenter);
// ---
securityConfig = new AdapterSecurity(presenter);
// ---
validationConfig = new AdapterValidation(presenter);
// ---
connectionProperties = new AdapterConnectionProperties(presenter, this);
// ---
final SingleSelectionModel<ConnectionDefinition> selectionModel = (SingleSelectionModel<ConnectionDefinition>)table.getSelectionModel();
poolConfig = new PoolConfigurationView(this);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler () {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
ConnectionDefinition selectedObject = getCurrentSelection();
connectionProperties.updateFrom(selectedObject.getProperties());
poolConfig.updateFrom(selectedObject.getJndiName(), selectedObject.getPoolConfig());
String nextState = selectedObject.isEnabled() ?
Console.CONSTANTS.common_label_disable():Console.CONSTANTS.common_label_enable();
disableBtn.setText(nextState);
}
});