form.setNumColumns(2);
}
public Widget asWidget() {
ToolStrip detailToolStrip = new ToolStrip();
editBtn = new ToolButton(Console.CONSTANTS.common_label_edit());
ClickHandler editHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(editBtn.getText().equals(Console.CONSTANTS.common_label_edit()))
presenter.onEditXA(form.getEditedEntity());
else
presenter.onSaveXADetails(form.getEditedEntity().getName(), form.getChangedValues());
}
};
editBtn.addClickHandler(editHandler);
detailToolStrip.addToolButton(editBtn);
ClickHandler clickHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
DataSource currentSelection = form.getEditedEntity();
Feedback.confirm(
"Delete DataSource",
"Really delete this DataSource '" + currentSelection.getName() + "' ?",
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.onDeleteXA(form.getEditedEntity());
}
}
});
}
};
ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete());
deleteBtn.addClickHandler(clickHandler);
detailToolStrip.addToolButton(deleteBtn);
ClickHandler disableHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
String state = form.getEditedEntity().isEnabled() ? Console.CONSTANTS.common_label_disable() : Console.CONSTANTS.common_label_enable();
final boolean doEnable = !form.getEditedEntity().isEnabled();
Feedback.confirm(state + " datasource", "Do you want to " + state + " this DataSource?",
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.onDisableXA(form.getEditedEntity(), doEnable);
}
}
});
}
};
ToolButton enableBtn = new ToolButton(Console.CONSTANTS.common_label_enOrDisable());
enableBtn.addClickHandler(disableHandler);
detailToolStrip.addToolButtonRight(enableBtn);
VerticalPanel panel = new VerticalPanel();
panel.add(detailToolStrip);
final TextItem nameItem = new TextItem("name", "Name");