Search in sources :

Example 1 with ModelNodeForm

use of org.jboss.hal.core.mbui.form.ModelNodeForm in project console by hal.

the class JGroupsPresenter method addStack.

// stack resources
@SuppressWarnings("ConstantConditions")
void addStack() {
    Metadata metadata = metadataRegistry.lookup(STACK_TEMPLATE);
    Metadata transportMetadata = metadataRegistry.lookup(TRANSPORT_TEMPLATE).forOperation(ADD);
    transportMetadata.copyAttribute(SOCKET_BINDING, metadata);
    metadata.makeWritable(SOCKET_BINDING);
    NameItem nameItem = new NameItem();
    String transportLabel = new LabelBuilder().label(TRANSPORT);
    TextBoxItem transportItem = new TextBoxItem(TRANSPORT, transportLabel);
    transportItem.setRequired(true);
    String id = Ids.build(Ids.JGROUPS_STACK_CONFIG, Ids.ADD);
    ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(nameItem, 0).unboundFormItem(transportItem, 2).unsorted().requiredOnly().build();
    AddResourceDialog dialog = new AddResourceDialog(Names.STACK, form, (name, model) -> {
        ResourceAddress stackAddress = STACK_TEMPLATE.resolve(filterStatementContext, name);
        String transport = transportItem.getValue();
        ResourceAddress transportAddress = TRANSPORT_TEMPLATE.resolve(filterStatementContext, name, transport);
        Operation addStackOperation = new Operation.Builder(stackAddress, ADD).build();
        Operation addTransportOperation = new Operation.Builder(transportAddress, ADD).payload(model).build();
        Composite composite = new Composite(addStackOperation, addTransportOperation);
        dispatcher.execute(composite, (CompositeResult result) -> {
            MessageEvent.fire(eventBus, Message.success(resources.messages().addResourceSuccess(Names.STACK, name)));
            reload();
        });
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 2 with ModelNodeForm

use of org.jboss.hal.core.mbui.form.ModelNodeForm in project console by hal.

the class ServerActions method copyServer.

// ------------------------------------------------------ server operations
public void copyServer(Server server, Callback callback) {
    Operation operation = new Operation.Builder(ResourceAddress.root(), READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, HOST).build();
    dispatcher.execute(operation, result -> {
        List<String> hosts = new ArrayList<>();
        result.asList().forEach(m -> hosts.add(m.asString()));
        // get the first host only to retrieve the r-r-d for server-config
        // as /host=*/server-config=*:read-operation-description(name=add) does not work
        AddressTemplate template = AddressTemplate.of("/host=" + hosts.get(0) + "/server-config=*");
        metadataProcessor.lookup(template, progress.get(), new SuccessfulMetadataCallback(eventBus, resources) {

            @Override
            public void onMetadata(Metadata metadata) {
                String id = Ids.build(SERVER_GROUP, statementContext.selectedServerGroup(), SERVER, FORM);
                SingleSelectBoxItem hostFormItem = new SingleSelectBoxItem(HOST, Names.HOST, hosts, false);
                hostFormItem.setRequired(true);
                NameItem nameItem = new NameItem();
                ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).fromRequestProperties().unboundFormItem(nameItem, 0).unboundFormItem(hostFormItem, 1, resources.messages().addServerHostHelp()).exclude(AUTO_START, SOCKET_BINDING_DEFAULT_INTERFACE, SOCKET_BINDING_GROUP, UPDATE_AUTO_START_WITH_SERVER_STATUS).build();
                AddResourceDialog dialog = new AddResourceDialog(resources.messages().copyServerTitle(), form, (resource, payload) -> {
                    // read server-config recursively to retrieve nested resources
                    ModelNode serverConfigModel = new ModelNode();
                    serverConfigModel.get(HOST).set(server.getHost());
                    serverConfigModel.get(SERVER_CONFIG).set(server.getName());
                    ResourceAddress serverAddress = new ResourceAddress(serverConfigModel);
                    Operation opReadServer = new Operation.Builder(serverAddress, READ_RESOURCE_OPERATION).param(RECURSIVE, true).build();
                    dispatcher.execute(opReadServer, new Consumer<ModelNode>() {

                        @Override
                        public void accept(ModelNode newServerModel) {
                            String newServerName = nameItem.getValue();
                            // set the chosen group in the model
                            newServerModel.get(GROUP).set(payload.get(GROUP).asString());
                            if (payload.hasDefined(SOCKET_BINDING_PORT_OFFSET)) {
                                newServerModel.get(SOCKET_BINDING_PORT_OFFSET).set(payload.get(SOCKET_BINDING_PORT_OFFSET).asLong());
                            }
                            newServerModel.get(NAME).set(newServerName);
                            ModelNode newServerModelAddress = new ModelNode();
                            newServerModelAddress.get(HOST).set(hostFormItem.getValue());
                            newServerModelAddress.get(SERVER_CONFIG).set(newServerName);
                            Operation opAddServer = new Operation.Builder(new ResourceAddress(newServerModelAddress), ADD).payload(newServerModel).build();
                            Composite comp = new Composite();
                            comp.add(opAddServer);
                            // create operation for each nested resource of the source server
                            createOperation(comp, JVM, newServerModel, newServerModelAddress);
                            createOperation(comp, INTERFACE, newServerModel, newServerModelAddress);
                            createOperation(comp, PATH, newServerModel, newServerModelAddress);
                            createOperation(comp, SYSTEM_PROPERTY, newServerModel, newServerModelAddress);
                            createOperation(comp, SSL, newServerModel, newServerModelAddress);
                            dispatcher.execute(comp, (CompositeResult result) -> {
                                MessageEvent.fire(eventBus, Message.success(resources.messages().addResourceSuccess(Names.SERVER, newServerName)));
                                callback.execute();
                            }, (operation1, failure) -> {
                                MessageEvent.fire(eventBus, Message.error(resources.messages().addResourceError(newServerName, failure)));
                                callback.execute();
                            }, (operation1, exception) -> {
                                MessageEvent.fire(eventBus, Message.error(resources.messages().addResourceError(newServerName, exception.getMessage())));
                                callback.execute();
                            });
                        }

                        private void createOperation(Composite composite, String resource, ModelNode model, ModelNode baseAddress) {
                            if (model.hasDefined(resource)) {
                                List<Property> props = model.get(resource).asPropertyList();
                                props.forEach(p -> {
                                    String propname = p.getName();
                                    ModelNode _address = baseAddress.clone();
                                    _address.get(resource).set(propname);
                                    Operation operation = new Operation.Builder(new ResourceAddress(_address), ADD).payload(p.getValue()).build();
                                    composite.add(operation);
                                });
                            }
                        }
                    });
                });
                dialog.show();
            }
        });
    });
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) Dialog(org.jboss.hal.ballroom.dialog.Dialog) DISABLED(org.jboss.hal.core.runtime.server.ServerConfigStatus.DISABLED) Provider(javax.inject.Provider) Elements.a(org.jboss.gwt.elemento.core.Elements.a) TimeoutHandler.repeatUntilTimeout(org.jboss.hal.dmr.dispatch.TimeoutHandler.repeatUntilTimeout) STOPPED(org.jboss.hal.core.runtime.server.ServerConfigStatus.STOPPED) StatementContext(org.jboss.hal.meta.StatementContext) LoggerFactory(org.slf4j.LoggerFactory) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ManagementModel(org.jboss.hal.meta.ManagementModel) Icons(org.jboss.hal.resources.Icons) ModelNodeHelper.asEnumValue(org.jboss.hal.dmr.ModelNodeHelper.asEnumValue) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) OnError(org.jboss.hal.dmr.dispatch.Dispatcher.OnError) Elements.p(org.jboss.gwt.elemento.core.Elements.p) STARTED(org.jboss.hal.core.runtime.server.ServerConfigStatus.STARTED) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) SuspendState(org.jboss.hal.core.runtime.SuspendState) Message(org.jboss.hal.spi.Message) Timeouts(org.jboss.hal.core.runtime.Timeouts) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) EnumSet(java.util.EnumSet) CSS.marginLeft5(org.jboss.hal.resources.CSS.marginLeft5) Predicate(java.util.function.Predicate) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) FORM(org.jboss.hal.resources.Ids.FORM) ReadSocketBinding(org.jboss.hal.core.runtime.server.ServerUrlTasks.ReadSocketBinding) List(java.util.List) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) Callback(org.jboss.hal.spi.Callback) Action(org.jboss.hal.core.runtime.Action) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Core(org.jboss.hal.core.Core) Flow.series(org.jboss.hal.flow.Flow.series) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Subscription(rx.Subscription) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) DomGlobal.setTimeout(elemental2.dom.DomGlobal.setTimeout) ModelNode(org.jboss.hal.dmr.ModelNode) Alert(org.jboss.hal.ballroom.Alert) MessageEvent(org.jboss.hal.spi.MessageEvent) SHORT_TIMEOUT(org.jboss.hal.resources.UIConstants.SHORT_TIMEOUT) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) ModelNodeHelper.getOrDefault(org.jboss.hal.dmr.ModelNodeHelper.getOrDefault) HashMap(java.util.HashMap) RUNNING(org.jboss.hal.core.runtime.RunningState.RUNNING) Result(org.jboss.hal.core.runtime.Result) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) OnFail(org.jboss.hal.dmr.dispatch.Dispatcher.OnFail) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Property(org.jboss.hal.dmr.Property) Strings(com.google.common.base.Strings) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) TimeoutHandler.repeatOperationUntil(org.jboss.hal.dmr.dispatch.TimeoutHandler.repeatOperationUntil) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ReadSocketBindingGroup(org.jboss.hal.core.runtime.server.ServerUrlTasks.ReadSocketBindingGroup) BlockingDialog(org.jboss.hal.ballroom.dialog.BlockingDialog) Logger(org.slf4j.Logger) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) EventBus(com.google.web.bindery.event.shared.EventBus) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) CompletableSubscriber(rx.CompletableSubscriber) Consumer(java.util.function.Consumer) Composite(org.jboss.hal.dmr.Composite) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Resources(org.jboss.hal.resources.Resources) SUSPENDED(org.jboss.hal.core.runtime.SuspendState.SUSPENDED) RunningState(org.jboss.hal.core.runtime.RunningState) Elements.span(org.jboss.gwt.elemento.core.Elements.span) Elements(org.jboss.gwt.elemento.core.Elements) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Form(org.jboss.hal.ballroom.form.Form) URL_KEY(org.jboss.hal.core.runtime.server.ServerUrlTasks.URL_KEY) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) ArrayList(java.util.ArrayList) Metadata(org.jboss.hal.meta.Metadata) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) Consumer(java.util.function.Consumer) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property)

Example 3 with ModelNodeForm

use of org.jboss.hal.core.mbui.form.ModelNodeForm in project console by hal.

the class OtherSettingsPresenter method addSecurityDomain.

// -------------------------------------------- Security Domain
void addSecurityDomain() {
    Metadata metadata = metadataRegistry.lookup(SECURITY_DOMAIN_TEMPLATE);
    // emulate capability-reference on default-realm
    String capabilityReference = metadata.getDescription().findAttribute(ATTRIBUTES + "/" + REALMS + "/" + VALUE_TYPE, REALM).getValue().get(CAPABILITY_REFERENCE).asString();
    String id = Ids.build(Ids.ELYTRON_SECURITY_DOMAIN, Ids.ADD);
    NameItem nameItem = new NameItem();
    ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(DEFAULT_REALM).unsorted().build();
    form.getFormItem(DEFAULT_REALM).setRequired(true);
    form.getFormItem(DEFAULT_REALM).registerSuggestHandler(new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, capabilityReference, metadata.getTemplate()));
    new AddResourceDialog(resources.messages().addResourceTitle(Names.SECURITY_DOMAIN), form, (name, model) -> {
        if (model != null) {
            // add the default-realm in the list of realms
            ModelNode realm = new ModelNode();
            realm.get(REALM).set(model.get(DEFAULT_REALM).asString());
            model.get(REALMS).add(realm);
        }
        ResourceAddress address = SECURITY_DOMAIN_TEMPLATE.resolve(statementContext, nameItem.getValue());
        crud.add(Names.SECURITY_DOMAIN, name, address, model, (n, a) -> reload(SECURITY_DOMAIN, nodes -> getView().updateResourceElement(SECURITY_DOMAIN, nodes)));
    }).show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) FinishRemove(org.jboss.hal.ballroom.form.Form.FinishRemove) StatementContext(org.jboss.hal.meta.StatementContext) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) FinishReset(org.jboss.hal.ballroom.form.Form.FinishReset) RequireAtLeastOneAttributeValidation(org.jboss.hal.core.mbui.form.RequireAtLeastOneAttributeValidation) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) CrudOperations(org.jboss.hal.core.CrudOperations) ModelNodeHelper.move(org.jboss.hal.dmr.ModelNodeHelper.move) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) ComplexAttributeOperations(org.jboss.hal.core.ComplexAttributeOperations) FinderPath(org.jboss.hal.core.finder.FinderPath) PathsAutoComplete(org.jboss.hal.core.configuration.PathsAutoComplete) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Finder(org.jboss.hal.core.finder.Finder) ValidationResult(org.jboss.hal.ballroom.form.ValidationResult) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) Requires(org.jboss.hal.spi.Requires) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) AddressTemplates(org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) Consumer(java.util.function.Consumer) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) FormItem(org.jboss.hal.ballroom.form.FormItem) NameTokens(org.jboss.hal.meta.token.NameTokens) MbuiPresenter(org.jboss.hal.core.mbui.MbuiPresenter) Resources(org.jboss.hal.resources.Resources) SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) MbuiView(org.jboss.hal.core.mbui.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) Collections(java.util.Collections) Form(org.jboss.hal.ballroom.form.Form) SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) 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)

