// // Copyright 2002 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wDelConfirmPane: // Generates a confirmation page consisting of a button // which activates the delete or revert operation #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wSpecPane.h" #include "p4wDelConfirmPane.h" p4wDelConfirmPane::p4wDelConfirmPane( p4wView & ParentView, p4wRequest & Request ) : p4wSpecPane( ParentView, Request, 1 ) { } p4wDelConfirmPane::~p4wDelConfirmPane() { } void p4wDelConfirmPane::RenderConfirm() { // // Generate a confirm delete or revert page that just consists // of a button that does the work. if( !URLIsOK() ) { RenderError( "Requested URL is invalid in this context", 1 ); return; } // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); p4wHtml htm; p4wURL urlMaker; StrBuf title; StrBuf grayIcon; StrBuf clearIcon; AllCommands lac = fRequest.GetLastReturnType(); StrBuf path; StrBuf newBase; StrBuf deleteURL; path.Set( fRequest.GetReturnURL( lac ).Text() ); int isFileBrowser = lac != AC_PATHBROWSER; int isDepot = fRequest.GetViewMode() != VM_WORKSPACE; // // Used to generate line & vertical white space urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Set the page title switch( fRequest.GetCmd() ) { case AC_DELETELABELCONFIRM: title.Set( "Delete Label Spec:" ); break; case AC_DELETEBRANCHCONFIRM: title.Set( "Delete Branch Spec:" ); break; case AC_DELETEJOBCONFIRM: title.Set( "Delete Job:" ); break; case AC_REVERTCONFIRM: title.Set( "Revert:" ); break; default: break; } // // Begin the pane. htm.comment( "BEGIN DELETE CONFIRM PANE" ); htm.beginForm( actionURL.Text() ); // // Generate title with line underneath htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << title; htm.endSpan(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); // // Generate linkified path if this is a revert command if( fRequest.GetCmd() == AC_REVERTCONFIRM ) { htm.beginTRow(); htm.beginCol(); htm.beginSpan( "path" ); htm << " "; fRequest << htm; htm.Clear(); (void)OutputDirectoryHeader( path.Text(), isFileBrowser, 1, isDepot ); htm.endSpan(); if (!fRequest.isLocalRequest() && fRequest.GetViewMode() == VM_WORKSPACE) { htm << " "; htm.beginSpan("remote"); htm << "<nobr>"; htm << "(workspace files are located on remote machine \"" << fRequest.GetHost() << "\")"; htm << "</nobr>"; htm.endSpan(); } htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "10", "0", "", 1 ); htm.endCol(); htm.endTRow(); } else { // // Some vertical white space htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "15", "0", "", 1 ); htm.endCol(); htm.endTRow(); } htm.beginTRow(); htm.beginCol(); htm.beginDList(); htm.dListTag(); htm.text( "You are about to " ); AllCommands ac; StrBuf p1; StrBuf p2; switch( fRequest.GetCmd() ) { case AC_DELETEJOBCONFIRM: htm.text( "delete job spec " ); ac = AC_JOBVIEW; p1.Set( fRequest.GetURL() ); p2.Set( fRequest.GetURL() ); break; case AC_DELETELABELCONFIRM: htm.text( "delete label spec " ); ac = AC_LABELVIEW; p1.Set( fRequest.GetURL() ); p2.Set( fRequest.GetURL() ); break; case AC_DELETEBRANCHCONFIRM: htm.text( "delete branch spec " ); ac = AC_BRANCHVIEW; p1.Set( fRequest.GetURL() ); p2.Set( fRequest.GetURL() ); break; case AC_REVERTCONFIRM: htm.text( "revert " ); if( fRequest.GetURL().Length() && fRequest.GetURL() != "..." ) { ac = AC_BROWSEFILE; p1.Set( fRequest.GetURL() ); } else { ac = AC_PATHBROWSER; } p2.Set( fRequest.GetPath() ); break; default: htm.text( "delete item " ); break; } fRequest.UseNewBase( newBase, NULL, "path", NULL ); newBase << p1; urlMaker.ConstructURL( deleteURL, newBase.Text(), ac, NULL, fRequest.GetUnicode() ); htm.beginLink( deleteURL.Text() ); htm.text( p4wStrBuf().EscapeHTML( p2, Unicode() ).Text() ); htm.endLink(); htm.text( ".<BR>" ); htm.text( "Are you sure you want to do this?" ); htm.linebreak(); htm.dListVal(); fRequest << htm; // // Generate the buttons DoSubmit(); // // End the pane. htm.Clear(); htm.endDList(); htm.endCol(); htm.endTRow(); htm.endForm(); htm.comment( "END DELETE CONFIRM PANE" ); fRequest << htm; } void p4wDelConfirmPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( AC_DELETECONFPROC, NULL, 1, actionURL ); } int p4wDelConfirmPane::URLIsOK() { // // Return true only if the command request is valid if( !fRequest.GetURL().Length() ) return 0; switch( fRequest.GetCmd() ) { case AC_DELETEJOBCONFIRM: case AC_DELETELABELCONFIRM: case AC_DELETEBRANCHCONFIRM: case AC_REVERTCONFIRM: return 1; break; default: return 0; } return 0; } void p4wDelConfirmPane::DoSubmit() { // // Generate the yes and no buttons named by // their appropriate commands p4wHtml htm; switch( fRequest.GetCmd() ) { case AC_DELETEJOBCONFIRM: htm.button( "deleteJob", "Yes" ); htm.hiddenField( "formActions", "deleteJob" ); htm.button( "job", "No" ); htm.hiddenField( "formActions", "job" ); break; case AC_DELETELABELCONFIRM: htm.button( "deleteLabel", "Yes" ); htm.hiddenField( "formActions", "deleteLabel" ); htm.button( "label", "No" ); htm.hiddenField( "formActions", "label" ); break; case AC_DELETEBRANCHCONFIRM: htm.button( "deleteBranch", "Yes" ); htm.hiddenField( "formActions", "deleteBranch" ); htm.button( "branch", "No" ); htm.hiddenField( "formActions", "branch" ); break; case AC_REVERTCONFIRM: { htm.button( "revert", "Yes" ); htm.hiddenField( "formActions", "revert" ); if( fRequest.GetURL().Length() && fRequest.GetURL() != "..." ) { htm.button( "file", "No" ); htm.hiddenField( "formActions", "file" ); } else { htm.button( "path", "No" ); htm.hiddenField( "formActions", "path" ); } 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; } break; } default: break; } fRequest << htm; }
# | 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/p4wDelConfirmPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |