// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wEditPane: // Construct a form used to send an edit command #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wEditPane.h" p4wEditPane::p4wEditPane( p4wView & ParentView, p4wRequest & Request, int isFileBrowser ) : p4wRunPane( ParentView, Request ), fIsFileBrowser(isFileBrowser), fState(gettingchanges), fSeenBegin(0), fGotOneChange(0), fGotOneFile(0) { } p4wEditPane::~p4wEditPane() { } // ------------------------------------- // Render functions. // void p4wEditPane::Begin() { if( fSeenBegin ) { return; } // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); // // Begin the pane. DoComment( "BEGIN EDIT PANE" ); BeginForm( "Open for Edit:", actionURL ); fSeenBegin = 1; // // Start the Options segment BeginOptions(); } void p4wEditPane::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 ) { DoCheckbox( 0, 0, "OptionChg", "changelist", "Put opened files in changelist", 1, 0, 1 ); BeginSelect( "changelistVal", "setCheckedValue(document.forms['Run'].elements['OptionChg'], 'changelist')" ); DoOption( "default" ); fGotOneChange = 1; } DoOption( varList->GetVar("change")->Text() ); } else if( fState == gettingfiles ) { // // Skip files already opened UNLESS user specifically chose this file. // Also skip files deleted at head revision unless we have it. if( !fIsFileBrowser ) { StrPtr * action = varList->GetVar( "action" ); StrPtr * haveRev = varList->GetVar( "haveRev" ); StrPtr * headAction = varList->GetVar( "headAction" ); if( action != NULL ) return; if( !haveRev && ( *headAction == "delete" ) ) return; } if( !fGotOneFile && !fIsFileBrowser ) { FilesIn( 0, 0, fRequest.GetPath().Text(), NULL ); BeginSelected( 1, FilesUnchecked() ); fGotOneFile = 1; } StrPtr *depotFile = varList->GetVar( "depotFile" ); StrPtr *clientFile = varList->GetVar( "clientFile" ); StrPtr *type = varList->GetVar( "type" ); StrPtr *headType = varList->GetVar( "headType" ); StrPtr *headRev = varList->GetVar( "headRev" ); StrPtr *haveRev = varList->GetVar( "haveRev" ); // // If clientFile isn't available use depotFile instead if( !clientFile ) clientFile = depotFile; // // Construct the have/head revision, file type string // which is displayed with the filename StrBuf filetype; const char *ftype = NULL; if( headRev && headType ) { filetype << "#"; if( haveRev ) filetype << haveRev->Text() << "/"; else filetype << "0" << "/"; filetype << headRev->Text() << " "; filetype << headType->Text(); ftype = filetype.Text(); } if( !fIsFileBrowser ) { // // 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, depotFile, ftype ); } else { if( fGotOneChange ) DoCheckbox( 1, 0, "OptionFt", "filetype", "Change filetype:", 1, 1, 1 ); else DoCheckbox( 0, 0, "OptionFt", "filetype", "Change filetype:", 1, 1, 1 ); if( type ) { DoFileType( 1, type->Text() ); } else if( headType ) { DoFileType( 1, headType->Text() ); } else { DoFileType( 1, "text" ); } BeginFiles( fRequest.GetPath() ); DoListItem( depotFile->Text(), 0, ftype ); DoHidden( 1, "File", depotFile->Text() ); } } } void p4wEditPane::End() { switch( fState ) { case gettingchanges: { // // End the Option select box if( fGotOneChange ) EndSelect(); // // Pathbrowser: display the filetype options and // start the Files section. If this is a Filebrowser // page, defer this until after we find out the file // type so we can fill out the file type options correctly. if( !fIsFileBrowser ) { if( fGotOneChange ) DoCheckbox( 1, 0, "OptionFt", "filetype", "Change filetype:", 1, 1, 1 ); else DoCheckbox( 0, 0, "OptionFt", "filetype", "Change filetype:", 1, 1, 1 ); DoFileType( 1, "text" ); // // Generate the Files portion. BeginFiles( fRequest.GetPath() ); } fState = gettingfiles; if( FatalError() ) { // // End the pane. BeginButtons(); DoHidden( 0, "formActions", "edit" ); DoHidden( 0, "formActions", "redisplay" ); DoButton( "edit", "Open for edit" ); EndButtons(); EndForm(); DoComment( "END EDIT PANE" ); fState = done; } } break; case gettingfiles: { // // End the Files list if we had one. Other // choices have already been rendered. if( fGotOneFile ) { EndFiles(); // // Pathbrowser at the top directory level has only // one choice: all files in view, so hard-code it. } else if( !fIsFileBrowser && 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 if( !fIsFileBrowser ) { FilesIn( 0, 1, fRequest.GetPath().Text(), NULL ); } // // End the pane. BeginButtons(); DoHidden( 0, "formActions", "edit" ); DoHidden( 0, "formActions", "redisplay" ); DoButton( "edit", "Open for edit" ); EndButtons(); EndForm(); DoComment( "END EDIT PANE" ); fState = done; } default: break; } } void p4wEditPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( AC_EDITPROCESSOR, NULL, 1, actionURL ); } void p4wEditPane::HandleError( Error *err ) { // // Override this because we want to ignore most fstat errors when invoked // from the path browser. If this was invoked from the file browser, output // the error and set the File variable in case user submits the form anyway. if( !fIsFileBrowser ) { DoHandleError( err, 1 ); } else { DoHandleError( err, 0 ); fGotOneFile = 1; DoHidden( 1, "File", fRequest.GetPath().Text() ); } }
# | 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/p4wEditPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |