#include #include #include #include "projet.h" #include "projetx.m" #include static unsigned *ptselitem=NULL; /* Pr‚sente l'information sur la r‚vision couramment s‚lectionn‚ dans la VERSION::select */ PUBLIC void VERSION_ONE::showinfo() { const char *ptinfo = info; if (ptinfo == NULL) ptinfo = "\n"; DIALOG_TEXTBOX dia; while (*ptinfo != '\0'){ char ligne[800]; char *pt = ligne; if (*info == ';') ptinfo++; while (*ptinfo != '\n' && *ptinfo != '\0') *pt++ = *ptinfo++; if (*ptinfo == '\n') ptinfo++; *pt = '\0'; dia.newf_text ("",ligne); } char verstr[MAXSIZ_REVISION],title[100]; rev.format (verstr); snprintf (title,sizeof(title)-1,MSG_U(T_REVTITLE,"Révision %s"),verstr); int nof = 0; dia.edit (title,"",help_nil,nof); } static void version_add2dia (const VERSION_ONE *one, DIALOG &dia) { char buf1[100],buf2[100]; one->format(buf1,buf2); dia.new_menuitem (buf1,buf2); } /* Retourne information sur une r‚vision sp‚cifique. Retourne NULL si sel invalide. */ PUBLIC VERSION_ONE *VERSION_DAT::get(int sel) { VERSION_ONE *ret = NULL; if (sel >= 0 && sel < list.getnb()){ ret = list.getitem(sel); } return ret; } /* Retourne information sur une r‚vision sp‚cifique. Retourne NULL si trouve pas. */ PUBLIC VERSION_ONE *VERSION_DAT::get( const REVISION *rev, int & noitem) // Contiendra la position de la r‚vision trouv‚ // dans la table (on pourra faire get(noitem) plus tard). // ou -1 si trouve pas. { noitem = -1; VERSION_ONE *ret = NULL; for (int i=0; irev.cmp(rev)==0){ // R‚vision existe ret = one; noitem = i; break; } } return ret; } /* Retourne information sur une r‚vision sp‚cifique. Retourne NULL si trouve pas. */ PUBLIC VERSION_ONE *VERSION_DAT::get(const REVISION *rev) { int noitem; return get (rev,noitem); } /* Retourne le nombre de r‚vision dans la table. */ PUBLIC int VERSION_DAT::getnb() { return list.getnb(); } /* Elimine une r‚vision de la liste version.dat Retourne -1 si trouve pas la r‚vision. */ PUBLIC int VERSION_DAT::delrev(const REVISION *rev) { int ret = -1; for (int i=0; irev.cmp(rev)==0){ // R‚vision existe, on l'efface list.remove_del (i); ret = 0; break; } } return ret; } /* Pr‚paration d'une sous-page pour la s‚lection interactive d'une version. Retourne -1 si erreur. */ PUBLIC int VERSION_DAT::setselect( DIALOG &dia, REVISION_TYPE minsel, // S‚lection de r‚vision ou d'une version. REVISION_TYPE maxsel, // unsigned *selitem, const char *path_check, // Pr‚sente uniquement les r‚vision // d‚j… dans path_check si != NULL int lookup[]) // Correspondance entre le X'ieme item // de la PAGE_PICK et un VERSION_ONE { int ret = -1; char *path_rev[200]; int nbprev = -1; if (path_check != NULL){ nbprev = projet_getrevdir (path_check,path_rev,200); } if (list.getnb() == 0 || nbprev == 0){ xconf_error (MSG_U(E_NOVERSION,"Aucune révision sélectionnable")); }else{ ptselitem = selitem; int nb = 0; setintgstatus(); if (nbprev > 0){ for (int i=0; irev.type(); if (type >= minsel && type <= maxsel){ version_add2dia (one,dia); lookup[nb] = i; nb++; } } } #ifdef MISSING ret = version_setpos (pick,nb); #else ret = 0; #endif } return ret; } /* S‚lection interactive d'une r‚vision d'un projet Retourne NULL si abandon ou erreur. */ PUBLIC VERSION_ONE *VERSION_DAT::select( REVISION_TYPE minsel, // S‚lection de r‚vision ou d'une version. REVISION_TYPE maxsel, // const char *path_check) // Pr‚sente uniquement les r‚vision // d‚j… dans path_check si != NULL { VERSION_ONE *ret = NULL; DIALOG_RECORDS dia; dia.settype (DIATYPE_POPUP); dia.newf_head ("",MSG_U(H_VERSIONS,"Version\tProg\tDate\tRévision")); unsigned selitem = list.getnb()-1; int lookup[list.getnb()]; if (lookup != NULL && setselect (dia,minsel,maxsel,&selitem,path_check,lookup)!=-1){ int nof = dia.getnb()-1; while (1){ MENU_STATUS code = dia.editmenu(MSG_U(T_VERSIONS,"Versions") ,"" ,help_nil ,nof,0); if (code == MENU_QUIT || code == MENU_ESCAPE){ break; }else{ VERSION_ONE *one = list.getitem(lookup[nof]); UISTATE state; diajava_lastmousestate (state); if (state.rightb){ one->showinfo(); }else{ ret = one; break; } } } } return ret; } /* S‚lection d'une version comme version courante pour usager Retourne != 0 si s‚lection valide. */ int version_setmain ( USERINFO *user, const char *path_check) // Pr‚sente uniquement les r‚vision // d‚j… dans path_check si != NULL { int ret = 0; VERSION_DAT version(user); VERSION_ONE *rev = version.select (REVISION_VERSION ,REVISION_LIVRE,path_check); if (rev != NULL && user->setversion (rev)){ // V‚rifie si l'environnement existe pour l'usager ret = 1; } return ret; } /* Enregistre toutes les r‚visions dans un page (de s‚lection) */ PUBLIC void VERSION_DAT::setuppick(DIALOG &dia) { int nb = list.getnb(); setintgstatus(); for (int i=0; i