Example 4 with ModelNodeForm

use of org.jboss.hal.core.mbui.form.ModelNodeForm in project console by hal.

the class OtherSettingsPresenter method addKeyManager.

// ------------------------------------------------------ key manager
void addKeyManager() {
    Metadata metadata = metadataRegistry.lookup(KEY_MANAGER_TEMPLATE);
    Metadata crMetadata = metadata.forComplexAttribute(CREDENTIAL_REFERENCE, true);
    crMetadata.copyComplexAttributeAttributes(asList(STORE, ALIAS, TYPE, CLEAR_TEXT), metadata);
    String id = Ids.build(Ids.ELYTRON_KEY_MANAGER, Ids.ADD);
    NameItem nameItem = new NameItem();
    ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(STORE, ALIAS, TYPE, CLEAR_TEXT).unsorted().build();
    form.addFormValidation(new RequireAtLeastOneAttributeValidation<>(asList(STORE, CLEAR_TEXT), resources));
    new AddResourceDialog(resources.messages().addResourceTitle(Names.KEY_MANAGER), form, (name, model) -> {
        if (model != null) {
            move(model, STORE, CREDENTIAL_REFERENCE + "/" + STORE);
            move(model, ALIAS, CREDENTIAL_REFERENCE + "/" + ALIAS);
            move(model, TYPE, CREDENTIAL_REFERENCE + "/" + TYPE);
            move(model, CLEAR_TEXT, CREDENTIAL_REFERENCE + "/" + CLEAR_TEXT);
        }
        ResourceAddress address = KEY_MANAGER_TEMPLATE.resolve(statementContext, nameItem.getValue());
        crud.add(Names.KEY_MANAGER, name, address, model, (n, a) -> reload(KEY_MANAGER, nodes -> getView().updateResourceElement(KEY_MANAGER, nodes)));
    }).show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) FinishRemove(org.jboss.hal.ballroom.form.Form.FinishRemove) StatementContext(org.jboss.hal.meta.StatementContext) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) FinishReset(org.jboss.hal.ballroom.form.Form.FinishReset) RequireAtLeastOneAttributeValidation(org.jboss.hal.core.mbui.form.RequireAtLeastOneAttributeValidation) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) CrudOperations(org.jboss.hal.core.CrudOperations) ModelNodeHelper.move(org.jboss.hal.dmr.ModelNodeHelper.move) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) ComplexAttributeOperations(org.jboss.hal.core.ComplexAttributeOperations) FinderPath(org.jboss.hal.core.finder.FinderPath) PathsAutoComplete(org.jboss.hal.core.configuration.PathsAutoComplete) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Finder(org.jboss.hal.core.finder.Finder) ValidationResult(org.jboss.hal.ballroom.form.ValidationResult) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) Requires(org.jboss.hal.spi.Requires) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) AddressTemplates(org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) Consumer(java.util.function.Consumer) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) FormItem(org.jboss.hal.ballroom.form.FormItem) NameTokens(org.jboss.hal.meta.token.NameTokens) MbuiPresenter(org.jboss.hal.core.mbui.MbuiPresenter) Resources(org.jboss.hal.resources.Resources) SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) MbuiView(org.jboss.hal.core.mbui.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) Collections(java.util.Collections) Form(org.jboss.hal.ballroom.form.Form) 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)

Example 5 with ModelNodeForm

use of org.jboss.hal.core.mbui.form.ModelNodeForm in project console by hal.

the class ResourcePanel method update.

void update(Node<Context> node, ResourceAddress address, Metadata metadata) {
    SafeHtml safeHtml = SafeHtmlUtils.fromSafeConstant(metadata.getDescription().getDescription());
    Elements.innerHtml(this.description, safeHtml);
    tabs.setContent(dataId, PLACE_HOLDER_ELEMENT);
    tabs.setContent(attributesId, PLACE_HOLDER_ELEMENT);
    tabs.setContent(operationsId, PLACE_HOLDER_ELEMENT);
    Elements.setVisible(tabs.element(), description.hasAttributes());
    Elements.setVisible(empty, !description.hasAttributes());
    if (description.hasAttributes()) {
        Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).build();
        dispatcher.execute(operation, result -> {
            List<String> plainObjects = new ArrayList<>();
            flattenDescription(metadata.getDescription().get(ATTRIBUTES), plainObjects);
            flattenModel(result, plainObjects);
            ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(Ids.MODEL_BROWSER, node.id, Ids.FORM), metadata).includeRuntime().showDeprecated().onSave((f, changedValues) -> modelBrowser.save(address, changedValues, metadata)).prepareReset(f -> modelBrowser.reset(address, f, metadata)).build();
            tabs.setContent(dataId, form.element());
            PatternFly.initComponents();
            form.attach();
            form.view(result);
        });
        tabs.setContent(attributesId, new AttributesTable(metadata.getDescription().getAttributes(ATTRIBUTES), resources).element());
        if (!metadata.getDescription().getOperations().isEmpty()) {
            tabs.setContent(operationsId, new OperationsTable(metadata.getDescription().getOperations(), resources).element());
        }
    }
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Iterator(java.util.Iterator) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) Node(org.jboss.hal.ballroom.tree.Node) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ArrayList(java.util.ArrayList) ModelType(org.jboss.hal.dmr.ModelType) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) PLACE_HOLDER_ELEMENT(org.jboss.hal.core.modelbrowser.ModelBrowser.PLACE_HOLDER_ELEMENT) Property(org.jboss.hal.dmr.Property) List(java.util.List) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) CSS.lead(org.jboss.hal.resources.CSS.lead) Resources(org.jboss.hal.resources.Resources) Elements.p(org.jboss.gwt.elemento.core.Elements.p) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HTMLElement(elemental2.dom.HTMLElement) PatternFly(org.jboss.hal.ballroom.PatternFly) Metadata(org.jboss.hal.meta.Metadata) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Elements(org.jboss.gwt.elemento.core.Elements) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) ModelNode(org.jboss.hal.dmr.ModelNode)

Aggregations

ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)12 ModelNode (org.jboss.hal.dmr.ModelNode)12 Metadata (org.jboss.hal.meta.Metadata)12 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)10 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)10 List (java.util.List)9 NameItem (org.jboss.hal.core.mbui.dialog.NameItem)9 Operation (org.jboss.hal.dmr.Operation)9 Ids (org.jboss.hal.resources.Ids)9 Resources (org.jboss.hal.resources.Resources)9 Map (java.util.Map)8 Inject (javax.inject.Inject)8 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)8 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)8 Names (org.jboss.hal.resources.Names)8 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)7 EventBus (com.google.web.bindery.event.shared.EventBus)7 Form (org.jboss.hal.ballroom.form.Form)7 TextBoxItem (org.jboss.hal.ballroom.form.TextBoxItem)7 SafeHtmlUtils (com.google.gwt.safehtml.shared.SafeHtmlUtils)6