Search in sources :

Example 1 with SuggestHandler

use of org.jboss.hal.ballroom.form.SuggestHandler in project console by hal.

the class DefaultFormItemProvider method checkCapabilityReference.

private void checkCapabilityReference(ModelNode attributeDescription, FormItem<?> formItem) {
    SuggestHandler suggestHandler = null;
    if (attributeDescription.hasDefined(CAPABILITY_REFERENCE)) {
        Dispatcher dispatcher = Core.INSTANCE.dispatcher();
        StatementContext statementContext = Core.INSTANCE.statementContext();
        String reference = attributeDescription.get(CAPABILITY_REFERENCE).asString();
        Capabilities capabilities = metadata.getCapabilities();
        if (capabilities.supportsSuggestions()) {
            suggestHandler = new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, reference, metadata.getTemplate());
        } else if (capabilities.contains(reference)) {
            suggestHandler = new ReadChildrenAutoComplete(dispatcher, statementContext, capabilities.lookup(reference));
        }
    }
    if (suggestHandler != null) {
        formItem.registerSuggestHandler(suggestHandler);
    }
}
Also used : SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) Capabilities(org.jboss.hal.meta.capabilitiy.Capabilities) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) SuggestHandler(org.jboss.hal.ballroom.form.SuggestHandler) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) StatementContext(org.jboss.hal.meta.StatementContext)

Example 2 with SuggestHandler

use of org.jboss.hal.ballroom.form.SuggestHandler in project console by hal.

the class LoggingView method addRootLogger.

private void addRootLogger() {
    Metadata metadata = mbuiContext.metadataRegistry().lookup(ROOT_LOGGER_TEMPLATE);
    Form<ModelNode> form = new ModelNodeForm.Builder<>("logging-root-logger-add", metadata).fromRequestProperties().include(LEVEL, HANDLERS).build();
    AddResourceDialog dialog = new AddResourceDialog(mbuiContext.resources().messages().addResourceTitle(Names.ROOT_LOGGER), form, (name, model) -> {
        Operation operation = new Operation.Builder(ROOT_LOGGER_TEMPLATE.resolve(mbuiContext.statementContext()), ADD).payload(model).build();
        mbuiContext.dispatcher().execute(operation, result -> {
            MessageEvent.fire(mbuiContext.eventBus(), Message.success(mbuiContext.resources().messages().addSingleResourceSuccess(Names.ROOT_LOGGER)));
            presenter.reload();
        });
    });
    SuggestHandler suggestHandler = new ReadChildrenAutoComplete(mbuiContext.dispatcher(), mbuiContext.statementContext(), asList(ASYNC_HANDLER_TEMPLATE, CONSOLE_HANDLER_TEMPLATE, CUSTOM_HANDLER_TEMPLATE, FILE_HANDLER_TEMPLATE, PERIODIC_ROTATING_FILE_HANDLER_TEMPLATE, PERIODIC_SIZE_ROTATING_FILE_HANDLER_TEMPLATE, SIZE_ROTATING_FILE_HANDLER_TEMPLATE, SYSLOG_HANDLER_TEMPLATE));
    dialog.getForm().getFormItem(HANDLERS).registerSuggestHandler(suggestHandler);
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) SuggestHandler(org.jboss.hal.ballroom.form.SuggestHandler) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)

Aggregations

ReadChildrenAutoComplete (org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)2 SuggestHandler (org.jboss.hal.ballroom.form.SuggestHandler)2 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)1 SuggestCapabilitiesAutoComplete (org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete)1 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)1 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)1 ModelNode (org.jboss.hal.dmr.ModelNode)1 Operation (org.jboss.hal.dmr.Operation)1 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)1 Metadata (org.jboss.hal.meta.Metadata)1 StatementContext (org.jboss.hal.meta.StatementContext)1 Capabilities (org.jboss.hal.meta.capabilitiy.Capabilities)1