Search in sources :

Example 6 with HCTextNode

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);
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCTextNode(com.helger.html.hc.impl.HCTextNode)

Example 7 with HCTextNode

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);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) CRMGroupManager(com.helger.peppol.crm.CRMGroupManager) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) HCTextNode(com.helger.html.hc.impl.HCTextNode) ICRMGroup(com.helger.peppol.crm.ICRMGroup) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)

Example 8 with HCTextNode

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);
}
Also used : Locale(java.util.Locale) HCTable(com.helger.html.hc.html.tabular.HCTable) HCNodeList(com.helger.html.hc.impl.HCNodeList) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) HCRow(com.helger.html.hc.html.tabular.HCRow) ICRMSubscriber(com.helger.peppol.crm.ICRMSubscriber) HCTextNode(com.helger.html.hc.impl.HCTextNode) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) DataTables(com.helger.photon.uictrls.datatables.DataTables) Nonnull(javax.annotation.Nonnull)

Example 9 with HCTextNode

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");
    }
}
Also used : Locale(java.util.Locale) PrismPluginLineNumbers(com.helger.photon.uictrls.prism.PrismPluginLineNumbers) HCNodeList(com.helger.html.hc.impl.HCNodeList) VESID(com.helger.phive.api.executorset.VESID) RequestFieldBoolean(com.helger.photon.core.form.RequestFieldBoolean) IReadableResource(com.helger.commons.io.resource.IReadableResource) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) PSReader(com.helger.schematron.pure.exchange.PSReader) Document(org.w3c.dom.Document) PSSchema(com.helger.schematron.pure.model.PSSchema) MapBasedNamespaceContext(com.helger.xml.namespace.MapBasedNamespaceContext) IValidationType(com.helger.phive.api.IValidationType) SchematronPreprocessException(com.helger.schematron.pure.preprocess.SchematronPreprocessException) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) RequestField(com.helger.photon.core.form.RequestField) CollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler) ExtValidationKeySelect(com.helger.peppol.phive.ExtValidationKeySelect) IXMLWriterSettings(com.helger.xml.serialize.write.IXMLWriterSettings) XMLWriterSettings(com.helger.xml.serialize.write.XMLWriterSettings) IXMLWriterSettings(com.helger.xml.serialize.write.IXMLWriterSettings) IValidationExecutor(com.helger.phive.api.execute.IValidationExecutor) HCPrismJS(com.helger.photon.uictrls.prism.HCPrismJS) IValidationSourceXML(com.helger.phive.engine.source.IValidationSourceXML) PSPreprocessor(com.helger.schematron.pure.preprocess.PSPreprocessor) SchematronPreprocessException(com.helger.schematron.pure.preprocess.SchematronPreprocessException) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) HCUL(com.helger.html.hc.html.grouping.HCUL) SchematronResourceSCH(com.helger.schematron.sch.SchematronResourceSCH) IPSQueryBinding(com.helger.schematron.pure.binding.IPSQueryBinding) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) BootstrapSubmitButton(com.helger.photon.bootstrap4.button.BootstrapSubmitButton) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) HCTextNode(com.helger.html.hc.impl.HCTextNode) IHCNode(com.helger.html.hc.IHCNode)

Example 10 with HCTextNode

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;
}
Also used : HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapBadge(com.helger.photon.bootstrap4.badge.BootstrapBadge) HCCode(com.helger.html.hc.html.textlevel.HCCode) HCSmall(com.helger.html.hc.html.textlevel.HCSmall) HCTextNode(com.helger.html.hc.impl.HCTextNode) Nonnull(javax.annotation.Nonnull)

Aggregations

HCTextNode (com.helger.html.hc.impl.HCTextNode)25 HCNodeList (com.helger.html.hc.impl.HCNodeList)17 Locale (java.util.Locale)15 HCA (com.helger.html.hc.html.textlevel.HCA)14 ISimpleURL (com.helger.commons.url.ISimpleURL)11 HCRow (com.helger.html.hc.html.tabular.HCRow)11 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)11 HCTable (com.helger.html.hc.html.tabular.HCTable)10 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)10 BootstrapDataTables (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)10 DataTables (com.helger.photon.uictrls.datatables.DataTables)10 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)10 Nonnull (javax.annotation.Nonnull)8 HCCheckBox (com.helger.html.hc.html.forms.HCCheckBox)5 HCCode (com.helger.html.hc.html.textlevel.HCCode)5 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)5 RequestField (com.helger.photon.core.form.RequestField)5 RequestFieldBoolean (com.helger.photon.core.form.RequestFieldBoolean)5 HCEdit (com.helger.html.hc.html.forms.HCEdit)4 HCDiv (com.helger.html.hc.html.grouping.HCDiv)4