}
Widget asWidget() {
ToolStrip topLevelTools = new ToolStrip();
topLevelTools.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_add(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
presenter.launchNewAdapterWizard();
}
}));
ClickHandler clickHandler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ResourceAdapter selection = getCurrentSelection();
Feedback.confirm(
Console.MESSAGES.deleteTitle("Resource Adapter"),
Console.MESSAGES.deleteConfirm("Resource Adapter " + selection.getArchive()),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.onDelete(selection);
}
}
});
}
};
ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete());
deleteBtn.addClickHandler(clickHandler);
topLevelTools.addToolButtonRight(deleteBtn);
// -------
table = new DefaultCellTable<ResourceAdapter>(5,
new ProvidesKey<ResourceAdapter>() {
@Override
public Object getKey(ResourceAdapter item) {
return item.getArchive();
}
});
dataProvider = new ListDataProvider<ResourceAdapter>();
dataProvider.addDataDisplay(table);
TextColumn<ResourceAdapter> nameColumn = new TextColumn<ResourceAdapter>() {
@Override
public String getValue(ResourceAdapter record) {
return record.getArchive();
}
};
TextColumn<ResourceAdapter> numberConnections = new TextColumn<ResourceAdapter>() {
@Override
public String getValue(ResourceAdapter record) {
return String.valueOf(record.getConnectionDefinitions().size());
}
};
Column<ResourceAdapter, ResourceAdapter> option = new Column<ResourceAdapter, ResourceAdapter>(
new TextLinkCell<ResourceAdapter>(Console.CONSTANTS.common_label_view(), new ActionCell.Delegate<ResourceAdapter>() {
@Override
public void execute(ResourceAdapter selection) {
presenter.getPlaceManager().revealPlace(
new PlaceRequest(NameTokens.ResourceAdapterPresenter).with("name", selection.getArchive())
);
}
})
) {
@Override
public ResourceAdapter getValue(ResourceAdapter manager) {
return manager;
}
};
table.addColumn(nameColumn, "Archive");
table.addColumn(numberConnections, "Connection Def.");
table.addColumn(option, "Option");
// -------
VerticalPanel formpanel = new VerticalPanel();
formpanel.setStyleName("fill-layout-width");
form = new Form<ResourceAdapter>(ResourceAdapter.class);
form.setNumColumns(2);
FormToolStrip<ResourceAdapter> toolStrip = new FormToolStrip<ResourceAdapter>(
form,
new FormToolStrip.FormCallback<ResourceAdapter>() {
@Override
public void onSave(Map<String, Object> changeset) {
presenter.onSave(form.getEditedEntity(), form.getChangedValues());
}
@Override
public void onDelete(ResourceAdapter entity) {
}
});
toolStrip.providesDeleteOp(false);
formpanel.add(toolStrip.asWidget());
// ----
TextItem nameItem = new TextItem("archive", "Archive");
ComboBoxItem txItem = new ComboBoxItem("transactionSupport", "TX");
txItem.setDefaultToFirstOption(true);
txItem.setValueMap(new String[]{"NoTransaction", "LocalTransaction", "XATransaction"});
form.setFields(nameItem, txItem);
final FormHelpPanel helpPanel = new FormHelpPanel(
new FormHelpPanel.AddressCallback() {
@Override
public ModelNode getAddress() {
ModelNode address = Baseadress.get();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", "*");
return address;
}
}, form
);
formpanel.add(helpPanel.asWidget());
form.bind(table);
formpanel.add(form.asWidget());
form.setEnabled(false);
table.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
ResourceAdapter ra = getCurrentSelection();
propertyEditor.setProperties("", ra.getProperties());
}
});
// ----
propertyEditor = new PropertyEditor(this, true);
// ----
MultipleToOneLayout layoutBuilder = new MultipleToOneLayout()
.setPlain(true)
.setTitle("Resource Adapter")
.setHeadline("JCA Resource Adapters")
.setDescription(Console.CONSTANTS.subsys_jca_resource_adapter_desc())
.setMaster(Console.MESSAGES.available("Resource Adapter"), table)
.setMasterTools(topLevelTools.asWidget())
.addDetail("Attributes", formpanel)
.addDetail("Properties", propertyEditor.asWidget());
propertyEditor.setAllowEditProps(false);