use of org.jboss.hal.meta.MetadataRegistry in project console by hal.
the class StoreElement method tableForm.
private Form<ModelNode> tableForm(CacheType cacheType, Store store, Table table, MetadataRegistry metadataRegistry) {
AddressTemplate template = cacheType.template.append(STORE + "=" + store.resource).append(TABLE + "=" + table.resource);
Metadata metadata = metadataRegistry.lookup(template);
String id = Ids.build(cacheType.baseId, store.baseId, table.baseId, Ids.FORM);
return new ModelNodeForm.Builder<>(id, metadata).include(PREFIX).customFormItem(ID_COLUMN, ad -> new ColumnFormItem(ID_COLUMN)).customFormItem(DATA_COLUMN, ad -> new ColumnFormItem(DATA_COLUMN)).customFormItem(TIMESTAMP_COLUMN, ad -> new ColumnFormItem(TIMESTAMP_COLUMN)).include(BATCH_SIZE, FETCH_SIZE).unsorted().onSave((f, changedValues) -> presenter.saveTable(table, changedValues)).prepareReset(f -> presenter.resetTable(table, f)).build();
}
use of org.jboss.hal.meta.MetadataRegistry 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.meta.MetadataRegistry 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);
}
}
Aggregations