Search in sources :

Example 1 with MetadataRegistry

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();
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) ModelNode(org.jboss.hal.dmr.ModelNode) IsElement(org.jboss.gwt.elemento.core.IsElement) JQuery.$(org.jboss.hal.ballroom.JQuery.$) CSS.bootstrapSelect(org.jboss.hal.resources.CSS.bootstrapSelect) HashMap(java.util.HashMap) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Property(org.jboss.hal.dmr.Property) AddressTemplate(org.jboss.hal.meta.AddressTemplate) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) EmptyState(org.jboss.hal.ballroom.EmptyState) HTMLSelectElement(elemental2.dom.HTMLSelectElement) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Ids(org.jboss.hal.resources.Ids) CSS(org.jboss.hal.resources.CSS) CSS.btnGroup(org.jboss.hal.resources.CSS.btnGroup) CSS.selectpicker(org.jboss.hal.resources.CSS.selectpicker) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) CSS.width(org.jboss.hal.resources.CSS.width) Attachable(org.jboss.hal.ballroom.Attachable) Elements(org.jboss.gwt.elemento.core.Elements) SelectBoxBridge(org.jboss.hal.ballroom.form.SelectBoxBridge) Form(org.jboss.hal.ballroom.form.Form) Metadata(org.jboss.hal.meta.Metadata) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm)

Example 2 with MetadataRegistry

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);
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) HashMap(java.util.HashMap) LayoutBuilder.column(org.jboss.hal.ballroom.LayoutBuilder.column) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.section(org.jboss.gwt.elemento.core.Elements.section) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) HalViewImpl(org.jboss.hal.core.mvp.HalViewImpl) Metadata(org.jboss.hal.meta.Metadata) TableButtonFactory(org.jboss.hal.core.mbui.table.TableButtonFactory) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) LayoutBuilder.row(org.jboss.hal.ballroom.LayoutBuilder.row) Ids(org.jboss.hal.resources.Ids) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) NamedNode(org.jboss.hal.dmr.NamedNode) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) Form(org.jboss.hal.ballroom.form.Form) HTMLElement(elemental2.dom.HTMLElement) Metadata(org.jboss.hal.meta.Metadata) Tabs(org.jboss.hal.ballroom.Tabs) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm)

Example 3 with MetadataRegistry

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);
    }
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) HashMap(java.util.HashMap) LayoutBuilder.column(org.jboss.hal.ballroom.LayoutBuilder.column) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.section(org.jboss.gwt.elemento.core.Elements.section) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) HalViewImpl(org.jboss.hal.core.mvp.HalViewImpl) Metadata(org.jboss.hal.meta.Metadata) TableButtonFactory(org.jboss.hal.core.mbui.table.TableButtonFactory) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) LayoutBuilder.row(org.jboss.hal.ballroom.LayoutBuilder.row) Ids(org.jboss.hal.resources.Ids) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) NamedNode(org.jboss.hal.dmr.NamedNode) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) Form(org.jboss.hal.ballroom.form.Form) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) HTMLElement(elemental2.dom.HTMLElement) Metadata(org.jboss.hal.meta.Metadata) NamedNode(org.jboss.hal.dmr.NamedNode)

Aggregations

HTMLElement (elemental2.dom.HTMLElement)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Tabs (org.jboss.hal.ballroom.Tabs)3 Form (org.jboss.hal.ballroom.form.Form)3 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)3 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)3 ModelNode (org.jboss.hal.dmr.ModelNode)3 ModelNodeHelper.failSafeGet (org.jboss.hal.dmr.ModelNodeHelper.failSafeGet)3 AddressTemplate (org.jboss.hal.meta.AddressTemplate)3 Metadata (org.jboss.hal.meta.Metadata)3 MetadataRegistry (org.jboss.hal.meta.MetadataRegistry)3 Ids (org.jboss.hal.resources.Ids)3 Names (org.jboss.hal.resources.Names)3 Resources (org.jboss.hal.resources.Resources)3 Elements.h (org.jboss.gwt.elemento.core.Elements.h)2 Elements.p (org.jboss.gwt.elemento.core.Elements.p)2 Elements.section (org.jboss.gwt.elemento.core.Elements.section)2 LayoutBuilder.column (org.jboss.hal.ballroom.LayoutBuilder.column)2 LayoutBuilder.row (org.jboss.hal.ballroom.LayoutBuilder.row)2