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