use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class RealmsPresenter method addPropertiesRealm.
// ------------------------------------------------------ properties realm
void addPropertiesRealm() {
Metadata metadata = metadataRegistry.lookup(PROPERTIES_REALM_TEMPLATE);
Metadata upMetadata = metadata.forComplexAttribute(USERS_PROPERTIES, true);
upMetadata.copyComplexAttributeAttributes(asList(PATH, RELATIVE_TO), metadata);
String id = Ids.build(Ids.ELYTRON_PROPERTIES_REALM, Ids.ADD);
NameItem nameItem = new NameItem();
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(PATH, RELATIVE_TO, GROUPS_ATTRIBUTE).build();
form.getFormItem(RELATIVE_TO).registerSuggestHandler(new PathsAutoComplete());
new AddResourceDialog(resources.messages().addResourceTitle(Names.PROPERTIES_REALM), form, (name, model) -> {
if (model != null) {
move(model, PATH, USERS_PROPERTIES + "/" + PATH);
move(model, RELATIVE_TO, USERS_PROPERTIES + "/" + RELATIVE_TO);
}
ResourceAddress address = PROPERTIES_REALM_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.PROPERTIES_REALM, name, address, model, (n, a) -> reload(PROPERTIES_REALM, nodes -> getView().updateResourceElement(PROPERTIES_REALM, nodes)));
}).show();
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class RealmsPresenter method resetKeyMapper.
void resetKeyMapper(String jdbcRealm, int pqIndex, String keyMapper, Form<ModelNode> form) {
String type = new LabelBuilder().label(keyMapper);
Metadata metadata = metadataRegistry.lookup(JDBC_REALM_TEMPLATE).forComplexAttribute(PRINCIPAL_QUERY).forComplexAttribute(keyMapper);
ca.reset(jdbcRealm, keyMapperAttribute(pqIndex, keyMapper), type, JDBC_REALM_TEMPLATE, metadata, form, new Form.FinishReset<ModelNode>(form) {
@Override
public void afterReset(Form<ModelNode> form) {
reloadJdbcRealms();
}
});
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class CacheViewImpl method initConfiguration.
private void initConfiguration(CacheType cacheType, MetadataRegistry metadataRegistry, Resources resources) {
Metadata metadata = metadataRegistry.lookup(cacheType.template);
Tabs tabs = new Tabs(Ids.build(cacheType.baseId, Ids.TAB_CONTAINER));
form = new ModelNodeForm.Builder<Cache>(Ids.build(cacheType.baseId, Ids.FORM), metadata).onSave((form, changedValues) -> presenter.saveCache(changedValues)).prepareReset(f -> presenter.resetCache(f)).build();
tabs.add(Ids.build(cacheType.baseId, Ids.TAB), resources.constants().attributes(), form.element());
registerAttachable(form);
components = new HashMap<>();
for (Component component : cacheType.components) {
String tabId = Ids.build(cacheType.baseId, component.baseId, Ids.TAB);
String formId = Ids.build(cacheType.baseId, component.baseId, Ids.FORM);
Metadata cm = metadataRegistry.lookup(cacheType.template.append(COMPONENT + "=" + component.resource));
Form<ModelNode> cf = new ModelNodeForm.Builder<>(formId, cm).singleton(() -> presenter.readComponent(component), () -> presenter.addComponent(component)).onSave((f, changedValues) -> presenter.saveComponent(component, changedValues)).prepareReset(f -> presenter.resetComponent(component, f)).prepareRemove(f -> presenter.removeComponent(component, f)).build();
tabs.add(tabId, component.type, cf.element());
components.put(component, cf);
}
registerAttachables(components.values());
HTMLElement section = section().add(h(1).textContent(cacheType.type)).add(p().textContent(metadata.getDescription().getDescription())).add(tabs).element();
navigation.addPrimary(Ids.build(cacheType.baseId, Ids.ITEM), Names.CONFIGURATION, pfIcon("settings"), section);
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class CacheViewImpl method initBackups.
private void initBackups(CacheType cacheType, MetadataRegistry metadataRegistry, TableButtonFactory tableButtonFactory) {
if (cacheType.backups) {
AddressTemplate backupTemplate = cacheType.template.append(COMPONENT + "=" + BACKUPS).append(BACKUP + "=*");
Metadata backupMeta = metadataRegistry.lookup(backupTemplate);
backupTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(cacheType.baseId, BACKUPS, Ids.TABLE), backupMeta).button(tableButtonFactory.add(backupTemplate, table -> presenter.addBackup())).button(tableButtonFactory.remove(backupTemplate, table -> presenter.removeBackup(table.selectedRow().getName()))).column(NAME, (cell, type, row, meta) -> row.getName()).build();
backupForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(cacheType.baseId, BACKUPS, Ids.FORM), backupMeta).onSave((form, changedValues) -> presenter.saveCacheBackup(form.getModel().getName(), changedValues)).prepareReset(form -> presenter.resetBackup(form.getModel().getName(), form)).build();
HTMLElement backupSection = section().add(h(1).textContent(Names.BACKUPS)).add(p().textContent(backupMeta.getDescription().getDescription())).add(backupTable).add(backupForm).element();
navigation.addPrimary(Ids.build(cacheType.baseId, BACKUP, Ids.ITEM), Names.BACKUP, fontAwesome("life-ring"), backupSection);
registerAttachable(backupTable, backupForm);
}
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class PolicyElement method injectRemove.
private void injectRemove(Form<ModelNode> form, Callback callback) {
// hacky way to inject the remove link into the form tools, depends on FormLink internals!
String linksId = Ids.build(form.getId(), "links");
Element formLinks = form.element().querySelector(HASH + linksId);
if (formLinks != null) {
HTMLLIElement removeLink = li().add(a().css(clickable).on(click, event -> callback.execute()).add(i().css(pfIcon("remove"))).data(OPERATION, REMOVE).add(span().css(formLinkLabel).textContent(resources.constants().remove()))).element();
formLinks.insertBefore(removeLink, formLinks.lastElementChild);
}
}
Aggregations