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());
}
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());
}
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());
}
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);
}
}
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);
}
}
Aggregations