use of org.jboss.hal.core.configuration.PathsAutoComplete in project console by hal.
the class RealmsPresenter method addPropertiesRealm.
// ------------------------------------------------------ properties realm
void addPropertiesRealm() {
Metadata metadata = metadataRegistry.lookup(PROPERTIES_REALM_TEMPLATE);
Metadata upMetadata = metadata.forComplexAttribute(USERS_PROPERTIES, true);
upMetadata.copyComplexAttributeAttributes(asList(PATH, RELATIVE_TO), metadata);
String id = Ids.build(Ids.ELYTRON_PROPERTIES_REALM, Ids.ADD);
NameItem nameItem = new NameItem();
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(PATH, RELATIVE_TO, GROUPS_ATTRIBUTE).build();
form.getFormItem(RELATIVE_TO).registerSuggestHandler(new PathsAutoComplete());
new AddResourceDialog(resources.messages().addResourceTitle(Names.PROPERTIES_REALM), form, (name, model) -> {
if (model != null) {
move(model, PATH, USERS_PROPERTIES + "/" + PATH);
move(model, RELATIVE_TO, USERS_PROPERTIES + "/" + RELATIVE_TO);
}
ResourceAddress address = PROPERTIES_REALM_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.PROPERTIES_REALM, name, address, model, (n, a) -> reload(PROPERTIES_REALM, nodes -> getView().updateResourceElement(PROPERTIES_REALM, nodes)));
}).show();
}
use of org.jboss.hal.core.configuration.PathsAutoComplete in project console by hal.
the class ServletContainerView method attach.
@Override
public void attach() {
super.attach();
settings.get(ServletContainerSetting.WEBSOCKETS).getFormItem(BUFFER_POOL).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, presenter.getStatementContext(), AddressTemplate.of("/{selected.profile}/subsystem=io/buffer-pool=*")));
settings.get(ServletContainerSetting.WEBSOCKETS).getFormItem(WORKER).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, presenter.getStatementContext(), AddressTemplate.of("/{selected.profile}/subsystem=io/worker=*")));
settings.get(SESSIONS).getFormItem(RELATIVE_TO).registerSuggestHandler(new PathsAutoComplete());
}
use of org.jboss.hal.core.configuration.PathsAutoComplete in project console by hal.
the class OtherSettingsPresenter method addCredentialStore.
// -------------------------------------------- Credential Store
void addCredentialStore() {
Metadata metadata = metadataRegistry.lookup(CREDENTIAL_STORE_TEMPLATE);
SafeHtml typeHelp = SafeHtmlUtils.fromString(metadata.getDescription().get(ATTRIBUTES).get(TYPE).get(DESCRIPTION).asString());
Metadata crMetadata = metadata.forComplexAttribute(CREDENTIAL_REFERENCE, true);
crMetadata.copyComplexAttributeAttributes(asList(STORE, ALIAS, TYPE, CLEAR_TEXT), metadata);
TextBoxItem typeItem = new TextBoxItem("type-", resources.constants().type());
String id = Ids.build(Ids.ELYTRON_CREDENTIAL_STORE, Ids.ADD);
NameItem nameItem = new NameItem();
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(CREATE, PATH, RELATIVE_TO, STORE, ALIAS, TYPE, CLEAR_TEXT).unboundFormItem(typeItem, 3, typeHelp).unsorted().build();
form.getFormItem(RELATIVE_TO).registerSuggestHandler(new PathsAutoComplete());
form.addFormValidation(new RequireAtLeastOneAttributeValidation<>(asList(STORE, CLEAR_TEXT), resources));
form.addFormValidation(form1 -> {
ValidationResult result = ValidationResult.OK;
String typeValue = typeItem.getValue();
FormItem<String> locationAttr = form1.getFormItem(PATH);
boolean invalidLocation = locationAttr.isEmpty() && (typeItem.isEmpty() || Collections.binarySearch(FILE_BASED_CS, typeValue) > -1);
if (invalidLocation) {
form1.getFormItem(PATH).showError(resources.constants().requiredField());
result = ValidationResult.invalid(resources.messages().pathRequired());
}
return result;
});
new AddResourceDialog(resources.messages().addResourceTitle(Names.CREDENTIAL_STORE), form, (name, model) -> {
if (model != null) {
move(model, STORE, CREDENTIAL_REFERENCE + "/" + STORE);
move(model, ALIAS, CREDENTIAL_REFERENCE + "/" + ALIAS);
move(model, TYPE, CREDENTIAL_REFERENCE + "/" + TYPE);
move(model, CLEAR_TEXT, CREDENTIAL_REFERENCE + "/" + CLEAR_TEXT);
}
if (!typeItem.isEmpty()) {
model.get(TYPE).set(typeItem.getValue());
}
ResourceAddress address = CREDENTIAL_STORE_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.CREDENTIAL_STORE, name, address, model, (n, a) -> reload(CREDENTIAL_STORE, nodes -> getView().updateResourceElement(CREDENTIAL_STORE, nodes)));
}).show();
}
use of org.jboss.hal.core.configuration.PathsAutoComplete 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();
}
Aggregations