// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wSyncPane: // Generates a form for performing a sync #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wSyncPane.h" #include "p4wMenuPane.h" // // Options for sync static char *const syncOpts[] = { "default", "rev", "atChange", "at", "have" }; static char *const syncOptsText[] = { "Head Revision", "Revision Number", "Changelist Number", "Label or Date", "Same Revision" }; p4wSyncPane::p4wSyncPane( p4wView & ParentView, p4wRequest & Request, int isFileBrowser, int isRemoveCmd ) : p4wRunPane( ParentView, Request ), fIsFileBrowser(isFileBrowser), fGotOneFile(0), fIsRemoveCmd(isRemoveCmd) { } p4wSyncPane::~p4wSyncPane() { } // ------------------------------------- // Render functions. // void p4wSyncPane::Begin() { // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); const StrPtr *sr = fRequest.GetDynArg( "sr" ); StrBuf title; // // Begin the pane and start the form DoComment( "BEGIN SYNC PANE" ); if( fIsRemoveCmd ) { BeginForm( "Remove from Workspace:", actionURL ); } else if( fRequest.GetCmd() == AC_SYNCCHANGE ) { if (!sr) { fRequest << "<font color=\"#FF0000\"> Unintelligible revision specification '' - unable to process!</font><p>"; return; } title.Set( "Sync to Changelist #" ); title << p4wStrBuf().EscapeHTML(*sr, Unicode()) << ":"; p4wHtml htm; htm.beginTRow(); htm.beginCol(); fRequest << htm; htm.Clear(); p4wMenuPane::renderSubChgMenu( &fRequest, NULL ); htm.endCol(); htm.endTRow(); fRequest << htm; BeginForm( title.Text(), actionURL ); } else if( fRequest.GetCmd() == AC_SYNCLABEL ) { if (!sr) { fRequest << "<font color=\"#FF0000\"> Unintelligible revision specification '' - unable to process!</font><p>"; return; } title.Set( "Sync Workspace to Label " ); title << p4wStrBuf().EscapeHTML(*sr, Unicode()) << ":"; BeginForm( title.Text(), actionURL ); } else { BeginForm( "Sync:", actionURL ); } // // Generate the Options segment. If this is a Remove from workspace // request, hard-code that option instead. Also, we need to // check for sr dynamic argument to see if this is a sync to // label request. int newRow; int endTRow; int endRRow; int endCol; if( fIsRemoveCmd ) { DoHidden( 0, "Option", "rev" ); DoHidden( 0, "revVal", "none" ); DoHidden( 0, "isRemove", "1" ); } else if( fRequest.GetCmd() == AC_SYNCLABEL ) { if (!sr) { fRequest << "<font color=\"#FF0000\"> Unintelligible revision specification '' - unable to process!</font><p>"; return; } BeginOptions(); DoHidden( 0, "Option", "at" ); DoHidden( 0, "atVal", sr->Text() ); DoCheckbox( 0, 0, "Force", "force", "Force", 1, 1, 1 ); } else if( fRequest.GetCmd() == AC_SYNCCHANGE ) { if (!sr) { fRequest << "<font color=\"#FF0000\"> Unintelligible revision specification '' - unable to process!</font><p>"; return; } BeginOptions(); DoHidden( 0, "Option", "atChange" ); DoHidden( 0, "atChangeVal", sr->Text() ); DoCheckbox( 0, 0, "OptionSync", "restricted", "Restrict to files only in this changelist", 1, 1, 1 ); DoCheckbox( 1, 0, "Force", "force", "Force", 1, 1, 1 ); } else { BeginOptions(); int checked; for( int opt = 0; opt < 5; opt++ ) { StrBuf textName; StrBuf onClickStr; if( opt == 0 ) checked = 1; else checked = 0; newRow = ( opt != 0 ); endTRow = ( opt == 1 ); endRRow = ( opt == 0 || opt == 4 ); endCol = ( opt == 0 || opt == 4 || opt == 5 ); DoRadio( newRow, checked, "Option", syncOpts[opt], syncOptsText[opt], endCol, endRRow, syncOpts[opt] ); if( endRRow ) continue; textName << syncOpts[opt] << "Val"; onClickStr.Set("setCheckedValue(document.forms['Run'].elements['Option'], '"); onClickStr << syncOpts[opt] << "')"; if( opt == 1 ) DoText( textName.Text(), NULL, 8, endTRow, onClickStr.Text() ); else DoText( textName.Text(), NULL, 20, endTRow, onClickStr.Text() ); if( opt == 2 ) { DoCheckbox( 0, 0, "OptionSync", "restricted", "restrict to files only in this changelist", 0, 1 ); } else if( opt == 3 ) { StrBuf np; StrBuf lURL; p4wURL urlMaker; fRequest.UseNewBase( np, NULL, "path", "/" ); urlMaker.ConstructURL( lURL, np.Text(), AC_LABELSPATH, NULL ); p4wHtml htm(1); htm.text( " " ); htm.beginLink( lURL.Text() ); htm.text( "View labels with files in current path" ); htm.endLink(); fRequest << htm; } } DoCheckbox( 1, 0, "Force", "force", "Force", 1, 1, 1 ); } // // Start off the Files portion. BeginFiles( fRequest.GetPath() ); } void p4wSyncPane::Render( StrDict * varList ) { // // Skip files opened for add or branch // 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 && ( ( *action == "add" ) || ( *action == "branch" ) ) ) return; if( !haveRev && ( *headAction == "delete" || *headAction == "move/delete" ) ) return; // // If this is a Remove from workspace command, skip files // that are opened by user, or that are already removed from workspace if( ( fIsRemoveCmd && action ) || ( fIsRemoveCmd && !haveRev ) ) return; } if( !fGotOneFile && !fIsFileBrowser ) { // // Generate the files options and default selection // based on the type of sync command. if( fIsRemoveCmd ) { FilesIn( 0, 0, fRequest.GetPath().Text(), NULL ); BeginSelected( 1, FilesUnchecked() ); } else { FilesIn( 1, 1, fRequest.GetPath().Text(), "All Files", 1 ); BeginSelected( 0, FilesUnchecked() ); } fGotOneFile = 1; } StrPtr *depotFile = varList->GetVar( "depotFile" ); StrPtr *clientFile = varList->GetVar( "clientFile" ); // // If clientFile isn't available use depotFile instead if( !clientFile ) clientFile = depotFile; 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 ); } else { DoListItem( depotFile->Text() ); DoHidden( 1, "File", depotFile->Text() ); } } void p4wSyncPane::End() { const StrPtr *sr = fRequest.GetDynArg( "sr" ); // // 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 ) { if( !fIsRemoveCmd ) { FilesIn( 1, 1, p4wStrBuf().EscapeHTML(fRequest.GetPath(), Unicode()).Text(), "All Files", 1 ); } else { FilesIn( 0, 1, p4wStrBuf().EscapeHTML(fRequest.GetPath(), Unicode()).Text(), NULL, 0 ); } } // // Generate the buttons // // Generate formActions hidden fields (used to identify // submit buttons BeginButtons(); DoHidden( 0, "formActions", "preview" ); DoHidden( 0, "formActions", "sync" ); DoHidden( 0, "formActions", "redisplay" ); // // Generate preview and sync buttons if( fIsRemoveCmd ) { DoButton( "preview", "Preview Remove" ); DoButton( "sync", "Remove" ); } else { DoButton( "preview", "Preview Sync" ); DoButton( "sync", "Sync" ); } EndButtons(); // // End the pane. EndForm(); DoComment( "END SYNC PANE" ); } void p4wSyncPane::RenderNoFiles() { // // Draw the form without the Selected Files option (used // by the Sync to Changelist and Sync to Label forms). // These forms do not need to process a p4 request's data. Begin(); End(); } void p4wSyncPane::GetAction( StrBuf & actionURL ) { const StrPtr *sr = fRequest.GetDynArg( "sr" ); StrBufDict args; StrBuf lacVal; lacVal << (int)fRequest.GetCmd(); // // Sync to label needs the label argument passed in url if( sr ) { args.SetVar( "sr", sr->Text() ); // // Pass the lac (last ac) value if this is a sync // to changelist or sync to label command so that // the status page can use the correct tab and // subnavigation menu. if( fRequest.GetCmd() == AC_SYNCCHANGE || fRequest.GetCmd() == AC_SYNCLABEL ) args.SetVar( "lac", lacVal.Text() ); ConstructAction( AC_SYNCPROCESSOR, &args, 1, actionURL ); // Remove from workspace can also use this for constructing // a better title for the result page. } else if( fRequest.GetCmd() == AC_REMOVEFRM || fRequest.GetCmd() == AC_REMOVEFILEFRM ) { args.SetVar( "lac", lacVal.Text() ); ConstructAction( AC_SYNCPROCESSOR, &args, 1, actionURL ); } else { ConstructAction( AC_SYNCPROCESSOR, NULL, 1, actionURL ); } } void p4wSyncPane::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/p4wSyncPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |