/**
 * Copyright (C) 2015-2017 Philip Helger (www.helger.com)
 * philip[at]helger[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.helger.pd.publisher.app.secure.page;

import javax.annotation.Nonnull;

import com.helger.commons.annotation.Nonempty;
import com.helger.commons.collection.ext.ICommonsSortedSet;
import com.helger.commons.url.ISimpleURL;
import com.helger.html.hc.html.grouping.HCUL;
import com.helger.html.hc.html.sections.HCH3;
import com.helger.html.hc.html.textlevel.HCA;
import com.helger.html.hc.impl.HCNodeList;
import com.helger.pd.indexer.mgr.PDMetaManager;
import com.helger.pd.publisher.app.pub.CMenuPublic;
import com.helger.pd.publisher.app.pub.page.PagePublicSearchSimple;
import com.helger.pd.publisher.ui.AbstractAppWebPage;
import com.helger.peppol.identifier.generic.participant.IParticipantIdentifier;
import com.helger.photon.bootstrap3.alert.BootstrapInfoBox;
import com.helger.photon.core.app.CApplication;
import com.helger.photon.uicore.css.CPageParam;
import com.helger.photon.uicore.page.WebPageExecutionContext;

public final class PageSecureAllParticipants extends AbstractAppWebPage
{
  public PageSecureAllParticipants (@Nonnull @Nonempty final String sID)
  {
    super (sID, "All participants");
  }

  @Override
  protected void fillContent (final WebPageExecutionContext aWPEC)
  {
    final HCNodeList aNodeList = aWPEC.getNodeList ();

    final ICommonsSortedSet <IParticipantIdentifier> aAllIDs = PDMetaManager.getStorageMgr ()
                                                                            .getAllContainedParticipantIDs ();
    aNodeList.addChild (new HCH3 ().addChild (aAllIDs.size () + " participants are contained"));

    final HCUL aUL = new HCUL ();
    for (final IParticipantIdentifier aParticipantID : aAllIDs)
    {
      final String sParticipantID = aParticipantID.getURIEncoded ();
      final ISimpleURL aShowDetails = aWPEC.getLinkToMenuItem (CApplication.APP_ID_PUBLIC, CMenuPublic.MENU_SEARCH)
                                           .add (PagePublicSearchSimple.FIELD_QUERY, sParticipantID)
                                           .add (CPageParam.PARAM_ACTION, CPageParam.ACTION_VIEW)
                                           .add (PagePublicSearchSimple.FIELD_PARTICIPANT_ID, sParticipantID);
      aUL.addItem (new HCA (aShowDetails).addChild (sParticipantID));
    }

    if (aUL.hasChildren ())
      aNodeList.addChild (aUL);
    else
      aNodeList.addChild (new BootstrapInfoBox ().addChild ("No participant identifier is yet in the index"));
  }
}

@@ -917,21 +917,21 @@
 tml.
-grouping.HCUL
+sections.HCH3
 ;%0Aim
@@ -955,37 +955,85 @@
 tml.hc.html.
-sections.HCH3
+tabular.HCRow;%0Aimport com.helger.html.hc.html.tabular.IHCCell
 ;%0Aimport com
@@ -1473,16 +1473,74 @@
 nfoBox;%0A
+import com.helger.photon.bootstrap3.table.BootstrapTable;%0A
 import c
@@ -2339,29 +2339,91 @@
 nal 
-HCUL aUL = new HCUL (
+BootstrapTable aTable = new BootstrapTable ().setCondensed (true).setBordered (true
 );%0A 
@@ -2556,24 +2556,166 @@
 Encoded ();%0A
+%0A      final HCRow aRow = aTable.addBodyRow ();%0A      aRow.addCell (sParticipantID);%0A%0A      final IHCCell %3C?%3E aActionCell = aRow.addCell ();%0A%0A
       final 
@@ -2792,16 +2792,79 @@
 _PUBLIC,
+%0A                                                              
  CMenuPu
@@ -2879,16 +2879,23 @@
 U_SEARCH
+_SIMPLE
 )%0A      
@@ -3209,18 +3209,27 @@
    a
-UL.addItem
+ActionCell.addChild
  (ne
@@ -3259,30 +3259,24 @@
 dChild (
-sParticipantID
+%22Search%22
 ));%0A    
@@ -3291,22 +3291,25 @@
 f (a
-UL.hasChildren
+Table.hasBodyRows
  ())
@@ -3340,10 +3340,13 @@
 d (a
-UL
+Table
 );%0A 

Using a table