Changeset 7358


Ignore:
Timestamp:
11/18/06 18:02:28 (6 years ago)
Author:
sys
Message:

Activation nouveau système d'outline

Location:
trunk/Jav_GE/com/scenari/m/ge/agent
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jav_GE/com/scenari/m/ge/agent/HAgentExport.java

    r7357 r7358  
    8181 
    8282/** 
    83  * Spécialisation des agents de type Export. Dans des agents de type Export, l'API "AgentAvecResultat" est obligatoire 
    84  * et renvoit un ensemble d'instructions javascript exécutant le traitement demandé. Ce traitement est spécifié par le 
    85  * paramètre de la méthode hGetResultat() au format QueryString : "cdaction=GoToNext&param=xxx&p2=yyy". 
     83 * Spécialisation des agents de type Export. Dans des agents de type Export, 
     84 * l'API "AgentAvecResultat" est obligatoire et renvoit un ensemble 
     85 * d'instructions javascript exécutant le traitement demandé. Ce traitement est 
     86 * spécifié par le paramètre de la méthode hGetResultat() au format QueryString : 
     87 * "cdaction=GoToNext&param=xxx&p2=yyy". 
    8688 */ 
    8789public abstract class HAgentExport extends HAgent implements IWAgentExport { 
    8890 
    89     /** API Resultat : Préfixe pour executer l'agent. */ 
    90     public static final String PREFIX_ACT = "act:"; 
    91  
    92     /** API Resultat : Préfixe pour obtenir l'agent sous forme d'objet. */ 
    93     public static final String PREFIX_OBJ = "obj:"; 
    94  
    95     /** API Resultat : Préfixe pour copier une ressource dans l'espace de destination.  
    96      * Les paramètres qui suivent le préfixe dépendent du généretaur. 
    97      * L'url de destination de la ressource copiée est retournée (format "destUrl" voir {@link IGenerator}). 
    98      */ 
    99     public static final String PREFIX_RES = "res:"; 
    100  
    101     /** API Resultat : Préfixe pour copier une ressource dans l'espace de destination.  
    102      * Les paramètres qui suivent le préfixe dépendent du généretaur. 
    103      * L'uri de destination de la ressource copiée est retournée (format "destUri" voir {@link IGenerator}). 
    104      */ 
    105     public static final String PREFIX_RESURI = "resUri:"; 
    106  
    107     /** API Resultat : Préfixe pour obtenir l'URL (dans l'envir. de destination) d'une Ressource  
    108      * issue de l'espace des fichiers de publication. Aucun ordre de copie n'est donné, seul l'url 
    109      * est retournée. 
    110      */ 
    111     public static final String PREFIX_PUBRES = "pubres:"; 
    112  
    113     /**  
    114      * API Resultat : Préfixe pour obtenir une l'arborescence des agents liés sous forme XML via. 
    115      * Options pour les ancètres (par défaut, aucun ancètre n'est publié) : 
    116      * <ul> 
    117      *  <li> "ancestors;" : ajoute tous les ancêtres au dialogue en cours. 
    118      *  <li> "ancestors-siblings;" : ajoute tous les ancêtres et leurs frères au dialogue en cours. 
    119      *  <li> "parent-siblings;" : ajoute le père et tous les frères au dialogue en cours. 
    120      * </ul> 
    121      * <br> 
    122      * Options pour les descendants (par défaut, aucun fils n'est publié) : 
    123      * <ul> 
    124      *  <li> "children;" : ajoute tous les fils directs au dialogue en cours. 
    125      *  <li> "descendants;" : ajoute tous les descndants au dialogue en cours. 
    126      * </ul> 
    127      *  
    128      * Les noeuds dont l'intitulé est null ne sont pas considérés comme des  
    129      * représentants de "parent", "sibling", "child" (etc.) et sont  
    130      * traversés pour rechercher les agents disposant d'un intitulé qui constituent  
    131      * les réels "points d'arrêt". 
    132      * Les noeuds dont l'intitulé est null ne sont pas puliés. Ils peuvent  
    133      * néanmoins être publiés avec l'option : 
    134      * <ul> 
    135      *  <li> publishInvisibleAgents; 
    136      * </ul> 
    137      *  
    138      */ 
    139     public static final String PREFIX_OUTLINE = "outline:"; 
    140  
    141     /** 
    142      * API Resultat : Préfixe pour obtenir le contenu d'une Ressource via l'API Resultat.  
    143      * Seules des ressources non binaires peuvent être récupérées. 
    144      */ 
    145     public static final String PREFIX_GET = "get:"; 
    146  
    147     /** 
    148      * API Resultat : Préfixe pour rechercher un agent dans le contexte du dialogue selon les critères  
    149      * passés en paramètre (format QueryString d'URL). 
    150      * <ul> 
    151      * <li>from= Spécifie le départ de la recherche. Par défaut c'est l'agent en cours, sinon, n'importequel  
    152      *          path de dialogue : "/@@" pour la racine par exemple. 
    153      * <li>dir= ancestor / descendantForward / descendantBackward / following / previous.  
    154      *          L'attribut dir peut être répété plusieurs fois pour définir plusieurs directions de recherche. 
    155      *          Si cet attribut n'est pas spécifié la séquence suivante est utilisée : ancestor + descendantForward. 
    156      * <li>codeAgentPrinc= CodeAgent principal recherché. 
    157      * <li>pathAgent= PathAgent exact recherché. 
    158      * <li>docSource= URI du docSource du composant. 
    159      * <li>regExpCodeAgent= Expression régulière appliqué sur le code de l'agent recherché. 
    160      * <li>computeResultWithArguments= Au lieu de retourner le path du dialogue trouvé, executa ce dialogue  
    161      *          avec les arguments passés en paramètre. 
    162      * </ul> 
    163      */ 
    164     public static final String PREFIX_LOOKFOR = "lookFor:"; 
    165  
    166     /** Liste de dialogues avec une page de résultats déjà traités. */ 
    167     protected List fDialogsTraites = new ArrayList(); 
    168  
    169     static { 
    170         //Ajout des fonctions au moteur XPath DOM 
    171         FunctionTable.installFunction("idExportAgent", new ZXPathIdExportAgent()); 
    172         FunctionTable.installFunction("idExportAgentHier", new ZXPathIdExportAgentHier()); 
    173         FunctionTable.installFunction("setEntryBuffer", new ZXPathSetEntryBuffer()); 
    174         FunctionTable.installFunction("initBuffer", new ZXPathInitBuffer()); 
    175         FunctionTable.installFunction("getEntryBuffer", new ZXPathGetEntryBuffer()); 
    176         FunctionTable.installFunction("transform", new ZXPathTransform()); 
    177         FunctionTable.installFunction("translateSrcPath2DestUri", new ZXPathTranslateSrcPath2DestUri()); 
    178         FunctionTable.installFunction("translatePubPath2DestUrl", new ZXPathTranslatePubPath2DestUrl()); 
    179         FunctionTable.installFunction("scanFolder", new ZXPathScanFolder()); 
    180         FunctionTable.installFunction("getGeneratorProperty", new ZXPathGetGeneratorProperty()); 
    181         //Ajout des fonctions au moteur XPath DTM 
    182         ZXPath.hInstallFunction("idExportAgent", new com.scenari.m.ge.xpath.dtm.ZXPathIdExportAgent()); 
    183         ZXPath.hInstallFunction("idExportAgentHier", new com.scenari.m.ge.xpath.dtm.ZXPathIdExportAgentHier()); 
    184         ZXPath.hInstallFunction("setEntryBuffer", new com.scenari.m.ge.xpath.dtm.ZXPathSetEntryBuffer()); 
    185         ZXPath.hInstallFunction("getEntryBuffer", new com.scenari.m.ge.xpath.dtm.ZXPathGetEntryBuffer()); 
    186         ZXPath.hInstallFunction("initBuffer", new com.scenari.m.ge.xpath.dtm.ZXPathInitBuffer()); 
    187         ZXPath.hInstallFunction("transform", new com.scenari.m.ge.xpath.dtm.ZXPathTransform()); 
    188         ZXPath.hInstallFunction("translateSrcPath2DestUri", new com.scenari.m.ge.xpath.dtm.ZXPathTranslateSrcPath2DestUri()); 
    189         ZXPath.hInstallFunction("translatePubPath2DestUrl", new com.scenari.m.ge.xpath.dtm.ZXPathTranslatePubPath2DestUrl()); 
    190         ZXPath.hInstallFunction("scanFolder", new com.scenari.m.ge.xpath.dtm.ZXPathScanFolder()); 
    191     } 
    192      
    193     static { 
    194         //fonctions spécifiques BUILDER v3 
    195         FunctionTable.installFunction("switchAxis", new ZXPathSwitchAxis()); 
    196         FunctionTable.installFunction("gotoSubModel", new ZXPathGotoSubModel()); 
    197         FunctionTable.installFunction("gotoMeta", new ZXPathGotoMeta()); 
    198         FunctionTable.installFunction("currentModel", new ZXPathCurrentModel()); 
    199         FunctionTable.installFunction("rootModel", new ZXPathRootModel()); 
    200         FunctionTable.installFunction("getContent", new ZXPathGetContent()); 
    201         FunctionTable.installFunction("getUrl", new ZXPathGetUrl()); 
    202         FunctionTable.installFunction("getFullTitleText", new ZXPathGetFullTitleText()); 
    203         FunctionTable.installFunction("getShortTitleText", new ZXPathGetShortTitleText()); 
    204         FunctionTable.installFunction("lookForAncestorAgentByTypes", new ZXPathLookForAncestorAgentByTypes()); 
    205     } 
    206  
    207     /** 
    208      *  
    209      */ 
    210     public HAgentExport(com.scenari.m.co.composant.IWComposant pComposant, com.scenari.m.co.instance.IWInstFormation pInstance) { 
    211         super(pComposant, pInstance); 
    212     } 
    213  
    214     /** 
    215      * Retourne le résultat d'un agent. Le dialogue passé en parametre peut ne pas correspondre à celui de l'agent sur 
    216      * lequel on veut obtenir le résultat. Dans des agents de type Export, l'API "AgentAvecResultat" est obligatoire et 
    217      * pArgument doit être une chaine String. Si l'argument est préfixé de "act:" un block javascript est renvoyé 
    218      * comportant les ordres d'exécution d'un dialogue. Les paramètres doivent être au format QueryString des URL. 
    219      * Exemple : "act:cdaction=GoToNext&param=xxx&p2=yyy". Si l'argument est préfixé de "res:" une url de la ressource 
    220      * référencée est utilisée. L'expression de la ressource est dépendante du ContenuMgr de l'univers. Exemple pour un 
    221      * type ContenuMgrFs : - "res:{re_co}toto.gif", - "res:{re_un}logo.jpg", etc. 
    222      */ 
    223     public final IHDonneeCalculate hGetResultat(IHDialog pDialog, Object pArgument) throws java.lang.Exception { 
    224  
    225         String vParam = null; 
    226         if (pArgument == null) { 
    227             throw HLogMgr.hNewException("Impossible de calculer le résultat dans l'agent " + this + " car l'argument passé pour le calcul du résultat est null. Un argument de type String est obligatoire. Exemples : 'act:', 'obj:', 'res:monImage.gif'"); 
    228         } 
    229         if (pArgument instanceof String) { 
    230             vParam = (String) pArgument; 
    231         } else { 
    232             throw HLogMgr.hNewException("Impossible de calculer le résultat dans l'agent " + this + " car l'argument passé pour le calcul du résultat n'est pas de type String."); 
    233         } 
    234  
    235         //Préfixe d'execution de l'agent 
    236         //Préfixe pour récupérer un objet javascript de l'agent 
    237         if (vParam.startsWith(PREFIX_ACT) || vParam.startsWith(PREFIX_OBJ)) { 
    238  
    239             //Création du dialogue susceptible de traiter la requete 
    240             IWADialogExport vNewDialog = (IWADialogExport) hNewDialog(pDialog); 
    241             vNewDialog.wSetScriptMode((vParam.startsWith(PREFIX_ACT)) ? IWADialogExport.SCRIPT_MODE_EXE : IWADialogExport.SCRIPT_MODE_OBJ); 
    242             vNewDialog.hInitFromQueryString(vParam.substring(PREFIX_ACT.length())); 
    243  
    244             //Ecriture du script 
    245             StringBuffer vBuf = HPoolBuffer.get().hGetStringBuffer(); 
    246             //Calcul du script de sortie sur le dialogue précédent 
    247             if (pDialog instanceof IWADialogExport) { 
    248                 ((IWADialogExport) pDialog).hWriteScriptSortie(vBuf, vNewDialog); 
    249             } 
    250             //Calcul du script d'entrée 
    251             vNewDialog.hWriteScriptEntree(vBuf); 
    252             String vResult = vBuf.substring(0); 
    253             HPoolBuffer.get().hFreeStringBuffer(vBuf); 
    254  
    255             return new HDonneeVolatile(vResult); 
    256  
    257         } 
    258  
    259         // 
    260         else if (vParam.startsWith(PREFIX_RES)) { 
    261             IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
    262             if (vParam.length() > PREFIX_RES.length()) { 
    263                 String vResult = vGen.resolveDestUri2DestUrl(vGen.copyXxxPath2DestUri(vParam.substring(PREFIX_RES.length()), pDialog, this)); 
    264                 return new HDonneeVolatile(vResult); 
    265             } else { 
    266                 return IHDonneeCalculate.NULL; 
    267             } 
    268         } 
    269  
    270         // 
    271         else if (vParam.startsWith(PREFIX_RESURI)) { 
    272             IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
    273             if (vParam.length() > PREFIX_RESURI.length()) { 
    274                 String vResult = vGen.copyXxxPath2DestUri(vParam.substring(PREFIX_RES.length()), pDialog, this); 
    275                 return new HDonneeVolatile(vResult); 
    276             } else { 
    277                 return IHDonneeCalculate.NULL; 
    278             } 
    279         } 
    280  
    281         //Préfixe Ressource de l'espace de publication (fichiers de l'ihm) 
    282         else if (vParam.startsWith(PREFIX_PUBRES)) { 
    283             IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
    284             if (vParam.length() > PREFIX_PUBRES.length()) { 
    285                 String vResult = vGen.wGetScriptableFunctions().translatePubPath2DestUrl(vParam.substring(PREFIX_PUBRES.length())); 
    286                 return new HDonneeVolatile(vResult); 
    287             } else { 
    288                 return IHDonneeCalculate.NULL; 
    289             } 
    290         } 
    291  
    292         else if (vParam.startsWith(PREFIX_GET)) { 
    293             IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
    294             return vGen.copySrcPath2DataInMem(vParam.substring(PREFIX_RES.length()), pDialog, this); 
    295         } 
    296  
    297         else if (vParam.startsWith(PREFIX_OUTLINE)) { 
    298             return xPublishOutline(pDialog, vParam); 
    299         } 
    300  
    301         else if (vParam.startsWith(PREFIX_LOOKFOR)) { 
    302             return xLookFor((IWADialog) pDialog, vParam); 
    303         } 
    304  
    305         //Préfixe inconnu 
    306         else { 
    307             return wGetResultat(pDialog, vParam); 
    308         } 
    309     } 
    310  
    311     /** 
    312      *  
    313      */ 
    314     protected IHDonneeCalculate xLookFor(IWADialog pDialog, String pParam) throws Exception { 
    315         HParamsQueryString vParams = new HParamsQueryString(); 
    316         vParams.hInit(pParam.substring(PREFIX_LOOKFOR.length())); 
    317         String vFrom = vParams.hGetValue("from"); 
    318         String[] vDirs = vParams.hGetValues("dir"); 
    319         if (vDirs == null || vDirs.length == 0) { 
    320             vDirs = new String[2]; 
    321             vDirs[0] = "ancestor"; 
    322             vDirs[1] = "descendantForward"; 
    323         } 
    324         IWADialog vCurrentDialog = pDialog; 
    325         if (vFrom != null && vFrom.length() > 0) vCurrentDialog = (IWADialog) vCurrentDialog.hGoTo(vFrom); 
    326         StringBuffer vDialogPath = new StringBuffer(); 
    327         for (int i = 0; i < vDirs.length; i++) { 
    328             vDialogPath.setLength(0); 
    329             vDialogPath.append(vCurrentDialog.hGetUrlInInstance()); 
    330             String vDir = vDirs[i]; 
    331             if (vDir.equals("ancestor")) { 
    332                 List vHier = vCurrentDialog.hGetHier(); 
    333                 IWAgent vCurrAgent = vCurrentDialog.hGetAgent(); 
    334                 for (int j = vHier.size() - 1; j >= 0; j--) { 
    335                     vDialogPath.setLength(vDialogPath.lastIndexOf("/@")); 
    336                     IWAgent vParent = (IWAgent) vHier.get(j); 
    337                     if (vParent instanceof IWAgentAvecLiens) { 
    338                         IWAgent[] vChilds = ((IWAgentAvecLiens) vParent).hGetAgentsLies(pDialog); 
    339                         if (vChilds != null) { 
    340                             boolean vIsBeforeCurrent = true; 
    341                             for (int k = 0; k < vChilds.length; k++) { 
    342                                 if (vChilds[k] != null) { 
    343                                     if (vCurrAgent != vChilds[k]) { 
    344                                         vDialogPath.append('/'); 
    345                                         vDialogPath.append(vChilds[k].hGetAgentPath()); 
    346                                         if (xLookForEvalAgent(vChilds[k], pDialog, vParams)) { 
    347                                             //On a trouvé 
    348                                             return xLookForReturnResult(vDialogPath.toString(), pDialog, vParams); 
    349                                         } 
    350                                         String vResult = xLookForChildren(vChilds[k], pDialog, vDialogPath, vParams, vIsBeforeCurrent); 
    351                                         if (vResult != null) return xLookForReturnResult(vResult, pDialog, vParams); 
    352                                         vDialogPath.setLength(vDialogPath.lastIndexOf("/@")); 
    353                                     } else { 
    354                                         vIsBeforeCurrent = false; 
    355                                     } 
    356                                 } 
    357                             } 
    358                         } 
    359                     } 
    360                     vCurrAgent = vParent; 
    361                 } 
    362  
    363             } else if (vDir.equals("descendantForward")) { 
    364                 return xLookForReturnResult(xLookForChildren(vCurrentDialog.hGetAgent(), pDialog, vDialogPath, vParams, false), pDialog, vParams); 
    365             } else if (vDir.equals("descendantBackward")) { 
    366                 return xLookForReturnResult(xLookForChildren(vCurrentDialog.hGetAgent(), pDialog, vDialogPath, vParams, true), pDialog, vParams); 
    367             } else { 
    368                 HLogMgr.hPublishTrace("lookFor:dir=" + vDir + " unknown. Called from " + pDialog); 
    369             } 
    370         } 
    371  
    372         return IHDonneeCalculate.NULL; 
    373     } 
    374  
    375     /** 
    376      *  
    377      */ 
    378     protected String xLookForChildren(IWAgent pAgent, IWADialog pDialog, StringBuffer pDialogPath, HParamsQueryString pParams, boolean pBackward) throws Exception { 
    379         if (pAgent != null && (pAgent instanceof IWAgentAvecLiens)) { 
    380             IWAgent[] vChildren = ((IWAgentAvecLiens) pAgent).hGetAgentsLies(pDialog); 
    381             if (vChildren != null) { 
    382                 for (int i = (pBackward ? vChildren.length - 1 : 0); (pBackward ? i >= 0 : i < vChildren.length); i += (pBackward ? -1 : +1)) { 
    383                     if (vChildren[i] != null) { 
    384                         pDialogPath.append('/'); 
    385                         pDialogPath.append(vChildren[i].hGetAgentPath()); 
    386                         if (xLookForEvalAgent(vChildren[i], pDialog, pParams)) { 
    387                             return pDialogPath.toString(); 
    388                         } 
    389                         String vResult = xLookForChildren(vChildren[i], pDialog, pDialogPath, pParams, pBackward); 
    390                         if (vResult != null) return vResult; 
    391                         pDialogPath.setLength(pDialogPath.lastIndexOf("/@")); 
    392                     } 
    393                 } 
    394             } 
    395         } 
    396         return null; 
    397     } 
    398  
    399     /** 
    400      *  
    401      */ 
    402     protected boolean xLookForEvalAgent(IWAgent pAgent, IWADialog pDialog, HParamsQueryString pParams) { 
    403         String vPathAgent = pParams.hGetValue("pathAgent"); 
    404         if (vPathAgent != null && !pAgent.hGetAgentPath().equals(vPathAgent)) { 
    405             return false; 
    406         } 
    407         String vCodeAgentPrinc = pParams.hGetValue("codeAgentPrinc"); 
    408         if (vCodeAgentPrinc != null && !pAgent.hGetAgentPrinc().hGetCode().equals(vCodeAgentPrinc)) { 
    409             return false; 
    410         } 
    411         String vDocSource = pParams.hGetValue("docSource"); 
    412         if (vDocSource != null && !pAgent.hGetComposant().hGetDocSource().hGetUri().equalsIgnoreCase(vDocSource)) { 
    413             return false; 
    414         } 
    415         String vRegExpCodeAgent = pParams.hGetValue("regExpCodeAgent"); 
    416         if (vRegExpCodeAgent != null && !pAgent.hGetCode().matches(vRegExpCodeAgent)) { 
    417             return false; 
    418         } 
    419         return true; 
    420     } 
    421  
    422     /** 
    423      *  
    424      */ 
    425     protected IHDonneeCalculate xLookForReturnResult(String pPathDialogResult, IWADialog pDialog, HParamsQueryString pParams) throws Exception { 
    426         String vComputeArgs = pParams.hGetValue("computeResultWithArguments"); 
    427         if (vComputeArgs != null) { 
    428             IWADialog vNewDial = (IWADialog) pDialog.hGoTo(pPathDialogResult); 
    429             if (vNewDial != null && (vNewDial.hGetAgent() instanceof IWAgentAvecResultat)) { 
    430                 return ((IWAgentAvecResultat) vNewDial.hGetAgent()).hGetResultat(vNewDial, vComputeArgs); 
    431             } 
    432             return IHDonneeCalculate.NULL; 
    433         } 
    434         return new HDonneeVolatile(pPathDialogResult); 
    435     } 
    436  
    437     protected IHDonneeCalculate xPublishOutline(IHDialog pDialog, String pParam) throws Exception { 
    438         StringBuffer vBuf = HPoolBuffer.get().hGetStringBuffer(); 
    439         IHXmlWriter vWriter = new HXmlWriterSB(vBuf); 
    440         vWriter.hWriteOpenTag("outline"); 
    441  
    442         boolean vPublishInvisibleAgents = (pParam.indexOf("publishInvisibleAgents;") > 0); 
    443  
    444         StringBuffer vDialogPath = new StringBuffer(); 
    445         //Gestion des ancêtres 
    446         List vAgents = ((IWADialog) pDialog).hGetHier(); 
    447         //Stack pour publier la balises de clotures et les frères suivants 
    448         List vStackAncestors = new ArrayList(vAgents.size() * 3); 
    449         boolean vAncestorsSiblings = (pParam.indexOf("ancestors-siblings;") > 0); 
    450         boolean vAncestors = vAncestorsSiblings || (pParam.indexOf("ancestors;") > 0); 
    451         boolean vParentSiblings = vAncestorsSiblings || (pParam.indexOf("parent-siblings;") > 0); 
    452         boolean vParent = vAncestors || (pParam.indexOf("parent;") > 0); 
    453         IWAgentOutline vParentOutlinePub = null; 
    454         //boolean vAtLeastOneParentFound = false; 
    455         if (vParent) { 
    456             //On publie au moins le père 
    457             //On recherche le père avec titre 
    458             int vParentIdx = vAgents.size() - 1; 
    459             while (vParentIdx > 0) { 
    460                 if (((IWAgent) vAgents.get(vParentIdx)).hGetIntitule(pDialog).length() > 0) { 
    461                     break; 
    462                 } 
    463                 vParentIdx--; 
    464             } 
    465             //On publie les ancètres 
    466             for (int i = 0; i < vParentIdx; i++) { 
    467                 IWAgent vAgent = (IWAgent) vAgents.get(i); 
    468                 IWAgent vNext = (IWAgent) vAgents.get(i + 1); 
    469                 vDialogPath.append('/'); 
    470                 vDialogPath.append(vAgent.hGetAgentPath()); 
    471                 vStackAncestors.add(vAgent); 
    472                 String vTitle = vAgent.hGetIntitule(pDialog); 
    473                 boolean vPublished = (vAncestors && (vPublishInvisibleAgents || vTitle.length() > 0)); 
    474                 if (vPublished) { 
    475                     vWriter.hWriteOpenTag("child"); 
    476                     //if (vParentOutlinePub != null) vParentOutlinePub.publishDescLinkFor(vAgent, vWriter); 
    477                     //vAtLeastOneParentFound = true; 
    478                     vStackAncestors.add(Boolean.TRUE); 
    479                     vWriter.hWriteStartTag("entry"); 
    480                     vWriter.hWriteAttribut("dialog", vDialogPath.toString()); 
    481                     if (vTitle.length() > 0) { 
    482                         vWriter.hWriteAttribut("title", vTitle); 
    483                         vWriter.hWriteAttribut("position", "ancestor"); 
    484                     } 
    485                     vWriter.hWriteEndOpenTag(); 
    486                     vWriter.hWriteXmlFragment(vAgent.hGetDescriptif(pDialog)); 
    487                 } else { 
    488                     vStackAncestors.add(Boolean.FALSE); 
    489                 } 
    490                 if (vAncestorsSiblings && (vAgent instanceof IWAgentAvecLiens)) { 
    491                     //On publie les fils de cet ancêtre qui sont frères précédents du suivant. 
    492                     IWAgent[] vList = ((IWAgentAvecLiens) vAgent).hGetAgentsLies(pDialog); 
    493                     if (vList != null) { 
    494                         for (int j = 0; j < vList.length; j++) { 
    495                             if (vList[j] == vNext) break; 
    496                             if (vList[j] != null) xPublishOutlineSibling(vAgent, vList[j], pDialog, vWriter, vDialogPath, vPublishInvisibleAgents, null); 
    497                         } 
    498                     } 
    499                     vStackAncestors.add(vList); 
    500                 } else { 
    501                     vStackAncestors.add(null); 
    502                 } 
    503                 vParentOutlinePub = (vAgent instanceof IWAgentOutline) ? (IWAgentOutline) vAgent : null; 
    504             } 
    505             //On publie le père 
    506             int vLastParent = vAgents.size() - 1; 
    507             for (int i = vParentIdx; i <= vLastParent; i++) { 
    508                 IWAgent vAgent = (IWAgent) vAgents.get(i); 
    509                 IWAgent vNext = (i < vLastParent) ? (IWAgent) vAgents.get(i + 1) : this; 
    510                 vDialogPath.append('/'); 
    511                 vDialogPath.append(vAgent.hGetAgentPath()); 
    512                 vStackAncestors.add(vAgent); 
    513                 String vTitle = vAgent.hGetIntitule(pDialog); 
    514                 boolean vPublished = (vPublishInvisibleAgents || vTitle.length() > 0); 
    515                 if (vPublished) { 
    516                     vWriter.hWriteOpenTag("child"); 
    517                     //if (vParentOutlinePub != null) vParentOutlinePub.publishDescLinkFor(vAgent, vWriter); 
    518                     vStackAncestors.add(Boolean.TRUE); 
    519                     vWriter.hWriteStartTag("entry"); 
    520                     vWriter.hWriteAttribut("dialog", vDialogPath.toString()); 
    521                     if (vTitle.length() > 0) { 
    522                         vWriter.hWriteAttribut("title", vTitle); 
    523                         vWriter.hWriteAttribut("position", "parent"); 
    524                     } 
    525                     vWriter.hWriteEndOpenTag(); 
    526                     vWriter.hWriteXmlFragment(vAgent.hGetDescriptif(pDialog)); 
    527                 } else { 
    528                     vStackAncestors.add(Boolean.FALSE); 
    529                 } 
    530                 if (vParentSiblings && (vAgent instanceof IWAgentAvecLiens)) { 
    531                     //On publie les fils de cet ancêtre qui sont frères précédents du suivant. 
    532                     IWAgent[] vList = ((IWAgentAvecLiens) vAgent).hGetAgentsLies(pDialog); 
    533                     for (int j = 0; j < vList.length; j++) { 
    534                         if (vList[j] == vNext) break; 
    535                         if (vList[j] != null) xPublishOutlineSibling(vAgent, vList[j], pDialog, vWriter, vDialogPath, vPublishInvisibleAgents, "previous-siblings"); 
    536                     } 
    537                     vStackAncestors.add(vList); 
    538                 } else { 
    539                     vStackAncestors.add(null); 
    540                 } 
    541             } 
    542         } else { 
    543             //On n'ajoute pas les père mais on remplit le path du dialogue. 
    544             for (int i = 0; i < vAgents.size(); i++) { 
    545                 IWAgent vAgent = (IWAgent) vAgents.get(i); 
    546                 vDialogPath.append('/'); 
    547                 vDialogPath.append(vAgent.hGetAgentPath()); 
    548             } 
    549         } 
    550  
    551         xPublishOutlineEntry(vParentOutlinePub, this, pDialog, vWriter, vDialogPath, vPublishInvisibleAgents, (pParam.indexOf("children;") > 0) ? 1 : (pParam.indexOf("descendants;") > 0) ? Integer.MAX_VALUE : 0); 
    552  
    553         //Terminaison des ancêtres 
    554         IWAgent vNext = this; 
    555         boolean vIsSibling = true; 
    556         int vIdxAgents = vAgents.size() - 1; 
    557         for (int i = vStackAncestors.size() - 3; i >= 0; i = i - 3) { 
    558             IWAgent vAgent = (IWAgent) vStackAncestors.get(i); 
    559             boolean vPublished = ((Boolean) vStackAncestors.get(i + 1)).booleanValue(); 
    560             //On ajoute les frères suivants 
    561             IWAgent[] vList = (IWAgent[]) vStackAncestors.get(i + 2); 
    562             if (vList != null) { 
    563                 //Des frères à publier 
    564                 int j = 0; 
    565                 //On dépasse l'élément suivant 
    566                 for (; j < vList.length; j++) { 
    567                     if (vList[j] == vNext) break; 
    568                 } 
    569                 //On publie les frères suivants 
    570                 for (j++; j < vList.length; j++) { 
    571                     if (vList[j] != null) xPublishOutlineSibling(vAgent, vList[j], pDialog, vWriter, vDialogPath, vPublishInvisibleAgents, (vIsSibling) ? "next-siblings" : null); 
    572                 } 
    573             } 
    574             if (vPublished) { 
    575                 //une entrée a été publiée, on cloture l'entrée 
    576                 vWriter.hWriteCloseTag("entry"); 
    577                 vWriter.hWriteCloseTag("child"); 
    578                 vIsSibling = false; 
    579             } 
    580             vDialogPath.setLength(vDialogPath.lastIndexOf("/@")); 
    581             vNext = (IWAgent) vAgents.get(vIdxAgents--); 
    582         } 
    583  
    584         vWriter.hWriteCloseTag("outline"); 
    585         String vResult = vBuf.substring(0); 
    586         HPoolBuffer.get().hFreeStringBuffer(vBuf); 
    587         return new HDonneeVolatile(vResult); 
    588     } 
    589  
    590     /** 
    591      *  
    592      */ 
    593     protected void xPublishOutlineSibling(IWAgent pParent, IWAgent pChild, IHDialog pDialog, IHXmlWriter pWriter, StringBuffer pPathDialog, boolean pPublishInvisibleAgents, String pPosition) throws Exception { 
    594         if (!pChild.hIsActif(pDialog)) return; 
    595         String vTitle = pChild.hGetIntitule(pDialog); 
    596         //On ajoute le path du child 
    597         int vLenPath = pPathDialog.length(); 
    598         pPathDialog.append('/'); 
    599         pPathDialog.append(pChild.hGetAgentPath()); 
    600         IWAgentOutline vParentPublisher = (pParent instanceof IWAgentOutline) ? (IWAgentOutline) pParent : null; 
    601         if (pPublishInvisibleAgents || vTitle.length() > 0) { 
    602             //On publie ce noeud invisible 
    603             pWriter.hWriteOpenTag("child"); 
    604             //if (vParentPublisher != null) vParentPublisher.publishDescLinkFor(pChild, pWriter); 
    605             pWriter.hWriteStartTag("entry"); 
    606             pWriter.hWriteAttribut("dialog", pPathDialog.toString()); 
    607             if (vTitle.length() > 0) { 
    608                 pWriter.hWriteAttribut("title", vTitle); 
    609                 if (pPosition != null) pWriter.hWriteAttribut("position", pPosition); 
    610             } 
    611             pWriter.hWriteEndOpenTag(); 
    612             pWriter.hWriteXmlFragment(pChild.hGetDescriptif(pDialog)); 
    613         } 
    614         //On boucle sur les fils si ce child est invisible 
    615         if (vTitle.length() == 0 && (pChild instanceof IWAgentAvecLiens)) { 
    616             IWAgent[] vList = ((IWAgentAvecLiens) pChild).hGetAgentsLies(pDialog); 
    617             if (vList != null) { 
    618                 for (int i = 0; i < vList.length; i++) { 
    619                     if (vList[i] != null) xPublishOutlineSibling(pChild, vList[i], pDialog, pWriter, pPathDialog, pPublishInvisibleAgents, pPosition); 
    620                 } 
    621             } 
    622         } 
    623         //On referme 
    624         if (pPublishInvisibleAgents || vTitle.length() > 0) { 
    625             //On publie ce noeud invisible 
    626             pWriter.hWriteCloseTag("entry"); 
    627             pWriter.hWriteCloseTag("child"); 
    628         } 
    629         //On restaure le path. 
    630         pPathDialog.setLength(vLenPath); 
    631     } 
    632  
    633     /** 
    634      *  
    635      */ 
    636     protected void xPublishOutlineEntry(IWAgentOutline pParentOutlinePub, IWAgent pAgent, IHDialog pDialog, IHXmlWriter pWriter, StringBuffer pPathDialog, boolean pPublishInvisibleAgents, int pDepth) throws Exception { 
    637         String vTitle = pAgent.hGetIntitule(pDialog); 
    638         //On ajoute le path du child 
    639         int vLenPath = pPathDialog.length(); 
    640         pPathDialog.append('/'); 
    641         pPathDialog.append(pAgent.hGetAgentPath()); 
    642  
    643         IWAgentOutline vAgentOutlinePub = (pAgent instanceof IWAgentOutline) ? (IWAgentOutline) pAgent : null; 
    644  
    645         boolean vPublished = pPublishInvisibleAgents || vTitle.length() > 0; 
    646         if (vPublished) { 
    647             //On publie ce noeud invisible 
    648             pWriter.hWriteOpenTag("child"); 
    649             //if (pParentOutlinePub != null) pParentOutlinePub.publishDescLinkFor(pAgent, pWriter); 
    650             pWriter.hWriteStartTag("entry"); 
    651             pWriter.hWriteAttribut("dialog", pPathDialog.toString()); 
    652             if (vTitle.length() > 0) { 
    653                 pWriter.hWriteAttribut("title", vTitle); 
    654                 pWriter.hWriteAttribut("position", (pAgent == this) ? "this" : "descendant"); 
    655             } 
    656             pWriter.hWriteEndOpenTag(); 
    657             pWriter.hWriteXmlFragment(pAgent.hGetDescriptif(pDialog)); 
    658         } 
    659         //On boucle sur les fils 
    660         if (pDepth > 0 && (pAgent instanceof IWAgentAvecLiens)) { 
    661             IWAgent[] vList = ((IWAgentAvecLiens) pAgent).hGetAgentsLies(pDialog); 
    662             if (vList != null) { 
    663                 for (int i = 0; i < vList.length; i++) { 
    664                     IWAgent vChild = vList[i]; 
    665                     if (vChild != null && vChild.hIsActif(pDialog)) { 
    666                         if (vList[i] != null) xPublishOutlineEntry(vAgentOutlinePub, vChild, pDialog, pWriter, pPathDialog, pPublishInvisibleAgents, pDepth - 1); 
    667                     } 
    668                 } 
    669             } 
    670         } 
    671         //On referme 
    672         if (vPublished) { 
    673             //On publie ce noeud invisible 
    674             pWriter.hWriteCloseTag("entry"); 
    675             pWriter.hWriteCloseTag("child"); 
    676         } 
    677         //On restaure le path. 
    678         pPathDialog.setLength(vLenPath); 
    679     } 
    680  
    681     /** 
    682      * Méthode appelée par hGetResultat() si le préfixe est inconnu pour un résultat 
    683      * spécifique à la classe de composant. 
    684      */ 
    685     protected IHDonneeCalculate wGetResultat(IHDialog pDialog, String pParams) throws java.lang.Exception { 
    686         throw HLogMgr.hNewException("Le préfixe des paramètres '" + pParams + "' est inconnu de l'agent " + this + ". Aucun résultat ne peut-être renvoyé."); 
    687     } 
     91        /** API Resultat : Préfixe pour executer l'agent. */ 
     92        public static final String PREFIX_ACT = "act:"; 
     93 
     94        /** API Resultat : Préfixe pour obtenir l'agent sous forme d'objet. */ 
     95        public static final String PREFIX_OBJ = "obj:"; 
     96 
     97        /** 
     98         * API Resultat : Préfixe pour copier une ressource dans l'espace de 
     99         * destination. Les paramètres qui suivent le préfixe dépendent du 
     100         * généretaur. L'url de destination de la ressource copiée est retournée 
     101         * (format "destUrl" voir {@link IGenerator}). 
     102         */ 
     103        public static final String PREFIX_RES = "res:"; 
     104 
     105        /** 
     106         * API Resultat : Préfixe pour copier une ressource dans l'espace de 
     107         * destination. Les paramètres qui suivent le préfixe dépendent du 
     108         * généretaur. L'uri de destination de la ressource copiée est retournée 
     109         * (format "destUri" voir {@link IGenerator}). 
     110         */ 
     111        public static final String PREFIX_RESURI = "resUri:"; 
     112 
     113        /** 
     114         * API Resultat : Préfixe pour obtenir l'URL (dans l'envir. de destination) 
     115         * d'une Ressource issue de l'espace des fichiers de publication. Aucun 
     116         * ordre de copie n'est donné, seul l'url est retournée. 
     117         */ 
     118        public static final String PREFIX_PUBRES = "pubres:"; 
     119 
     120        /** 
     121         * API Resultat : Préfixe pour obtenir une l'arborescence des agents liés 
     122         * sous forme XML via. Options pour les ancètres (par défaut, aucun ancètre 
     123         * n'est publié) : 
     124         * <ul> 
     125         * <li> "ancestors;" : ajoute tous les ancêtres au dialogue en cours. 
     126         * <li> "ancestors-siblings;" : ajoute tous les ancêtres et leurs frères au 
     127         * dialogue en cours. 
     128         * <li> "parent-siblings;" : ajoute le père et tous les frères au dialogue 
     129         * en cours. 
     130         * </ul> 
     131         * <br> 
     132         * Options pour les descendants (par défaut, aucun fils n'est publié) : 
     133         * <ul> 
     134         * <li> "children;" : ajoute tous les fils directs au dialogue en cours. 
     135         * <li> "descendants;" : ajoute tous les descndants au dialogue en cours. 
     136         * </ul> 
     137         *  
     138         */ 
     139        public static final String PREFIX_OUTLINE = "outline:"; 
     140 
     141        /** 
     142         * API Resultat : Préfixe pour obtenir le contenu d'une Ressource via l'API 
     143         * Resultat. Seules des ressources non binaires peuvent être récupérées. 
     144         */ 
     145        public static final String PREFIX_GET = "get:"; 
     146 
     147        /** 
     148         * API Resultat : Préfixe pour rechercher un agent dans le contexte du 
     149         * dialogue selon les critères passés en paramètre (format QueryString 
     150         * d'URL). 
     151         * <ul> 
     152         * <li>from= Spécifie le départ de la recherche. Par défaut c'est l'agent 
     153         * en cours, sinon, n'importequel path de dialogue : "/@@" pour la racine 
     154         * par exemple. 
     155         * <li>dir= ancestor / descendantForward / descendantBackward / following / 
     156         * previous. L'attribut dir peut être répété plusieurs fois pour définir 
     157         * plusieurs directions de recherche. Si cet attribut n'est pas spécifié la 
     158         * séquence suivante est utilisée : ancestor + descendantForward. 
     159         * <li>codeAgentPrinc= CodeAgent principal recherché. 
     160         * <li>pathAgent= PathAgent exact recherché. 
     161         * <li>docSource= URI du docSource du composant. 
     162         * <li>regExpCodeAgent= Expression régulière appliqué sur le code de 
     163         * l'agent recherché. 
     164         * <li>computeResultWithArguments= Au lieu de retourner le path du dialogue 
     165         * trouvé, executa ce dialogue avec les arguments passés en paramètre. 
     166         * </ul> 
     167         */ 
     168        public static final String PREFIX_LOOKFOR = "lookFor:"; 
     169 
     170        /** Liste de dialogues avec une page de résultats déjà traités. */ 
     171        protected List fDialogsTraites = new ArrayList(); 
     172 
     173        static { 
     174                // Ajout des fonctions au moteur XPath DOM 
     175                FunctionTable.installFunction("idExportAgent", new ZXPathIdExportAgent()); 
     176                FunctionTable.installFunction("idExportAgentHier", new ZXPathIdExportAgentHier()); 
     177                FunctionTable.installFunction("setEntryBuffer", new ZXPathSetEntryBuffer()); 
     178                FunctionTable.installFunction("initBuffer", new ZXPathInitBuffer()); 
     179                FunctionTable.installFunction("getEntryBuffer", new ZXPathGetEntryBuffer()); 
     180                FunctionTable.installFunction("transform", new ZXPathTransform()); 
     181                FunctionTable.installFunction("translateSrcPath2DestUri", new ZXPathTranslateSrcPath2DestUri()); 
     182                FunctionTable.installFunction("translatePubPath2DestUrl", new ZXPathTranslatePubPath2DestUrl()); 
     183                FunctionTable.installFunction("scanFolder", new ZXPathScanFolder()); 
     184                FunctionTable.installFunction("getGeneratorProperty", new ZXPathGetGeneratorProperty()); 
     185                // Ajout des fonctions au moteur XPath DTM 
     186                ZXPath.hInstallFunction("idExportAgent", new com.scenari.m.ge.xpath.dtm.ZXPathIdExportAgent()); 
     187                ZXPath.hInstallFunction("idExportAgentHier", new com.scenari.m.ge.xpath.dtm.ZXPathIdExportAgentHier()); 
     188                ZXPath.hInstallFunction("setEntryBuffer", new com.scenari.m.ge.xpath.dtm.ZXPathSetEntryBuffer()); 
     189                ZXPath.hInstallFunction("getEntryBuffer", new com.scenari.m.ge.xpath.dtm.ZXPathGetEntryBuffer()); 
     190                ZXPath.hInstallFunction("initBuffer", new com.scenari.m.ge.xpath.dtm.ZXPathInitBuffer()); 
     191                ZXPath.hInstallFunction("transform", new com.scenari.m.ge.xpath.dtm.ZXPathTransform()); 
     192                ZXPath.hInstallFunction("translateSrcPath2DestUri", new com.scenari.m.ge.xpath.dtm.ZXPathTranslateSrcPath2DestUri()); 
     193                ZXPath.hInstallFunction("translatePubPath2DestUrl", new com.scenari.m.ge.xpath.dtm.ZXPathTranslatePubPath2DestUrl()); 
     194                ZXPath.hInstallFunction("scanFolder", new com.scenari.m.ge.xpath.dtm.ZXPathScanFolder()); 
     195        } 
     196 
     197        static { 
     198                // fonctions spécifiques BUILDER v3 
     199                FunctionTable.installFunction("switchAxis", new ZXPathSwitchAxis()); 
     200                FunctionTable.installFunction("gotoSubModel", new ZXPathGotoSubModel()); 
     201                FunctionTable.installFunction("gotoMeta", new ZXPathGotoMeta()); 
     202                FunctionTable.installFunction("currentModel", new ZXPathCurrentModel()); 
     203                FunctionTable.installFunction("rootModel", new ZXPathRootModel()); 
     204                FunctionTable.installFunction("getContent", new ZXPathGetContent()); 
     205                FunctionTable.installFunction("getUrl", new ZXPathGetUrl()); 
     206                FunctionTable.installFunction("getFullTitleText", new ZXPathGetFullTitleText()); 
     207                FunctionTable.installFunction("getShortTitleText", new ZXPathGetShortTitleText()); 
     208                FunctionTable.installFunction("lookForAncestorAgentByTypes", new ZXPathLookForAncestorAgentByTypes()); 
     209        } 
     210 
     211        /** 
     212         *  
     213         */ 
     214        public HAgentExport(com.scenari.m.co.composant.IWComposant pComposant, com.scenari.m.co.instance.IWInstFormation pInstance) { 
     215                super(pComposant, pInstance); 
     216        } 
     217 
     218        /** 
     219         * Retourne le résultat d'un agent. Le dialogue passé en parametre peut ne 
     220         * pas correspondre à celui de l'agent sur lequel on veut obtenir le 
     221         * résultat. Dans des agents de type Export, l'API "AgentAvecResultat" est 
     222         * obligatoire et pArgument doit être une chaine String. Si l'argument est 
     223         * préfixé de "act:" un block javascript est renvoyé comportant les ordres 
     224         * d'exécution d'un dialogue. Les paramètres doivent être au format 
     225         * QueryString des URL. Exemple : "act:cdaction=GoToNext&param=xxx&p2=yyy". 
     226         * Si l'argument est préfixé de "res:" une url de la ressource référencée 
     227         * est utilisée. L'expression de la ressource est dépendante du ContenuMgr 
     228         * de l'univers. Exemple pour un type ContenuMgrFs : - 
     229         * "res:{re_co}toto.gif", - "res:{re_un}logo.jpg", etc. 
     230         */ 
     231        public final IHDonneeCalculate hGetResultat(IHDialog pDialog, Object pArgument) throws java.lang.Exception { 
     232 
     233                String vParam = null; 
     234                if (pArgument == null) { throw HLogMgr.hNewException("Impossible de calculer le résultat dans l'agent " + this 
     235                                + " car l'argument passé pour le calcul du résultat est null. Un argument de type String est obligatoire. Exemples : 'act:', 'obj:', 'res:monImage.gif'"); } 
     236                if (pArgument instanceof String) { 
     237                        vParam = (String) pArgument; 
     238                } else { 
     239                        throw HLogMgr.hNewException("Impossible de calculer le résultat dans l'agent " + this + " car l'argument passé pour le calcul du résultat n'est pas de type String."); 
     240                } 
     241 
     242                // Préfixe d'execution de l'agent 
     243                // Préfixe pour récupérer un objet javascript de l'agent 
     244                if (vParam.startsWith(PREFIX_ACT) || vParam.startsWith(PREFIX_OBJ)) { 
     245 
     246                        // Création du dialogue susceptible de traiter la requete 
     247                        IWADialogExport vNewDialog = (IWADialogExport) hNewDialog(pDialog); 
     248                        vNewDialog.wSetScriptMode((vParam.startsWith(PREFIX_ACT)) ? IWADialogExport.SCRIPT_MODE_EXE : IWADialogExport.SCRIPT_MODE_OBJ); 
     249                        vNewDialog.hInitFromQueryString(vParam.substring(PREFIX_ACT.length())); 
     250 
     251                        // Ecriture du script 
     252                        StringBuffer vBuf = HPoolBuffer.get().hGetStringBuffer(); 
     253                        // Calcul du script de sortie sur le dialogue précédent 
     254                        if (pDialog instanceof IWADialogExport) { 
     255                                ((IWADialogExport) pDialog).hWriteScriptSortie(vBuf, vNewDialog); 
     256                        } 
     257                        // Calcul du script d'entrée 
     258                        vNewDialog.hWriteScriptEntree(vBuf); 
     259                        String vResult = vBuf.substring(0); 
     260                        HPoolBuffer.get().hFreeStringBuffer(vBuf); 
     261 
     262                        return new HDonneeVolatile(vResult); 
     263 
     264                } 
     265 
     266                // 
     267                else if (vParam.startsWith(PREFIX_RES)) { 
     268                        IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
     269                        if (vParam.length() > PREFIX_RES.length()) { 
     270                                String vResult = vGen.resolveDestUri2DestUrl(vGen.copyXxxPath2DestUri(vParam.substring(PREFIX_RES.length()), pDialog, this)); 
     271                                return new HDonneeVolatile(vResult); 
     272                        } else { 
     273                                return IHDonneeCalculate.NULL; 
     274                        } 
     275                } 
     276 
     277                // 
     278                else if (vParam.startsWith(PREFIX_RESURI)) { 
     279                        IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
     280                        if (vParam.length() > PREFIX_RESURI.length()) { 
     281                                String vResult = vGen.copyXxxPath2DestUri(vParam.substring(PREFIX_RES.length()), pDialog, this); 
     282                                return new HDonneeVolatile(vResult); 
     283                        } else { 
     284                                return IHDonneeCalculate.NULL; 
     285                        } 
     286                } 
     287 
     288                // Préfixe Ressource de l'espace de publication (fichiers de l'ihm) 
     289                else if (vParam.startsWith(PREFIX_PUBRES)) { 
     290                        IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
     291                        if (vParam.length() > PREFIX_PUBRES.length()) { 
     292                                String vResult = vGen.wGetScriptableFunctions().translatePubPath2DestUrl(vParam.substring(PREFIX_PUBRES.length())); 
     293                                return new HDonneeVolatile(vResult); 
     294                        } else { 
     295                                return IHDonneeCalculate.NULL; 
     296                        } 
     297                } 
     298 
     299                else if (vParam.startsWith(PREFIX_GET)) { 
     300                        IGenerator vGen = ((HContextGenerator) pDialog.hGetContext()).hGetGenerator(); 
     301                        return vGen.copySrcPath2DataInMem(vParam.substring(PREFIX_RES.length()), pDialog, this); 
     302                } 
     303 
     304                else if (vParam.startsWith(PREFIX_OUTLINE)) { 
     305                        return xPublishOutline(pDialog, vParam); 
     306                } 
     307 
     308                else if (vParam.startsWith(PREFIX_LOOKFOR)) { 
     309                        return xLookFor((IWADialog) pDialog, vParam); 
     310                } 
     311 
     312                // Préfixe inconnu 
     313                else { 
     314                        return wGetResultat(pDialog, vParam); 
     315                } 
     316        } 
     317 
     318        /** 
     319         *  
     320         */ 
     321        protected IHDonneeCalculate xLookFor(IWADialog pDialog, String pParam) throws Exception { 
     322                HParamsQueryString vParams = new HParamsQueryString(); 
     323                vParams.hInit(pParam.substring(PREFIX_LOOKFOR.length())); 
     324                String vFrom = vParams.hGetValue("from"); 
     325                String[] vDirs = vParams.hGetValues("dir"); 
     326                if (vDirs == null || vDirs.length == 0) { 
     327                        vDirs = new String[2]; 
     328                        vDirs[0] = "ancestor"; 
     329                        vDirs[1] = "descendantForward"; 
     330                } 
     331                IWADialog vCurrentDialog = pDialog; 
     332                if (vFrom != null && vFrom.length() > 0) vCurrentDialog = (IWADialog) vCurrentDialog.hGoTo(vFrom); 
     333                StringBuffer vDialogPath = new StringBuffer(); 
     334                for (int i = 0; i < vDirs.length; i++) { 
     335                        vDialogPath.setLength(0); 
     336                        vDialogPath.append(vCurrentDialog.hGetUrlInInstance()); 
     337                        String vDir = vDirs[i]; 
     338                        if (vDir.equals("ancestor")) { 
     339                                List vHier = vCurrentDialog.hGetHier(); 
     340                                IWAgent vCurrAgent = vCurrentDialog.hGetAgent(); 
     341                                for (int j = vHier.size() - 1; j >= 0; j--) { 
     342                                        vDialogPath.setLength(vDialogPath.lastIndexOf("/@")); 
     343                                        IWAgent vParent = (IWAgent) vHier.get(j); 
     344                                        if (vParent instanceof IWAgentAvecLiens) { 
     345                                                IWAgent[] vChilds = ((IWAgentAvecLiens) vParent).hGetAgentsLies(pDialog); 
     346                                                if (vChilds != null) { 
     347                                                        boolean vIsBeforeCurrent = true; 
     348                                                        for (int k = 0; k < vChilds.length; k++) { 
     349                                                                if (vChilds[k] != null) { 
     350                                                                        if (vCurrAgent != vChilds[k]) { 
     351                                                                                vDialogPath.append('/'); 
     352                                                                                vDialogPath.append(vChilds[k].hGetAgentPath()); 
     353                                                                                if (xLookForEvalAgent(vChilds[k], pDialog, vParams)) { 
     354                                                                                        // On a trouvé 
     355                                                                                        return xLookForReturnResult(vDialogPath.toString(), pDialog, vParams); 
     356                                                                                } 
     357                                                                                String vResult = xLookForChildren(vChilds[k], pDialog, vDialogPath, vParams, vIsBeforeCurrent); 
     358                                                                                if (vResult != null) return xLookForReturnResult(vResult, pDialog, vParams); 
     359                                                                                vDialogPath.setLength(vDialogPath.lastIndexOf("/@")); 
     360                                                                        } else { 
     361                                                                                vIsBeforeCurrent = false; 
     362                                                                        } 
     363                                                                } 
     364                                                        } 
     365                                                } 
     366                                        } 
     367                                        vCurrAgent = vParent; 
     368                                } 
     369 
     370                        } else if (vDir.equals("descendantForward")) { 
     371                                return xLookForReturnResult(xLookForChildren(vCurrentDialog.hGetAgent(), pDialog, vDialogPath, vParams, false), pDialog, vParams); 
     372                        } else if (vDir.equals("descendantBackward")) { 
     373                                return xLookForReturnResult(xLookForChildren(vCurrentDialog.hGetAgent(), pDialog, vDialogPath, vParams, true), pDialog, vParams); 
     374                        } else { 
     375                                HLogMgr.hPublishTrace("lookFor:dir=" + vDir + " unknown. Called from " + pDialog); 
     376                        } 
     377                } 
     378 
     379                return IHDonneeCalculate.NULL; 
     380        } 
     381 
     382        /** 
     383         *  
     384         */ 
     385        protected String xLookForChildren(IWAgent pAgent, IWADialog pDialog, StringBuffer pDialogPath, HParamsQueryString pParams, boolean pBackward) throws Exception { 
     386                if (pAgent != null && (pAgent instanceof IWAgentAvecLiens)) { 
     387                        IWAgent[] vChildren = ((IWAgentAvecLiens) pAgent).hGetAgentsLies(pDialog); 
     388                        if (vChildren != null) { 
     389                                for (int i = (pBackward ? vChildren.length - 1 : 0); (pBackward ? i >= 0 : i < vChildren.length); i += (pBackward ? -1 : +1)) { 
     390                                        if (vChildren[i] != null) { 
     391                                                pDialogPath.append('/'); 
     392                                                pDialogPath.append(vChildren[i].hGetAgentPath()); 
     393                                                if (xLookForEvalAgent(vChildren[i], pDialog, pParams)) { return pDialogPath.toString(); } 
     394                                                String vResult = xLookForChildren(vChildren[i], pDialog, pDialogPath, pParams, pBackward); 
     395                                                if (vResult != null) return vResult; 
     396                                                pDialogPath.setLength(pDialogPath.lastIndexOf("/@")); 
     397                                        } 
     398                                } 
     399                        } 
     400                } 
     401                return null; 
     402        } 
     403 
     404        /** 
     405         *  
     406         */ 
     407        protected boolean xLookForEvalAgent(IWAgent pAgent, IWADialog pDialog, HParamsQueryString pParams) { 
     408                String vPathAgent = pParams.hGetValue("pathAgent"); 
     409                if (vPathAgent != null && !pAgent.hGetAgentPath().equals(vPathAgent)) { return false; } 
     410                String vCodeAgentPrinc = pParams.hGetValue("codeAgentPrinc"); 
     411                if (vCodeAgentPrinc != null && !pAgent.hGetAgentPrinc().hGetCode().equals(vCodeAgentPrinc)) { return false; } 
     412                String vDocSource = pParams.hGetValue("docSource"); 
     413                if (vDocSource != null && !pAgent.hGetComposant().hGetDocSource().hGetUri().equalsIgnoreCase(vDocSource)) { return false; } 
     414                String vRegExpCodeAgent = pParams.hGetValue("regExpCodeAgent"); 
     415                if (vRegExpCodeAgent != null && !pAgent.hGetCode().matches(vRegExpCodeAgent)) { return false; } 
     416                return true; 
     417        } 
     418 
     419        /** 
     420         *  
     421         */ 
     422        protected IHDonneeCalculate xLookForReturnResult(String pPathDialogResult, IWADialog pDialog, HParamsQueryString pParams) throws Exception { 
     423                String vComputeArgs = pParams.hGetValue("computeResultWithArguments"); 
     424                if (vComputeArgs != null) { 
     425                        IWADialog vNewDial = (IWADialog) pDialog.hGoTo(pPathDialogResult); 
     426                        if (vNewDial != null && (vNewDial.hGetAgent() instanceof IWAgentAvecResultat)) { return ((IWAgentAvecResultat) vNewDial.hGetAgent()).hGetResultat(vNewDial, vComputeArgs); } 
     427                        return IHDonneeCalculate.NULL; 
     428                } 
     429                return new HDonneeVolatile(pPathDialogResult); 
     430        } 
     431 
     432        /** 
     433         * Construction de l'outline. 
     434         */ 
     435        protected IHDonneeCalculate xPublishOutline(IHDialog pDialog, String pParam) throws Exception { 
     436                IWADialog vDialog = pDialog instanceof IWADialog && ((IWADialog) pDialog).hGetAgent() == this ? (IWADialog) pDialog : hNewDialog(pDialog); 
     437                boolean vAncestorsSiblings = (pParam.indexOf("ancestors-siblings;") > 0); 
     438                boolean vAncestors = vAncestorsSiblings || (pParam.indexOf("ancestors;") > 0); 
     439                boolean vParentSiblings = vAncestorsSiblings || (pParam.indexOf("parent-siblings;") > 0); 
     440                boolean vParent = vAncestors || (pParam.indexOf("parent;") > 0); 
     441 
     442                // Instanciation du walker 
     443                OutlineWalker vWalker = new OutlineWalker(); 
     444                vWalker.setCurrentDialog(vDialog); 
     445                if (vAncestors) { 
     446                        vWalker.setScopeStartingPoint(OutlineWalker.DIR_UP_DOWN, 0, true); 
     447                } else { 
     448                        vWalker.setScopeStartingPoint(OutlineWalker.DIR_DOWN_UP, vParent ? 1 : 0, true); 
     449                } 
     450                if (vAncestorsSiblings) { 
     451                        vWalker.setUncle(OutlineWalker.DIR_UP_DOWN, OutlineWalker.NO_LIMIT); 
     452                } else if (vParentSiblings) { 
     453                        vWalker.setUncle(OutlineWalker.DIR_DOWN_UP, 1); 
     454                } 
     455 
     456                // Serializer 
     457                StringBuffer vBuf = HPoolBuffer.get().hGetStringBuffer(); 
     458                IHXmlWriter vWriter = new HXmlWriterSB(vBuf); 
     459                vWriter.hWriteOpenTag("outline"); 
     460 
     461                if (vWalker.gotoFirstChild()) { 
     462                        do { 
     463                                vWriter.hWriteOpenTag("child"); 
     464                                xPublishOutlineXml(vWalker, vWriter); 
     465                                vWriter.hWriteCloseTag("child"); 
     466                        } while (vWalker.gotoNextSibling()); 
     467                } 
     468 
     469                vWriter.hWriteCloseTag("outline"); 
     470                String vResult = vBuf.substring(0); 
     471                HPoolBuffer.get().hFreeStringBuffer(vBuf); 
     472                return new HDonneeVolatile(vResult); 
     473        } 
     474 
     475        protected void xPublishOutlineXml(OutlineWalker pWalker, IHXmlWriter pWriter) throws Exception { 
     476                pWriter.hWriteStartTag("entry"); 
     477                pWriter.hWriteAttribut("dialog", pWalker.getDialogUrl()); 
     478                pWriter.hWriteAttribut("title", pWalker.getAgent().hGetIntitule(pWalker.getCurrentDialog())); 
     479                pWriter.hWriteAttribut("position", pWalker.getPosition()); 
     480                pWriter.hWriteEndOpenTag(); 
     481                pWriter.hWriteXmlFragment(pWalker.getAgent().hGetDescriptif(pWalker.getCurrentDialog())); 
     482                if (pWalker.gotoFirstChild()) { 
     483                        pWriter.hWriteOpenTag("child"); 
     484                        xPublishOutlineXml(pWalker, pWriter); 
     485                        pWriter.hWriteCloseTag("child"); 
     486                        while (pWalker.gotoNextSibling()) { 
     487                                pWriter.hWriteOpenTag("child"); 
     488                                xPublishOutlineXml(pWalker, pWriter); 
     489                                pWriter.hWriteCloseTag("child"); 
     490                        } 
     491                } 
     492                pWriter.hWriteCloseTag("entry"); 
     493        } 
     494 
     495        /** 
     496         * Méthode appelée par hGetResultat() si le préfixe est inconnu pour un 
     497         * résultat spécifique à la classe de composant. 
     498         */ 
     499        protected IHDonneeCalculate wGetResultat(IHDialog pDialog, String pParams) throws java.lang.Exception { 
     500                throw HLogMgr.hNewException("Le préfixe des paramètres '" + pParams + "' est inconnu de l'agent " + this + ". Aucun résultat ne peut-être renvoyé."); 
     501        } 
    688502 
    689503} 
  • trunk/Jav_GE/com/scenari/m/ge/agent/IWAgentOutline.java

    r7357 r7358  
    1515         * @return true si invisible. 
    1616         */ 
    17     public boolean isSkipped(IHDialog pDialog); 
     17    public boolean isSkipped(IHDialog pDialog) throws Exception; 
    1818 
    1919    /** 
    20      * Indique que cet agent représente le contenu de son père et non un noeud fils de l'outline. 
     20     * Indique que cet agent et ses descendants ne doit pas être publié dans l'outline. 
    2121     */ 
    22     public boolean isFolderContent(IHDialog pDialog); 
     22    public boolean isRejected(IHDialog pDialog) throws Exception; 
    2323     
    2424} 
  • trunk/Jav_GE/com/scenari/m/ge/agent/OutlineWalker.java

    r7357 r7358  
    66import com.scenari.m.co.agent.IWADialog; 
    77import com.scenari.m.co.agent.IWAgent; 
     8import com.scenari.m.co.agent.IWAgentAvecLiens; 
    89 
    910public class OutlineWalker { 
     
    4647        /** Position utilisée en interne des noeuds qui ne sont jamais retournés. */ 
    4748        protected static final String POS_SKIPPED = "skipped"; 
     49         
     50        /** */ 
     51        protected static final IWAgent[] NO_CHILD = new IWAgent[0]; 
    4852 
    4953        protected static class StopModel { 
     
    107111        protected StringBuffer fXCursorUrlDial = new StringBuffer(128); 
    108112 
    109         protected int fXCursorDepth = -1; 
     113        protected int fXCursorIdx = -1; 
    110114 
    111115        protected IWAgent[] fXCursorStackAgent = new IWAgent[12]; 
    112116 
    113         protected IWAgent[][] fXCursorStackSiblings = new IWAgent[12][]; 
     117        protected IWAgent[][] fXCursorStackChildren = new IWAgent[12][]; 
    114118 
    115119        protected String[] fXCursorStackPos = new String[12]; 
    116120 
    117121        /** url du dialogue constituant le point de départ de l'arbre. */ 
    118         protected String fXStartingPointUrlDial = null; 
     122        protected String fXPrefixStartPUrlDial = null; 
    119123 
    120124        /** mémorise si le point de départ est inclut dans l'arbre à publier ou pas. */ 
     
    126130        /** Distance entre le point courant et le startingPoint. */ 
    127131        protected int fXOffsetCurrentFromStartP = 0; 
     132         
     133        /** Index de l'agent correspondant au Parent dans fXAgentsStartP2Curr. */ 
     134        protected int fXIdxAgentParent = -1; 
    128135 
    129136        /** Variable d'état. */ 
     
    140147                fCurrentDialog = pDialog; 
    141148                fCurrentUrlDialog = pDialog.hGetUrlInInstance(); 
     149        } 
     150 
     151        public IWADialog getCurrentDialog() { 
     152                return fCurrentDialog; 
    142153        } 
    143154 
     
    198209        public void gotoRoot() throws Exception { 
    199210                xInitIfNeeded(); 
    200                 fXCursorUrlDial.setLength(0); 
    201                 fXCursorUrlDial.append(fXStartingPointUrlDial); 
    202                 fXCursorDepth = -1; 
     211                xResetCursorStack(); 
     212                fXCursorUrlDial.append(fXPrefixStartPUrlDial); 
    203213        } 
    204214 
     
    208218        public void gotoCurrent() throws Exception { 
    209219                xInitIfNeeded(); 
     220                xResetCursorStack(); 
    210221                xEnsureStackSize(fXAgentsStartP2Curr.length); 
    211                 for (int i = 0, vParentOffset = fXAgentsStartP2Curr.length - 2; i < fXAgentsStartP2Curr.length; i++) { 
     222                fXCursorUrlDial.append(fCurrentUrlDialog); 
     223                for (int i = fXAgentsStartP2Curr.length-1; i >=0 ; i--) { 
    212224                        fXCursorStackAgent[i] = fXAgentsStartP2Curr[i]; 
    213                         fXCursorStackPos[i] = (i < vParentOffset) ? POS_ANC : (i == vParentOffset) ? POS_PARENT : POS_CURRENT; 
    214                 } 
    215                 fXCursorDepth = fXAgentsStartP2Curr.length - 1; 
    216                 fXCursorUrlDial.setLength(0); 
    217                 fXCursorUrlDial.append(fCurrentUrlDialog); 
     225                        fXCursorStackPos[i] = xGetPosMainAxis(i); 
     226                } 
     227                fXCursorIdx = fXAgentsStartP2Curr.length - 1; 
    218228        } 
    219229 
     
    224234         * @return false si aucun fils, le cursor est alors inchangé. 
    225235         */ 
    226         public boolean gotoFirstChild() { 
    227                 xInitIfNeeded(); 
    228  
     236        public boolean gotoFirstChild() throws Exception { 
     237                xInitIfNeeded(); 
     238                IWAgent[] vChildren; 
     239                if(fXCursorIdx == -1) { 
     240                        //On est sur le root 
     241                        if(fXStartingPointIncluded) { 
     242                                vChildren = new IWAgent[1]; 
     243                                vChildren[0] = fXAgentsStartP2Curr[0]; 
     244                        } else { 
     245                                xPush(fXAgentsStartP2Curr[0], xGetPosMainAxis(0)); 
     246                                vChildren = xGetCursorChildren(); 
     247                        } 
     248                } else { 
     249                        vChildren = xGetCursorChildren(); 
     250                } 
     251                return xSearchFirstChild(vChildren); 
     252        } 
     253        protected boolean xSearchFirstChild(IWAgent[] pChildren) throws Exception { 
     254                for (int i = 0; i < pChildren.length; i++) { 
     255                        IWAgent vAgt = pChildren[i]; 
     256                        if(vAgt instanceof IWAgentOutline) { 
     257                                IWAgentOutline vAgtOutline = (IWAgentOutline)vAgt; 
     258                                if(vAgtOutline.isRejected(fCurrentDialog)) continue; 
     259                                if(vAgtOutline.isSkipped(fCurrentDialog)) { 
     260                                        xPush(vAgt, POS_SKIPPED); 
     261                                        if(xSearchFirstChild(xGetCursorChildren())) return true; 
     262                                        xPop(); 
     263                                } 
     264                        } 
     265                        xPush(vAgt, xGetNewPos(xGetCursorVisiblePos(), vAgt, fXCursorIdx+1)); 
     266                        return true; 
     267                } 
    229268                return false; 
    230269        } 
     
    234273         * au curseur actuel. 
    235274         *  
    236          * @return false si aucun frère suivant, le cursor est alors inchangé. 
    237          */ 
    238         public boolean gotoNextSibling() { 
    239                 xInitIfNeeded(); 
    240  
     275         * @return false si aucun frère suivant, le cursor est alors repassé au père (sauf si on était à la racine). 
     276         */ 
     277        public boolean gotoNextSibling() throws Exception { 
     278                xInitIfNeeded(); 
     279                //si idx = -1 ou 0 : pas de frères. 
     280                if(fXCursorIdx <= 0) return false; 
     281                 
     282                IWAgent vCurAgt = fXCursorStackAgent[fXCursorIdx]; 
     283                //On élimine l'élément actuel et on remonte au père. 
     284                //On est donc replacé sur le père. 
     285                xPop(); 
     286                IWAgent[] vSiblings = xGetCursorChildren(); 
     287                //On part de la fin pour éviter une boucle infinie si le même agent était présent 2 fois. 
     288                int vStart = Integer.MAX_VALUE; 
     289                for (int i = vSiblings.length-1; i >=0; i--) { 
     290                        if(vCurAgt == vSiblings[i]) { 
     291                                vStart = i+1; 
     292                                break; 
     293                        } 
     294                } 
     295                //On recherche le suivant 
     296                if(xSearchNextSibling(vSiblings, vStart)) return true; 
     297                if(xIsSkipped(getAgent())) { 
     298                        //Si le père est un élément skippé, on poursuit la recherche à ce niveau. 
     299                        return gotoNextSibling(); 
     300                } 
     301                return false; 
     302        } 
     303        protected boolean xSearchNextSibling(IWAgent[] pSiblings, int pStart) throws Exception { 
     304                for (int i = pStart; i < pSiblings.length; i++) { 
     305                        //On a passé le frère 
     306                        IWAgent vSibling = pSiblings[i]; 
     307                        if(vSibling == null) continue; 
     308                        if(vSibling instanceof IWAgentOutline) { 
     309                                IWAgentOutline vAgtOutline = (IWAgentOutline)vSibling; 
     310                                if(vAgtOutline.isRejected(fCurrentDialog)) continue; 
     311                                if(vAgtOutline.isSkipped(fCurrentDialog)) { 
     312                                        xPush(vSibling, POS_SKIPPED); 
     313                                        if(xSearchNextSibling(xGetCursorChildren(), 0)) return true; 
     314                                        xPop(); 
     315                                } 
     316                        } 
     317                        //On ajoute le frère. 
     318                        xPush(vSibling, xGetNewPos(xGetCursorVisiblePos(), vSibling, fXCursorIdx+1)); 
     319                        return true; 
     320                } 
     321                //Pas trouvé, on remonte 
    241322                return false; 
    242323        } 
     
    249330         *         cursor est alors inchangé. 
    250331         */ 
    251         public boolean gotoParent() { 
    252                 xInitIfNeeded(); 
    253  
    254                 return false; 
     332        public boolean gotoParent() throws Exception{ 
     333                xInitIfNeeded(); 
     334                if(fXCursorIdx < 0) return false; 
     335                xPop(); 
     336                return true; 
    255337        } 
    256338 
    257339        /* ########### Propriétés du noeud pointé par le curseur. ############# */ 
    258340 
    259         public String getPosition() { 
    260                 xInitIfNeeded(); 
    261                 return fXCursorDepth >= 0 ? fXCursorStackPos[fXCursorDepth] : POS_ROOT; 
    262         } 
    263  
    264         public IWAgent getAgent() { 
    265                 xInitIfNeeded(); 
    266                 return fXCursorDepth >= 0 ? fXCursorStackAgent[fXCursorDepth] : null; 
    267         } 
    268  
    269         public String getDialogUrl() { 
     341        public String getPosition() throws Exception{ 
     342                xInitIfNeeded(); 
     343                return fXCursorIdx >= 0 ? fXCursorStackPos[fXCursorIdx] : POS_ROOT; 
     344        } 
     345 
     346        public IWAgent getAgent() throws Exception{ 
     347                xInitIfNeeded(); 
     348                return fXCursorIdx >= 0 ? fXCursorStackAgent[fXCursorIdx] : null; 
     349        } 
     350 
     351        public String getDialogUrl() throws Exception{ 
    270352                xInitIfNeeded(); 
    271353                return fXCursorUrlDial.substring(0, fXCursorUrlDial.length()); 
     354        } 
     355        public CharSequence getDialogUrlAsCharSeq() throws Exception{ 
     356                xInitIfNeeded(); 
     357                return fXCursorUrlDial; 
    272358        } 
    273359 
     
    276362         * l'outline. 
    277363         */ 
    278         public int getOffsetFromStartingPoint() { 
    279                 xInitIfNeeded(); 
    280                 if (fXCursorDepth < 0) return 0; 
     364        public int getOffsetFromStartingPoint() throws Exception{ 
     365                xInitIfNeeded(); 
     366                if (fXCursorIdx < 0) return 0; 
    281367                int vOffset = 0; 
    282                 for (int i = fXStartingPointIncluded ? 0 : 1; i <= fXCursorDepth; i++) { 
     368                for (int i = fXStartingPointIncluded ? 0 : 1; i <= fXCursorIdx; i++) { 
    283369                        if (fXCursorStackPos[i] != POS_SKIPPED) vOffset++; 
    284370                } 
     
    287373 
    288374        /** si positif : plus bas que Current. si négatif au dessus de Current. */ 
    289         public int getOffsetFromCurrent() { 
     375        public int getOffsetFromCurrent() throws Exception{ 
    290376                xInitIfNeeded(); 
    291377                return getOffsetFromStartingPoint() - fXOffsetCurrentFromStartP; 
     
    298384        protected void xResetIfNeeded() { 
    299385                if (fXIsInitialized) { 
    300                         fXCursorUrlDial.setLength(0); 
    301                         fXCursorDepth = -1; 
    302                         for (int i = 0; i < fXCursorStackAgent.length; i++) { 
    303                                 fXCursorStackAgent[i] = null; 
    304                         } 
    305                         for (int i = 0; i < fXCursorStackSiblings.length; i++) { 
    306                                 fXCursorStackSiblings[i] = null; 
    307                         } 
    308                         for (int i = 0; i < fXCursorStackPos.length; i++) { 
    309                                 fXCursorStackPos[i] = null; 
    310                         } 
    311                         fXStartingPointUrlDial = null; 
     386                        xResetCursorStack(); 
     387                        fXPrefixStartPUrlDial = null; 
    312388                        fXStartingPointIncluded = true; 
    313389                        fXAgentsStartP2Curr = null; 
     
    317393 
    318394        /** 
     395         * Reset les props du cursor 
     396         */ 
     397        protected void xResetCursorStack() { 
     398                fXCursorUrlDial.setLength(0); 
     399                fXCursorIdx = -1; 
     400                for (int i = 0; i < fXCursorStackAgent.length; i++) { 
     401                        fXCursorStackAgent[i] = null; 
     402                        fXCursorStackChildren[i] = null; 
     403                        fXCursorStackPos[i] = null; 
     404                } 
     405        } 
     406 
     407        /** 
    319408         * Doit être appelé dans toute utilisation du Walker pour initilaiser si 
    320409         * nécessaire le walker. 
    321410         */ 
    322         protected void xInitIfNeeded() { 
     411        protected void xInitIfNeeded() throws Exception{ 
    323412                if (!fXIsInitialized) { 
    324413                        // On recherche le startingPoint 
    325                         fXStartingPointUrlDial = null; 
     414                        fXPrefixStartPUrlDial = null; 
     415                        fXIdxAgentParent = -1; 
    326416                        fXStartingPointIncluded = fStartingPointIncludeInScope; 
    327417                        if (fStartingPointDir == DIR_UP_DOWN) { 
    328418                                List vHier = fCurrentDialog.hGetHier(); 
    329419                                // On cherche le point de départ 
    330                                 int vIdxUrl = fCurrentUrlDialog.indexOf('/', 1); 
     420                                int vIdxUrl = fCurrentUrlDialog.indexOf('/'); 
    331421                                int vOffset = 0; 
    332422                                int vVisibleOffset = 0; 
    333423                                for (; vOffset < vHier.size() && vVisibleOffset < fStartingPointOffset; vOffset++) { 
    334424                                        IWAgent vAgent = (IWAgent) vHier.get(vOffset); 
    335                                         if (!isSkipped(vAgent)) vVisibleOffset++; 
     425                                        if (!xIsSkipped(vAgent)) vVisibleOffset++; 
    336426                                        StopModel vStopModel = xSearchStopModel(vAgent.hGetComposant().hGetComposantType().hGetCode(), fStartingStopModels); 
    337427                                        if (vStopModel != null) { 
     
    343433                                } 
    344434                                if (vOffset < vHier.size()) { 
    345                                         // On a trouvé un startingPoint 
    346                                         fXStartingPointUrlDial = fCurrentUrlDialog.substring(0, vIdxUrl); 
     435                                        // On a trouvé un startingPoint (sinon startingPoint = current) 
     436                                        fXPrefixStartPUrlDial = fCurrentUrlDialog.substring(0, vIdxUrl); 
    347437                                        fXAgentsStartP2Curr = new IWAgent[vHier.size() - vOffset + 1]; 
    348438                                        int vMax = fXAgentsStartP2Curr.length - 1; 
    349                                         for (int i = 0; i < vMax; i++) { 
     439                                        for (int i = vMax-1; i >= 0; i--) { 
    350440                                                fXAgentsStartP2Curr[i] = (IWAgent) vHier.get(i + vOffset); 
    351                                                 if ((i > 0 || fXStartingPointIncluded) && !isSkipped(fXAgentsStartP2Curr[i])) fXOffsetCurrentFromStartP++; 
     441                                                if ((i > 0 || fXStartingPointIncluded) && !xIsSkipped(fXAgentsStartP2Curr[i])) { 
     442                                                        if(fXIdxAgentParent < 0) fXIdxAgentParent = i; 
     443                                                        fXOffsetCurrentFromStartP++; 
     444                                                } 
    352445                                        } 
    353446                                        fXAgentsStartP2Curr[vMax] = fCurrentDialog.hGetAgent(); 
    354                                         if (!isSkipped(fCurrentDialog.hGetAgent())) fXOffsetCurrentFromStartP++; 
     447                                        if (!xIsSkipped(fCurrentDialog.hGetAgent())) fXOffsetCurrentFromStartP++; 
    355448                                } 
    356449                        } else if (fStartingPointDir == DIR_DOWN_UP) { 
     
    359452                                vHier.add(fCurrentDialog.hGetAgent()); 
    360453                                // On cherche le point de départ 
    361                                 int vIdxUrl = fCurrentUrlDialog.length(); 
     454                                int vIdxUrl = fCurrentUrlDialog.lastIndexOf('/'); 
    362455                                int vOffset = vHier.size() - 1; 
    363456                                int vVisibleOffset = 0; 
    364457                                for (; vOffset >= 0 && vVisibleOffset < fStartingPointOffset; vOffset--) { 
    365458                                        IWAgent vAgent = (IWAgent) vHier.get(vOffset); 
    366                                         if (!isSkipped(vAgent)) vVisibleOffset++; 
     459                                        if (!xIsSkipped(vAgent)) vVisibleOffset++; 
    367460                                        StopModel vStopModel = xSearchStopModel(vAgent.hGetComposant().hGetComposantType().hGetCode(), fStartingStopModels); 
    368461                                        if (vStopModel != null) { 
     
    373466                                } 
    374467                                // On a trouvé un startingPoint, sinon c'est le root du dialogue 
    375                                 fXStartingPointUrlDial = fCurrentUrlDialog.substring(0, vIdxUrl); 
     468                                fXPrefixStartPUrlDial = fCurrentUrlDialog.substring(0, vIdxUrl); 
    376469                                fXAgentsStartP2Curr = new IWAgent[vHier.size() - vOffset]; 
    377                                 int vMax = fXAgentsStartP2Curr.length; 
     470                                int vMax = fXAgentsStartP2Curr.length-1; 
    378471                                fXOffsetCurrentFromStartP = 0; 
    379                                 for (int i = 0; i < vMax; i++) { 
     472                                for (int i = vMax; i >= 0; i--) { 
    380473                                        fXAgentsStartP2Curr[i] = (IWAgent) vHier.get(i + vOffset); 
    381                                         if ((i > 0 || fXStartingPointIncluded) && !isSkipped(fXAgentsStartP2Curr[i])) fXOffsetCurrentFromStartP++; 
     474                                        if ((i > 0 || fXStartingPointIncluded) && !xIsSkipped(fXAgentsStartP2Curr[i])) { 
     475                                                if(fXIdxAgentParent < 0 && i < vMax) fXIdxAgentParent = i; //1er visible après le current. 
     476                                                fXOffsetCurrentFromStartP++; 
     477                                        } 
    382478                                } 
    383479                        } 
    384480 
    385                         if (fXStartingPointUrlDial == null) { 
     481                        if (fXPrefixStartPUrlDial == null) { 
    386482                                // Pas de startingPoint trouvé => égal à Current 
    387                                 fXStartingPointUrlDial = fCurrentUrlDialog; 
     483                                fXPrefixStartPUrlDial = fCurrentUrlDialog.substring(0, fCurrentUrlDialog.lastIndexOf('/')); 
    388484                                fXAgentsStartP2Curr = new IWAgent[1]; 
    389485                                fXAgentsStartP2Curr[0] = fCurrentDialog.hGetAgent(); 
    390                                 fXOffsetCurrentFromStartP = fXStartingPointIncluded ? 1 : 0; 
     486                                fXOffsetCurrentFromStartP = fXStartingPointIncluded ? 0 : -1; 
    391487                        } 
    392488                        // On initialise l'url du curseur à la racine 
    393                         fXCursorUrlDial.append(fXStartingPointUrlDial); 
     489                        fXCursorUrlDial.append(fXPrefixStartPUrlDial); 
    394490                        // Le walker est initialisé. 
    395491                        fXIsInitialized = true; 
     
    419515 
    420516                        IWAgent[][] vNewSiblings = new IWAgent[vNewSize][]; 
    421                         System.arraycopy(fXCursorStackSiblings, 0, vNewSiblings, 0, fXCursorStackSiblings.length); 
    422                         fXCursorStackSiblings = vNewSiblings; 
    423                 } 
    424         } 
    425  
    426         protected boolean isSkipped(IWAgent pAgt) { 
     517                        System.arraycopy(fXCursorStackChildren, 0, vNewSiblings, 0, fXCursorStackChildren.length); 
     518                        fXCursorStackChildren = vNewSiblings; 
     519                } 
     520        } 
     521         
     522        /** Ajoute un agent à la stack. */ 
     523        protected void xPush(IWAgent pAgt, String pPos) { 
     524                fXCursorIdx++; 
     525                xEnsureStackSize(fXCursorIdx); 
     526                fXCursorStackAgent[fXCursorIdx] = pAgt; 
     527                fXCursorStackPos[fXCursorIdx] = pPos; 
     528                fXCursorUrlDial.append('/'); 
     529                fXCursorUrlDial.append(pAgt.hGetAgentPath()); 
     530        } 
     531         
     532        /** Ajoute un agent à la stack. */ 
     533        protected void xPop() { 
     534                fXCursorStackAgent[fXCursorIdx] = null; 
     535                fXCursorStackPos[fXCursorIdx] = null; 
     536                fXCursorStackChildren[fXCursorIdx] = null; 
     537                fXCursorIdx--; 
     538                fXCursorUrlDial.setLength(fXCursorUrlDial.lastIndexOf("/")); 
     539        } 
     540         
     541        /** Ajoute un agent à la stack. */ 
     542        protected IWAgent[] xGetCursorChildren() throws Exception { 
     543                IWAgent vAgt = fXCursorStackAgent[fXCursorIdx]; 
     544                if(fXCursorStackChildren[fXCursorIdx] == null) { 
     545                        fXCursorStackChildren[fXCursorIdx] = (vAgt instanceof IWAgentAvecLiens) ? ((IWAgentAvecLiens)vAgt).hGetAgentsLies(fCurrentDialog) : NO_CHILD; 
     546                } 
     547                return fXCursorStackChildren[fXCursorIdx]; 
     548        } 
     549 
     550        protected boolean xIsSkipped(IWAgent pAgt) throws Exception { 
    427551                return (pAgt instanceof IWAgentOutline) && ((IWAgentOutline) pAgt).isSkipped(fCurrentDialog); 
    428552        } 
     553         
     554        /** Retourne ANC, PARENT, ou CURRENT*/ 
     555        protected String xGetPosMainAxis(int pIdx) throws Exception{ 
     556                if(xIsSkipped(fXAgentsStartP2Curr[pIdx])) return POS_SKIPPED; 
     557                return fXIdxAgentParent > pIdx ? POS_ANC : fXIdxAgentParent == pIdx ? POS_PARENT : POS_CURRENT; 
     558        } 
     559         
     560        /** Retourne la position visible du cursor. */ 
     561        protected String xGetCursorVisiblePos() { 
     562                int vIdx = fXCursorIdx; 
     563                String vPos = vIdx >= 0 ? fXCursorStackPos[vIdx] : POS_ROOT; 
     564                while(vPos == POS_SKIPPED) { 
     565                        vPos = vIdx > 0 ? fXCursorStackPos[--vIdx] : POS_ROOT; 
     566                } 
     567                return vPos; 
     568        } 
     569 
     570        /** true si cet agent est sur l'axe principal à l'index donnée. */ 
     571        protected boolean xIsInMainAxis(IWAgent pAgt, int pIdx){ 
     572                if(pIdx >= fXAgentsStartP2Curr.length) return false; 
     573                return pAgt == fXAgentsStartP2Curr[pIdx]; 
     574        } 
     575 
     576        /** Retourne la nouvelle position en fonction de la position visible du parent. */ 
     577        protected String xGetNewPos(String pVisibleParentPos, IWAgent pNewAgt, int pNewIdx) throws Exception{ 
     578                String vPos; 
     579                if(pVisibleParentPos == POS_ANC) { 
     580                        vPos = xIsInMainAxis(pNewAgt, pNewIdx) ? xGetPosMainAxis(pNewIdx) : POS_UNCLE; 
     581                } else if(pVisibleParentPos == POS_CHILD) { 
     582                        vPos = POS_DESC; 
     583                } else if(pVisibleParentPos == POS_COUSIN) { 
     584                        vPos = POS_COUSIN; 
     585                } else if(pVisibleParentPos == POS_CURRENT) { 
     586                        vPos = POS_CHILD; 
     587                } else if(pVisibleParentPos == POS_DESC) { 
     588                        vPos = POS_DESC; 
     589                } else if(pVisibleParentPos == POS_PARENT) { 
     590                        vPos = xIsInMainAxis(pNewAgt, pNewIdx) ? POS_CURRENT : POS_SIBLING; 
     591                } else if(pVisibleParentPos == POS_ROOT) { 
     592                        vPos = xIsInMainAxis(pNewAgt, pNewIdx) ? xGetPosMainAxis(pNewIdx) : POS_UNCLE; 
     593                } else if(pVisibleParentPos == POS_SIBLING) { 
     594                        vPos = POS_CHILD; 
     595                } else { //if(pVisibleParentPos == POS_UNCLE)  
     596                        vPos = POS_COUSIN; 
     597                } 
     598                return vPos; 
     599        } 
    429600} 
  • trunk/Jav_GE/com/scenari/m/ge/agent/pages/HAgentPages.java

    r3325 r7358  
    4141import com.scenari.m.co.agent.IWAgentAvecResultat; 
    4242import com.scenari.m.co.composant.IWComposant; 
     43import com.scenari.m.co.dialog.IHDialog; 
    4344import com.scenari.m.co.instance.IWInstFormation; 
    4445import com.scenari.m.ge.agent.HAgentExport; 
    4546import com.scenari.m.ge.agent.IWADialogExport; 
     47import com.scenari.m.ge.agent.IWAgentOutline; 
    4648import com.scenari.m.ge.generateur.IDynamicFile; 
    4749import com.scenari.m.ge.generateur.IFileModel; 
     
    5153 *   
    5254 */ 
    53 public class HAgentPages extends HAgentExport implements IWAgentAvecResultat { 
     55public class HAgentPages extends HAgentExport implements IWAgentAvecResultat, IWAgentOutline { 
    5456 
    5557    /** 
     
    107109 
    108110    } 
     111 
     112        public boolean isRejected(IHDialog pDialog) { 
     113                return false; 
     114        } 
     115 
     116        public boolean isSkipped(IHDialog pDialog) { 
     117                return false; 
     118        } 
    109119} 
  • trunk/Jav_GE/com/scenari/m/ge/agent/scenario/HAgentScenario.java

    r5339 r7358  
    4747import com.scenari.m.co.instance.IWInstFormation; 
    4848import com.scenari.m.ge.agent.HAgentExport; 
     49import com.scenari.m.ge.agent.IWAgentOutline; 
    4950import com.scenari.m.ge.composant.scenario.WComposantScenario; 
    5051 
     
    5253 *   
    5354 */ 
    54 public class HAgentScenario extends HAgentExport implements IWAgentAvecResultat, IWAgentAvecLiens { 
     55public class HAgentScenario extends HAgentExport implements IWAgentAvecResultat, IWAgentAvecLiens, IWAgentOutline { 
    5556 
    5657    /** 
     
    105106     * spécifique à chaque classe de composant. 
    106107     */ 
    107     public com.scenari.m.co.agent.IWAgent[] hGetAgentsLies(com.scenari.m.co.dialog.IHDialog pDialog, java.lang.Object pCriteres) throws java.lang.Exception { 
     108    public IWAgent[] hGetAgentsLies(IHDialog pDialog, Object pCriteres) throws java.lang.Exception { 
    108109        return hGetAgentsLies(pDialog); 
    109110    } 
     
    113114     * est spécifique à chaque classe de composant. 
    114115     */ 
    115     public com.scenari.m.co.agent.IWAgent[] hGetAgentsLies(java.lang.Object pCriteres) throws java.lang.Exception { 
     116    public IWAgent[] hGetAgentsLies(Object pCriteres) throws java.lang.Exception { 
    116117        return hGetAgentsLies(); 
    117118    } 
     
    120121     *  
    121122     */ 
    122     protected java.lang.Class xGetClassDialog() { 
     123    protected Class xGetClassDialog() { 
    123124        return HDialogScenario.class; 
    124125    } 
     126 
     127        public boolean isRejected(IHDialog pDialog) throws Exception{ 
     128                return false; 
     129        } 
     130 
     131        public boolean isSkipped(IHDialog pDialog) throws Exception { 
     132                return hGetIntitule(pDialog).length() == 0; 
     133        } 
    125134} 
Note: See TracChangeset for help on using the changeset viewer.