Search in sources :

Example 21 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class SSLPresenter method changeAccountKey.

void changeAccountKey(String name) {
    Metadata metadata = metadataRegistry.lookup(CERTIFICATE_AUTHORITY_ACCOUNT_TEMPLATE).forOperation(CHANGE_ACCOUNT_KEY);
    String id = Ids.build(CERTIFICATE_AUTHORITY_ACCOUNT, FORM);
    String title = new LabelBuilder().label(CERTIFICATE_AUTHORITY_ACCOUNT);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).build();
    form.setSaveCallback((form1, changedValues) -> {
        ResourceAddress address = CERTIFICATE_AUTHORITY_ACCOUNT_TEMPLATE.resolve(statementContext, name);
        Operation operation = new Operation.Builder(address, CHANGE_ACCOUNT_KEY).payload(form.getModel()).build();
        dispatcher.execute(operation, result -> MessageEvent.fire(getEventBus(), Message.success(resources.messages().changeAccountKeySuccess(name))), (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().changeAccountKeyError(name, failure))), (operation1, exception) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().changeAccountKeyError(name, exception.getMessage()))));
    });
    Dialog dialog = new Dialog.Builder(title).add(p().textContent(resources.messages().changeAccountKeyQuestion(name)).element()).add(form.element()).primary(resources.constants().change(), form::save).size(Dialog.Size.MEDIUM).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(form);
    dialog.show();
    form.edit(new ModelNode());
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) 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) Dialog(org.jboss.hal.ballroom.dialog.Dialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 22 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class SSLPresenter method updateAccount.

void updateAccount(String name) {
    Metadata metadata = metadataRegistry.lookup(CERTIFICATE_AUTHORITY_ACCOUNT_TEMPLATE).forOperation(UPDATE_ACCOUNT);
    String id = Ids.build(CERTIFICATE_AUTHORITY_ACCOUNT, FORM);
    String title = new LabelBuilder().label(CERTIFICATE_AUTHORITY_ACCOUNT);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).build();
    form.setSaveCallback((form1, changedValues) -> {
        ResourceAddress address = CERTIFICATE_AUTHORITY_ACCOUNT_TEMPLATE.resolve(statementContext, name);
        Operation operation = new Operation.Builder(address, UPDATE_ACCOUNT).payload(form.getModel()).build();
        dispatcher.execute(operation, result -> MessageEvent.fire(getEventBus(), Message.success(resources.messages().updateAccountSuccess(name))), (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().updateAccountError(name, failure))), (operation1, exception) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().updateAccountError(name, exception.getMessage()))));
    });
    Dialog dialog = new Dialog.Builder(title).add(p().textContent(resources.messages().updateAccountQuestion(name)).element()).add(form.element()).primary(resources.constants().update(), form::save).size(Dialog.Size.MEDIUM).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(form);
    dialog.show();
    form.edit(new ModelNode());
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) 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) Dialog(org.jboss.hal.ballroom.dialog.Dialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 23 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class SSLPresenter method deactivateAccount.

void deactivateAccount(String name) {
    Metadata metadata = metadataRegistry.lookup(CERTIFICATE_AUTHORITY_ACCOUNT_TEMPLATE).forOperation(DEACTIVATE_ACCOUNT);
    String id = Ids.build(CERTIFICATE_AUTHORITY_ACCOUNT, FORM);
    String title = new LabelBuilder().label(CERTIFICATE_AUTHORITY_ACCOUNT);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).build();
    form.setSaveCallback((form1, changedValues) -> {
        ResourceAddress address = CERTIFICATE_AUTHORITY_ACCOUNT_TEMPLATE.resolve(statementContext, name);
        Operation operation = new Operation.Builder(address, DEACTIVATE_ACCOUNT).payload(form.getModel()).build();
        dispatcher.execute(operation, result -> MessageEvent.fire(getEventBus(), Message.success(resources.messages().deactivateAccountSuccess(name))), (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().deactivateAccountError(name, failure))), (operation1, exception) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().deactivateAccountError(name, exception.getMessage()))));
    });
    Dialog dialog = new Dialog.Builder(title).add(p().textContent(resources.messages().deactivateAccountQuestion(name)).element()).add(form.element()).primary(resources.constants().deactivate(), form::save).size(Dialog.Size.MEDIUM).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(form);
    dialog.show();
    form.edit(new ModelNode());
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) 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) Dialog(org.jboss.hal.ballroom.dialog.Dialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 24 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog 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 25 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog 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)30 ModelNode (org.jboss.hal.dmr.ModelNode)26 Operation (org.jboss.hal.dmr.Operation)23 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)22 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)21 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)18 Metadata (org.jboss.hal.meta.Metadata)17 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)15 AddressTemplate (org.jboss.hal.meta.AddressTemplate)12 FlowContext (org.jboss.hal.flow.FlowContext)11 Form (org.jboss.hal.ballroom.form.Form)9 Ids (org.jboss.hal.resources.Ids)9 Resources (org.jboss.hal.resources.Resources)9 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)8 EventBus (com.google.web.bindery.event.shared.EventBus)8 Inject (javax.inject.Inject)8 Provider (javax.inject.Provider)8 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)8 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)8 Progress (org.jboss.hal.flow.Progress)8