VERSION 5.00 Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} SubmitForm BorderStyle = 3 'Fixed Dialog Caption = "Submit" ClientHeight = 6960 ClientLeft = 45 ClientTop = 435 ClientWidth = 8535 ControlBox = 0 'False MaxButton = 0 'False MinButton = 0 'False OleObjectBlob = "SubmitForm.dsx":0000 ShowInTaskbar = 0 'False StartUpPosition = 1 'CenterOwner End Attribute VB_Name = "SubmitForm" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Const CmdTitle = "Check In to Perforce" Private Const TwipsMultiplier = 20 Private Const DefaultJobStatus = "(default)" Private m_Cancelled As Boolean Public m_submit As P4COM.p4 Private m_f As Fstat Private m_Jobs() As String Private m_InfoArr() As String Private Sub cmdCancel_Click() On Error GoTo Error_Block Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "cmdCancel_Click") m_Cancelled = True Me.Hide Exit Sub Error_Block: t.Report End Sub Private Sub cmdSelect_Click() On Error GoTo Error_Block Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "cmdSelect_Click") Dim j As Integer For j = 0 To FileList.ListCount - 1 FileList.Selected(j) = True Next Exit_Block: Exit Sub Error_Block: t.Report End Sub Private Sub cmdUnSelect_Click() On Error GoTo Error_Block Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "cmdUnSelect_Click") Dim j As Integer For j = 0 To FileList.ListCount - 1 If FileList.list(j) = m_f.DepotFile Then FileList.Selected(j) = True Else FileList.Selected(j) = False End If Next Exit_Block: Exit Sub Error_Block: t.Report End Sub Private Function GetSelcount(lb As MSForms.ListBox) As Integer Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "GetSelcount") Dim i As Integer GetSelcount = 0 For i = 0 To lb.ListCount - 1 If lb.Selected(i) Then GetSelcount = GetSelcount + 1 End If Next End Function Private Function GetJobStatus(job As String) As String Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "GetJobStatus") Dim i As Integer ' If user has specified new status then that's what we want If Len(JobStatus.Text) <> 0 And JobStatus.Text <> DefaultJobStatus Then GetJobStatus = JobStatus.Text Exit Function End If ' Extra job status from stored list For i = LBound(m_Jobs) To UBound(m_Jobs) If Left$(m_Jobs(i), Len(job)) = job Then GetJobStatus = Mid$(m_Jobs(i), Len(job) + 2) If GetJobStatus = "ignore" Then GetJobStatus = "closed" End If Exit Function End If Next End Function Private Sub GetSelectedItems(list() As String, lb As MSForms.ListBox, IsJobs As Boolean) Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "GetSelectedItems") Dim i As Integer Dim j As Integer Dim job As String Dim ind As Integer i = 0 For j = 0 To lb.ListCount - 1 If lb.Selected(j) Then If Not IsJobs Then list(i) = lb.list(j) Else ' For jobs we have to construct list of jobs and either ' original statuses, or new generic status job = lb.list(j) ind = InStr(1, job, " ") ' Remove job description If ind > 0 Then job = Left$(job, ind - 1) End If job = job & " " & GetJobStatus(job) list(i) = job End If i = i + 1 End If Next End Sub Private Sub cmdSubmit_Click() On Error GoTo Error_Block Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "cmdSubmit_Click") Const DefaultDescription As String = "" Dim i As Integer Dim j As Integer Dim FileSelCount As Integer Dim JobSelCount As Integer Dim Files() As String Dim Jobs() As String Dim SubmitArgs As String If Len(ChangeDescription.Text) = 0 Or Left$(ChangeDescription.Text, Len(DefaultDescription)) = DefaultDescription Then MsgBox "Please enter a description.", vbExclamation + vbOKOnly, CmdTitle GoTo Exit_Block End If FileSelCount = GetSelcount(FileList) JobSelCount = GetSelcount(JobList) If FileSelCount = 0 Then MsgBox "You cannot check in unless one or more files is checked.", vbOKOnly + vbExclamation, CmdTitle GoTo Exit_Block Else SubmitArgs = vbNullString If KeepCheckedOut.Value Then SubmitArgs = "-r" End If ' Find all selected files and pass in to the submit ReDim Files(FileSelCount - 1) As String GetSelectedItems Files, FileList, False If JobSelCount > 0 Then ReDim Jobs(JobSelCount - 1) As String GetSelectedItems Jobs, JobList, True SubmitArgs = SubmitArgs & " -s" End If m_submit.ArrayVar("Files") = Files m_submit.ArrayVar("Jobs") = Jobs m_submit.Var("Description") = UnixString(ChangeDescription.Text) m_InfoArr = m_submit.Run("submit -i " & SubmitArgs) Me.Hide End If Exit_Block: Exit Sub Error_Block: t.Report End Sub Private Function JobDescription(job As String) As String Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "JobDescription") Dim Desc As String Dim spec As P4COM.p4 Set spec = NewP4 spec.ParseForms spec.ExceptionLevel = 0 spec.Connect InitP4 spec spec.Run "job -o " & job If spec.VarExists("Description") Then Desc = WindowsString(spec.Var("Description")) If Right$(Desc, 2) = vbCrLf Then Desc = Left$(Desc, Len(Desc) - 2) End If End If JobDescription = Desc spec.Disconnect End Function Private Sub UpdateJobStatuses(lb As MSForms.ComboBox) Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "UpdateJobStatuses") Dim Desc As String Dim val As Variant Dim opt As Variant Dim i As Integer Dim values() As String Dim Options() As String Dim FoundStatus As Boolean Dim spec As P4COM.p4 lb.AddItem DefaultJobStatus Set spec = NewP4 spec.ParseForms spec.ExceptionLevel = 0 spec.Connect InitP4 spec spec.Run ("jobspec -o") values = spec.ArrayVar("Fields") FoundStatus = False For Each val In values i = InStr(1, val, " Status ") If i > 0 Then If InStr(i, val, " select ") = 0 Then Exit Sub End If FoundStatus = True Exit For End If Next If Not FoundStatus Then Exit Sub values = spec.ArrayVar("Values") For Each val In values i = InStr(1, val, "Status ") If i > 0 Then Options = Split(Mid$(val, Len("Status ") + 1), "/") For Each opt In Options lb.AddItem opt Next Exit For End If Next spec.Disconnect End Sub Private Function JobName(JobText As String) As String ' Extra jobname from field which may contain job and status Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "JobName") Dim i As Integer i = InStr(JobText, " ") If i > 0 Then JobName = Left$(JobText, i - 1) Else JobName = JobText End If End Function Public Function DoSubmit(Title As String, submit As P4COM.p4, f As Fstat, InfoArr() As String) As VbMsgBoxResult Dim t As Tracker: Set t = GStackTrace.Enter(TypeName(Me), "DoSubmit") Dim i As Integer Dim Files() As String Dim YDist As Integer Caption = Title m_Cancelled = False FileList.Clear ChangeDescription.Text = WindowsString(submit.Var("Description")) Set m_submit = submit Set m_f = f Files = submit.ArrayVar("Files") m_Jobs = submit.ArrayVar("Jobs") For i = LBound(m_Jobs) To UBound(m_Jobs) JobList.AddItem JobName(m_Jobs(i)) & " - " & JobDescription(JobName(m_Jobs(i))) If InStr(1, m_Jobs(i), " ignore") = 0 Then ' Mark last one added as selected JobList.Selected(JobList.ListCount - 1) = True End If Next UpdateJobStatuses JobStatus ' Decide if we want to show list of files or not ' Note that we update list in anycase for use in OK click If RegOptions.SubmitCurrentDocOnly Then FileList.AddItem f.DepotFile FileList.Selected(FileList.ListCount - 1) = True FileList.Visible = False cmdSelect.Visible = False cmdUnselect.Visible = False If IsEmptyArray(m_Jobs) Then ' Hide Jobs stuff too YDist = FileList.Top - JobStatus.Top + FileList.Height JobStatusLabel.Visible = False JobListLabel.Visible = False JobStatus.Visible = False JobList.Visible = False Else YDist = FileList.Height End If cmdSubmit.Top = cmdSubmit.Top - YDist cmdCancel.Top = cmdCancel.Top - YDist KeepCheckedOut.Top = KeepCheckedOut.Top - YDist Me.Height = Me.Height - (TwipsMultiplier * YDist) ' convert to twips Else If IsEmptyArray(m_Jobs) Then ' Hide Jobs stuff and move everything else up YDist = FileList.Top - JobStatus.Top JobStatusLabel.Visible = False JobListLabel.Visible = False JobStatus.Visible = False JobList.Visible = False FileList.Top = FileList.Top - YDist cmdSelect.Top = cmdSelect.Top - YDist cmdUnselect.Top = cmdUnselect.Top - YDist cmdSubmit.Top = cmdSubmit.Top - YDist cmdCancel.Top = cmdCancel.Top - YDist KeepCheckedOut.Top = KeepCheckedOut.Top - YDist Me.Height = Me.Height - (TwipsMultiplier * YDist) ' convert to twips End If For i = LBound(Files) To UBound(Files) FileList.AddItem Files(i) If Files(i) = f.DepotFile Then ' Mark last one added as selected FileList.Selected(FileList.ListCount - 1) = True End If Next End If ChangeDescription.SelStart = 0 ChangeDescription.SelLength = Len(ChangeDescription.Text) Screen.MousePointer = vbDefault SetParent2 Me, g_p4interface.App.Caption Me.Show vbModal InfoArr = m_InfoArr If m_Cancelled Then DoSubmit = vbCancel Else DoSubmit = vbOK End If Unload Me End Function Private Sub FileList_Click() Dim j As Integer For j = 0 To FileList.ListCount - 1 If FileList.list(j) = m_f.DepotFile Then FileList.Selected(j) = True End If Next End Sub Private Sub FileList_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) FileList_Click End Sub