Search in sources :

Example 11 with NameItem

use of org.jboss.hal.core.mbui.dialog.NameItem 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 12 with NameItem

use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.

the class RealmsPresenter method addJdbcRealm.

void addJdbcRealm() {
    Metadata metadata = metadataRegistry.lookup(JDBC_REALM_TEMPLATE).forComplexAttribute(PRINCIPAL_QUERY);
    NameItem nameItem = new NameItem();
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(Ids.ELYTRON_JDBC_REALM, Ids.ADD), metadata).addOnly().requiredOnly().unboundFormItem(nameItem, 0).build();
    AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(Names.JDBC_REALM), form, (n1, model) -> {
        ModelNode payload = new ModelNode();
        payload.get(PRINCIPAL_QUERY).add(model);
        crud.add(Names.JDBC_REALM, nameItem.getValue(), JDBC_REALM_TEMPLATE, payload, (n2, address) -> reloadJdbcRealms());
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 13 with NameItem

use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.

the class FilterPresenter method addResponseHeader.

void addResponseHeader() {
    Metadata metadata = metadataRegistry.lookup(RESPONSE_HEADER_TEMPLATE);
    ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(Ids.UNDERTOW_RESPONSE_HEADER_ADD, metadata).unboundFormItem(new NameItem(), 0).fromRequestProperties().build();
    List<String> responseHeader = Arrays.stream(ResponseHeader.values()).map(ResponseHeader::header).collect(toList());
    form.getFormItem(HEADER_NAME).registerSuggestHandler(new StaticAutoComplete(responseHeader));
    AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(Names.RESPONSE_HEADER), form, (name, model) -> {
        // noinspection ConstantConditions
        SafeHtml successMessage = resources.messages().addResourceSuccess(Names.RESPONSE_HEADER, model.get(HEADER_NAME).asString());
        crud.add(name, RESPONSE_HEADER_TEMPLATE, model, successMessage, (n, a) -> reload());
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Metadata(org.jboss.hal.meta.Metadata) StaticAutoComplete(org.jboss.hal.ballroom.autocomplete.StaticAutoComplete) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm)

Example 14 with NameItem

use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.

the class SocketBindingGroupPresenter method addSocketBinding.

// ------------------------------------------------------ nested socket binding resources
void addSocketBinding(SocketBinding socketBinding) {
    Metadata metadata = metadataRegistry.lookup(ROOT_TEMPLATE.append(socketBinding.templateSuffix()));
    NameItem nameItem = new NameItem();
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(socketBinding.baseId, Ids.ADD), metadata).unboundFormItem(nameItem, 0).fromRequestProperties().build();
    FormItem<Object> formItem = form.getFormItem(SOCKET_BINDING_REF);
    if (formItem != null) {
        AddressTemplate template = ROOT_TEMPLATE.append(INBOUND.templateSuffix());
        formItem.registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, template));
    }
    AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(socketBinding.type), form, (name, model) -> {
        name = nameItem.getValue();
        ResourceAddress address = SELECTED_TEMPLATE.append(socketBinding.templateSuffix()).resolve(statementContext, name);
        crud.add(socketBinding.type, name, address, model, (n, a) -> reload());
    });
    dialog.show();
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)

Example 15 with NameItem

use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.

the class ServerPresenter method addLocation.

void addLocation() {
    Metadata metadata = metadataRegistry.lookup(LOCATION_TEMPLATE);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.UNDERTOW_HOST_LOCATION_ADD, metadata).unboundFormItem(new NameItem(), 0).fromRequestProperties().build();
    form.getFormItem(HANDLER).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, HANDLER_SUGGESTIONS));
    AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(Names.LOCATION), form, (name, model) -> {
        ResourceAddress address = SELECTED_HOST_TEMPLATE.append(LOCATION + EQUALS + encodeValue(name)).resolve(statementContext);
        crud.add(Names.LOCATION, name, address, model, (n, a) -> reloadLocation());
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)

Aggregations

AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)37 NameItem (org.jboss.hal.core.mbui.dialog.NameItem)37 ModelNode (org.jboss.hal.dmr.ModelNode)37 Metadata (org.jboss.hal.meta.Metadata)35 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)34 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)32 List (java.util.List)28 Ids (org.jboss.hal.resources.Ids)28 EventBus (com.google.web.bindery.event.shared.EventBus)27 Inject (javax.inject.Inject)27 Form (org.jboss.hal.ballroom.form.Form)27 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)27 StatementContext (org.jboss.hal.meta.StatementContext)27 Resources (org.jboss.hal.resources.Resources)27 Names (org.jboss.hal.resources.Names)26 Arrays.asList (java.util.Arrays.asList)25 CrudOperations (org.jboss.hal.core.CrudOperations)25 Finder (org.jboss.hal.core.finder.Finder)25 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)25 MetadataRegistry (org.jboss.hal.meta.MetadataRegistry)25