use of org.jboss.hal.client.configuration.SocketBinding.INBOUND in project console by hal.
the class SocketBindingGroupView method init.
@PostConstruct
@SuppressWarnings("ConstantConditions")
void init() {
AddressTemplate inboundTemplate = ROOT_TEMPLATE.append(INBOUND.templateSuffix());
Metadata inboundMetadata = mbuiContext.metadataRegistry().lookup(inboundTemplate);
inboundTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(INBOUND.baseId, Ids.TABLE), inboundMetadata).button(mbuiContext.tableButtonFactory().add(inboundTemplate, table -> presenter.addSocketBinding(INBOUND))).button(mbuiContext.tableButtonFactory().remove(inboundTemplate, table -> presenter.removeSocketBinding(INBOUND, table.selectedRow().getName()))).column(NAME, (cell, type, row, meta) -> row.getName()).column(PORT, (cell, type, row, meta) -> row.get(PORT).asString()).column(new InlineAction<>(Names.CLIENT_MAPPINGS, row -> presenter.showClientMappings(row))).build();
inboundForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(INBOUND.baseId, Ids.FORM), inboundMetadata).include(INTERFACE, PORT, FIXED_PORT, MULTICAST_ADDRESS, MULTICAST_PORT).unsorted().onSave((form, changedValues) -> presenter.saveSocketBinding(INBOUND, form, changedValues)).prepareReset(form -> presenter.resetSocketBinding(INBOUND, form)).build();
HTMLElement inboundSection = section().add(h(1).textContent(Names.INBOUND)).add(p().textContent(inboundMetadata.getDescription().getDescription())).add(inboundTable).add(inboundForm).element();
Metadata clientMappingsMetadata = inboundMetadata.forComplexAttribute(CLIENT_MAPPINGS);
clientMappingTable = new ModelNodeTable.Builder<NamedNode>(Ids.SOCKET_BINDING_GROUP_INBOUND_CLIENT_MAPPING_TABLE, clientMappingsMetadata).button(mbuiContext.tableButtonFactory().add(inboundTemplate, table -> presenter.addClientMapping(clientMappingsMetadata))).button(mbuiContext.tableButtonFactory().remove(inboundTemplate, table -> presenter.removeClientMapping(table.selectedRow().get(INDEX).asInt(-1)))).column(SOURCE_NETWORK).column(Names.DESTINATION, (cell, type, row, meta) -> {
String address = row.get(DESTINATION_ADDRESS).asString();
if (row.hasDefined(DESTINATION_PORT)) {
address += ":" + row.get(DESTINATION_PORT).asInt();
}
return address;
}).build();
clientMappingForm = new ModelNodeForm.Builder<NamedNode>(Ids.SOCKET_BINDING_GROUP_INBOUND_CLIENT_MAPPING_FORM, clientMappingsMetadata).include(SOURCE_NETWORK, DESTINATION_ADDRESS, DESTINATION_PORT).unsorted().onSave((form, changedValues) -> presenter.saveClientMapping(clientMappingsMetadata, form.getModel(), changedValues)).build();
HTMLElement clientMappingSection = section().add(h(1).textContent(Names.CLIENT_MAPPINGS)).add(p().textContent(clientMappingsMetadata.getDescription().getDescription())).add(clientMappingTable).add(clientMappingForm).element();
String id = Ids.build(INBOUND.baseId, Ids.PAGES);
String parentId = Ids.build(INBOUND.baseId, Ids.PAGE);
inboundPages = new Pages(id, parentId, inboundSection);
inboundPages.addPage(parentId, Ids.SOCKET_BINDING_GROUP_INBOUND_CLIENT_MAPPING_PAGE, () -> Names.INBOUND + ": " + presenter.inbound, () -> Names.CLIENT_MAPPINGS, clientMappingSection);
navigation.insertPrimary(Ids.build(INBOUND.baseId, Ids.ITEM), // NON-NLS
"socket-binding-group-outbound-local-item", Names.INBOUND, fontAwesome("arrow-circle-o-left"), inboundPages);
registerAttachable(inboundTable, inboundForm, clientMappingTable, clientMappingForm);
}
Aggregations