use of org.jboss.hal.ballroom.table.Table 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);
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class FilterView method updateHostRefs.
@SuppressWarnings("ConstantConditions")
private void updateHostRefs(final Table<NamedNode> table, final Form<NamedNode> form) {
FormItem<String> formItem = form.getFormItem(HOSTS);
if (formItem != null) {
if (table.hasSelection()) {
ResourceAddress filterRefAddress = HOST_TEMPLATE.append(FILTER_REF + "=" + table.selectedRow().getName()).resolve(mbuiContext.statementContext());
Operation filterRefOp = new Operation.Builder(filterRefAddress, READ_RESOURCE_OPERATION).build();
ResourceAddress locationFilterRefAddress = HOST_TEMPLATE.append(LOCATION + "=*").append(FILTER_REF + "=" + table.selectedRow().getName()).resolve(mbuiContext.statementContext());
Operation locationFilterRefOp = new Operation.Builder(locationFilterRefAddress, READ_RESOURCE_OPERATION).build();
mbuiContext.dispatcher().execute(new Composite(filterRefOp, locationFilterRefOp), (CompositeResult result) -> {
SortedSet<String> hosts = new TreeSet<>();
result.step(0).get(RESULT).asList().stream().map(node -> {
ResourceAddress adr = new ResourceAddress(node.get(ADDRESS));
ResourceAddress host = adr.getParent();
ResourceAddress server = host.getParent();
return server.lastValue() + "/" + host.lastValue();
}).forEach(hosts::add);
result.step(1).get(RESULT).asList().stream().map(node -> {
ResourceAddress adr = new ResourceAddress(node.get(ADDRESS));
ResourceAddress host = adr.getParent().getParent();
ResourceAddress server = host.getParent();
return server.lastValue() + "/" + host.lastValue();
}).forEach(hosts::add);
formItem.setValue(String.join(", ", hosts));
}, (op1, failure) -> formItem.clearValue());
} else {
formItem.clearValue();
}
}
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class HandlerView method updateHostRefs.
@SuppressWarnings("ConstantConditions")
private void updateHostRefs(final Table<NamedNode> table, final Form<NamedNode> form) {
FormItem<String> formItem = form.getFormItem(HOSTS);
if (formItem != null) {
if (table.hasSelection()) {
ResourceAddress address = HOST_TEMPLATE.append(LOCATION + "=*").resolve(mbuiContext.statementContext());
Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION).build();
mbuiContext.dispatcher().execute(operation, result -> {
String hosts = result.asList().stream().filter(node -> table.selectedRow().getName().equals(node.get(RESULT).get(HANDLER).asString())).map(node -> {
ResourceAddress adr = new ResourceAddress(node.get(ADDRESS));
ResourceAddress host = adr.getParent();
ResourceAddress server = host.getParent();
return server.lastValue() + "/" + host.lastValue();
}).distinct().sorted().collect(Collectors.joining(", "));
formItem.setValue(hosts);
}, (op1, failure) -> formItem.clearValue());
} else {
formItem.clearValue();
}
}
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class SecurityManagerView method createPermissionUI.
private void createPermissionUI(Permission permission) {
Metadata metadata = metadataRegistry.lookup(DEPLOYMENT_PERMISSIONS_TEMPLATE).forComplexAttribute(permission.resource);
Constraint constraint = Constraint.writable(DEPLOYMENT_PERMISSIONS_TEMPLATE, permission.resource);
EmptyState emptyState = new EmptyState.Builder(Ids.DEPLOYMENT_PERMISSIONS_EMPTY, Names.DEPLOYMENT_PERMISSIONS).description(resources.messages().noDeploymentPermissions()).primaryAction(resources.constants().add(), () -> presenter.addDeploymentPermissions(), constraint).build();
emptyState.element().classList.add(marginTopLarge);
emptyStates.put(permission, emptyState);
Table<ModelNode> table = new ModelNodeTable.Builder<>(Ids.build(permission.baseId, Ids.TABLE), metadata).button(resources.constants().add(), t -> presenter.addPermission(permission), constraint).button(resources.constants().remove(), t -> presenter.removePermission(permission, t.selectedRow().get(HAL_INDEX).asInt()), Scope.SELECTED, constraint).column(CLASS).build();
tables.put(permission, table);
registerAttachable(table);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(permission.baseId, Ids.FORM), metadata).onSave((f, changedValues) -> presenter.savePermission(permission, f.getModel().get(HAL_INDEX).asInt(), changedValues)).build();
forms.put(permission, form);
registerAttachable(form);
HTMLElement masterDetail;
HTMLElement section = section().add(emptyState).add(masterDetail = div().add(h(1).textContent(permission.type)).add(p().textContent(metadata.getDescription().getDescription())).add(table).add(form).element()).element();
masterDetails.put(permission, masterDetail);
navigation.addPrimary(Ids.build(permission.baseId, Ids.ITEM), permission.type, permission.icon, section);
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class EEView method buildServicePanel.
@SuppressWarnings("ConstantConditions")
private HTMLElement buildServicePanel(String baseId, AddressTemplate template, String type) {
Metadata metadata = metadataRegistry.lookup(template);
Table<NamedNode> table = new ModelNodeTable.Builder<NamedNode>(Ids.build(baseId, Ids.TABLE), metadata).column(NAME, (cell, t, row, meta) -> row.getName()).button(tableButtonFactory.add(Ids.build(baseId, Ids.ADD), type, template, (name, address) -> presenter.reload())).button(tableButtonFactory.remove(type, template, (api) -> api.selectedRow().getName(), () -> presenter.reload())).build();
registerAttachable(table);
tables.put(template.lastName(), table);
ModelNodeForm<NamedNode> form = new ModelNodeForm.Builder<NamedNode>(Ids.build(baseId, Ids.FORM), metadata).onSave((f, changedValues) -> {
AddressTemplate fullyQualified = template.replaceWildcards(table.selectedRow().getName());
presenter.save(fullyQualified, changedValues, metadata, resources.messages().modifyResourceSuccess(Names.EE, template.lastName()));
}).prepareReset(f -> {
String name = table.selectedRow().getName();
AddressTemplate fullyQualified = template.replaceWildcards(name);
presenter.reset(type, name, fullyQualified, f, metadata, resources.messages().modifyResourceSuccess(Names.EE, template.lastName()));
}).build();
forms.put(template.lastName(), form);
registerAttachable(form);
return section().add(h(1).textContent(type)).add(p().textContent(metadata.getDescription().getDescription())).add(table).add(form).element();
}
Aggregations