List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromString
public static SafeHtml fromString(String s)
From source file:org.jboss.hal.ballroom.HelpTextBuilder.java
License:Apache License
public SafeHtml helpText(Property property) { SafeHtmlBuilder help = new SafeHtmlBuilder(); ModelNode attribute = property.getValue(); boolean supportsExpression = attribute.hasDefined(EXPRESSIONS_ALLOWED) && attribute.get(EXPRESSIONS_ALLOWED).asBoolean(false); boolean required = attribute.hasDefined(NILLABLE) && !attribute.get(NILLABLE).asBoolean(false); List<String> requires = attribute.hasDefined(REQUIRES) ? attribute.get(REQUIRES).asList().stream().map(ModelNode::asString).collect(toList()) : Collections.emptyList(); List<String> alternatives = attribute.hasDefined(ALTERNATIVES) ? attribute.get(ALTERNATIVES).asList().stream().map(ModelNode::asString).collect(toList()) : Collections.emptyList(); RestartMode restartMode = restartRequired(attribute); if (restartMode == UNKNOWN) { logger.warn("Unknown restart mode in attribute description for '{}': '{}'", property.getName(), attribute.get(RESTART_REQUIRED).asString()); }/* w w w. ja v a2 s . c o m*/ boolean showRestartHelp = (restartMode == ALL_SERVICES || restartMode == RestartMode.JVM || restartMode == RESOURCE_SERVICES); SafeHtml desc = SafeHtmlUtils.fromSafeConstant(attribute.get(DESCRIPTION).asString()); help.append(desc); LabelBuilder labelBuilder = new LabelBuilder(); List<SafeHtml> textModules = new ArrayList<>(); if (required) { textModules.add(SafeHtmlUtils.fromString(CONSTANTS.requiredField())); } if (attribute.hasDefined(CAPABILITY_REFERENCE)) { textModules.add(MESSAGES.capabilityReference(attribute.get(CAPABILITY_REFERENCE).asString())); } if (supportsExpression) { textModules.add(SafeHtmlUtils.fromString(CONSTANTS.supportsExpressions())); } if (attribute.hasDefined(UNIT)) { textModules.add(MESSAGES.unit(attribute.get(UNIT).asString().toLowerCase())); } if (!requires.isEmpty()) { textModules.add(MESSAGES.requires(labelBuilder.enumeration(requires, CONSTANTS.and()))); } if (!alternatives.isEmpty()) { textModules.add(MESSAGES.alternativesHelp(labelBuilder.enumeration(alternatives, CONSTANTS.and()))); } if (showRestartHelp) { textModules.add(SafeHtmlUtils.fromString(restartMode.description())); } if (!textModules.isEmpty()) { help.appendHtmlConstant("<br/>"); for (SafeHtml html : textModules) { help.append(html); help.append(SafeHtmlUtils.fromString(". ")); } } return help.toSafeHtml(); }
From source file:org.jboss.hal.client.configuration.subsystem.datasource.wizard.PropertiesStep.java
License:Apache License
PropertiesStep(Dispatcher dispatcher, StatementContext statementContext, Environment environment, Provider<Progress> progress, Metadata metadata, Resources resources) { super(resources.constants().xaProperties()); this.dispatcher = dispatcher; this.statementContext = statementContext; this.environment = environment; this.progress = progress; this.resources = resources; dummy = new ModelNode().setEmptyObject(); propertiesItem = new PropertiesItem(VALUE); propertiesItem.setRequired(true);/* w w w . j av a 2s . c o m*/ ModelNode propertiesDescription = failSafeGet(metadata.getDescription(), "attributes/value/description"); //NON-NLS form = new ModelNodeForm.Builder<>(Ids.DATA_SOURCE_PROPERTIES_FORM, Metadata.empty()) .unboundFormItem(propertiesItem, 0, SafeHtmlUtils.fromString(propertiesDescription.asString())) .build(); propsAutoComplete = new StaticAutoComplete(Collections.emptyList()); propertiesItem.registerSuggestHandler(propsAutoComplete); registerAttachable(form); }
From source file:org.jboss.hal.client.configuration.subsystem.elytron.OtherSettingsPresenter.java
License:Apache License
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, LOCATION, 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(LOCATION); boolean invalidLocation = locationAttr.isEmpty() && (typeItem.isEmpty() || Collections.binarySearch(FILE_BASED_CS, typeValue) > -1); if (invalidLocation) { form1.getFormItem(LOCATION).showError(resources.constants().requiredField()); result = ValidationResult.invalid(resources.messages().locationRequired()); }/*from w w w. j a v a 2 s. com*/ 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(); }
From source file:org.jboss.hal.client.configuration.subsystem.elytron.OtherSettingsPresenter.java
License:Apache License
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()); }/*from w w w. ja v a2 s . co m*/ } 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(); }
From source file:org.jboss.hal.client.configuration.subsystem.infinispan.RemoteCacheContainerView.java
License:Apache License
@Inject public RemoteCacheContainerView(MetadataRegistry metadataRegistry, TableButtonFactory tableButtonFactory, Resources resources) {/*from ww w . j a v a2 s. c o m*/ Metadata metadata = metadataRegistry.lookup(REMOTE_CACHE_CONTAINER_TEMPLATE); configurationForm = new ModelNodeForm.Builder<>(Ids.REMOTE_CACHE_CONTAINER_CONFIGURATION_FORM, metadata) .onSave((form, changedValues) -> presenter.saveRemoteCacheContainer(changedValues)) .prepareReset(form -> presenter.resetRemoteCacheContainer(form)).build(); nearCacheElement = new NearCacheElement(metadataRegistry, resources); Tabs tabs = new Tabs(Ids.REMOTE_CACHE_CONTAINER_TABS); tabs.add(Ids.REMOTE_CACHE_CONTAINER_CONFIGURATION_TAB, resources.constants().attributes(), configurationForm.element()); tabs.add(Ids.REMOTE_CACHE_CONTAINER_NEAR_CACHE_TAB, Names.NEAR_CACHE, nearCacheElement.element()); HTMLElement configurationSection = section().add(h(1).textContent(Names.CONFIGURATION)) .add(p().textContent(metadata.getDescription().getDescription())).add(tabs).get(); metadata = metadataRegistry.lookup(REMOTE_CLUSTER_TEMPLATE); remoteClusterTable = new ModelNodeTable.Builder<NamedNode>(Ids.REMOTE_CLUSTER_TABLE, metadata) .button(tableButtonFactory.add(REMOTE_CLUSTER_TEMPLATE, table -> presenter.addRemoteCluster())) .button(tableButtonFactory.remove(REMOTE_CLUSTER_TEMPLATE, table -> presenter.removeRemoteCluster(table.selectedRow().getName()))) .column(Names.NAME, (cell, type, row, meta) -> row.getName()) .column(Names.SOCKET_BINDINGS, (cell, type, row, meta) -> { ModelNode socketBindings = row.get(SOCKET_BINDINGS); if (socketBindings.isDefined()) { return SafeHtmlUtils.fromString( socketBindings.asList().stream().map(ModelNode::asString).collect(joining(", "))) .asString(); } return ""; }).build(); remoteClusterForm = new ModelNodeForm.Builder<NamedNode>(Ids.REMOTE_CLUSTER_FORM, metadata).onSave( (form, changedValues) -> presenter.saveRemoteCluster(form.getModel().getName(), changedValues)) .build(); HTMLElement remoteClusterSection = section().add(h(1).textContent(Names.REMOTE_CLUSTER)) .add(p().textContent(metadata.getDescription().getDescription())).add(remoteClusterTable) .add(remoteClusterForm).get(); metadata = metadataRegistry.lookup(COMPONENT_CONNECTION_POOL_TEMPLATE); connectionPoolForm = new ModelNodeForm.Builder<>(Ids.CONNECTION_POOL_FORM, metadata) .singleton(() -> presenter.pingConnectionPool(), () -> presenter.addConnectionPool()) .onSave((form, changedValues) -> presenter.saveConnectionPool(changedValues)) .prepareReset(form -> presenter.resetConnectionPool(form)) .prepareRemove(form -> presenter.removeConnectionPool()).build(); HTMLElement connectionPoolSection = section().add(h(1).textContent(Names.CONNECTION_POOL)) .add(p().textContent(metadata.getDescription().getDescription())).add(connectionPoolForm).get(); metadata = metadataRegistry.lookup(THREAD_POOL_ASYNC_TEMPLATE); threadPoolForm = new ModelNodeForm.Builder<>(Ids.THREAD_POOL_FORM, metadata) .singleton(() -> presenter.pingThreadPool(), () -> presenter.addThreadPool()) .onSave((form, changedValues) -> presenter.saveThreadPool(changedValues)) .prepareReset(form -> presenter.resetThreadPool(form)) .prepareRemove(form -> presenter.removeThreadPool()).build(); HTMLElement threadPoolSection = section().add(h(1).textContent(Names.THREAD_POOL)) .add(p().textContent(metadata.getDescription().getDescription())).add(threadPoolForm).get(); metadata = metadataRegistry.lookup(COMPONENT_SECURITY_TEMPLATE); securityForm = new ModelNodeForm.Builder<>(Ids.SECURITY_FORM, metadata) .singleton(() -> presenter.pingSecurity(), () -> presenter.addSecurity()) .onSave((form, changedValues) -> presenter.saveSecurity(changedValues)) .prepareReset(form -> presenter.resetSecurity(form)) .prepareRemove(form -> presenter.removeSecurity()).build(); HTMLElement securitySection = section().add(h(1).textContent(Names.SECURITY)) .add(p().textContent(metadata.getDescription().getDescription())).add(securityForm).get(); navigation = new VerticalNavigation(); navigation.addPrimary(Ids.REMOTE_CACHE_CONTAINER_ITEM, Names.CONFIGURATION, pfIcon("settings"), configurationSection); navigation.addPrimary(Ids.REMOTE_CLUSTER_ITEM, Names.REMOTE_CLUSTER, pfIcon("cluster"), remoteClusterSection); navigation.addPrimary(Ids.CONNECTION_POOL_ITEM, Names.CONNECTION_POOL, pfIcon("connected"), connectionPoolSection); navigation.addPrimary(Ids.THREAD_POOL_ITEM, Names.THREAD_POOL, pfIcon("resource-pool"), threadPoolSection); navigation.addPrimary(Ids.SECURITY_ITEM, Names.SECURITY, fontAwesome("shield"), securitySection); registerAttachable(navigation); registerAttachable(configurationForm, nearCacheElement); registerAttachable(remoteClusterTable, remoteClusterForm); registerAttachable(connectionPoolForm, threadPoolForm, securityForm); initElement(row().add(column().addAll(navigation.panes()))); }
From source file:org.jboss.hal.client.configuration.subsystem.jmx.JmxView.java
License:Apache License
@Inject public JmxView(CrudOperations crud, Dispatcher dispatcher, MetadataRegistry metadataRegistry, StatementContext statementContext) { LabelBuilder labelBuilder = new LabelBuilder(); VerticalNavigation navigation = new VerticalNavigation(); registerAttachable(navigation);/*from w ww. j a va2s .c o m*/ // ------------------------------------------------------ configuration Metadata configMetadata = metadataRegistry.lookup(JMX_TEMPLATE); configForm = new ModelNodeForm.Builder<>(Ids.JMX_CONFIGURATION_FORM, configMetadata) .onSave((form, changedValues) -> crud.saveSingleton(Names.CONFIGURATION, JMX_TEMPLATE, changedValues, () -> presenter.reload())) .prepareReset(form -> crud.resetSingleton(Names.CONFIGURATION, JMX_TEMPLATE, form, configMetadata, new FinishReset<ModelNode>(form) { @Override public void afterReset(final Form<ModelNode> form) { presenter.reload(); } })) .build(); HTMLElement configLayout = section().add(h(1).textContent(Names.CONFIGURATION)) .add(p().textContent(configMetadata.getDescription().getDescription())).add(configForm).get(); navigation.addPrimary(Ids.JMX_CONFIGURATION_ITEM, Names.CONFIGURATION, pfIcon("settings"), configLayout); registerAttachable(configForm); // ------------------------------------------------------ audit log // The handlers are modeled as sub-resources of the audit-log configuration, // but in the UI here they're managed by a ListItem. Metadata handlerMetadata = metadataRegistry.lookup(AUDIT_LOG_HANDLER_TEMPLATE); SafeHtml handlerDescription = SafeHtmlUtils.fromString(handlerMetadata.getDescription().getDescription()); handlerItem = new ListItem(HANDLER, labelBuilder.label(HANDLER)); List<AddressTemplate> templates = asList( AddressTemplate.of("{domain.controller}/core-service=management/access=audit/file-handler=*"), AddressTemplate.of("{domain.controller}/core-service=management/access=audit/syslog-handler=*")); handlerItem.registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, templates)); Metadata alMetadata = metadataRegistry.lookup(AUDIT_LOG_TEMPLATE); this.alForm = new ModelNodeForm.Builder<>(Ids.JMX_AUDIT_LOG_FORM, alMetadata) .singleton( () -> new Operation.Builder(AUDIT_LOG_TEMPLATE.resolve(statementContext), READ_RESOURCE_OPERATION).build(), () -> crud.addSingleton(Names.AUDIT_LOG, AUDIT_LOG_TEMPLATE, address -> presenter.reload())) .unboundFormItem(handlerItem, Integer.MAX_VALUE, handlerDescription) .onSave((form, changedValues) -> presenter.saveAuditLog(changedValues, handlerItem.isModified(), handlerItem.getValue())) .prepareReset(form -> crud.resetSingleton(Names.AUDIT_LOG, AUDIT_LOG_TEMPLATE, form, alMetadata, new FinishReset<ModelNode>(form) { @Override public void afterReset(final Form<ModelNode> form) { presenter.reload(); } })) .prepareRemove(form -> crud.removeSingleton(Names.AUDIT_LOG, AUDIT_LOG_TEMPLATE, new FinishRemove<ModelNode>(form) { @Override public void afterRemove(final Form<ModelNode> form) { presenter.reload(); } })) .build(); HTMLElement alLayout = section().add(h(1).textContent(Names.AUDIT_LOG)) .add(p().textContent(alMetadata.getDescription().getDescription())).add(this.alForm).get(); navigation.addPrimary(Ids.JMX_AUDIT_LOG_ITEM, Names.AUDIT_LOG, fontAwesome("file-text-o"), alLayout); registerAttachable(this.alForm); // ------------------------------------------------------ remoting connector String type = labelBuilder.label(REMOTING_CONNECTOR_TEMPLATE.lastName()); Metadata rcMetadata = metadataRegistry.lookup(REMOTING_CONNECTOR_TEMPLATE); this.rcForm = new ModelNodeForm.Builder<>(Ids.JMX_REMOTING_CONNECTOR_FORM, rcMetadata) .singleton( () -> new Operation.Builder(REMOTING_CONNECTOR_TEMPLATE.resolve(statementContext), READ_RESOURCE_OPERATION).build(), () -> crud.addSingleton(type, REMOTING_CONNECTOR_TEMPLATE, address -> presenter.reload())) .onSave((form, changedValues) -> crud.saveSingleton(type, REMOTING_CONNECTOR_TEMPLATE, changedValues, () -> presenter.reload())) .prepareReset(form -> crud.resetSingleton(type, REMOTING_CONNECTOR_TEMPLATE, form, rcMetadata, new FinishReset<ModelNode>(form) { @Override public void afterReset(final Form<ModelNode> form) { presenter.reload(); } })) .prepareRemove(form -> crud.removeSingleton(type, REMOTING_CONNECTOR_TEMPLATE, new FinishRemove<ModelNode>(form) { @Override public void afterRemove(final Form<ModelNode> form) { presenter.reload(); } })) .build(); HTMLElement rcLayout = section().add(h(1).textContent(type)) .add(p().textContent(rcMetadata.getDescription().getDescription())).add(this.rcForm).get(); navigation.addPrimary(Ids.JMX_REMOTING_CONNECTOR_ITEM, type, pfIcon("topology"), rcLayout); registerAttachable(this.rcForm); // ------------------------------------------------------ main layout initElement(row().add(column().addAll(navigation.panes()))); }
From source file:org.jboss.hal.client.configuration.subsystem.undertow.ServletContainerView.java
License:Apache License
@Inject @SuppressWarnings("ConstantConditions") public ServletContainerView(Dispatcher dispatcher, MetadataRegistry metadataRegistry, Resources resources) { this.dispatcher = dispatcher; Metadata configurationMetadata = metadataRegistry.lookup(SERVLET_CONTAINER_TEMPLATE); configurationForm = new ModelNodeForm.Builder<>(Ids.UNDERTOW_SERVLET_CONTAINER_CONFIGURATION_FORM, configurationMetadata)/*w w w. j a v a2s . c o m*/ .onSave((form, changedValues) -> presenter.saveServletContainer(changedValues)) .prepareReset(form -> presenter.resetServletContainer(form)).build(); Metadata emptyMetadata = Metadata.empty(); ModelNode mimeMappingDescription = failSafeGet(configurationMetadata.getDescription(), "children/mime-mapping/description"); //NON-NLS mimeMappingItem = new PropertiesItem(MIME_MAPPING, Names.MIME_MAPPING); mimeMappingForm = new ModelNodeForm.Builder<>(Ids.UNDERTOW_SERVLET_CONTAINER_MIME_MAPPING_FORM, emptyMetadata) .unboundFormItem(mimeMappingItem, 0, SafeHtmlUtils.fromString(mimeMappingDescription.asString())) .exclude(VALUE) .onSave((form, changedValues) -> presenter.saveMimeMapping(mimeMappingItem.getValue())) .prepareReset(form -> presenter.resetMimeMapping(form)).build(); ModelNode welcomeFileDescription = failSafeGet(configurationMetadata.getDescription(), "children/welcome-file/description"); //NON-NLS welcomeFileItem = new ListItem(WELCOME_FILE, Names.WELCOME_FILE); welcomeFileForm = new ModelNodeForm.Builder<>(Ids.UNDERTOW_SERVLET_CONTAINER_WELCOME_FILE_FORM, emptyMetadata) .unboundFormItem(welcomeFileItem, 0, SafeHtmlUtils.fromString(welcomeFileDescription.asString())) .onSave((form, changedValues) -> presenter.saveWelcomeFile(welcomeFileItem.getValue().stream() .collect(toMap(Function.identity(), value -> null)))) .prepareReset(form -> presenter.resetWelcomeFile(form)).build(); Tabs tabs = new Tabs(Ids.UNDERTOW_SERVLET_CONTAINER_TAB_CONTAINER); tabs.add(Ids.UNDERTOW_SERVLET_CONTAINER_CONFIGURATION_TAB, resources.constants().attributes(), configurationForm.element()); tabs.add(Ids.UNDERTOW_SERVLET_CONTAINER_MIME_MAPPING_TAB, Names.MIME_MAPPING, mimeMappingForm.element()); tabs.add(Ids.UNDERTOW_SERVLET_CONTAINER_WELCOME_FILE_TAB, Names.WELCOME_FILE, welcomeFileForm.element()); HTMLElement configurationSection = section().add(h(1).textContent(Names.CONFIGURATION)) .add(p().textContent(configurationMetadata.getDescription().getDescription())).add(tabs).get(); settings = new EnumMap<>(ServletContainerSetting.class); Map<ServletContainerSetting, HTMLElement> settingsSections = new EnumMap<>(ServletContainerSetting.class); for (ServletContainerSetting setting : ServletContainerSetting.values()) { Metadata metadata = metadataRegistry .lookup(SERVLET_CONTAINER_TEMPLATE.append(setting.templateSuffix())); Form<ModelNode> form = failSafeFrom(setting, metadata); settings.put(setting, form); settingsSections.put(setting, section().add(h(1).textContent(setting.type)) .add(p().textContent(metadata.getDescription().getDescription())).add(form).get()); } VerticalNavigation navigation = new VerticalNavigation(); navigation.addPrimary(Ids.UNDERTOW_SERVLET_CONTAINER_CONFIGURATION_ITEM, Names.CONFIGURATION, pfIcon("settings"), configurationSection); for (ServletContainerSetting setting : NAVIGATION_ORDER) { navigation.addPrimary(Ids.build(setting.baseId, Ids.ITEM), setting.type, setting.icon, settingsSections.get(setting)); } registerAttachable(navigation, configurationForm, mimeMappingForm, welcomeFileForm); settings.values().forEach(s -> registerAttachable(s)); initElement(row().add(column().addAll(navigation.panes()))); }
From source file:org.jboss.hal.client.configuration.subsystem.webservice.ConfigElement.java
License:Apache License
@SuppressWarnings({ "ConstantConditions", "HardCodedStringLiteral" }) ConfigElement(Config configType, MetadataRegistry metadataRegistry, TableButtonFactory tableButtonFactory) { List<InlineAction<NamedNode>> inlineActions = new ArrayList<>(); inlineActions.add(new InlineAction<>("Pre", row -> presenter.showHandlerChains(row, PRE_HANDLER_CHAIN))); inlineActions.add(new InlineAction<>("Post", row -> presenter.showHandlerChains(row, POST_HANDLER_CHAIN))); Metadata metadata = metadataRegistry.lookup(configType.template); table = new ModelNodeTable.Builder<NamedNode>(Ids.build(configType.baseId, Ids.TABLE), metadata) .button(tableButtonFactory.add(configType.template, table -> presenter.addConfig())) .button(tableButtonFactory.remove(configType.template, table -> presenter.removeConfig(table.selectedRow().getName()))) .column(NAME, (cell, type, row, meta) -> row.getName()).column(inlineActions).build(); ModelNode propertyDescription = failSafeGet(metadata.getDescription(), "children/property/description"); propertiesItem = new PropertiesItem(PROPERTY); form = new ModelNodeForm.Builder<NamedNode>(Ids.build(configType.baseId, Ids.FORM), metadata) .unboundFormItem(propertiesItem, 0, SafeHtmlUtils.fromString(propertyDescription.asString())) .onSave((form, changedValues) -> presenter.saveConfig(form, changedValues, PROPERTY)) .prepareReset(form -> presenter.resetConfig(form)).build(); HTMLElement section = section().add(h(1).textContent(configType.type)) .add(p().textContent(metadata.getDescription().getDescription())).add(table).add(form).get(); handlerChain = new HandlerChainElement(configType, metadataRegistry, tableButtonFactory); handler = new HandlerElement(configType, metadataRegistry, tableButtonFactory); String id = Ids.build(configType.baseId, Ids.PAGES); String mainId = Ids.build(configType.baseId, Ids.PAGE); pages = new Pages(id, mainId, section); pages.addPage(mainId, handlerChainPageId(configType), () -> presenter.configSegment(), () -> presenter.handlerChainTypeSegment(), handlerChain); pages.addPage(handlerChainPageId(configType), handlerPageId(configType), () -> presenter.handlerChainSegment(), () -> Names.HANDLER, handler); }
From source file:org.jboss.hal.client.homepage.HomepageSection.java
License:Apache License
@PostConstruct void init() {/*from w w w .j a v a2 s. com*/ if (open()) { toggleIcon.classList.remove(FA_ANGLE_RIGHT); toggleIcon.classList.add(FA_ANGLE_DOWN); sectionBody.classList.add(in); } else { toggleIcon.classList.remove(FA_ANGLE_DOWN); toggleIcon.classList.add(FA_ANGLE_RIGHT); sectionBody.classList.remove(in); } sectionHeader.innerHTML = header(); sectionIntro.innerHTML = intro(); sectionBody.setAttribute("aria-expanded", String.valueOf(open())); //NON-NLS Elements.removeChildrenFrom(sectionSteps); for (String step : steps()) { HTMLLIElement li = li().innerHtml(SafeHtmlUtils.fromString(step)).get(); sectionSteps.appendChild(li); } bind(toggleSection, click, event -> toggle()); }
From source file:org.jboss.hal.client.runtime.managementoperations.ManagementOperationsPresenter.java
License:Apache License
@Override protected void reload() { if (environment.isStandalone()) { ResourceAddress addressFindNP = MANAGEMENT_OPERATIONS_TEMPLATE.resolve(statementContext); Operation operationFindNP = new Operation.Builder(addressFindNP, FIND_NON_PROGRESSING_OPERATION) .build();// w w w .ja va 2 s .c o m ResourceAddress addressMO = MANAGEMENT_OPERATIONS_TEMPLATE.resolve(statementContext); Operation operationMO = new Operation.Builder(addressMO, READ_CHILDREN_RESOURCES_OPERATION) .param(CHILD_TYPE, ACTIVE_OPERATION).build(); dispatcher.execute(new Composite(operationFindNP, operationMO), (CompositeResult result) -> { ModelNode resultNP = result.step(0).get(RESULT); ModelNode resultOperations = result.step(1).get(RESULT); final String nonProgressingId = resultNP.isDefined() ? resultNP.asString() : null; List<ManagementOperations> activeOps = asNamedNodes(resultOperations.asPropertyList()).stream() .map(ManagementOperations::new).peek(activeOp -> { if (nonProgressingId != null && nonProgressingId.equals(activeOp.getName())) { activeOp.setAsNonProgressing(); } }).collect(toList()); getView().update(activeOps); }); } else { // return available hosts, to later call a find-non-progressing-operation on each host Task<FlowContext> hostsTask = context -> { ResourceAddress address = new ResourceAddress(); Operation operation = new Operation.Builder(address, READ_CHILDREN_NAMES_OPERATION) .param(CHILD_TYPE, HOST).build(); return dispatcher.execute(operation).doOnSuccess(result -> { List<String> hosts = result.asList().stream().map(ModelNode::asString).collect(toList()); context.set(HOSTS, hosts); }).toCompletable(); }; // return running servers, to later call a find-non-progressing-operation on each runtime server Task<FlowContext> serversTask = context -> { // /host=*/server=*:query(select=[host,name],where={server-state=running}) ResourceAddress address = new ResourceAddress().add(HOST, WILDCARD).add(SERVER, WILDCARD); Operation operation = new Operation.Builder(address, QUERY) .param(SELECT, new ModelNode().add(HOST).add(NAME)) .param(WHERE, new ModelNode().set(SERVER_STATE, "running")).build(); return dispatcher.execute(operation).doOnSuccess(result -> { List<String> servers = Collections.emptyList(); if (result != null && result.isDefined()) { servers = result.asList().stream().map(r -> hostServerAddress(r.get(RESULT))) .collect(toList()); } context.set("servers", servers); }).toCompletable(); }; // call find-non-progressing-operation and read-resource of active operations // on each host and server Task<FlowContext> findNonProgressingTask = context -> { List<String> hosts = context.get(HOSTS); List<String> servers = context.get("servers"); Composite composite = new Composite(); for (String host : hosts) { ResourceAddress address = new ResourceAddress().add(HOST, host).add(CORE_SERVICE, MANAGEMENT) .add(SERVICE, MANAGEMENT_OPERATIONS); Operation operation = new Operation.Builder(address, FIND_NON_PROGRESSING_OPERATION).build(); composite.add(operation); ResourceAddress ad = new ResourceAddress(address.clone()).add(ACTIVE_OPERATION, WILDCARD); Operation operationMO = new Operation.Builder(ad, READ_RESOURCE_OPERATION).build(); composite.add(operationMO); } if (!servers.isEmpty()) { for (String server : servers) { ResourceAddress address = AddressTemplate.of(server).append(MANAGEMENT_OPERATIONS_TEMPLATE) .resolve(statementContext); Operation findOp = new Operation.Builder(address, FIND_NON_PROGRESSING_OPERATION).build(); composite.add(findOp); ResourceAddress ad = new ResourceAddress(address.clone()).add(ACTIVE_OPERATION, WILDCARD); Operation operation = new Operation.Builder(ad, READ_RESOURCE_OPERATION).build(); composite.add(operation); } } return dispatcher.execute(composite).doOnSuccess(response -> { List<String> nonProgressingOps = new ArrayList<>(); List<ManagementOperations> ops = new ArrayList<>(); for (ModelNode r : response) { ModelNode result = r.get(RESULT); if (result != null && result.isDefined()) { ModelType type = result.getType(); // if model is LIST it is the list of active operations if (ModelType.LIST.equals(type)) { for (ModelNode op : result.asList()) { ModelNode opResult = op.get(RESULT); // the result has two addresses // 1) the active-operation address itself, example // /host=master/server=server-three/core-service=management/service=management-operations/active-operation=1940701884 // 2) the resource address // /host=master/server=server-three/subsystem=elytron/filesystem-realm=file1 // the active-operation address should be store to later use it to cancel, if needed // the resource address is displayed to the user ModelNode activeOpAddress = op.get(ADDRESS); opResult.get(HAL_ACTIVE_OP_ADDRESS).set(activeOpAddress); String opId = null; List<Property> activeOperationAddressList = activeOpAddress.asPropertyList(); for (Property p : activeOperationAddressList) { if (p.getName().equals(ACTIVE_OPERATION)) { opId = p.getValue().asString(); } // the result doesn't show the full address of a running server // store the host and server to later show in the view if (p.getName().equals(HOST)) { opResult.get(HAL_ACTIVE_ADDRESS_HOST).set(p.getValue().asString()); } if (p.getName().equals(SERVER)) { opResult.get(HAL_ACTIVE_ADDRESS_SERVER).set(p.getValue().asString()); } } NamedNode node = new NamedNode(opId, opResult); ManagementOperations activeOp = new ManagementOperations(node); ops.add(activeOp); } } else { nonProgressingOps.add(result.asString()); } } } // if there are non progressing operations, mark them in the list if (!nonProgressingOps.isEmpty()) { Collections.sort(nonProgressingOps); for (ManagementOperations mop : ops) { if (nonProgressingOps.indexOf(mop.getName()) > -1) { mop.setAsNonProgressing(); } } } context.set("active-operations", ops); }).toCompletable(); }; series(new FlowContext(progress.get()), hostsTask, serversTask, findNonProgressingTask) .subscribe(new Outcome<FlowContext>() { @Override public void onError(FlowContext context, Throwable error) { MessageEvent.fire(getEventBus(), Message.error(SafeHtmlUtils .fromString("Error loading management operations: " + error.getMessage()))); } @Override public void onSuccess(FlowContext context) { List<ManagementOperations> ops = context.get("active-operations"); getView().update(ops); } }); } }