/* * Copyright 2004 Perforce Software. All rights reserved. * * Developed by Data Shades Ltd. */ #include <time.h> #include "FileOpDialog.h" FileOpDialog::FileOpDialog( PluginOperations *ops, TCHAR *op, TCHAR *filename, PerforceResults *results, PerforceOptions *options ) : Dialog( ops, IDD_FILE_OP_DIALOG, DialogWndProc ) { this->op = op; this->filename = filename; this->results = results; this->options = options; } void FileOpDialog::AppendLine( UniStrBuf *buf, TCHAR *name, StrPtr *value ) { buf->Append( name ); buf->Append( value ); buf->Append( _T("\r\n") ); } BOOL CALLBACK FileOpDialog::DialogWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND fileName = GetDlgItem( hWnd, IDC_FILENAME_EDIT ); HWND results = GetDlgItem( hWnd, IDC_RESULTS_EDIT ); HWND hide = GetDlgItem( hWnd, IDC_HIDE_CHECK ); HWND okButton = GetDlgItem( hWnd, IDOK ); switch(uMsg) { case WM_INITDIALOG: { FileOpDialog *dialog = ( FileOpDialog * )lParam; SaveDialogObject( hWnd, dialog ); SetWindowText( fileName, dialog->Filename() ); TCHAR *op = dialog->Operator(); if ( _tcscmp( op, _T("fstat") ) == 0 ) { UniStrBuf msg; if ( dialog->Results()->Count() > 0 ) { UniStrDict *dict = (UniStrDict *)dialog->Results()->Get( 0 ); StrPtr *value = dict->GetVar( "depotFile" ); if ( value ) { AppendLine( &msg, _T("Depot file: "), value ); } value = dict->GetVar( "clientFile" ); if ( value ) { AppendLine( &msg, _T("Your document: ") ,value ); } value = dict->GetVar( "headAction" ); if ( value ) { AppendLine( &msg, _T("Latest (head) action in depot: "), value ); } value = dict->GetVar( "headType" ); if ( value ) { AppendLine( &msg, _T("File type: "), value ); } value = dict->GetVar( "headTime" ); if ( value ) { long seconds = _ttol( (TCHAR *)value->Text() ); std::tm time; localtime_s( &time, (const time_t *)&seconds ); UniStrBuf timeBuff; TCHAR buff[128]; // Format time as YY/MM/DD HH:MM:SS wsprintf( buff, _T("%04d/%02d/%02d %02d:%02d:%02d"), time.tm_year+1900, time.tm_mon + 1, time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec ); msg.Append( _T("Last modified in depot: ") ); msg.Append( buff ); msg.Append( _T("\r\n") ); } value = dict->GetVar( "headRev" ); if ( value ) { AppendLine( &msg, _T("Latest (head) revision in depot: "), value ); } value = dict->GetVar( "headChange" ); if ( value ) { AppendLine( &msg, _T("Latest (head) changelist in depot: "), value ); } value = dict->GetVar( "haveRev" ); if ( value ) { AppendLine( &msg, _T("Revision in your workspace: "), value ); } value = dict->GetVar( "action" ); if ( value ) { AppendLine( &msg, _T("Open by you for: "), value ); } value = dict->GetVar( "change" ); if ( value ) { AppendLine( &msg, _T("In changelist: "), value ); } value = dict->GetVar( "actionOwner" ); if ( value ) { AppendLine( &msg, _T("Open by Perforce user: "), value ); } StrBuf key; for (int i=0;;i++) { key.Clear(); key << "otherOpen" << i; value = dict->GetVar( key.Text() ); if ( value == NULL ) { break; } AppendLine( &msg, _T("Also open by: "), value ); key.Clear(); key << "otherAction" << i; value = dict->GetVar( key.Text() ); if ( value ) { AppendLine( &msg, _T("Opened by them for: "), value ); } } value = dict->GetVar( "ourLock" ); if ( value ) { msg.Append( _T("Locked by you") ); msg.Append( _T("\r\n") ); } value = dict->GetVar( "otherLock" ); if ( value ) { msg.Append( _T("Locked by someone else") ); msg.Append( _T("\r\n") ); } } SetWindowText( results, (TCHAR *)msg.Text() ); } else { SetWindowText( results, (TCHAR *)dialog->Results()->GetText() ); } if ( _tcscmp( op, _T("edit") ) == 0 ) { SetWindowText( hWnd, _T("P4GT - Confirmation of Check Out from Perforce") ); } else if ( _tcscmp( op, _T("add") ) == 0 ) { SetWindowText( hWnd, _T("P4GT - Confirmation of Add to Perforce") ); } else if ( _tcscmp( op, _T("revert") ) == 0 ) { SetWindowText( hWnd, _T("P4GT - Confirmation of Undo Add/Check Out") ); ShowWindow( hide, FALSE ); } else if ( _tcscmp( op, _T("lock") ) == 0 ) { SetWindowText( hWnd, _T("P4GT - Confirmation of Lock Document") ); ShowWindow( hide, FALSE ); } else if ( _tcscmp( op, _T("unlock") ) == 0 ) { SetWindowText( hWnd, _T("P4GT - Confirmation of Unlock Document") ); ShowWindow( hide, FALSE ); } else if ( _tcscmp( op, _T("submit") ) == 0 ) { SetWindowText( hWnd, _T("P4GT - Confirmation of Check In to Perforce") ); ShowWindow( hide, FALSE ); } else if ( _tcscmp( op, _T("fstat") ) == 0 ) { SetWindowText( hWnd, _T("P4GT - Document Status") ); ShowWindow( hide, FALSE ); } Centre( hWnd ); SaveInitialSizes( hWnd ); SetResizeFlags( fileName, RESIZE_WIDTH ); SetResizeFlags( results, RESIZE_WIDTH | RESIZE_HEIGHT ); SetResizeFlags( hide, RESIZE_TOP ); SetResizeFlags( okButton, RESIZE_TOP | RESIZE_LEFT_HALF ); return true; break; } case WM_GETMINMAXINFO: SetMinimumSize( hWnd, (LPMINMAXINFO) lParam ); return true; break; case WM_SIZE: Resize( hWnd, lParam ); return true; break; case WM_PAINT: { FileOpDialog *dialog = ( FileOpDialog * )DialogObject( hWnd ); dialog->PaintSizeGrip( hWnd ); break; } case WM_NCHITTEST: { return HitTestSizeGrip( hWnd, lParam ); } case WM_CTLCOLORSTATIC: // Make the background of edit boxes white instead of the read-only grey. if ( ( HWND )lParam == GetDlgItem( hWnd, IDC_FILENAME_EDIT ) || ( HWND )lParam == GetDlgItem( hWnd, IDC_RESULTS_EDIT ) ) { return ( BOOL )GetStockObject( WHITE_BRUSH ); } break; case WM_COMMAND: switch ( LOWORD( wParam ) ) { case IDOK: { HWND check = GetDlgItem( hWnd, IDC_HIDE_CHECK ); int hide = ( int )SendMessage( check, BM_GETCHECK, 0, 0 ); if ( hide ) { FileOpDialog *dialog = ( FileOpDialog * )DialogObject( hWnd ); PerforceOptions *options = dialog->Options(); options->SetOptionValue( SHOW_CONFIRMATION_OPTION, FALSE ); } FinishDialog( hWnd, TRUE ); return true; } case IDCANCEL: FinishDialog( hWnd, FALSE ); return true; } } return false; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 11314 | Robert Cowham | Initial population of perforce_software version of P4OFC | ||
//guest/robert_cowham/perforce/P4OFC/main/libp4gt/FileOpDialog.cpp | |||||
#1 | 10843 | Robert Cowham |
Initial version of P4OFC source code. See README.txt (and LICENSE.txt and doc\P4OFC-Design.docx) |