// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wAddPane: // Construct the final add form #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wAddPane.h" p4wAddPane::p4wAddPane( p4wView & ParentView, p4wRequest & Request, int isFile, int unchecked ) : p4wRunPane( ParentView, Request, unchecked ), fGotOneChange(0), fState(gettingchanges), fNFiles(0), fNAlreadyInP4(0), fIsFileBrowser(isFile) { fNeedsTRTD = 0; } p4wAddPane::~p4wAddPane() { } // ------------------------------------- // Render functions. // void p4wAddPane::Begin() { // // Only the first state (getting the list of changes) is // processed here. if( fState != gettingchanges ) return; // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); // // Begin the pane. DoComment( "BEGIN ADD PANE" ); BeginForm( "Open for Add:", actionURL ); // // Start the Options segment BeginOptions(); } void p4wAddPane::Render( StrDict * varList ) { // // This is called for the list of changes, and also for the fstats used for // the list of files to add. If we are processing fstats from the path // browser, filter out files in the depot unless they have been deleted // from the depot (and are therefore eligible to be re-added). if( fState == gettingfiles ) { StrPtr *depotFile = varList->GetVar( "clientFile" ); StrPtr *headAction = varList->GetVar( "headAction" ); if( fIsFileBrowser ) { // // We can only get here if this file // was detected in the depot. We only want // to show this file as available to be opened // if the file was deleted at head revision. if( headAction && ( *headAction == "delete" || *headAction == "move/delete" ) ) { ++fNFiles; DoListItem( depotFile->Text(), 0 ); DoHidden( 1, "File", depotFile->Text() ); } } else { StrPtr * haveRev = varList->GetVar("haveRev"); if( headAction && ( *headAction == "delete" || *headAction == "move/delete" ) ) { ++fNFiles; // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; DoFile( !FilesUnchecked(), depotFile, depotFile ); } else ++fNAlreadyInP4; } return; } // Get the user/client information. Ignore changes that are // not by this user/client. StrPtr *noCase = fRequest.GetProtocol( "nocase" ); StrPtr *owner = varList->GetVar( "user" ); const char * client = varList->GetVar( "client" )->Text(); int notOwner = 0; if( ( noCase && owner->CCompare( fRequest.GetUser() ) ) || ( !noCase && owner->XCompare( fRequest.GetUser() ) ) ) notOwner = 1; if( notOwner || strcmp( client, fRequest.GetClient().Text() ) ) return; if( !fGotOneChange ) { BeginOptionChange( "Put opened files in changelist", 0, 0 ); fGotOneChange = 1; } DoOption( varList->GetVar( "change" )->Text() ); } void p4wAddPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( AC_ADDPROCESSOR, NULL, 1, actionURL ); } void p4wAddPane::End() { if( fState == gettingchanges ) { // // End the Option select box if( fGotOneChange ) { EndSelect(); DoCheckbox( 1, 0, "OptionFt", "filetype", "Specify filetype:", 1, 1, 1 ); } else { DoCheckbox( 0, 0, "OptionFt", "filetype", "Specify filetype:", 1, 1, 1 ); } // // Generate the "Specify filetype" section DoFileType( 1, "text" ); // // Generate the Files portion. BeginFiles( fRequest.GetPath() ); if( FatalError() ) { BeginButtons(); DoButton( "add", "Open for add" ); EndButtons(); EndForm(); DoComment( "END ADD PANE" ); return; } fState = gettingfiles; } else { // // End the pane. if( !fNFiles ) { StrBuf errMsg; if( !fIsFileBrowser ) errMsg << "No new files found in " << p4wStrBuf().EscapeHTML(fRequest.GetPath(), Unicode()).Text() << "."; else errMsg << p4wStrBuf().EscapeHTML(fRequest.GetPath(), Unicode()).Text() << ": can't add existing file."; RenderError( errMsg.Text(), 1 ); } if( fNAlreadyInP4 ) { StrBuf errMsg; char buf[40]; sprintf(buf, "<br>%d existing file", fNAlreadyInP4); errMsg.Set( buf ); if (fNAlreadyInP4 > 1) errMsg << "s"; errMsg << " cannot be added."; RenderError( errMsg.Text(), 0 ); } BeginButtons(); DoButton( "add", "Open for add" ); EndButtons(); EndForm(); DoComment( "END ADD PANE" ); } } void p4wAddPane::HandleError( Error *err ) { // // Files eligible for add exhibit "no such file" warning. These // are the files we will put on the form. if( err->GetSeverity() == E_WARN && err->GetGeneric() == EV_EMPTY ) { StrBuf errMsg; StrBuf origErr; // // If the server supports special characters in filenames, // we need to un-escape any characters that have been // escaped for the previous fstats const StrPtr *server = fRequest.GetProtocol( "server2" ); if( server && server->Atoi() > 17 ) { err->Fmt( &origErr ); errMsg.Set( p4wStrBuf().UnescapeP4Chars( origErr ).Text() ); } else { err->Fmt( &errMsg ); } char *e = strstr( errMsg.Text(), "- no such file" ); char *c = strstr( errMsg.Text(), "- file(s) not in client" ); if( e || c ) { StrBuf filename; if( e ) filename.Set( errMsg.Text(), e - errMsg.Text() - 1 ); else filename.Set( errMsg.Text(), c - errMsg.Text() - 1 ); // // Output this file with a checkbox ++fNFiles; if( !fIsFileBrowser ) { // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; DoFile( !FilesUnchecked(), &filename, &filename ); } else { DoListItem( filename.Text(), 0 ); DoHidden( 1, "File", filename.Text() ); } return; } } // // Override this because we want to ignore most fstat errors DoHandleError( err, 1 ); } void p4wAddPane::EndPage() { // // This may be called by the View class to end the page // when no files were chosen. EndForm(); DoComment( "END ADD PANE" ); }
# | 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/p4wAddPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |