Search in sources :

Example 1 with FileFormItem

use of org.jboss.hal.core.ui.FileFormItem in project console by hal.

the class LoggingProfileView method addFileHandlerResource.

private void addFileHandlerResource(String templateSuffix, String id, String type, String... attributes) {
    AddressTemplate metadataTemplate = LOGGING_PROFILE_TEMPLATE.append(templateSuffix);
    Metadata metadata = mbuiContext.metadataRegistry().lookup(metadataTemplate);
    AddressTemplate selectionTemplate = SELECTED_LOGGING_PROFILE_TEMPLATE.append(templateSuffix);
    ModelNodeForm.Builder<ModelNode> builder = new ModelNodeForm.Builder<>(id, metadata).fromRequestProperties().unboundFormItem(new NameItem(), 0).customFormItem("file", (attributeDescription) -> new FileFormItem(FILE, true)).unsorted();
    if (attributes != null) {
        builder.include(asList(attributes));
    }
    AddResourceDialog dialog = new AddResourceDialog(mbuiContext.resources().messages().addResourceTitle(type), builder.build(), (name, modelNode) -> {
        ResourceAddress address = selectionTemplate.resolve(selectionAwareStatementContext, name);
        crud().add(type, name, address, modelNode, (n, a) -> presenter.reload());
    });
    dialog.show();
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) Constraint(org.jboss.hal.meta.security.Constraint) StatementContext(org.jboss.hal.meta.StatementContext) LOGGING_PROFILE_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.LOGGING_PROFILE_TEMPLATE) TAB_CONTAINER(org.jboss.hal.resources.Ids.TAB_CONTAINER) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) CrudOperations(org.jboss.hal.core.CrudOperations) Table(org.jboss.hal.ballroom.table.Table) Collections.emptyList(java.util.Collections.emptyList) SuggestHandler(org.jboss.hal.ballroom.form.SuggestHandler) FORM(org.jboss.hal.resources.Ids.FORM) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PostConstruct(javax.annotation.PostConstruct) JSON_FORMATTER_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.JSON_FORMATTER_TEMPLATE) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) ModelNode(org.jboss.hal.dmr.ModelNode) FileFormItem(org.jboss.hal.core.ui.FileFormItem) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) XML_FORMATTER_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.XML_FORMATTER_TEMPLATE) TAB(org.jboss.hal.resources.Ids.TAB) Elements.section(org.jboss.gwt.elemento.core.Elements.section) AddressTemplate(org.jboss.hal.meta.AddressTemplate) MbuiElement(org.jboss.hal.spi.MbuiElement) Constants(org.jboss.hal.resources.Constants) EmptyState(org.jboss.hal.ballroom.EmptyState) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) DomGlobal.document(elemental2.dom.DomGlobal.document) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) CATEGORY(org.jboss.hal.resources.Names.CATEGORY) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) CSS.marginTopLarge(org.jboss.hal.resources.CSS.marginTopLarge) FormItem(org.jboss.hal.ballroom.form.FormItem) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) MbuiView(org.jboss.hal.spi.MbuiView) SELECTED_LOGGING_PROFILE_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.SELECTED_LOGGING_PROFILE_TEMPLATE) NamedNode(org.jboss.hal.dmr.NamedNode) Elements(org.jboss.gwt.elemento.core.Elements) Form(org.jboss.hal.ballroom.form.Form) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) FileFormItem(org.jboss.hal.core.ui.FileFormItem)

Aggregations

DomGlobal.document (elemental2.dom.DomGlobal.document)1 HTMLElement (elemental2.dom.HTMLElement)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 Elements (org.jboss.gwt.elemento.core.Elements)1 Elements.h (org.jboss.gwt.elemento.core.Elements.h)1 Elements.p (org.jboss.gwt.elemento.core.Elements.p)1 Elements.section (org.jboss.gwt.elemento.core.Elements.section)1 EmptyState (org.jboss.hal.ballroom.EmptyState)1 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)1 Tabs (org.jboss.hal.ballroom.Tabs)1 VerticalNavigation (org.jboss.hal.ballroom.VerticalNavigation)1 ReadChildrenAutoComplete (org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)1 Form (org.jboss.hal.ballroom.form.Form)1 FormItem (org.jboss.hal.ballroom.form.FormItem)1 SuggestHandler (org.jboss.hal.ballroom.form.SuggestHandler)1 Table (org.jboss.hal.ballroom.table.Table)1