// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wAddSelectPane: // Construct a form used to select files to add #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wAddSelectPane.h" p4wAddSelectPane::p4wAddSelectPane( p4wView & ParentView, p4wRequest & Request ) : p4wSpecPane( ParentView, Request, 1 ), fNMaps(0), fSeenBegin(0) { } p4wAddSelectPane::~p4wAddSelectPane() { } void p4wAddSelectPane::Begin() { // // Fetch and build the ACTION value. StrBuf actionURL; GetAction( actionURL ); p4wHtml htm; p4wURL urlMaker; StrBuf grayIcon; StrBuf clearIcon; // // Begin the pane. if( !fHadFatalError ) { urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); int isFileBrowser = fRequest.GetLastReturnType() != AC_PATHBROWSER; int useDepot = ( fRequest.GetViewMode() != VM_WORKSPACE ); htm.comment( "BEGIN ADD SELECT PANE" ); htm.beginForm( actionURL.Text(), "ADDSELECT" ); // // title with line underneath htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << "Open for add:"; htm.endSpan(); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); // // linkified path htm.beginTRow(); htm.beginCol(); fRequest << htm; htm.Clear(); (void)OutputDirectoryHeader( fRequest.GetPath().Text(), isFileBrowser, 1, useDepot ); 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(), "15", "0", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.beginDList(); ++fSeenBegin; } fRequest << htm; } void p4wAddSelectPane::RenderInfo( char *data, char level ) { // // Parse the where output to get the local path. Only consider non-exclusionary // mappings that match the path. The last match fitting this description // will be used. // // Filter out exclusionary mappings if( *data == '-' ) return; // // Strip off trailing ... int i; for( i = strlen( data ) - 1; i > 0; i-- ) if( data[i] != '.' ) break; data[i+1] = '\0'; // // Filter out mappings that don't match the path. // Consider whether this is a case-sensitive server. char *s; char *t = strstr( data, "..." ); if( t ) { s = strstr( t+4, "..." ); *t = '\0'; int c; c = StrPtr::SCompare( data, fRequest.GetPath().Text() ); if( c != 0 ) return; if( s ) { fWherePath.Set( s+4 ); ++fNMaps; } } } void p4wAddSelectPane::Render( StrDict *varList ) { StrPtr *unmap = varList->GetVar( "unmap" ); StrPtr *depotFile = varList->GetVar( "depotFile" ); StrPtr *path = varList->GetVar( "path" ); StrBuf currPath; // // Parse 'where' output for servers 4.2+ which use // tagged output currPath << fRequest.GetPath() << "..."; // // Filter out exclusionary mappings if( unmap ) return; // // Filter out mappings that don't match path // considering the case-sensitivity of the server if( StrPtr::SCompare( depotFile->Text(), currPath.Text() ) ) return; // // Strip off trailing ... and set the where path fWherePath.Set( path->Text(), path->Length() - 3 ); ++fNMaps; } void p4wAddSelectPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( AC_ADDSELECTPROCESSOR, NULL, 1, actionURL ); } void p4wAddSelectPane::End() { // // Generate the File selection portion. If we found one real mapping // only, it is considered legitimate, so offer options to add files // in current dir and current dir and below. // // If we're in workspace mode, use this path. p4wHtml htm(1); if( fHadFatalError ) { if( fSeenBegin ) { htm.endDList(); htm.endCol(); htm.endTRow(); htm.endForm(); htm.comment( "END ADDSELECT PANE" ); fRequest << htm; } return; } htm.dListTag(); htm.text( "Select files to add:", "b" ); if( fNMaps == 0 && fRequest.GetViewMode() == VM_WORKSPACE ) { fWherePath.Set( fRequest.GetPath() ); ++fNMaps; } if( fNMaps == 0 ) { htm.hiddenField( "LocalPath", p4wStrBuf().EscapeHTML( fRequest.GetPath(), Unicode() ).Text() ); htm.hiddenField( "Files", "entered" ); htm.dListVal(); htm.text( "No single workspace path could be found " ); htm.text( "that maps to current depot path " ); htm.text( fWherePath.Text() ); htm.paragraph(); htm.dListVal(); htm.text( "Enter list of files to add, relative to current depot path:" ); htm.linebreak(); htm.beginTextbox( "File", 10, 60 ); htm.endTextbox(); } else { htm.hiddenField( "LocalPath", p4wStrBuf().EscapeHTML( fWherePath, Unicode() ).Text() ); htm.paragraph(); htm.beginDList(); htm.dListTag(); htm.radio( "Files", "inAdd", 1 ); htm.label( "By path:", "inAdd", "b" ); htm.dListVal(); htm.text( "Let P4Web scan \"" ); htm.text( p4wStrBuf().EscapeHTML(fWherePath, Unicode()).Text() ); htm.text( "\" " ); htm.beginSelect( "dirVal", 0, 0, 0, "setCheckedValue(document.forms['ADDSELECT'].elements['Files'], 'inAdd')" ); htm.selectOpt(); htm.text( "and subdirectories" ); htm.selectOpt(); htm.text( "at this level only" ); htm.endSelect(); htm.text( " for new files to add." ); htm.linebreak(); htm.text( "Click the \"Continue\" button below to see a list of new files found in this path.", "i", "-2" ); htm.paragraph(); htm.dListTag(); htm.radio( "Files", "entered" ); htm.label( "By name:", "entered", "b" ); htm.dListVal(); htm.text( "Enter files to add (relative to the \"" ); htm.text( p4wStrBuf().EscapeHTML(fWherePath, Unicode()).Text() ); htm.text( "\" path) here:" ); htm.dListVal(); htm.beginTextbox( "File", 10, 60, "setCheckedValue(document.forms['ADDSELECT'].elements['Files'], 'entered')" ); htm.endTextbox(); htm.endDList(); } htm.paragraph(); htm.dListVal(); htm.button( "submitFiles", "Continue" ); htm.text( " using files " ); htm.radio( "CheckOption", "checked", 1 ); htm.label( "checked or ", "checked" ); htm.radio( "CheckOption", "unchecked" ); htm.label( "unchecked", "unchecked" ); // // End the pane. htm.endDList(); htm.endCol(); htm.endTRow(); htm.endForm(); htm.comment( "END ADDSELECT PANE" ); fRequest << htm; } void p4wAddSelectPane::RenderError( char *data, int escapeHTML ) { RenderErrorList( data, escapeHTML ); } void p4wAddSelectPane::HandleError( Error *err ) { // // Special handling for "files not in client" error if( err->GetSeverity() == E_WARN && err->GetGeneric() == EV_EMPTY ) { StrBuf errMsg; err->Fmt(&errMsg); char *c = strstr( errMsg.Text(), "- file(s) not in client" ); if( c ) { ++fHadFatalError; RenderErrorTxt( errMsg.Text(), 1 ); return; } } // // Override this because we want to ignore most fstat errors DoHandleError( err, 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/p4wAddSelectPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |