// // Copyright 2001 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wJobPane: // Display the job fields and optionally the the fixes to the job, // or display a form to edit the job #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wJobPane.h" p4wJobPane::p4wJobPane( p4wView & ParentView, p4wRequest & Request, int isForm ) : p4wSpecPane( ParentView, Request, isForm ), fState( gettingJob ), fSeenFixes( 0 ) { } p4wJobPane::~p4wJobPane() { } void p4wJobPane::Begin() { // // Begin the pane (but only once) if( fIsForm ) { p4wSpecPane::Begin(); return; } else if( fState != gettingJob ) { return; } p4wSpecPane::Begin(); } int p4wJobPane::IgnoreField( const char * field ) { // // No fields are ignored return 0; } int p4wJobPane::CustomField( const char * field, StrDict * varList, int len, SpecElem *se ) { int retVal; if( fIsForm ) retVal = doCustomForm( field, varList, len ); else retVal = doCustomNotForm( field, varList ); return retVal; } void p4wJobPane::Render( StrDict *varList ) { // // Generate either the job detail or the fixes // output, based on state if this is not a form. if( fIsForm || fState == gettingJob ) p4wSpecPane::Render( varList ); else doFixes( varList ); } void p4wJobPane::doFixes( StrDict *varList ) { // // Display the output of the fixes -j job command StrBuf url; const StrPtr *change = varList->GetVar( "Change" ); const StrPtr *u = varList->GetVar( "User" ); const StrPtr *client = varList->GetVar( "Client" ); StrBuf user; p4wHtml htm; fRequest.ConstructSafeURL( url, change->Text(), AC_DESCRIBE, NULL ); user << u << "@" << client; // // The first fix has the title as the first element // of the table. Subsequent fixes have a blank first // table element. if( !fSeenFixes ) { ++fSeenFixes; } else { htm.beginTRow(); htm.beginCol(); htm.endCol(); } htm.beginCol(); htm.text( p4wStrBuf().Expand( StrRef( "%Job%" ), *varList, Unicode() ).Text() ); htm.text( " fixed by change " ); htm.beginLink( url.Text() ); htm.text( p4wStrBuf().Expand( StrRef( "%Change%" ), *varList, Unicode() ).Text() ); htm.endLink(); htm.text( " on " ); htm.text( p4wStrBuf().Expand( StrRef( "%Date@*m/*d/*Y *H:*M%" ), *varList, Unicode() ).Text() ); htm.text( " by " ); htm.text( p4wStrBuf().EscapeHTML( user, Unicode() ).Text() ); htm.endCol(); htm.endTRow(); fRequest << htm; } int p4wJobPane::doCustomNotForm( const char *field, StrDict *varList ) { SpecElem *se; Error e; // // Output fields that require special processing. se = fSpec->Find( StrRef(field), &e ); // // Use <PRE> for all text fields so // that the original line endings are preserved if( !se->IsDate() && !se->IsList() ) { StrPtr * val = varList->GetVar( StrRef(field) ); p4wHtml htm; StrBuf tag; tag << field << ":"; htm.beginTRow(); htm.beginCol( "top" ); htm.text( tag.Text(), "b" ); htm.endCol(); htm.beginCol(); htm.beginUnformatted( "normal" ); // // Convert http: & https: into real links in // text fields htm.text( p4wStrBuf().EscapeHTMLDoURLs( *val, Unicode() ).Text() ); htm.endUnformatted(); htm.endCol(); htm.endTRow(); fRequest << htm; // // We're done with this custom field. return 1; } else { return 0; } } int p4wJobPane::doCustomForm( const char * field, StrDict * varList, int maxFieldLen ) { // // Put the Save button and field description link // next to the Job field. if( strcmp( field, "Job" ) ) return 0; p4wHtml htm; StrPtr * val = varList->GetVar( "Job" ); htm.beginTRow(); htm.beginCol(); htm.text( "Job:", "b" ); htm.endCol(); htm.beginCol("0", "0", "3"); htm.textField( "Job", p4wStrBuf().EscapeHTML( *val, Unicode() ).Text(), maxFieldLen ); htm.text( " " ); fRequest << htm; OutputHREF( "[Click ", fRequest.GetURL().Text(), AC_JOBFIELDS, NULL, "here", " for job field descriptions]" ); htm.Clear(); htm.endCol(); htm.endTRow(); fRequest << htm; return 1; } void p4wJobPane::End() { // // If this is a form, end the table and form p4wHtml htm; if( fIsForm ) { p4wSpecPane::End(); return; } // // Not a form: handle state transitions if( FatalError() && fState == gettingJob ) { p4wSpecPane::End(); return; } const StrPtr *jf = fRequest.GetStateArg( "jf" ); if( fState == gettingJob && ((jf && *jf == "y") || fRequest.GetCmd() == AC_FIXESJOB) ) { fState = gettingFixes; htm.beginTRow(); htm.beginCol(); htm.text( "Fixes:", "b" ); htm.endCol(); fRequest << htm; return; } // // End the pane. If we issued a fixes command but had // no fixes, we need to terminate the table row. if( fRequest.GetCmd() == AC_FIXESJOB && !fSeenFixes ) { htm.endTRow(); fRequest << htm; } p4wSpecPane::End(); } void p4wJobPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value int usePath = ( AC_EDITJOB ? 1 : 0 ); ConstructAction( AC_JOBCMD, NULL, usePath, actionURL ); } void p4wJobPane::RenderInfo( char *data, char level ) { if (!fRequest.bQuiet()) printf("%s\n", data); }
# | 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/p4wJobPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |