use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class ConnectionView method init.
@PostConstruct
void init() {
Metadata metadata = mbuiContext.metadataRegistry().lookup(POOLED_CONNECTION_FACTORY_TEMPLATE);
crForm = cr.form(Ids.MESSAGING_SERVER, metadata, CREDENTIAL_REFERENCE, PASSWORD, () -> pooledConnectionFactoryForm.<String>getFormItem(PASSWORD).getValue(), () -> presenter.pooledConnectionFactoryAddress(pooledConnectionFactoryTable.hasSelection() ? pooledConnectionFactoryTable.selectedRow().getName() : null), () -> presenter.reload());
pooledConnectionFactoryTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(MESSAGING_SERVER, POOLED_CONNECTION_FACTORY, Ids.TABLE), metadata).button(mbuiContext.resources().constants().add(), table -> presenter.addPooledConnectionFactory(ServerSubResource.POOLED_CONNECTION_FACTORY), Constraint.executable(POOLED_CONNECTION_FACTORY_TEMPLATE, ADD)).button(mbuiContext.resources().constants().remove(), table -> presenter.remove(ServerSubResource.POOLED_CONNECTION_FACTORY, table.selectedRow()), Scope.SELECTED, Constraint.executable(POOLED_CONNECTION_FACTORY_TEMPLATE, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
pooledConnectionFactoryForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(Ids.MESSAGING_POOLED_CONNECTION_FACTORY, Ids.FORM), metadata).onSave((form, changedValues) -> presenter.save(ServerSubResource.POOLED_CONNECTION_FACTORY, form, changedValues)).prepareReset(form -> presenter.reset(ServerSubResource.POOLED_CONNECTION_FACTORY, form)).build();
pooledConnectionFactoryForm.addFormValidation(new CredentialReference.AlternativeValidation<>(PASSWORD, () -> crForm.getModel(), mbuiContext.resources()));
Tabs tabs = new Tabs(Ids.build(Ids.MESSAGING_SERVER, POOLED_CONNECTION_FACTORY, Ids.TAB_CONTAINER));
tabs.add(Ids.build(Ids.MESSAGING_SERVER, POOLED_CONNECTION_FACTORY, ATTRIBUTES, Ids.TAB), mbuiContext.resources().constants().attributes(), pooledConnectionFactoryForm.element());
tabs.add(Ids.build(Ids.MESSAGING_SERVER, POOLED_CONNECTION_FACTORY, CREDENTIAL_REFERENCE, Ids.TAB), Names.CREDENTIAL_REFERENCE, crForm.element());
HTMLElement htmlSection = section().add(h(1).textContent(Names.POOLED_CONNECTION_FACTORY)).add(p().textContent(metadata.getDescription().getDescription())).add(pooledConnectionFactoryTable).add(tabs).element();
registerAttachable(pooledConnectionFactoryTable, pooledConnectionFactoryForm, crForm);
navigation.insertPrimary(Ids.build(MESSAGING_SERVER, POOLED_CONNECTION_FACTORY, Ids.ITEM), null, Names.POOLED_CONNECTION_FACTORY, "pficon pficon-replicator", htmlSection);
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class DestinationView method init.
@PostConstruct
void init() {
Metadata roleMetadata = mbuiContext.metadataRegistry().lookup(ROLE_TEMPLATE);
roleTable = new ModelNodeTable.Builder<NamedNode>(Ids.MESSAGING_SECURITY_SETTING_ROLE_TABLE, roleMetadata).button(mbuiContext.tableButtonFactory().add(ROLE_TEMPLATE, table -> presenter.addSecuritySettingRole())).button(mbuiContext.tableButtonFactory().remove(ROLE_TEMPLATE, table -> presenter.removeSecuritySettingRole(table.selectedRow()))).column(SECURITY_SETTING, mbuiContext.resources().constants().pattern(), (cell, type, row, meta) -> row.get(SECURITY_SETTING).asString()).column(ROLE, mbuiContext.resources().constants().role(), (cell, type, row, meta) -> row.getName()).build();
roleForm = new ModelNodeForm.Builder<NamedNode>(Ids.MESSAGING_SECURITY_SETTING_ROLE_FORM, roleMetadata).onSave((form, changedValues) -> presenter.saveSecuritySettingRole(form, changedValues)).prepareReset(form -> presenter.resetSecuritySettingRole(form)).build();
registerAttachable(roleTable, roleForm);
HTMLElement roleSection = section().add(h(1).textContent(Names.SECURITY_SETTING)).add(p().textContent(roleMetadata.getDescription().getDescription())).add(roleTable).add(roleForm).element();
// noinspection HardCodedStringLiteral
navigation.insertPrimary(Ids.MESSAGING_SECURITY_SETTING_ROLE_ITEM, "messaging-address-setting-item", Names.SECURITY_SETTING, fontAwesome("lock"), roleSection);
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class LoggingProfileView method init.
@PostConstruct
@SuppressWarnings("Duplicates")
void init() {
Constants constants = mbuiContext.resources().constants();
noRootLogger = new EmptyState.Builder(Ids.LOGGING_PROFILE + "-root-logger-empty", constants.noRootLogger()).description(constants.noRootLoggerDescription()).icon(fontAwesome("sitemap")).primaryAction(constants.add(), this::addRootLogger).build();
noRootLogger.element().classList.add(marginTopLarge);
// hack which relies on the element hierarchy given in the template. will break if you change that hierarchy.
rootLoggerForm.element().parentNode.appendChild(noRootLogger.element());
rootLoggerVisibility(false);
// --------------------------- json formatter
AddressTemplate jsonTemplate = LOGGING_PROFILE_TEMPLATE.append(JSON_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
LabelBuilder labelBuilder = new LabelBuilder();
Metadata jsonMetadata = mbuiContext.metadataRegistry().lookup(jsonTemplate);
Metadata jsonKeyOverridesMetadata = jsonMetadata.forComplexAttribute(KEY_OVERRIDES);
String jsonLabel = labelBuilder.label(jsonTemplate.lastName());
jsonFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, TABLE), jsonMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, ADD), Names.JSON_FORMATTER, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(jsonTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.JSON_FORMATTER, table.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(jsonTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
jsonFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, FORM), jsonMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(jsonLabel, form.getModel().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(jsonLabel, jsonFormatterTable.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), form, jsonMetadata, () -> presenter.reload())).build();
jsonKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, FORM), jsonKeyOverridesMetadata).singleton(() -> {
StatementContext jsonStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> jsonFormatterTable.hasSelection() ? jsonFormatterTable.selectedRow().getName() : null);
ResourceAddress address = jsonTemplate.resolve(jsonStatementContext, presenter.getLoggingProfile());
return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
}, () -> presenter.addComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), jsonKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
Tabs jsonTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, TAB_CONTAINER));
jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, ATTRIBUTES, TAB), constants.attributes(), jsonFormatterForm.element());
jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, jsonKeyOverridesForm.element());
HTMLElement jsonSection = section().add(h(1).textContent(Names.JSON_FORMATTER)).add(p().textContent(jsonMetadata.getDescription().getDescription())).add(jsonFormatterTable).add(jsonTabs).element();
registerAttachable(jsonFormatterTable, jsonFormatterForm, jsonKeyOverridesForm);
navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, JSON, Ids.ITEM), null, Names.JSON_FORMATTER, jsonSection);
// --------------------------- xml formatter
AddressTemplate xmlTemplate = LOGGING_PROFILE_TEMPLATE.append(XML_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
Metadata xmlMetadata = mbuiContext.metadataRegistry().lookup(xmlTemplate);
Metadata xmlKeyOverridesMetadata = xmlMetadata.forComplexAttribute(KEY_OVERRIDES);
String xmlLabel = labelBuilder.label(xmlTemplate.lastName());
xmlFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, TABLE), xmlMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, XML, FORMATTER, ADD), Names.XML_FORMATTER, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(xmlTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.XML_FORMATTER, table.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(xmlTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
xmlFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, FORM), xmlMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(xmlLabel, form.getModel().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(xmlLabel, xmlFormatterTable.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), form, xmlMetadata, () -> presenter.reload())).build();
xmlKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, FORM), xmlKeyOverridesMetadata).singleton(() -> {
StatementContext xmlStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> xmlFormatterTable.hasSelection() ? xmlFormatterTable.selectedRow().getName() : null);
ResourceAddress address = xmlTemplate.resolve(xmlStatementContext, presenter.getLoggingProfile());
return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
}, () -> presenter.addComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), xmlKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
Tabs xmlTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, XML, TAB_CONTAINER));
xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, ATTRIBUTES, TAB), constants.attributes(), xmlFormatterForm.element());
xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, xmlKeyOverridesForm.element());
HTMLElement xmlSection = section().add(h(1).textContent(Names.XML_FORMATTER)).add(p().textContent(xmlMetadata.getDescription().getDescription())).add(xmlFormatterTable).add(xmlTabs).element();
registerAttachable(xmlFormatterTable, xmlFormatterForm, xmlKeyOverridesForm);
navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, XML, Ids.ITEM), null, Names.XML_FORMATTER, xmlSection);
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class MapperDecoderView method init.
@PostConstruct
void init() {
Metadata metadata = mbuiContext.metadataRegistry().lookup(CONSTANT_PERMISSION_MAPPER_TEMPLATE);
constantPermissionMapperElement = new ResourceElement.Builder(Ids.ELYTRON_CONSTANT_PERMISSION_MAPPER, CONSTANT_PERMISSION_MAPPER, metadata, mbuiContext).column(NAME, (cell, type, row, meta) -> row.getName()).setComplexListAttribute(PERMISSIONS, asList(CLASS_NAME, MODULE), asList(CLASS_NAME, MODULE), modelNode -> build(modelNode.get(CLASS_NAME).asString(), modelNode.get(MODULE).asString())).onCrud(() -> presenter.reload(CONSTANT_PERMISSION_MAPPER, this::updateConstantPermissionMapper)).build();
navigation.insertSecondary("mappers-decoders-permission-mapper-item", build(Ids.ELYTRON_CONSTANT_PERMISSION_MAPPER, ITEM), "mappers-decoders-custom-permission-mapper-item", "Constant Permission Mapper", constantPermissionMapperElement.element());
registerAttachable(constantPermissionMapperElement);
// =========
String mappedId = "mappers-decoders-mapped-role-mapper";
Metadata mappedMetadata = mbuiContext.metadataRegistry().lookup(MAPPED_ROLE_MAPPER_TEMPLATE);
LabelBuilder labelBuilder = new LabelBuilder();
String title = labelBuilder.label(MAPPED_ROLE_MAPPER);
mappedRoleMapperTable = new ModelNodeTable.Builder<NamedNode>(build(mappedId, TABLE), mappedMetadata).button(mbuiContext.tableButtonFactory().add(MAPPED_ROLE_MAPPER_TEMPLATE, table -> presenter.addMappedRoleMapper())).button(mbuiContext.tableButtonFactory().remove(title, MAPPED_ROLE_MAPPER_TEMPLATE, table -> table.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
mappedRoleMapperForm = new ModelNodeForm.Builder<NamedNode>(build(mappedId, FORM), mappedMetadata).customFormItem(ROLE_MAP, desc -> new RoleMapListItem(ROLE_MAP, labelBuilder.label(ROLE_MAP))).onSave((form, changedValues) -> {
String name = form.getModel().getName();
ResourceAddress address = MAPPED_ROLE_MAPPER_TEMPLATE.resolve(mbuiContext.statementContext(), name);
saveForm(title, name, address, changedValues, mappedMetadata);
}).build();
HTMLElement mappedSection = section().add(h(1).textContent(Names.SIMPLE_PERMISSION_MAPPER)).add(p().textContent(metadata.getDescription().getDescription())).add(mappedRoleMapperTable).add(mappedRoleMapperForm).element();
registerAttachable(mappedRoleMapperTable, mappedRoleMapperForm);
navigation.insertSecondary("mappers-decoders-role-mappers", build(mappedId, ITEM), null, title, mappedSection);
// =========
Metadata spmMetadata = mbuiContext.metadataRegistry().lookup(AddressTemplates.SIMPLE_PERMISSION_MAPPER_TEMPLATE);
simplePermissionMapperElement = new SimplePermissionMapperElement(spmMetadata, mbuiContext.tableButtonFactory());
navigation.insertSecondary("mappers-decoders-permission-mapper-item", build(Ids.ELYTRON_SIMPLE_PERMISSION_MAPPER, ITEM), "mappers-decoders-simple-permission-mapper-item", "Simple Permission Mapper", simplePermissionMapperElement.element());
registerAttachable(simplePermissionMapperElement);
}
use of org.jboss.hal.ballroom.table.Table in project console by hal.
the class MbuiViewProcessor method processMbuiElements.
// ------------------------------------------------------ process @MbuiElement
@SuppressWarnings("HardCodedStringLiteral")
private void processMbuiElements(TypeElement type, Document document, MbuiViewContext context) {
ElementFilter.fieldsIn(type.getEnclosedElements()).stream().filter(field -> MoreElements.isAnnotationPresent(field, MbuiElement.class)).forEach(field -> {
// verify the field
if (field.getModifiers().contains(Modifier.PRIVATE)) {
error(field, "@%s member must not be private", MbuiElement.class.getSimpleName());
}
if (field.getModifiers().contains(Modifier.STATIC)) {
error(field, "@%s member must not be static", MbuiElement.class.getSimpleName());
}
// verify the selector
String selector = getSelector(field);
org.jdom2.Element element = verifySelector(selector, field, document);
// delegate to specific processors based on element type
ElementType elementType = getMbuiElementType(field.asType());
if (elementType == null) {
error(field, "Unsupported type %s. Please choose one of %s", field.asType(), EnumSet.allOf(ElementType.class));
} else {
MbuiElementProcessor elementProcessor = null;
switch(elementType) {
case VerticalNavigation:
elementProcessor = new VerticalNavigationProcessor(this, elementUtils, xPathFactory);
break;
case Table:
elementProcessor = new DataTableProcessor(this, elementUtils, xPathFactory);
break;
case Form:
elementProcessor = new FormProcessor(this, elementUtils, xPathFactory);
break;
default:
break;
}
elementProcessor.process(field, element, selector, context);
}
});
}
Aggregations