// Copyright 2001 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wLabelFilesPane: // Displays output of the files @label command #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wLabelFilesPane.h" p4wLabelFilesPane::p4wLabelFilesPane( p4wView & ParentView, p4wRequest & Request ) : p4wPane( ParentView, Request ), fOverflowMsg(0) { } p4wLabelFilesPane::~p4wLabelFilesPane() { } void p4wLabelFilesPane::Begin() { // // Begin the pane. p4wHtml htm; StrBuf title; 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 LABELFILES PANE" ); title << "View Files in Label " << p4wStrBuf().EscapeHTML( fRequest.GetURL(), Unicode() ).Text() << ":"; htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << title; htm.endSpan(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "20", "0", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.beginDList(); htm.dListTag(); fRequest << htm; } void p4wLabelFilesPane::RenderInfo( char *data, char level ) { // // Output the list of files in the label ( files @label cmd ). // This callback is used for servers older than 2002.1 which // use OutputInfo() rather than OutputStat(). if( !PageLimitExceeded() ) { p4wHtml htm; htm.dListVal(); char *endChar = strstr( data, " - " ); *endChar = '\0'; htm.text( p4wStrBuf().EscapeHTML( StrRef ( data ), Unicode() ).Text() ); fRequest << htm; } } void p4wLabelFilesPane::Render( StrDict *varList ) { // // Output the list of files in the label (files @label cmd). // This callback is used for post-2002.1 servers which // use tagged output (OutputStat vs OutputInfo). StrPtr *rev = varList->GetVar( "rev" ); StrPtr *depotFile = varList->GetVar( "depotFile" ); if( !PageLimitExceeded() ) { p4wHtml htm(1); p4wURL urlMaker; StrBuf url, url2; StrBuf newBase; StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Fetch some information about this file. StrPtr *action = varList->GetVar("action"); StrPtr *rev2 = varList->GetVar("rev"); StrPtr *depotFile = varList->GetVar("depotFile"); StrPtr *type = varList->GetVar("type"); // // Build the base URL if( fRequest.GetViewMode() != VM_WORKSPACE ) { fRequest.ConstructSafeURL( url, depotFile->Text() + 2, AC_BROWSEFILE, NULL ); } else { fRequest.UseNewBase( newBase, NULL, "md", "d" ); fRequest.UseNewBase( newBase, newBase.Text(), "cd", "//" ); fRequest.UseNewBase( newBase, newBase.Text(), "wr", NULL ); fRequest.UseNewBase( newBase, newBase.Text(), "path", depotFile->Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_BROWSEFILE, NULL, fRequest.GetUnicode() ); } htm.dListVal(); if (fRequest.GetCmd() != AC_LABELFILESTEXT) { int isWriteable; if( type && ( strstr(type->Text(), "text") || strstr(type->Text(), "symlink") || strstr(type->Text(), "unicode") || strstr(type->Text(), "utf16") ) ) { isWriteable = 1; } else { isWriteable = 0; } int doDiff = 0; int revNo = atoi( rev->Text() ); int doText = ( isWriteable && ( strcmp( action->Text(), "delete" ) ) ); if( ( revNo > 1 ) && ( ( !strcmp( action->Text(), "edit" ) ) || ( !strcmp( action->Text(), "integrate" ) ) ) ) doDiff = 1; if( doText ) { StrBufDict tempArgs; tempArgs.SetVar( "rev1", varList->GetVar("rev") ); if( fRequest.GetViewMode() == VM_WORKSPACE ) { urlMaker.ConstructURL( url2, newBase.Text(), AC_FILETEXTDEPOT, &tempArgs, fRequest.GetUnicode() ); } else { fRequest.ConstructSafeURL( url2, depotFile->Text() + 2, AC_FILETEXTDEPOT, &tempArgs ); } StrBuf textIcon; urlMaker.ConstructIcon( textIcon, "/showtextsmallIcon", 18, 25, "View file text", 1, "absmiddle" ); htm.beginLink( url2.Text(), NULL, NULL, NULL, "View file text" ); htm << textIcon; htm.endLink(); } else htm.icon( clearIcon.Text(), "18", "25", "", 1, 0, 0, "absmiddle" ); if (doDiff) { p4wStrBuf rev1; rev1 << ( revNo - 1 ); StrPtr * rev2 = varList->GetVar("rev"); StrBufDict args; args.SetVar( "rev1", rev1 ); args.SetVar( "rev2", rev2 ); if( fRequest.GetViewMode() == VM_WORKSPACE ) { urlMaker.ConstructURL( url2, newBase.Text(), AC_DIFF2, &args, fRequest.GetUnicode() ); } else { fRequest.ConstructSafeURL( url2, depotFile->Text() + 2, AC_DIFF2, &args ); } StrBuf altText; StrBuf diffIcon; altText.Set( "Diff rev #" ); altText << rev1 << " vs. rev #" << rev2; urlMaker.ConstructIcon( diffIcon, "/rundiffprevsmallIcon", 18, 25, altText.Text(), 1, "absmiddle" ); htm.beginLink( url2.Text() ); htm << diffIcon; htm.endLink(); } else htm.icon( clearIcon.Text(), "18", "25", "", 1, 0, 0, "absmiddle" ); // Output this entry & url htm.beginLink( url.Text() ); } htm << p4wStrBuf().EscapeHTML( *depotFile, Unicode() ); if (fRequest.GetCmd() != AC_LABELFILESTEXT) htm.endLink(); htm << "#" << p4wStrBuf().EscapeHTML( *rev, Unicode() ); htm << crlf; fRequest << htm; } else if (!fOverflowMsg) { fOverflowMsg = 1; p4wHtml htm(1); p4wURL urlMaker; StrBuf url; StrBuf newBase; htm.linebreak(); fRequest.UseNewBase( newBase, NULL, "path", fRequest.GetURL().Text() ); urlMaker.ConstructURL( url, newBase.Text(), AC_LABELFILESTEXT, NULL, fRequest.GetUnicode() ); htm.beginLink(url.Text()); htm << "Redisplay the files as a simple text list"; htm.endLink(); fRequest << htm; } } void p4wLabelFilesPane::End() { // // End the pane p4wHtml htm; htm.endDList(); htm.endCol(); htm.endTRow(); htm.comment( "END LABELFILES PANE" ); fRequest << htm; } void p4wLabelFilesPane::RenderError( char *data, int escapeHTML ) { RenderErrorList( data, escapeHTML ); }
# | 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/p4wLabelFilesPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |