use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class LoggingProfileView method init.
@PostConstruct
@SuppressWarnings("Duplicates")
void init() {
Constants constants = mbuiContext.resources().constants();
noRootLogger = new EmptyState.Builder(Ids.LOGGING_PROFILE + "-root-logger-empty", constants.noRootLogger()).description(constants.noRootLoggerDescription()).icon(fontAwesome("sitemap")).primaryAction(constants.add(), this::addRootLogger).build();
noRootLogger.element().classList.add(marginTopLarge);
// hack which relies on the element hierarchy given in the template. will break if you change that hierarchy.
rootLoggerForm.element().parentNode.appendChild(noRootLogger.element());
rootLoggerVisibility(false);
// --------------------------- json formatter
AddressTemplate jsonTemplate = LOGGING_PROFILE_TEMPLATE.append(JSON_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
LabelBuilder labelBuilder = new LabelBuilder();
Metadata jsonMetadata = mbuiContext.metadataRegistry().lookup(jsonTemplate);
Metadata jsonKeyOverridesMetadata = jsonMetadata.forComplexAttribute(KEY_OVERRIDES);
String jsonLabel = labelBuilder.label(jsonTemplate.lastName());
jsonFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, TABLE), jsonMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, ADD), Names.JSON_FORMATTER, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(jsonTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.JSON_FORMATTER, table.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(jsonTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
jsonFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, FORM), jsonMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(jsonLabel, form.getModel().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(jsonLabel, jsonFormatterTable.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), form, jsonMetadata, () -> presenter.reload())).build();
jsonKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, FORM), jsonKeyOverridesMetadata).singleton(() -> {
StatementContext jsonStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> jsonFormatterTable.hasSelection() ? jsonFormatterTable.selectedRow().getName() : null);
ResourceAddress address = jsonTemplate.resolve(jsonStatementContext, presenter.getLoggingProfile());
return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
}, () -> presenter.addComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), jsonKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
Tabs jsonTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, TAB_CONTAINER));
jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, ATTRIBUTES, TAB), constants.attributes(), jsonFormatterForm.element());
jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, jsonKeyOverridesForm.element());
HTMLElement jsonSection = section().add(h(1).textContent(Names.JSON_FORMATTER)).add(p().textContent(jsonMetadata.getDescription().getDescription())).add(jsonFormatterTable).add(jsonTabs).element();
registerAttachable(jsonFormatterTable, jsonFormatterForm, jsonKeyOverridesForm);
navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, JSON, Ids.ITEM), null, Names.JSON_FORMATTER, jsonSection);
// --------------------------- xml formatter
AddressTemplate xmlTemplate = LOGGING_PROFILE_TEMPLATE.append(XML_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
Metadata xmlMetadata = mbuiContext.metadataRegistry().lookup(xmlTemplate);
Metadata xmlKeyOverridesMetadata = xmlMetadata.forComplexAttribute(KEY_OVERRIDES);
String xmlLabel = labelBuilder.label(xmlTemplate.lastName());
xmlFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, TABLE), xmlMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, XML, FORMATTER, ADD), Names.XML_FORMATTER, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(xmlTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.XML_FORMATTER, table.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(xmlTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
xmlFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, FORM), xmlMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(xmlLabel, form.getModel().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(xmlLabel, xmlFormatterTable.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), form, xmlMetadata, () -> presenter.reload())).build();
xmlKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, FORM), xmlKeyOverridesMetadata).singleton(() -> {
StatementContext xmlStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> xmlFormatterTable.hasSelection() ? xmlFormatterTable.selectedRow().getName() : null);
ResourceAddress address = xmlTemplate.resolve(xmlStatementContext, presenter.getLoggingProfile());
return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
}, () -> presenter.addComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), xmlKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
Tabs xmlTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, XML, TAB_CONTAINER));
xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, ATTRIBUTES, TAB), constants.attributes(), xmlFormatterForm.element());
xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, xmlKeyOverridesForm.element());
HTMLElement xmlSection = section().add(h(1).textContent(Names.XML_FORMATTER)).add(p().textContent(xmlMetadata.getDescription().getDescription())).add(xmlFormatterTable).add(xmlTabs).element();
registerAttachable(xmlFormatterTable, xmlFormatterForm, xmlKeyOverridesForm);
navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, XML, Ids.ITEM), null, Names.XML_FORMATTER, xmlSection);
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class JcaPresenter method launchAddThreadPool.
// ------------------------------------------------------ thread pools (for normal and distributed work managers)
/**
* Used to bring up the dialog to add thread pools for the normal and the distributed work managers.
* <p>
* Only one long and one short running thread pool is allowed per (distributed) work manager. This method takes care of
* showing the right attributes in the dialog. If there are already long and short running thread pools attached to the work
* manager an error message is shown.
*/
void launchAddThreadPool(AddressTemplate workmanagerTemplate, String workmanager) {
dispatcher.execute(threadPoolsOperation(workmanagerTemplate, workmanager), (CompositeResult cr) -> {
boolean lrtPresent = !cr.step(0).get(RESULT).asPropertyList().isEmpty();
boolean srtPresent = !cr.step(1).get(RESULT).asPropertyList().isEmpty();
if (lrtPresent && srtPresent) {
MessageEvent.fire(getEventBus(), Message.error(resources.messages().allThreadPoolsExist()));
} else {
FormItem<String> typeItem;
if (!lrtPresent && !srtPresent) {
typeItem = new SingleSelectBoxItem(TYPE, resources.constants().type(), asList(Names.LONG_RUNNING, Names.SHORT_RUNNING), false);
typeItem.setRequired(true);
} else {
typeItem = new TextBoxItem(TYPE, resources.constants().type());
typeItem.setValue(lrtPresent ? Names.SHORT_RUNNING : Names.LONG_RUNNING);
typeItem.setEnabled(false);
}
// for the metadata it doesn't matter whether we use the LRT or SRT template nor
// whether we use the normal or distributed workmanager version
Metadata metadata = metadataRegistry.lookup(WORKMANAGER_LRT_TEMPLATE);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.JCA_THREAD_POOL_ADD, metadata).fromRequestProperties().unboundFormItem(typeItem, 0).include(MAX_THREADS, QUEUE_LENGTH, THREAD_FACTORY).unsorted().build();
AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(THREAD_POOL), form, (name, modelNode) -> {
String type = typeItem.getValue();
AddressTemplate tpTemplate = Names.LONG_RUNNING.equals(type) ? workmanagerTemplate.append(WORKMANAGER_LRT_TEMPLATE.lastName() + EQUALS + workmanager) : workmanagerTemplate.append(WORKMANAGER_SRT_TEMPLATE.lastName() + EQUALS + workmanager);
ResourceAddress address = tpTemplate.resolve(statementContext, workmanager);
Operation operation = new Operation.Builder(address, ADD).payload(modelNode).build();
dispatcher.execute(operation, result -> {
MessageEvent.fire(getEventBus(), Message.success(resources.messages().addResourceSuccess(THREAD_POOL, name)));
loadThreadPools(workmanagerTemplate, workmanager);
});
});
dialog.show();
}
});
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class LoggingProfileView method addAsyncHandler.
// ------------------------------------------------------ async handler
void addAsyncHandler() {
AddressTemplate metadataTemplate = LOGGING_PROFILE_TEMPLATE.append(ASYNC_HANDLER + EQ_WILDCARD);
Metadata metadata = mbuiContext.metadataRegistry().lookup(metadataTemplate);
AddressTemplate selectionTemplate = SELECTED_LOGGING_PROFILE_TEMPLATE.append(ASYNC_HANDLER + EQ_WILDCARD);
AddResourceDialog dialog = new AddResourceDialog(Ids.build(Ids.LOGGING_PROFILE, "handler-async", Ids.TABLE, Ids.ADD), mbuiContext.resources().messages().addResourceTitle(Names.ASYNC_ACTION_HANDLER), metadata, asList(LEVEL, "subhandlers", "queue-length", "overflow-action"), (name, modelNode) -> {
ResourceAddress address = selectionTemplate.resolve(selectionAwareStatementContext, name);
crud().add(Names.ASYNC_ACTION_HANDLER, name, address, modelNode, (n, a) -> presenter.reload());
});
List<AddressTemplate> templates = asList(SELECTED_LOGGING_PROFILE_TEMPLATE.append(CONSOLE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(CUSTOM_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(PERIODIC_ROTATING_FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(PERIODIC_SIZE_ROTATING_FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(SIZE_ROTATING_FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(SYSLOG_HANDLER + EQ_WILDCARD));
dialog.getForm().getFormItem("subhandlers").registerSuggestHandler(new ReadChildrenAutoComplete(mbuiContext.dispatcher(), selectionAwareStatementContext, templates));
dialog.show();
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class LoggingProfileView method removeResource.
private void removeResource(Table<NamedNode> table, String templateSuffix, String type) {
String name = table.selectedRow().getName();
AddressTemplate selectionTemplate = SELECTED_LOGGING_PROFILE_TEMPLATE.append(templateSuffix);
ResourceAddress address = selectionTemplate.resolve(selectionAwareStatementContext, name);
crud().remove(type, name, address, () -> presenter.reload());
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class JGroupsPresenter method addRelay.
void addRelay() {
AddressTemplate addressTemplate = AddressTemplate.of(SELECTED_RELAY_TEMPLATE.resolve(filterStatementContext));
crud.addSingleton(Ids.build(RELAY, Ids.ADD, Ids.FORM), Names.RELAY, addressTemplate, address -> reload());
}
Aggregations