use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class OtherSettingsPresenter method addPolicy.
// -------------------------------------------- Policy
void addPolicy(String complexAttribute, String type) {
Metadata metadata = metadataRegistry.lookup(POLICY_TEMPLATE).forComplexAttribute(complexAttribute);
String id = Ids.build(Ids.ELYTRON_POLICY, complexAttribute, Ids.ADD);
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(new NameItem(), 0).addOnly().build();
new AddResourceDialog(type, form, (name, model) -> {
ResourceAddress address = POLICY_TEMPLATE.resolve(statementContext, name);
ModelNode payload = new ModelNode();
payload.get(complexAttribute).set(model != null && model.isDefined() ? model : new ModelNode().setEmptyObject());
crud.add(type, address, payload, resources.messages().addSingleResourceSuccess(type), (n, a) -> reloadPolicy());
}).show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class OtherSettingsPresenter method addKeyStore.
// ------------------------------------------------------ key store
void addKeyStore() {
Metadata metadata = metadataRegistry.lookup(KEY_STORE_TEMPLATE);
Metadata crMetadata = metadata.forComplexAttribute(CREDENTIAL_REFERENCE, true);
crMetadata.copyComplexAttributeAttributes(asList(STORE, ALIAS, CLEAR_TEXT), metadata);
String id = Ids.build(Ids.ELYTRON_KEY_STORE, Ids.ADD);
NameItem nameItem = new NameItem();
// there is a special handling for "type" attribute, as this attribute name exists in key-store and
// credential-reference complex attribute. We must create an unbound form item for credential-reference-type
String crType = "credential-reference-type";
String crTypeLabel = new LabelBuilder().label(crType);
TextBoxItem crTypeItem = new TextBoxItem(crType, crTypeLabel);
SafeHtml crTypeItemHelp = SafeHtmlUtils.fromString(metadata.getDescription().get(ATTRIBUTES).get(CREDENTIAL_REFERENCE).get(VALUE_TYPE).get(TYPE).get(DESCRIPTION).asString());
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(TYPE, PATH, RELATIVE_TO, STORE, ALIAS, CLEAR_TEXT).unboundFormItem(crTypeItem, 7, crTypeItemHelp).unsorted().build();
form.getFormItem(RELATIVE_TO).registerSuggestHandler(new PathsAutoComplete());
form.addFormValidation(new RequireAtLeastOneAttributeValidation<>(asList(STORE, CLEAR_TEXT), resources));
new AddResourceDialog(resources.messages().addResourceTitle(Names.KEY_STORE), form, (name, model) -> {
if (model != null) {
move(model, STORE, CREDENTIAL_REFERENCE + "/" + STORE);
move(model, ALIAS, CREDENTIAL_REFERENCE + "/" + ALIAS);
move(model, CLEAR_TEXT, CREDENTIAL_REFERENCE + "/" + CLEAR_TEXT);
if (!crTypeItem.isEmpty()) {
model.get(CREDENTIAL_REFERENCE).get(TYPE).set(crTypeItem.getValue());
}
}
ResourceAddress address = KEY_STORE_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.KEY_STORE, name, address, model, (n, a) -> reload(KEY_STORE, nodes -> getView().updateResourceElement(KEY_STORE, nodes)));
}).show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class ClusteringPresenter method addClusterConnection.
void addClusterConnection(ServerSubResource ssr) {
Metadata metadata = metadataRegistry.lookup(ssr.template);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(new NameItem(), 0).fromRequestProperties().requiredOnly().build();
List<AddressTemplate> templates = asList(SELECTED_SERVER_TEMPLATE.append(CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(IN_VM_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(HTTP_CONNECTOR + EQ_WILDCARD), SELECTED_SERVER_TEMPLATE.append(REMOTE_CONNECTOR + EQ_WILDCARD));
form.getFormItem(CONNECTOR_NAME).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, templates));
new AddResourceDialog(resources.messages().addResourceTitle(ssr.type), form, (name, model) -> {
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + "=" + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class ClusteringPresenter method showBroadcastOrDiscoveryGroupAddDialog.
void showBroadcastOrDiscoveryGroupAddDialog(ServerSubResource ssr, Consumer<ModelNodeForm.Builder<ModelNode>> formBuilderAugmenter, Consumer<Form<ModelNode>> formAugmenter) {
Metadata metadata = metadataRegistry.lookup(ssr.template);
NameItem nameItem = new NameItem();
ModelNodeForm.Builder<ModelNode> formBuilder = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(nameItem, 0).fromRequestProperties().include(JGROUPS_CLUSTER, SOCKET_BINDING).unsorted();
formBuilderAugmenter.accept(formBuilder);
Form<ModelNode> form = formBuilder.build();
formAugmenter.accept(form);
// validation that requires one of jgroups-cluster and socket-binding to be configured
FormValidation<ModelNode> jgroupsOrSocketValidation = new FormValidation<ModelNode>() {
@Override
public ValidationResult validate(Form<ModelNode> form) {
if (form.getFormItem(JGROUPS_CLUSTER).isEmpty() && form.getFormItem(SOCKET_BINDING).isEmpty()) {
return ValidationResult.invalid(resources.messages().jgroupsClusterOrSocketBindingMustBeSet());
}
return ValidationResult.OK;
}
};
form.getFormItem(SOCKET_BINDING).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, SOCKET_BINDING_TEMPLATE));
form.addFormValidation(jgroupsOrSocketValidation);
new AddResourceDialog(resources.messages().addResourceTitle(ssr.type), form, (name, model) -> {
name = nameItem.getValue();
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + "=" + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class ConnectionPresenter method addHttp.
void addHttp(ServerSubResource ssr) {
Metadata metadata = metadataRegistry.lookup(ssr.template);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(ssr.baseId, Ids.ADD), metadata).unboundFormItem(new NameItem(), 0).fromRequestProperties().requiredOnly().build();
form.getFormItem(HTTP_LISTENER).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, AddressTemplate.of("/{selected.profile}/subsystem=undertow/server=*/http-listener=*")));
new AddResourceDialog(ssr.type, form, (name, model) -> {
ResourceAddress address = SELECTED_SERVER_TEMPLATE.append(ssr.resource + EQ + name).resolve(statementContext);
crud.add(ssr.type, name, address, model, (n, a) -> reload());
}).show();
}
Aggregations