// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wFTypePane: // Construct a form used to send a reopen command to change file type #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wFTypePane.h" // ------------------------------------- // Constructors and destructor. // p4wFTypePane::p4wFTypePane( p4wView & ParentView, p4wRequest & Request, int isFileBrowser ) : p4wRunPane( ParentView, Request ), fIsFileBrowser(isFileBrowser), fSeenBegin(0), fGotOneFile(0), fGotError(0) { } p4wFTypePane::~p4wFTypePane() { } // ------------------------------------- // Render functions. // void p4wFTypePane::Begin() { if( fSeenBegin ) { return; } // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); // // Begin the pane. DoComment( "BEGIN FILE TYPE PANE" ); BeginForm( "Change Filetype:", actionURL ); // // Generate the Options section BeginOptions(); // // If this is a single file rather than a directory, // defer rendering the file type dialog until we know // the file type. Otherwise just render it now for // a directory. if( !fIsFileBrowser ) { DoFileType( 0, "text" ); // // Start the Files section BeginFiles( fRequest.GetPath() ); } fSeenBegin = 1; } void p4wFTypePane::Render( StrDict * varList ) { // // Generates entries in the Files section. If path browser, use a // list of files with checkboxes; otherwise just output the one // file from the file browser. if( !fGotOneFile && !fIsFileBrowser ) { // // 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", "in", "All opened files", 0, 0, "Filesin" ); DoHidden( 0, "dirVal", "and subdirectories" ); } else { 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(); if( type && *type != *headType ) filetype << ", opened as " << type; ftype = filetype.Text(); } else if( type ) { filetype << "opened as " << type; 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 { // // Display checkboxes and radio buttons to help // user change the file type if( type ) { DoFileType( 0, type->Text() ); } else if( headType ) { DoFileType( 0, headType->Text() ); } else { DoFileType( 0, "text" ); } // // Start the Files section BeginFiles( fRequest.GetPath() ); DoListItem( depotFile->Text(), 0, ftype ); DoHidden( 1, "File", depotFile->Text() ); } } void p4wFTypePane::End() { // // 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 ); } // // Reopen button only if we didn't get an error when trying // to fstat the file. if( !fGotError ) { BeginButtons(); DoHidden( 0, "formActions", "reopen" ); DoHidden( 0, "formActions", "redisplay" ); DoButton( "reopen", "Change Filetype" ); EndButtons(); } // // End the pane. EndForm(); DoComment( "END FILE TYPE PANE" ); } void p4wFTypePane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( AC_FTYPEPROCESSOR, NULL, 1, actionURL ); } void p4wFTypePane::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, // generate the error and set a flag so that we don't display the // button if( !fIsFileBrowser ) { DoHandleError( err, 1 ); } else { DoHandleError( err, 0 ); fGotError = 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/p4wFTypePane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |