// // Copyright 1999 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wRevertPane: // Generates a form used for constructing a revert command #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wRevertPane.h" p4wRevertPane::p4wRevertPane( p4wView & ParentView, p4wRequest & Request ) : p4wRunPane( ParentView, Request ), fState(gettingchanges), fSeenBegin(0), fGotOneChange(0), fGotOneFile(0) { } p4wRevertPane::~p4wRevertPane() { } // ------------------------------------- // Render functions. // void p4wRevertPane::Begin() { if( fSeenBegin ) { return; } // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); // // Begin the pane. DoComment( "BEGIN REVERT PANE" ); BeginForm( "Revert:", actionURL ); // // Start the Options segment BeginOptions(); DoCheckbox( 0, 0, "OptionUnch", "unchanged", "Restrict to unchanged files", 1, 1, 1 ); fSeenBegin = 1; } void p4wRevertPane::Render( StrDict * varList ) { if( fState == gettingchanges ) { // 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( "Restrict to changelist", 1 ); fGotOneChange = 1; } DoOption( varList->GetVar( "change" )->Text() ); } else if( fState == gettingfiles ) { if( !fGotOneFile ) { // // If we are at the // directory, the // Files in subdirectory/this level only // choices are either redundant or useless, // so replace them with one choice for // all opened files. if( fRequest.GetPath() == "//" ) DoRadio( 0, 0, "Files", "all", "All Files", 0, 0, "Filesin" ); else FilesIn( 1, 0, fRequest.GetPath().Text(), "All Files", 1 ); BeginSelected( 1, FilesUnchecked() ); fGotOneFile = 1; } StrPtr *depotFile = varList->GetVar( "depotFile" ); StrPtr *clientFile = varList->GetVar( "clientFile" ); StrPtr *action = varList->GetVar( "action" ); StrBuf fileText; // // If clientFile isn't available use depotFile instead if( !clientFile ) clientFile = depotFile; fileText << depotFile << " " << action; // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; // // Display depotFile in form, but send clientFile // in command for performance reasons. DoFile( !FilesUnchecked(), clientFile, &fileText ); } } void p4wRevertPane::End() { switch( fState ) { case gettingchanges: { // // End the Option select box EndSelect(); // // Generate the Files portion. BeginFiles( fRequest.GetPath() ); fState = gettingfiles; } break; case gettingfiles: { // // End the Files list if we had one. Other // choices were rendered earlier. if( fGotOneFile ) { EndFiles(); // // Pathbrowser at the top directory level has only // one choice: all files in view, so hard-code it. } else if( fRequest.GetPath() == "//" ) { DoListItem( "All files in //..." ); DoHidden( 0, "Files", "in" ); DoHidden( 0, "dirVal", "and subdirectories" ); // // Pathbrowser not at top directory: show options // of Files in this path and files in this path and // subdirectories } else { FilesIn( 1, 1, fRequest.GetPath().Text(), "All Files", 1 ); } // // Generate the buttons BeginButtons(); DoHidden( 0, "formActions", "revert" ); DoHidden( 0, "formActions", "redisplay" ); // // The preview button requires checking the protocol // level of the server to find out if it's supported. const StrPtr *srv = fRequest.GetProtocol( "server2" ); if( srv && srv->Atoi() > 13 ) { DoHidden( 0, "formActions", "preview" ); DoButton( "preview", "Preview Revert" ); } // // Revert button DoButton( "revert", "Revert" ); EndButtons(); // // End the pane. EndForm(); DoComment( "END REVERT PANE" ); fState = done; } default: break; } } void p4wRevertPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( AC_REVERTPROCESSOR, NULL, 1, actionURL ); } void p4wRevertPane::HandleError( Error *err ) { // // Override this because we want to ignore most fstat errors DoHandleError( err, 1 ); }
# | 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/p4wRevertPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |