// // Copyright 2008 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wDiff2FilesPane: // Generates a form for specifying 2 files to diff #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wDiff2FilesPane.h" #include "p4wMenuPane.h" // // Options for sync static char *const diff2Opts[] = { "default", "have", "rev", "atChange", "at", "date", }; static char *const diff2OptsText[] = { "Head revision", "Have revision", "Revision number:", "<nobr>Changelist number:</nobr>", "Label:", "Date:", }; p4wDiff2FilesPane::p4wDiff2FilesPane( p4wView & ParentView, p4wRequest & Request ) : p4wRunPane( ParentView, Request ) { } p4wDiff2FilesPane::~p4wDiff2FilesPane() { } // ------------------------------------- // Render functions. // void p4wDiff2FilesPane::Begin() { // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); // // Begin the pane and start the form DoComment( "BEGIN DIFF2 FILES PANE" ); p4wHtml htm; if (fRequest.GetCmd() == AC_DIFF2DIRS && fRequest.GetScreenChunks() & SCRN_TITLE) { p4wURL urlMaker; StrBuf title; StrBuf grayIcon; StrBuf clearIcon; title.Set( p4wMenuPane::GetMenuTitle( AC_DIFF2DIRS ) ); title << ":"; // // Used to generate a line underneath the title urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Workspace mode needs to use a full path in its urls StrBuf baseWMPath; fRequest.UseNewBase( baseWMPath, NULL, "path", fRequest.GetPath().Text() ); // Output the title htm.beginTRow(); htm.beginCol(0, 0, "3"); htm.beginTable(); // put the whole line in a table to prevent wrapping htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << title << " "; htm.endSpan(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); // // Generate line underneath the title htm.beginTRow(); htm.beginCol( "top", 0, "3" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top", 0, "3" ); fRequest << htm; htm.Clear(); (void)OutputDirectoryHeader( fRequest.GetDepotPath().Text(), 0, 1, fRequest.GetViewMode() != VM_WORKSPACE ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top", 0, "3" ); htm.icon( clearIcon.Text(), "15", "1", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); } htm.beginTRow(); htm.beginCol(); const StrPtr *mu = fRequest.GetDynArg("mu"); if (mu || fRequest.GetLastReturnType() == AC_BROWSEFILE) { int show = mu ? atoi(mu->Text()) : -1; htm.SetRequest(&fRequest); htm.RenderFileMenu(show ? show : -1); htm << "<script language=javascript>" << crlf; htm << "setmushow("; htm << show; htm << ");" << crlf; htm << "</script>" << crlf; } htm.beginForm( actionURL.Text(), "Diff2Files" ); htm.beginTable( "0", NULL, "0", "5" ); fRequest << htm; } void p4wDiff2FilesPane::RenderContent() { p4wHtml htm; p4wURL urlMaker; StrBuf temp; StrBuf grayIcon; StrBuf clearIcon; urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); if (fRequest.GetCmd() != AC_DIFF2DIRS) { htm.beginTRow(); htm.beginCol(0,0,0,"100%"); htm.icon( clearIcon.Text(), "1", "8", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "8", "8", "", 1 ); htm.endCol(); htm.endTRow(); } htm.beginTRow(); htm.beginCol(); htm.beginTable( "0", NULL, "0", "3" ); htm.beginTRow(); htm.beginCol(0,0,"100%"); if (fRequest.GetCmd() == AC_DIFF2DIRS) { htm.text( "First folder path:" ); htm.linebreak(); temp.Set( p4wStrBuf().EscapeHTML(fRequest.GetDepotPath(), Unicode()) ); temp << "..."; htm.textField( "File1", temp.Text(), 55 ); } else { htm.text( "First file path:" ); htm.linebreak(); htm.textField( "File1", p4wStrBuf().EscapeHTML(fRequest.GetDepotPath(), Unicode()).Text(), 55 ); } htm.paragraph(); htm << "Specify which depot file revision"; if (fRequest.GetCmd() == AC_DIFF2DIRS) htm << "s"; htm << " to compare:"; htm.endCol(); htm.endTRow(); fRequest << htm; htm.Clear(); int newRow; int endTRow; int endRRow; int endCol; int checked; int opt; for( opt = 0; opt < 6; opt++ ) { StrBuf textName; StrBuf onClickStr; if( opt == 0 ) checked = 1; else checked = 0; newRow = 1; endRRow = ( opt == 0 || opt == 1 ); endCol = ( opt == 0 || opt == 1 ); DoRadio( newRow, checked, "Rev1", diff2Opts[opt], diff2OptsText[opt], endCol, endRRow, diff2Opts[opt], endRRow ? "22px" : 0 ); if( endRRow ) continue; htm.endCol(); htm.beginCol(); fRequest << htm; htm.Clear(); textName << diff2Opts[opt] << "Val1"; onClickStr.Set("setCheckedValue(document.forms['Diff2Files'].elements['Rev1'], '"); onClickStr << diff2Opts[opt] << "')"; if( opt == 2 ) { DoText( textName.Text(), NULL, 20, 0, onClickStr.Text() ); htm.endCol(); htm.beginCol(0,0,0,0,0, fRequest.GetJavascriptMode() == 2 ? 0 : "100%"); htm.icon( clearIcon.Text(), "1", "100%", "", 1 ); htm.endCol(); htm.endTRow(); fRequest << htm; htm.Clear(); } else if (opt == 5) { DoText( textName.Text(), NULL, 20, 0, onClickStr.Text(), "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')", textName.Text() ); htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('" << textName.Text() << "');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; htm.endCol(); htm.endTRow(); fRequest << htm; htm.Clear(); } else { DoText( textName.Text(), NULL, 20, 1, onClickStr.Text() ); } } htm.endTable(); htm.endCol(); htm.beginCol(); htm.endCol(); htm.beginCol(); htm.beginTable( "0", NULL, "0", "3" ); htm.beginTRow(); htm.beginCol(0,0,"100%"); if (fRequest.GetCmd() == AC_DIFF2DIRS) { htm.text( "Second folder path:" ); htm.linebreak(); temp.Set( p4wStrBuf().EscapeHTML(fRequest.GetDepotPath(), Unicode()) ); temp << "..."; htm.textField( "File2", temp.Text(), 55 ); } else { htm.text( "Second file path:" ); htm.linebreak(); htm.textField( "File2", p4wStrBuf().EscapeHTML(fRequest.GetDepotPath(), Unicode()).Text(), 55 ); } htm.paragraph(); htm << "Specify which depot file revision"; if (fRequest.GetCmd() == AC_DIFF2DIRS) htm << "s"; htm << " to compare:"; htm.endCol(); htm.endTRow(); fRequest << htm; htm.Clear(); for( opt = 0; opt < 6; opt++ ) { StrBuf textName; StrBuf onClickStr; if( opt == 0 ) checked = 1; else checked = 0; newRow = 1; endRRow = ( opt == 0 || opt == 1 ); endCol = ( opt == 0 || opt == 1 ); StrBuf opttxt; opttxt.Set(diff2Opts[opt]); opttxt << "2"; DoRadio( newRow, checked, "Rev2", diff2Opts[opt], diff2OptsText[opt], endCol, endRRow, opttxt.Text(), endRRow ? "22px" : 0 ); if( endRRow ) continue; htm.endCol(); htm.beginCol(); fRequest << htm; htm.Clear(); textName << diff2Opts[opt] << "Val2"; onClickStr.Set("setCheckedValue(document.forms['Diff2Files'].elements['Rev2'], '"); onClickStr << diff2Opts[opt] << "')"; if( opt == 2 ) { DoText( textName.Text(), NULL, 20, 0, onClickStr.Text() ); htm.endCol(); htm.beginCol(0,0,0,0,0, fRequest.GetJavascriptMode() == 2 ? 0 : "100%"); htm.icon( clearIcon.Text(), "1", "100%", "", 1 ); htm.endCol(); htm.endTRow(); fRequest << htm; htm.Clear(); } else if (opt == 5) { DoText( textName.Text(), NULL, 20, 0, onClickStr.Text(), "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')", textName.Text() ); htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('" << textName.Text() << "');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; htm.endCol(); htm.endTRow(); fRequest << htm; htm.Clear(); } else { DoText( textName.Text(), NULL, 20, 1, onClickStr.Text() ); } } htm.endTable(); htm.endCol(); htm.beginCol(0,0,0,0,0,"100%"); htm.icon( clearIcon.Text(), "1", "100%", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0,0,"100%"); htm.button("Diff2", fRequest.GetCmd() == AC_DIFF2DIRS ? "Diff Folders" : "Diff Files"); htm.endCol(); htm.endTRow(); fRequest << htm; } void p4wDiff2FilesPane::End() { EndForm(); DoComment( "END DIFF2 FILES PANE" ); } void p4wDiff2FilesPane::GetAction( StrBuf & actionURL ) { ConstructAction( AC_DIFF2FILESPROCESSOR, NULL, 1, actionURL ); } void p4wDiff2FilesPane::HandleError( Error *err ) { DoHandleError( err, 1 ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 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. |
||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |