Search in sources :

Example 1 with OperationFormBuilder

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

the class CloseConnectionsDialog method show.

void show() {
    Form<ModelNode> cfaForm = new OperationFormBuilder<>(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_ADDRESS_FORM, metadata, CLOSE_CONNECTIONS_FOR_ADDRESS).build();
    Form<ModelNode> ccForm = new OperationFormBuilder<>(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_CONSUMER_FORM, metadata, CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS).build();
    Form<ModelNode> cfuForm = new OperationFormBuilder<>(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_USER_FORM, metadata, CLOSE_CONNECTIONS_FOR_USER).build();
    operationToForm = new HashMap<>();
    operationToForm.put(CLOSE_CONNECTIONS_FOR_ADDRESS, cfaForm);
    operationToForm.put(CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS, ccForm);
    operationToForm.put(CLOSE_CONNECTIONS_FOR_USER, cfuForm);
    tabs = new Tabs(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_TABS);
    tabs.add(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_ADDRESS_TAB, resources.constants().forAddress(), cfaForm.element());
    tabs.add(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_CONSUMER_TAB, resources.constants().consumersForAddress(), ccForm.element());
    tabs.add(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_USER_TAB, resources.constants().forUser(), cfuForm.element());
    tabToOperation = new HashMap<>();
    tabToOperation.put(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_ADDRESS_TAB, CLOSE_CONNECTIONS_FOR_ADDRESS);
    tabToOperation.put(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_CONSUMER_TAB, CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS);
    tabToOperation.put(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_USER_TAB, CLOSE_CONNECTIONS_FOR_USER);
    Dialog dialog = new Dialog.Builder(resources.constants().close()).add(p().textContent(resources.constants().chooseConnectionsToClose()).element()).add(tabs.element()).primary(resources.constants().close(), this::onClose).size(Size.MEDIUM).closeIcon(true).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(cfaForm, ccForm, cfuForm);
    cfaForm.edit(new ModelNode());
    ccForm.edit(new ModelNode());
    cfuForm.edit(new ModelNode());
    dialog.show();
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Tabs(org.jboss.hal.ballroom.Tabs) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 2 with OperationFormBuilder

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

the class ConfigurationChangesPresenter method launchAdd.

void launchAdd() {
    AddressTemplate template;
    if (environment.isStandalone()) {
        template = HOST_CONFIGURATION_CHANGES_TEMPLATE;
    } else {
        if (hostOnly) {
            template = HOST_CONFIGURATION_CHANGES_TEMPLATE;
        } else {
            template = PROFILE_CONFIGURATION_CHANGES_TEMPLATE.replaceWildcards(profile);
        }
    }
    metadataProcessor.lookup(template, progress.get(), new SuccessfulMetadataCallback(getEventBus(), resources) {

        @Override
        public void onMetadata(Metadata metadata) {
            String id = Ids.build(Ids.CONFIGURATION_CHANGES, Ids.ADD);
            Form<ModelNode> form = new OperationFormBuilder<>(id, metadata, ADD).build();
            ModelNode changeModel = new ModelNode();
            Dialog dialog = new Dialog.Builder(resources.constants().configurationChanges()).add(form.element()).primary(resources.constants().yes(), () -> {
                boolean valid = form.save();
                // if the form contains validation error, don't close the dialog
                if (valid) {
                    crud.addSingleton(Names.CONFIGURATION_CHANGES, template, form.getModel(), address -> reload());
                }
                return valid;
            }).secondary(resources.constants().cancel(), () -> true).closeIcon(true).closeOnEsc(true).build();
            dialog.registerAttachable(form);
            dialog.show();
            form.edit(changeModel);
        }
    });
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) Dialog(org.jboss.hal.ballroom.dialog.Dialog) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) OPTIONAL(org.jboss.hal.meta.AddressTemplate.OPTIONAL) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CSS.formControlStatic(org.jboss.hal.resources.CSS.formControlStatic) HTMLElement(elemental2.dom.HTMLElement) Server(org.jboss.hal.core.runtime.server.Server) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Skeleton.applicationHeight(org.jboss.hal.ballroom.Skeleton.applicationHeight) CrudOperations(org.jboss.hal.core.CrudOperations) CONFIGURATION_CHANGES(org.jboss.hal.meta.token.NameTokens.CONFIGURATION_CHANGES) CSS.wrap(org.jboss.hal.resources.CSS.wrap) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) MARGIN_BIG(org.jboss.hal.ballroom.Skeleton.MARGIN_BIG) CSS.px(org.jboss.hal.resources.CSS.px) FinderPath(org.jboss.hal.core.finder.FinderPath) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HalView(org.jboss.hal.core.mvp.HalView) Optional(java.util.Optional) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) ModelNode(org.jboss.hal.dmr.ModelNode) Elements.div(org.jboss.gwt.elemento.core.Elements.div) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) CSSProperties(elemental2.dom.CSSProperties) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) Inject(javax.inject.Inject) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) LARGE(org.jboss.hal.ballroom.dialog.Dialog.Size.LARGE) Requires(org.jboss.hal.spi.Requires) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) HTMLPreElement(elemental2.dom.HTMLPreElement) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) ADD(org.jboss.hal.resources.Ids.ADD) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Elements.pre(org.jboss.gwt.elemento.core.Elements.pre) Resources(org.jboss.hal.resources.Resources) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Form(org.jboss.hal.ballroom.form.Form) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Form(org.jboss.hal.ballroom.form.Form) Dialog(org.jboss.hal.ballroom.dialog.Dialog) Metadata(org.jboss.hal.meta.Metadata) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 3 with OperationFormBuilder

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

the class JmsQueuePresenter method changePriority.

void changePriority(List<JmsMessage> messages) {
    if (messages.isEmpty()) {
        noMessagesSelected();
    } else {
        Metadata metadata = metadataRegistry.lookup(MESSAGING_CORE_QUEUE_TEMPLATE);
        Form<ModelNode> form = new OperationFormBuilder<>(Ids.JMS_MESSAGE_CHANGE_PRIORITY_FORM, metadata, CHANGE_MESSAGE_PRIORITY).build();
        Dialog dialog = new Dialog.Builder(resources.constants().changePriority()).add(form.element()).cancel().primary(resources.constants().ok(), () -> {
            boolean valid = form.save();
            if (valid) {
                Operation operation;
                int priority = form.getModel().get(NEW_PRIORITY).asInt();
                if (messages.size() == 1) {
                    operation = new Operation.Builder(queueAddress(), CHANGE_MESSAGE_PRIORITY).param(MESSAGE_ID, messages.get(0).getMessageId()).param(NEW_PRIORITY, priority).build();
                } else {
                    operation = new Operation.Builder(queueAddress(), CHANGE_MESSAGES_PRIORITY).param(FILTER, filter(messages)).param(NEW_PRIORITY, priority).build();
                }
                dispatcher.execute(operation, result -> {
                    reload();
                    MessageEvent.fire(getEventBus(), Message.success(resources.messages().changePrioritySuccess(priority)));
                });
            }
            return valid;
        }).build();
        dialog.registerAttachable(form);
        dialog.show();
        ModelNode model = new ModelNode();
        form.edit(model);
        FormItem<Number> messageId = form.getFormItem(MESSAGE_ID);
        messageId.setValue(42L);
        Elements.setVisible(messageId.element(Form.State.EDITING), false);
        FormItem<Number> priorityItem = form.getFormItem(NEW_PRIORITY);
        if (messages.size() == 1) {
            priorityItem.setValue(messages.get(0).get(JMS_PRIORITY).asLong());
        }
        priorityItem.setFocus(true);
    }
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) Provider(javax.inject.Provider) StatementContext(org.jboss.hal.meta.StatementContext) LoggerFactory(org.slf4j.LoggerFactory) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Map(java.util.Map) Message(org.jboss.hal.spi.Message) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) Collections.emptyList(java.util.Collections.emptyList) FinderPath(org.jboss.hal.core.finder.FinderPath) Collectors.joining(java.util.stream.Collectors.joining) List(java.util.List) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HalView(org.jboss.hal.core.mvp.HalView) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ModelNode(org.jboss.hal.dmr.ModelNode) Completable(rx.Completable) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) HashMap(java.util.HashMap) FlowContext(org.jboss.hal.flow.FlowContext) Inject(javax.inject.Inject) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) AddressTemplates(org.jboss.hal.client.runtime.subsystem.messaging.AddressTemplates) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) Requires(org.jboss.hal.spi.Requires) Logger(org.slf4j.Logger) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) ModelNodeHelper.failSafeBoolean(org.jboss.hal.dmr.ModelNodeHelper.failSafeBoolean) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) FormItem(org.jboss.hal.ballroom.form.FormItem) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) Type(org.jboss.hal.client.runtime.subsystem.messaging.Destination.Type) Elements(org.jboss.gwt.elemento.core.Elements) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Form(org.jboss.hal.ballroom.form.Form) Dialog(org.jboss.hal.ballroom.dialog.Dialog) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 4 with OperationFormBuilder

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

the class JmsQueuePresenter method move.

void move(List<JmsMessage> messages) {
    if (messages.isEmpty()) {
        noMessagesSelected();
    } else {
        Metadata metadata = metadataRegistry.lookup(MESSAGING_CORE_QUEUE_TEMPLATE);
        Form<ModelNode> form = new OperationFormBuilder<>(Ids.JMS_MESSAGE_MOVE_FORM, metadata, MOVE_MESSAGE).build();
        Dialog dialog = new Dialog.Builder(resources.constants().move()).add(form.element()).cancel().primary(resources.constants().ok(), () -> {
            boolean valid = form.save();
            if (valid) {
                Operation operation;
                String destination = form.getModel().get(OTHER_QUEUE_NAME).asString();
                boolean rejectDuplicates = failSafeBoolean(form.getModel(), REJECT_DUPLICATES);
                if (messages.size() == 1) {
                    operation = new Operation.Builder(queueAddress(), MOVE_MESSAGE).param(MESSAGE_ID, messages.get(0).getMessageId()).param(OTHER_QUEUE_NAME, destination).param(REJECT_DUPLICATES, rejectDuplicates).build();
                } else {
                    operation = new Operation.Builder(queueAddress(), MOVE_MESSAGES).param(FILTER, filter(messages)).param(OTHER_QUEUE_NAME, destination).param(REJECT_DUPLICATES, rejectDuplicates).build();
                }
                dispatcher.execute(operation, result -> {
                    reload();
                    MessageEvent.fire(getEventBus(), Message.success(resources.messages().moveMessageSuccess(destination)));
                });
            }
            return valid;
        }).build();
        dialog.registerAttachable(form);
        dialog.show();
        ModelNode model = new ModelNode();
        form.edit(model);
        FormItem<Number> messageId = form.getFormItem(MESSAGE_ID);
        messageId.setValue(42L);
        Elements.setVisible(messageId.element(Form.State.EDITING), false);
        form.getFormItem(OTHER_QUEUE_NAME).setFocus(true);
    }
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) Provider(javax.inject.Provider) StatementContext(org.jboss.hal.meta.StatementContext) LoggerFactory(org.slf4j.LoggerFactory) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Map(java.util.Map) Message(org.jboss.hal.spi.Message) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) Collections.emptyList(java.util.Collections.emptyList) FinderPath(org.jboss.hal.core.finder.FinderPath) Collectors.joining(java.util.stream.Collectors.joining) List(java.util.List) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HalView(org.jboss.hal.core.mvp.HalView) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ModelNode(org.jboss.hal.dmr.ModelNode) Completable(rx.Completable) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) HashMap(java.util.HashMap) FlowContext(org.jboss.hal.flow.FlowContext) Inject(javax.inject.Inject) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) AddressTemplates(org.jboss.hal.client.runtime.subsystem.messaging.AddressTemplates) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) Requires(org.jboss.hal.spi.Requires) Logger(org.slf4j.Logger) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) ModelNodeHelper.failSafeBoolean(org.jboss.hal.dmr.ModelNodeHelper.failSafeBoolean) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) FormItem(org.jboss.hal.ballroom.form.FormItem) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) Type(org.jboss.hal.client.runtime.subsystem.messaging.Destination.Type) Elements(org.jboss.gwt.elemento.core.Elements) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Form(org.jboss.hal.ballroom.form.Form) Dialog(org.jboss.hal.ballroom.dialog.Dialog) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) ModelNode(org.jboss.hal.dmr.ModelNode)

Aggregations

Dialog (org.jboss.hal.ballroom.dialog.Dialog)4 OperationFormBuilder (org.jboss.hal.core.mbui.form.OperationFormBuilder)4 ModelNode (org.jboss.hal.dmr.ModelNode)4 EventBus (com.google.web.bindery.event.shared.EventBus)3 NameToken (com.gwtplatform.mvp.client.annotations.NameToken)3 ProxyCodeSplit (com.gwtplatform.mvp.client.annotations.ProxyCodeSplit)3 ProxyPlace (com.gwtplatform.mvp.client.proxy.ProxyPlace)3 PlaceRequest (com.gwtplatform.mvp.shared.proxy.PlaceRequest)3 Inject (javax.inject.Inject)3 Provider (javax.inject.Provider)3 DialogFactory (org.jboss.hal.ballroom.dialog.DialogFactory)3 Form (org.jboss.hal.ballroom.form.Form)3 Finder (org.jboss.hal.core.finder.Finder)3 FinderPath (org.jboss.hal.core.finder.FinderPath)3 FinderPathFactory (org.jboss.hal.core.finder.FinderPathFactory)3 ApplicationFinderPresenter (org.jboss.hal.core.mvp.ApplicationFinderPresenter)3 HalView (org.jboss.hal.core.mvp.HalView)3 HasPresenter (org.jboss.hal.core.mvp.HasPresenter)3 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)3 Operation (org.jboss.hal.dmr.Operation)3