use of com.helger.html.hc.impl.HCTextNode in project peppol-practical by phax.
the class PagePublicToolsParticipantInformation method _printTecInfo.
private void _printTecInfo(@Nonnull final IHCLI<?> aLIEndpoint, final String sTecInfo, final String sTecContact) {
final HCDiv aDiv = div("Technical info: ");
if (StringHelper.hasText(sTecInfo)) {
final boolean bIsEmail = EmailAddressHelper.isValid(sTecInfo);
aDiv.addChild(bIsEmail ? HCA_MailTo.createLinkedEmail(sTecInfo) : new HCTextNode(sTecInfo));
}
if (StringHelper.hasText(sTecContact)) {
if (aDiv.getChildCount() > 1)
aDiv.addChild(" / ");
final boolean bIsEmail = EmailAddressHelper.isValid(sTecContact);
aDiv.addChild(bIsEmail ? HCA_MailTo.createLinkedEmail(sTecContact) : new HCTextNode(sTecContact));
}
if (aDiv.getChildCount() > 1)
aLIEndpoint.addChild(aDiv);
}
use of com.helger.html.hc.impl.HCTextNode in project peppol-practical by phax.
the class PageSecureCRMGroup method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final CRMGroupManager aCRMGroupMgr = PPMetaManager.getCRMGroupMgr();
// Toolbar on top
final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addButtonNew("Create new CRM group", createCreateURL(aWPEC));
// List existing
final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Sender email address"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ICRMGroup aCurObject : aCRMGroupMgr.getAll()) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
aRow.addCell(aCurObject.getSenderEmailAddress());
aRow.addCell(createEditLink(aWPEC, aCurObject), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject));
}
aNodeList.addChild(aTable);
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aDataTables);
}
use of com.helger.html.hc.impl.HCTextNode in project peppol-practical by phax.
the class PageSecureCRMSubscriber method _getList.
@Nonnull
private IHCNode _getList(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final Collection<? extends ICRMSubscriber> aCRMSubscribers, @Nonnull final String sIDSuffix) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
// List existing
final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Email address"), new DTCol("Last Mod").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new DTCol("Groups"), new BootstrapDTColAction(aDisplayLocale)).setID(getID() + sIDSuffix);
for (final ICRMSubscriber aCurObject : aCRMSubscribers) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(StringHelper.getConcatenatedOnDemand(aCurObject.getSalutationDisplayName(aDisplayLocale), " ", aCurObject.getName())));
aRow.addCell(aCurObject.getEmailAddress());
aRow.addCell(PDTToString.getAsString(aCurObject.hasLastModificationDateTime() ? aCurObject.getLastModificationDateTime() : aCurObject.getCreationDateTime(), aDisplayLocale));
aRow.addCell(HCExtHelper.nl2divList(aCurObject.getAllAssignedGroups().stream().map(ICRMGroup::getDisplayName).collect(Collectors.joining("\n"))));
final IHCCell<?> aActionCell = aRow.addCell();
aActionCell.addChildren(createEditLink(aWPEC, aCurObject), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject), new HCTextNode(" "));
aActionCell.addChild(isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
return new HCNodeList().addChild(aTable).addChild(aDataTables);
}
use of com.helger.html.hc.impl.HCTextNode in project peppol-practical by phax.
the class PageSecureSchematronTools method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
{
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
final BootstrapForm aForm = aToolbar.addAndReturnChild(new BootstrapForm(aWPEC).setFormType(EBootstrapFormType.INLINE));
aForm.addFormGroup(new BootstrapFormGroup().setCtrl(new ExtValidationKeySelect(new RequestField(FIELD_VESID), aDisplayLocale)));
aForm.addFormGroup(new BootstrapFormGroup().setCtrl(new ActionSelect(new RequestField(CPageParam.PARAM_ACTION))));
aForm.addFormGroup(new BootstrapFormGroup().setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_STYLE_OUTPUT, DEFAULT_STYLE_OUTPUT)), new HCTextNode(" format?")));
aForm.addFormGroup(new BootstrapFormGroup().setCtrl(new BootstrapSubmitButton().addChild("Run")));
aNodeList.addChild(aToolbar);
}
final String sVESID = aWPEC.params().getAsString(FIELD_VESID);
final VESID aVESID = VESID.parseIDOrNull(sVESID);
final boolean bStyleOutput = aWPEC.params().isCheckBoxChecked(FIELD_STYLE_OUTPUT, DEFAULT_STYLE_OUTPUT);
final IValidationExecutorSet<IValidationSourceXML> aVES = ExtValidationKeyRegistry.getFromIDOrNull(aVESID);
if (aVES != null) {
if (aWPEC.hasAction(ACTION_SHOW_PREPROCESSED_SCHEMA)) {
LOGGER.info("Showing preprocessed Schematron of " + aVESID.getAsSingleID());
final MapBasedNamespaceContext aNSCtx = new MapBasedNamespaceContext();
aNSCtx.addDefaultNamespaceURI(CSchematron.NAMESPACE_SCHEMATRON);
aNSCtx.addMapping("xsl", "http://www.w3.org/1999/XSL/Transform");
aNSCtx.addMapping("svrl", CSVRL.SVRL_NAMESPACE_URI);
final IXMLWriterSettings XWS = new XMLWriterSettings().setIndent(EXMLSerializeIndent.INDENT_AND_ALIGN).setNamespaceContext(aNSCtx);
aNodeList.addChild(info("Showing preprocessed version of " + aVESID.getAsSingleID()));
final BootstrapTabBox aTabBox = new BootstrapTabBox();
for (final IValidationExecutor<?> aVE : aVES.getAllExecutors()) {
final IReadableResource aRes = aVE.getValidationArtefact().getRuleResource();
final IValidationType aType = aVE.getValidationArtefact().getValidationArtefactType();
if (aType == EValidationType.SCHEMATRON_PURE || aType == EValidationType.SCHEMATRON_SCH) {
IHCNode aTabContent;
try {
// Read Schematron
final PSSchema aSchema = new PSReader(aRes, null, null).readSchema();
final IPSQueryBinding aQueryBinding = PSQueryBindingRegistry.getQueryBindingOfNameOrThrow(aSchema.getQueryBinding());
final PSPreprocessor aPreprocessor = PSPreprocessor.createPreprocessorWithoutInformationLoss(aQueryBinding);
// Pre-process
final PSSchema aPreprocessedSchema = aPreprocessor.getAsPreprocessedSchema(aSchema);
if (aPreprocessedSchema == null)
throw new SchematronPreprocessException("Failed to preprocess schema " + aSchema + " with query binding " + aQueryBinding);
// Convert to XML string
final String sXML = MicroWriter.getNodeAsString(aPreprocessedSchema.getAsMicroElement(), XWS);
IHCNode aCode;
if (bStyleOutput) {
final HCPrismJS aPrism = new HCPrismJS(EPrismLanguage.MARKUP).addPlugin(new PrismPluginLineNumbers()).addChild(sXML);
aCode = aPrism;
} else
aCode = pre(sXML);
final CollectingPSErrorHandler aErrHdl = new CollectingPSErrorHandler();
aPreprocessedSchema.validateCompletely(aErrHdl);
if (aErrHdl.isEmpty()) {
aTabContent = aCode;
} else {
final HCUL aUL = new HCUL();
aErrHdl.getAllErrors().forEach(x -> aUL.addItem(x.getErrorText(aDisplayLocale)));
aTabContent = new HCNodeList().addChild(error("Errors in the Schematron:").addChild(aUL)).addChild(aCode);
}
} catch (final Exception ex) {
aTabContent = error("Error parsing Schematron: " + ex.getMessage());
}
aTabBox.addTab("t" + aTabBox.getTabCount(), FilenameHelper.getBaseName(aRes.getPath()), aTabContent);
} else if (aType == EValidationType.SCHEMATRON_XSLT) {
final IHCNode aTabContent = info("This is already XSLT");
aTabBox.addTab("t" + aTabBox.getTabCount(), FilenameHelper.getBaseName(aRes.getPath()), aTabContent);
}
}
if (aTabBox.hasNoTabs())
aNodeList.addChild(warn("No Schematron artefacts found"));
else
aNodeList.addChild(aTabBox);
} else if (aWPEC.hasAction(ACTION_SHOW_XSLT)) {
LOGGER.info("Showing XSLT version of " + aVESID.getAsSingleID());
final MapBasedNamespaceContext aNSCtx = new MapBasedNamespaceContext();
aNSCtx.addDefaultNamespaceURI(CSchematron.NAMESPACE_SCHEMATRON);
aNSCtx.addMapping("xsl", "http://www.w3.org/1999/XSL/Transform");
aNSCtx.addMapping("svrl", CSVRL.SVRL_NAMESPACE_URI);
final IXMLWriterSettings XWS = new XMLWriterSettings().setIndent(EXMLSerializeIndent.INDENT_AND_ALIGN).setNamespaceContext(aNSCtx);
aNodeList.addChild(info("Showing XSLT version of " + aVESID.getAsSingleID()));
final BootstrapTabBox aTabBox = new BootstrapTabBox();
for (final IValidationExecutor<IValidationSourceXML> aVE : aVES.getAllExecutors()) {
final IReadableResource aRes = aVE.getValidationArtefact().getRuleResource();
final IValidationType aType = aVE.getValidationArtefact().getValidationArtefactType();
if (aType == EValidationType.SCHEMATRON_PURE || aType == EValidationType.SCHEMATRON_SCH) {
IHCNode aTabContent;
try {
// Read Schematron
final SchematronResourceSCH aSch = new SchematronResourceSCH(aRes);
if (!aSch.isValidSchematron())
throw new SchematronPreprocessException("Invalid Schematron!");
final Document aXSLT = aSch.getXSLTProvider().getXSLTDocument();
if (aXSLT == null)
throw new SchematronPreprocessException("Failed to convert to XSLT!");
// Convert to XML string
final String sXML = XMLWriter.getNodeAsString(aXSLT, XWS);
// Highlight
if (bStyleOutput) {
final HCPrismJS aPrism = new HCPrismJS(EPrismLanguage.MARKUP).addPlugin(new PrismPluginLineNumbers()).addChild(sXML);
aTabContent = aPrism;
} else
aTabContent = pre(sXML);
} catch (final Exception ex) {
aTabContent = error("Error parsing Schematron: " + ex.getMessage());
}
aTabBox.addTab("t" + aTabBox.getTabCount(), FilenameHelper.getBaseName(aRes.getPath()), aTabContent);
} else if (aType == EValidationType.SCHEMATRON_XSLT) {
final IHCNode aTabContent = info("This is already XSLT");
aTabBox.addTab("t" + aTabBox.getTabCount(), FilenameHelper.getBaseName(aRes.getPath()), aTabContent);
}
}
if (aTabBox.hasNoTabs())
aNodeList.addChild(warn("No Schematron artefacts found"));
else
aNodeList.addChild(aTabBox);
} else {
// TODO other action when necessary
}
LOGGER.info("Done");
}
}
use of com.helger.html.hc.impl.HCTextNode in project peppol-practical by phax.
the class AppCommonUI method _createFormattedID.
@Nonnull
private static IHCNode _createFormattedID(@Nonnull final String sID, @Nullable final String sName, @Nullable final EBootstrapBadgeType eType, final boolean bIsDeprecated, final boolean bInDetails) {
if (sName == null) {
// No nice name present
if (bInDetails)
return new HCCode().addChild(sID);
return new HCTextNode(sID);
}
final HCNodeList ret = new HCNodeList();
ret.addChild(new BootstrapBadge(eType).addChild(sName));
if (bIsDeprecated) {
ret.addChild(" ").addChild(new BootstrapBadge(EBootstrapBadgeType.WARNING).addChild("Identifier is deprecated"));
}
if (bInDetails) {
ret.addChild(new HCSmall().addChild(" (").addChild(new HCCode().addChild(sID)).addChild(")"));
}
return ret;
}
Aggregations