Search in sources :

Example 16 with Form

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();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Message(org.jboss.hal.spi.Message) RequireAtLeastOneAttributeValidation(org.jboss.hal.core.mbui.form.RequireAtLeastOneAttributeValidation) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) Requires(org.jboss.hal.spi.Requires) CrudOperations(org.jboss.hal.core.CrudOperations) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) ModelNodeHelper.move(org.jboss.hal.dmr.ModelNodeHelper.move) ModelNodeHelper.failSafeBoolean(org.jboss.hal.dmr.ModelNodeHelper.failSafeBoolean) Operation(org.jboss.hal.dmr.Operation) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) Ids(org.jboss.hal.resources.Ids) AddressTemplates(org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) ComplexAttributeOperations(org.jboss.hal.core.ComplexAttributeOperations) EventBus(com.google.web.bindery.event.shared.EventBus) FinderPath(org.jboss.hal.core.finder.FinderPath) PathsAutoComplete(org.jboss.hal.core.configuration.PathsAutoComplete) Consumer(java.util.function.Consumer) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) NameTokens(org.jboss.hal.meta.token.NameTokens) MbuiPresenter(org.jboss.hal.core.mbui.MbuiPresenter) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Resources(org.jboss.hal.resources.Resources) MbuiView(org.jboss.hal.core.mbui.MbuiView) Finder(org.jboss.hal.core.finder.Finder) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) PathsAutoComplete(org.jboss.hal.core.configuration.PathsAutoComplete) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 17 with Form

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();
        }
    });
}
Also used : ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Form(org.jboss.hal.ballroom.form.Form) Metadata(org.jboss.hal.meta.Metadata) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 18 with Form

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);
}
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 19 with Form

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);
    }
}
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)

Example 20 with Form

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);
    }
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Element(elemental2.dom.Element) IsElement(org.jboss.gwt.elemento.core.IsElement) OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.OPERATION) CSS.clickable(org.jboss.hal.resources.CSS.clickable) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) HTMLElement(elemental2.dom.HTMLElement) EmptyState(org.jboss.hal.ballroom.EmptyState) 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) REMOVE(org.jboss.hal.dmr.ModelDescriptionConstants.REMOVE) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) EventType.click(org.jboss.gwt.elemento.core.EventType.click) CUSTOM_POLICY(org.jboss.hal.dmr.ModelDescriptionConstants.CUSTOM_POLICY) HTMLLIElement(elemental2.dom.HTMLLIElement) Callback(org.jboss.hal.spi.Callback) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Resources(org.jboss.hal.resources.Resources) Attachable(org.jboss.hal.ballroom.Attachable) HASH(org.jboss.hal.resources.UIConstants.HASH) CSS.formLinkLabel(org.jboss.hal.resources.CSS.formLinkLabel) JACC_POLICY(org.jboss.hal.dmr.ModelDescriptionConstants.JACC_POLICY) NamedNode(org.jboss.hal.dmr.NamedNode) Elements(org.jboss.gwt.elemento.core.Elements) Form(org.jboss.hal.ballroom.form.Form) Element(elemental2.dom.Element) IsElement(org.jboss.gwt.elemento.core.IsElement) HTMLElement(elemental2.dom.HTMLElement) HTMLLIElement(elemental2.dom.HTMLLIElement) HTMLLIElement(elemental2.dom.HTMLLIElement)

Aggregations

Form (org.jboss.hal.ballroom.form.Form)76 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)69 ModelNode (org.jboss.hal.dmr.ModelNode)69 Metadata (org.jboss.hal.meta.Metadata)69 Ids (org.jboss.hal.resources.Ids)65 Names (org.jboss.hal.resources.Names)61 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)55 List (java.util.List)54 NamedNode (org.jboss.hal.dmr.NamedNode)52 Resources (org.jboss.hal.resources.Resources)52 Inject (javax.inject.Inject)46 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)44 EventBus (com.google.web.bindery.event.shared.EventBus)42 Map (java.util.Map)41 StatementContext (org.jboss.hal.meta.StatementContext)41 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)40 ModelNodeHelper.asNamedNodes (org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes)39 AddressTemplate (org.jboss.hal.meta.AddressTemplate)39 MetadataRegistry (org.jboss.hal.meta.MetadataRegistry)39 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)38