// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wLabelsPane: // Displays output of the labels command #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wLabelsPane.h" #include "p4wMenuPane.h" p4wLabelsPane::p4wLabelsPane( p4wView & ParentView, p4wRequest & Request ) : p4wPane(ParentView, Request), fSeenBegin(0), fRowCtr(0), fLabelCtr(0), fLfl('\0') { } p4wLabelsPane::~p4wLabelsPane() { } void p4wLabelsPane::Begin() { // // See if we have a dyn arg requesting AC_LABELSPATH const StrPtr *lfl = fRequest.GetDynArg( "lfl" ); if (lfl && (*(lfl->Text()) & 2)) fRequest.SetCmd(AC_LABELSPATH); // // Genenerate the page title, a form to filter labels // by path, and the column headers for the table of labels p4wHtml htm; p4wURL urlMaker; StrBuf grayIcon; StrBuf clearIcon; // // Used to generate a line underneath the title, and // some vertical whitespace urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); htm.comment( "BEGIN LABELS PANE" ); if (fRequest.GetScreenChunks() & SCRN_TITLE) { // Output the title htm.beginTRow(); htm.beginCol(); htm.beginTable(0, 0, "0", "0"); htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << "Labels:"; htm.endSpan(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); // // Generate line underneath the title htm.beginTRow(); htm.beginCol( "top" ); htm.icon( clearIcon.Text(), "2", "1", "", 1 ); htm.linebreak(); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); } fRequest << htm; htm.Clear(); // // Generate the labels filter form if (fRequest.GetScreenChunks() & SCRN_FILTER) doForm(); // // Start the table of labels htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "6", "1", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.beginTable( "0", "100%", "0", "1", "#7F7F7F" ); htm.beginTRow( NULL, NULL, "#FFFFFF" ); htm.beginCol(); htm.beginTable( "0", "100%", "0", "0", "#FFFFFF" ); htm.beginTRow( NULL, NULL, "#EEEEEE" ); htm.beginColHead(); htm.icon( clearIcon.Text(), "18", "18", "", 1 ); htm.endColHead(); // // Generate table headings htm.beginColHead( NULL, "left" ); htm << "Label"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm << "<script language=javascript>" << crlf; htm << "document.write(\"<img src='/clearpixelIcon?ac=20' height='0' width='2' border='0' alt='' title=''>\")" << crlf; htm << "</script>" << crlf; htm << "<noscript>" << crlf; htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm << "</noscript>" << crlf; htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Updated"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Accessed"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Owner"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Description"; htm.endColHead(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top", NULL, "12", NULL, NULL, NULL, "5" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); fRequest << htm; if (lfl) fLfl = *(lfl->Text()); const StrPtr *lnm = fRequest.GetDynArg( "lnm", HE_None ); if (lnm) fLnm << lnm->Text(); const StrPtr *low = fRequest.GetDynArg( "low", HE_None ); if (low) fLow << low->Text(); const StrPtr *ldu = fRequest.GetDynArg( "ldu" ); if (ldu) fLdu << ldu->Text(); const StrPtr *lda = fRequest.GetDynArg( "lda" ); if (lda) fLda << lda->Text(); } void p4wLabelsPane::Render( StrDict * varList ) { // // Build the list entry which contains urls for label & user const char *label = varList->GetVar( "label" )->Text(); const char *user = varList->GetVar( "Owner" )->Text(); if (fLfl & 0x01) { if (!user || strcmp(user, fRequest.GetUser().Text())) return; } if (fLnm.Length()) { if (!label || !strstr(label, fLnm.Text())) return; } if (fLow.Length()) { if (!user || strcmp(user, fLow.Text())) return; } if (fLdu.Length()) { char *p; StrBuf date; date << p4wStrBuf().Expand(StrRef("%Update@*Y/*m/*d%"), *varList, Unicode() ); switch(*(p = fLdu.Text())) { case '_': if (strncmp(date.Text(), p+1, strlen(p+1)) != 0) return; break; case '-': if (fLdu.Length() == 11 ) { if (strcmp(date.Text(), p+1) >= 0) { return; } } else if (strcmp(date.Text(), p+1) > 0) { return; } break; default: if (fLdu.Length() == 10 ) { if (strcmp(date.Text(), p) < 0) { return; } } else if (strncmp(date.Text(), p, strlen(p)) < 0) { return; } break; } } if (fLda.Length()) { char *p; StrBuf date; date << p4wStrBuf().Expand(StrRef("%Access@*Y/*m/*d%"), *varList, Unicode() ); switch(*(p = fLda.Text())) { case '_': if (strncmp(date.Text(), p+1, strlen(p+1)) != 0) return; break; case '-': if (fLda.Length() == 11 ) { if (strcmp(date.Text(), p+1) >= 0) { return; } } else if (strcmp(date.Text(), p+1) > 0) { return; } break; default: if (fLda.Length() == 10 ) { if (strcmp(date.Text(), p) < 0) { return; } } else if (strncmp(date.Text(), p, strlen(p)) < 0) { return; } break; } } StrBuf labelURL; StrBuf userURL; p4wHtml htm(1); StrBuf newBase; p4wURL urlMaker; StrBuf clearIcon; // // We have at least one label in the list fSeenBegin = 1; // // Used to generate some vertical whitespace urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; // // Build the label URL fRequest.UseNewBase( newBase, NULL, "path", NULL ); newBase << label; urlMaker.ConstructURL( labelURL, newBase.Text(), AC_LABELVIEW, NULL, fRequest.GetUnicode() ); // // Build the user URL fRequest.UseNewBase( newBase, NULL, "path", NULL ); newBase << user; urlMaker.ConstructURL( userURL, newBase.Text(), AC_USERVIEW, NULL, fRequest.GetUnicode() ); // // Save off the Options StrBuf options; options << p4wStrBuf().Expand(StrRef("%Options% "), *varList, Unicode() ).Text(); // // Begin the row for this label htm.beginTRow( "top", 0, 0, (fRowCtr & 0x01) ? "list_row alt_row" : "list_row" ); htm.beginCol(); htm.endCol(); // // Label htm.beginCol(0,0,0,0,0,0,0,1); htm.beginLink( labelURL.Text() ); htm.text( p4wStrBuf().EscapeHTML( StrRef(label), Unicode() ).Text() ); htm.endLink(); htm << crlf; htm << "<script language=javascript>" << crlf; htm << "document.write(\"<span class='muaro'><a href='javascript:showMenu(\\\""; htm << p4wStrBuf().EscapeHTML( StrRef(label), Unicode() ).Text(); htm << "\\\",\\\"m"; htm << fLabelCtr; htm << "\\\",\\\"label\\\","; if (strcmp(user, fRequest.GetUser().Text()) && !strstr(options.Text(), "unlocked")) // other user & locked? htm << p4wMenuPane::GetLockedLabelMenuShowVals(); else htm << -1; htm << ",\\\"\\\")' id='id_m"; htm << fLabelCtr++; htm << "' title ='Menu'>"; htm << " "; htm << "</a></span>"; htm << "\")" << crlf; htm << "</script>" << crlf; htm.endCol(); htm.beginCol(); htm.endCol(); // // Update Date htm.beginCol(); htm.text( p4wStrBuf().Expand( StrRef( "%Update@*Y/*m/*d%" ), *varList, Unicode() ).Text() ); htm.endCol(); htm.beginCol(); htm.endCol(); // // Access Date htm.beginCol(); StrPtr *access = varList->GetVar("Access"); if (access && *(access->Text()) != '0') { htm.text( p4wStrBuf().Expand(StrRef("%Access@*Y/*m/*d% "), *varList, Unicode() ).Text() ); } htm.endCol(); htm.beginCol(); htm.endCol(); // // User htm.beginCol(); htm.beginLink( userURL.Text() ); htm.text( p4wStrBuf().EscapeHTML( StrRef(user), Unicode() ).Text() ); htm.endLink(); htm.endCol(); htm.beginCol(); htm.endCol(); // // Description htm.beginCol(); StrBuf buf; buf.Set( p4wStrBuf().Expand( StrRef( "%Description%" ), *varList, Unicode() ).Text() ); if (buf.Length() > 4096) *(buf.Text() + 4096) = '\0'; htm.text( buf.Text() ); htm.endCol(); htm.endTRow(); // // Vertical space between rows htm.beginTRow( 0, 0, 0, (fRowCtr++ & 0x01) ? "alt_row b" : "b" ); htm.beginCol( 0, 0, "100%" ); htm.icon( clearIcon.Text(), "3", "1", "", 1 ); htm.endCol(); htm.endTRow(); fRequest << htm; } void p4wLabelsPane::End() { // // End the "Labels" list. p4wHtml htm; p4wURL urlMaker; StrBuf clearIcon; // // Used to generate some vertical whitespace urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); if( !fSeenBegin ) { htm.beginTRow(); htm.beginCol(); htm.endCol(); htm.beginCol( NULL, NULL, "4" ); htm.text( "No labels found." ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "5", "0", "", 1 ); htm.endCol(); htm.endTRow(); } // // End the pane. htm.endForm(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.comment( "END LABELS PANE" ); fRequest << htm; } void p4wLabelsPane::doForm() { // // Generate the labels filter form p4wHtml htm; p4wURL urlMaker; StrBuf actionURL; StrBuf path; StrBuf clearIcon; char *p; const StrPtr *lfl = fRequest.GetDynArg( "lfl", HE_Page ); const StrPtr *lnm = fRequest.GetDynArg( "lnm", HE_Page ); const StrPtr *low = fRequest.GetDynArg( "low", HE_Page ); const StrPtr *ldu = fRequest.GetDynArg( "ldu", HE_Page ); const StrPtr *lda = fRequest.GetDynArg( "lda", HE_Page ); // // Used to generate some whitespace urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Some browsers will truncate the path from the BASE // if the path does not end in a forward slash. So if // we're in workspace mode, use the full path as a precaution. if( fRequest.GetViewMode() == VM_WORKSPACE ) fRequest.UseNewBase( path, NULL, "path", fRequest.GetPath().Text() ); else path << fRequest.GetURL(); fRequest.ConstructSafeURL( actionURL, path.Text(), AC_LABELSPROCESSOR, NULL ); htm.beginTRow(); htm.beginCol(); fRequest << htm; htm.Clear(); StrBuf filtermsg; doFilterMessage(&filtermsg); fRequest.doShowHideBlock(SH_LABELS, "label filter", "Label Filter", filtermsg.Text()); htm.endCol(); htm.endTRow(); // // Start a DIV for showing/hiding the filter htm.beginTRow(); htm.beginCol(); htm << "<script language=javascript>" << crlf; htm << "document.write(\"<div id='showhideBlock'>\")" << crlf; htm << "</script>" << crlf; htm.beginTable(0, "100%", "0", "0"); // // Start the tables with the form htm.beginTRow(); htm.beginCol(); if( fRequest.GetJavascriptMode() != 2) htm.icon( clearIcon.Text(), "5", "1", "", 1 ); htm.beginForm( actionURL.Text() ); htm.beginTable( "0", "100%", "2", "0", "#FFFFFF" ); // // Top row of filter htm.beginTRow(); htm.beginCol(0,0,0,"100%"); htm.icon( clearIcon.Text(), "1", "14", "", 1 ); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.label("Label name contains:", "lnm"); htm.endCol(); htm.beginCol(); htm.textField("lnm", lnm && lnm->Length() ? lnm->Text() : 0, 0, "lnm"); htm.endCol(); htm.beginCol(); htm.icon( clearIcon.Text(), "1", "50", "", 1 ); htm.endCol(); htm.beginCol(); htm.text("Updated:"); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.radio("Updated", "on", ldu && *(ldu->Text()) == '_', 0, "uon"); htm.label("on ", "uon"); htm.radio("Updated", "before", ldu && *(ldu->Text()) == '-', 0, "ub4"); htm.label("before ", "ub4"); htm.radio("Updated", "after", !ldu || (*(ldu->Text()) != '_' && *(ldu->Text()) != '-'), 0, "uaf"); htm.label("after ", "uaf"); htm.endCol(); htm.beginCol(); if (ldu && ldu->Length()) { p = ldu->Text(); if (*p == '-' || *p == '_') p++; } else p = NULL; htm.textField("ldu", p ? p : 0, 0, "ldu", 0, "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')"); if (!p) { htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('ldu');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; } htm.endCol(); htm.beginCol(0,0,0,0,0,"100%"); htm.endCol(); htm.endTRow(); // // 2nd row of filter htm.beginTRow(); htm.beginCol(0,0,0,0,0,0,0,1); htm.label("Owner:", "low"); htm.endCol(); htm.beginCol(); if (lfl && (lfl->Atoi() & 1)) htm.textField("low", p4wStrBuf().EscapeHTML(fRequest.GetUser(), Unicode()).Text(), 0, "low"); else htm.textField("low", low && low->Length() ? low->Text() : 0, 0, "low"); htm.endCol(); htm.beginCol(); htm.endCol(); htm.beginCol(); htm.text("Accessed:"); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.radio("Accessed", "on", lda && *(lda->Text()) == '_', 0, "aon"); htm.label("on ", "aon"); htm.radio("Accessed", "before", lda && *(lda->Text()) == '-', 0, "ab4"); htm.label("before ", "ab4"); htm.radio("Accessed", "after", !lda || (*(lda->Text()) != '_' && *(lda->Text()) != '-'), 0, "aft"); htm.label("after ", "aft"); htm.endCol(); htm.beginCol(); if (lda && lda->Length()) { p = lda->Text(); if (*p == '-' || *p == '_') p++; } else p = NULL; htm.textField("lda", p ? p : 0, 0, "lda", 0, "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')"); if (!p) { htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('lda');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; } htm.endCol(); htm.endTRow(); // // Checkbox for displaying only labels in this path htm.beginTRow(); htm.beginCol(0,0,"100%",0,0,0,0,1); if( fRequest.GetCmd() == AC_LABELSPATH || (lfl && (lfl->Atoi() & 2))) htm.checkbox( "AllC", "n", 1 ); else htm.checkbox( "AllC", "n" ); htm.label( "Include only labels with files in current path", "AllC" ); htm.endCol(); htm.endTRow(); // // Filter button htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "5", "1", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0,0,"100%",0,0,0,0,1); htm.button( "Show", "Filter" ); // // Clear button htm.button( "Clear", "Reset Defaults" ); htm.endCol(); htm.endTRow(); htm.endTable(); StrBuf grayIcon; urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); htm.icon( clearIcon.Text(), "10", "100%", "", 1, "0", "0" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); htm.endCol(); htm.endTRow(); htm.endTable(); htm << "<script language=javascript>" << crlf; htm << "document.write(\"</div>\")" << crlf; htm << "</script>" << crlf; fRequest << htm; } void p4wLabelsPane::doFilterMessage(StrBuf *msg) { const StrPtr *lfl = fRequest.GetDynArg( "lfl", HE_Page ); const StrPtr *lnm = fRequest.GetDynArg( "lnm", HE_Page ); const StrPtr *low = fRequest.GetDynArg( "low", HE_Page ); const StrPtr *ldu = fRequest.GetDynArg( "ldu", HE_Page ); const StrPtr *lda = fRequest.GetDynArg( "lda", HE_Page ); if (lnm) *msg << "(Name contains: "" << lnm->Text() << """; char *p = NULL; if (lfl && (lfl->Atoi() & 1)) p = p4wStrBuf().EscapeHTML( fRequest.GetUser(), Unicode() ).Text(); else if (low) p = low->Text(); if (p) { if (*(msg->Text())) *msg << "; Owner: "; else *msg << "(Owner: "; *msg << """ << p << """; } if (fRequest.GetCmd() == AC_LABELSPATH || (lfl && (lfl->Atoi() & 2))) { if (*(msg->Text())) *msg << "; "; else *msg << "("; *msg << "Limit to current path"; } if (ldu) { if (*(msg->Text())) *msg << "; Updated "; else *msg << "(Updated "; switch(*(ldu->Text())) { case '-': if (ldu->Length() < 11) *msg << "on or"; *msg << " before"; p = ldu->Text()+1; break; case '_': if (ldu->Length() < 11) *msg << "in"; else *msg << "on"; p = ldu->Text()+1; break; default: if (ldu->Length() < 10) *msg << "in or"; *msg << " after"; p = ldu->Text(); break; } *msg << ": " << p; } if (lda) { if (*(msg->Text())) *msg << "; Accessed "; else *msg << "(Accessed "; switch(*(lda->Text())) { case '-': if (lda->Length() < 11) *msg << "on or"; *msg << " before"; p = lda->Text()+1; break; case '_': if (lda->Length() < 11) *msg << "in"; else *msg << "on"; p = lda->Text()+1; break; default: if (lda->Length() < 10) *msg << "in or"; *msg << " after"; p = lda->Text(); break; } *msg << ": " << p; } if (*(msg->Text())) *msg << ")"; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12234 | Matt Attaway |
Rejigger P4Web project in preparation for official sunsetting The bin directory contains the last official builds of P4Web from the Perforce download site. P4Web is soon to be completely sunsetted; these builds are here for folks who don't want to build their own. To better handle the archived builds the source code has been moved into a separate src directory. |
||
//guest/perforce_software/p4web/Panes/p4wLabelsPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |