From d2584400fe1c90b094d475d990dabb28d1380bee Mon Sep 17 00:00:00 2001 From: dannyparsons Date: Wed, 27 Apr 2016 12:29:08 +0100 Subject: [PATCH] fixed bugs in dlgStack --- instat/dlgStack.Designer.vb | 92 ++++++++++++++++----------------- instat/dlgStack.vb | 100 ++++++++++++++++++------------------ instat/ucrInput.vb | 4 ++ 3 files changed, 101 insertions(+), 95 deletions(-) diff --git a/instat/dlgStack.Designer.vb b/instat/dlgStack.Designer.vb index 9f1d2a1d6ef..4dbd7de6ac2 100644 --- a/instat/dlgStack.Designer.vb +++ b/instat/dlgStack.Designer.vb @@ -27,76 +27,90 @@ Partial Class dlgStack Me.lblFactorInto = New System.Windows.Forms.Label() Me.chkColumnsToCarry = New System.Windows.Forms.CheckBox() Me.lblNewDataFrameName = New System.Windows.Forms.Label() - Me.ucrNewDataFrameName = New instat.ucrVariableName() + Me.ucrNewDataName = New instat.ucrInputTextBox() + Me.ucrStackDataInto = New instat.ucrInputTextBox() + Me.ucrFactorInto = New instat.ucrInputTextBox() Me.ucrColumnsToCarryReceiver = New instat.ucrReceiverMultiple() Me.ucrSelectorStack = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() Me.ucrReceiverColumnsToBeStack = New instat.ucrReceiverMultiple() - Me.ucrFactorInto = New instat.ucrInputTextBox() - Me.ucrStackDataInto = New instat.ucrInputTextBox() Me.SuspendLayout() ' 'lblColumnsTostack ' Me.lblColumnsTostack.AutoSize = True - Me.lblColumnsTostack.Location = New System.Drawing.Point(249, 8) + Me.lblColumnsTostack.Location = New System.Drawing.Point(295, 13) Me.lblColumnsTostack.Name = "lblColumnsTostack" - Me.lblColumnsTostack.Size = New System.Drawing.Size(91, 13) + Me.lblColumnsTostack.Size = New System.Drawing.Size(90, 13) Me.lblColumnsTostack.TabIndex = 1 - Me.lblColumnsTostack.Tag = "Columns_to_stack" - Me.lblColumnsTostack.Text = "Columns to stack" + Me.lblColumnsTostack.Tag = "Columns_to_Stack" + Me.lblColumnsTostack.Text = "Columns to Stack" ' 'lblStackDataInto ' Me.lblStackDataInto.AutoSize = True - Me.lblStackDataInto.Location = New System.Drawing.Point(0, 258) + Me.lblStackDataInto.Location = New System.Drawing.Point(41, 256) Me.lblStackDataInto.Name = "lblStackDataInto" - Me.lblStackDataInto.Size = New System.Drawing.Size(79, 13) + Me.lblStackDataInto.Size = New System.Drawing.Size(85, 13) Me.lblStackDataInto.TabIndex = 9 - Me.lblStackDataInto.Tag = "Stack_data_into" - Me.lblStackDataInto.Text = "Stack data into" + Me.lblStackDataInto.Tag = "Stack_Data_Into" + Me.lblStackDataInto.Text = "Stack Data Into:" ' 'lblFactorInto ' Me.lblFactorInto.AutoSize = True - Me.lblFactorInto.Location = New System.Drawing.Point(0, 229) + Me.lblFactorInto.Location = New System.Drawing.Point(65, 227) Me.lblFactorInto.Name = "lblFactorInto" - Me.lblFactorInto.Size = New System.Drawing.Size(57, 13) + Me.lblFactorInto.Size = New System.Drawing.Size(61, 13) Me.lblFactorInto.TabIndex = 7 - Me.lblFactorInto.Tag = "Factor_into" - Me.lblFactorInto.Text = "Factor into" + Me.lblFactorInto.Tag = "Factor_Into" + Me.lblFactorInto.Text = "Factor Into:" ' 'chkColumnsToCarry ' Me.chkColumnsToCarry.AutoSize = True - Me.chkColumnsToCarry.Location = New System.Drawing.Point(295, 139) + Me.chkColumnsToCarry.Location = New System.Drawing.Point(287, 145) Me.chkColumnsToCarry.Name = "chkColumnsToCarry" - Me.chkColumnsToCarry.Size = New System.Drawing.Size(104, 17) + Me.chkColumnsToCarry.Size = New System.Drawing.Size(93, 17) Me.chkColumnsToCarry.TabIndex = 3 - Me.chkColumnsToCarry.Tag = "Columns_to_carry" - Me.chkColumnsToCarry.Text = "Columns to carry" + Me.chkColumnsToCarry.Tag = "Carry_Columns" + Me.chkColumnsToCarry.Text = "Carry Columns" Me.chkColumnsToCarry.UseVisualStyleBackColor = True ' 'lblNewDataFrameName ' Me.lblNewDataFrameName.AutoSize = True - Me.lblNewDataFrameName.Location = New System.Drawing.Point(0, 204) + Me.lblNewDataFrameName.Location = New System.Drawing.Point(5, 203) Me.lblNewDataFrameName.Name = "lblNewDataFrameName" Me.lblNewDataFrameName.Size = New System.Drawing.Size(121, 13) Me.lblNewDataFrameName.TabIndex = 5 Me.lblNewDataFrameName.Tag = "New_Data_Frame_Name:" Me.lblNewDataFrameName.Text = "New Data Frame Name:" ' - 'ucrNewDataFrameName + 'ucrNewDataName + ' + Me.ucrNewDataName.Location = New System.Drawing.Point(130, 200) + Me.ucrNewDataName.Name = "ucrNewDataName" + Me.ucrNewDataName.Size = New System.Drawing.Size(142, 21) + Me.ucrNewDataName.TabIndex = 14 + ' + 'ucrStackDataInto + ' + Me.ucrStackDataInto.Location = New System.Drawing.Point(130, 254) + Me.ucrStackDataInto.Name = "ucrStackDataInto" + Me.ucrStackDataInto.Size = New System.Drawing.Size(142, 21) + Me.ucrStackDataInto.TabIndex = 13 ' - Me.ucrNewDataFrameName.Location = New System.Drawing.Point(134, 198) - Me.ucrNewDataFrameName.Name = "ucrNewDataFrameName" - Me.ucrNewDataFrameName.Size = New System.Drawing.Size(147, 23) - Me.ucrNewDataFrameName.TabIndex = 6 + 'ucrFactorInto + ' + Me.ucrFactorInto.Location = New System.Drawing.Point(130, 227) + Me.ucrFactorInto.Name = "ucrFactorInto" + Me.ucrFactorInto.Size = New System.Drawing.Size(142, 21) + Me.ucrFactorInto.TabIndex = 12 ' 'ucrColumnsToCarryReceiver ' - Me.ucrColumnsToCarryReceiver.Location = New System.Drawing.Point(295, 156) + Me.ucrColumnsToCarryReceiver.Location = New System.Drawing.Point(287, 162) Me.ucrColumnsToCarryReceiver.Name = "ucrColumnsToCarryReceiver" Me.ucrColumnsToCarryReceiver.Selector = Nothing Me.ucrColumnsToCarryReceiver.Size = New System.Drawing.Size(121, 113) @@ -104,49 +118,35 @@ Partial Class dlgStack ' 'ucrSelectorStack ' - Me.ucrSelectorStack.Location = New System.Drawing.Point(0, 0) + Me.ucrSelectorStack.Location = New System.Drawing.Point(5, 7) Me.ucrSelectorStack.Name = "ucrSelectorStack" Me.ucrSelectorStack.Size = New System.Drawing.Size(242, 179) Me.ucrSelectorStack.TabIndex = 0 ' 'ucrBase ' - Me.ucrBase.Location = New System.Drawing.Point(0, 279) + Me.ucrBase.Location = New System.Drawing.Point(5, 279) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(410, 65) Me.ucrBase.TabIndex = 11 ' 'ucrReceiverColumnsToBeStack ' - Me.ucrReceiverColumnsToBeStack.Location = New System.Drawing.Point(248, 24) + Me.ucrReceiverColumnsToBeStack.Location = New System.Drawing.Point(287, 29) Me.ucrReceiverColumnsToBeStack.Name = "ucrReceiverColumnsToBeStack" Me.ucrReceiverColumnsToBeStack.Selector = Nothing Me.ucrReceiverColumnsToBeStack.Size = New System.Drawing.Size(121, 132) Me.ucrReceiverColumnsToBeStack.TabIndex = 2 ' - 'ucrFactorInto - ' - Me.ucrFactorInto.Location = New System.Drawing.Point(134, 227) - Me.ucrFactorInto.Name = "ucrFactorInto" - Me.ucrFactorInto.Size = New System.Drawing.Size(142, 21) - Me.ucrFactorInto.TabIndex = 12 - ' - 'ucrStackDataInto - ' - Me.ucrStackDataInto.Location = New System.Drawing.Point(134, 254) - Me.ucrStackDataInto.Name = "ucrStackDataInto" - Me.ucrStackDataInto.Size = New System.Drawing.Size(142, 21) - Me.ucrStackDataInto.TabIndex = 13 - ' 'dlgStack ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(428, 341) + Me.ClientSize = New System.Drawing.Size(416, 341) + Me.Controls.Add(Me.ucrNewDataName) Me.Controls.Add(Me.ucrStackDataInto) Me.Controls.Add(Me.ucrFactorInto) Me.Controls.Add(Me.lblNewDataFrameName) - Me.Controls.Add(Me.ucrNewDataFrameName) Me.Controls.Add(Me.ucrColumnsToCarryReceiver) Me.Controls.Add(Me.chkColumnsToCarry) Me.Controls.Add(Me.ucrSelectorStack) @@ -172,8 +172,8 @@ Partial Class dlgStack Friend WithEvents ucrSelectorStack As ucrSelectorByDataFrameAddRemove Friend WithEvents chkColumnsToCarry As CheckBox Friend WithEvents ucrColumnsToCarryReceiver As ucrReceiverMultiple - Friend WithEvents ucrNewDataFrameName As ucrVariableName Friend WithEvents lblNewDataFrameName As Label Friend WithEvents ucrFactorInto As ucrInputTextBox Friend WithEvents ucrStackDataInto As ucrInputTextBox + Friend WithEvents ucrNewDataName As ucrInputTextBox End Class diff --git a/instat/dlgStack.vb b/instat/dlgStack.vb index 69757efad03..57daa8ed8c2 100644 --- a/instat/dlgStack.vb +++ b/instat/dlgStack.vb @@ -26,7 +26,6 @@ Public Class dlgStack Else ReopenDialog() End If - TestOKEnabled() End Sub @@ -35,61 +34,73 @@ Public Class dlgStack ucrBase.iHelpTopicID = 57 ucrReceiverColumnsToBeStack.Selector = ucrSelectorStack ucrColumnsToCarryReceiver.Selector = ucrSelectorStack - - ucrNewDataFrameName.SetName(ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked") - SetStackIntoText("value") - SetFactorIntoText("variable") - ucrReceiverColumnsToBeStack.SetMeAsReceiver() + ucrNewDataName.SetValidationTypeAsRVariable() + 'TODO Should this be enforced for column names? + 'ucrStackDataInto.SetValidationTypeAsRVariable() + 'ucrFactorInto.SetValidationTypeAsRVariable() End Sub Private Sub ReopenDialog() 'TODO this is a work around for AssignTo not clearing in RSyntax - ucrNewDataFrameName.SetName(ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked") + If ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "" Then + ucrNewDataName.SetName(ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked") + End If End Sub Private Sub TestOKEnabled() - If Not ucrReceiverColumnsToBeStack.IsEmpty() Then - ucrBase.OKEnabled(True) - Else + If ucrReceiverColumnsToBeStack.IsEmpty() OrElse ucrNewDataName.IsEmpty() OrElse ucrStackDataInto.IsEmpty() OrElse ucrFactorInto.IsEmpty() Then ucrBase.OKEnabled(False) + Else + ucrBase.OKEnabled(True) End If End Sub Private Sub SetDefaults() - ucrNewDataFrameName.Reset() + ucrNewDataName.Reset() + ucrStackDataInto.Reset() + ucrFactorInto.Reset() ucrSelectorStack.Reset() - ucrSelectorStack.Focus() + ucrReceiverColumnsToBeStack.SetMeAsReceiver() chkColumnsToCarry.Checked = False - ucrColumnsToCarryReceiver.Visible = False - ucrNewDataFrameName.bUserTyped = False - + SetColumnsToCarryProperties() + If (ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "") Then + ucrNewDataName.SetName(ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked") + End If + SetStackIntoText("value") + SetFactorIntoText("variable") End Sub - Private Sub SetFactorIntoText(strNewVal As String) - ucrFactorInto.Name = strNewVal + Private Sub SetFactorIntoText(Optional strNewVal As String = Nothing) + If strNewVal IsNot Nothing Then ucrFactorInto.SetName(strNewVal) If ucrFactorInto.GetText = "" Or (ucrFactorInto.Text = "variable" AndAlso (Not frmMain.clsInstatOptions.bIncludeRDefaultParameters)) Then ucrBase.clsRsyntax.RemoveParameter("variable.name") Else - ucrBase.clsRsyntax.AddParameter("variable.name", Chr(34) & ucrFactorInto.Text & Chr(34)) + ucrBase.clsRsyntax.AddParameter("variable.name", Chr(34) & ucrFactorInto.GetText() & Chr(34)) End If + TestOKEnabled() End Sub - Private Sub SetStackIntoText(strNewVal As String) - ucrStackDataInto.Name = strNewVal - If ucrStackDataInto.GetText = "" Or (ucrStackDataInto.Text = "value" AndAlso (Not frmMain.clsInstatOptions.bIncludeRDefaultParameters)) Then + Private Sub SetStackIntoText(Optional strNewVal As String = Nothing) + If strNewVal IsNot Nothing Then ucrStackDataInto.SetName(strNewVal) + If ucrStackDataInto.IsEmpty Then ucrBase.clsRsyntax.RemoveParameter("value.name") Else - ucrBase.clsRsyntax.AddParameter("value.name", Chr(34) & ucrStackDataInto.Text & Chr(34)) + ucrBase.clsRsyntax.AddParameter("value.name", Chr(34) & ucrStackDataInto.GetText() & Chr(34)) End If + TestOKEnabled() End Sub Private Sub chkIDVariables_CheckedChanged(sender As Object, e As EventArgs) Handles chkColumnsToCarry.CheckedChanged + SetColumnsToCarryProperties() + End Sub + + Private Sub SetColumnsToCarryProperties() If chkColumnsToCarry.Checked Then ucrColumnsToCarryReceiver.Visible = True - SetIDVars() ucrColumnsToCarryReceiver.SetMeAsReceiver() + SetIDVars() Else ucrColumnsToCarryReceiver.Visible = False ucrReceiverColumnsToBeStack.SetMeAsReceiver() @@ -109,7 +120,6 @@ Public Class dlgStack Private Sub ucrIDVariablesReceiver_SelectionChanged() Handles ucrColumnsToCarryReceiver.SelectionChanged SetIDVars() - TestOKEnabled() End Sub Private Sub SetIDVars() @@ -118,37 +128,20 @@ Public Class dlgStack Else ucrBase.clsRsyntax.AddParameter("id.vars", "NULL") End If - - End Sub - - Private Sub txtFactorInto_Leave(sender As Object, e As EventArgs) - SetFactorIntoText(ucrFactorInto.Text) - TestOKEnabled() - End Sub - - Private Sub txtStackDataInto_Leave(sender As Object, e As EventArgs) - SetStackIntoText(ucrStackDataInto.Text) - TestOKEnabled() End Sub - Private Sub ucrDataFrameAddRemove_DataFrameChanged() Handles ucrSelectorStack.DataFrameChanged - 'Always change the data parameter when data frame changed. + Private Sub ucrSelectorStack_DataFrameChanged() Handles ucrSelectorStack.DataFrameChanged ucrBase.clsRsyntax.AddParameter("data", clsRFunctionParameter:=ucrSelectorStack.ucrAvailableDataFrames.clsCurrDataFrame) - 'For Stack ucrNewDataFrameName may also be changed when data frame changed. - If Not ucrNewDataFrameName.bUserTyped Then - ucrNewDataFrameName.SetName(ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked") + If (Not ucrNewDataName.UserTyped()) AndAlso ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "" Then + ucrNewDataName.SetName(ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked") End If - + TestOKEnabled() End Sub Private Sub chkIDVariables_KeyPress(sender As Object, e As KeyPressEventArgs) Handles chkColumnsToCarry.KeyPress If e.KeyChar = vbCr Then - If chkColumnsToCarry.Checked Then - chkColumnsToCarry.Checked = False - Else - chkColumnsToCarry.Checked = True - End If + chkColumnsToCarry.Checked = Not chkColumnsToCarry.Checked End If End Sub @@ -157,11 +150,20 @@ Public Class dlgStack TestOKEnabled() End Sub - Private Sub ucrNewDataFrameName_NameChanged() Handles ucrNewDataFrameName.NameChanged - If ucrNewDataFrameName.txtValidation.Text <> "" Then - ucrBase.clsRsyntax.SetAssignTo(ucrNewDataFrameName.txtValidation.Text, strTempDataframe:=ucrNewDataFrameName.txtValidation.Text) + Private Sub ucrNewDataName_NameChanged() Handles ucrNewDataName.NameChanged + If Not ucrNewDataName.IsEmpty Then + ucrBase.clsRsyntax.SetAssignTo(ucrNewDataName.GetText(), strTempDataframe:=ucrNewDataName.GetText()) Else ucrBase.clsRsyntax.RemoveAssignTo() End If + TestOKEnabled() + End Sub + + Private Sub ucrFactorInto_NameChanged() Handles ucrFactorInto.NameChanged + SetFactorIntoText() + End Sub + + Private Sub ucrStackDataInto_NameChanged() Handles ucrStackDataInto.NameChanged + SetStackIntoText() End Sub End Class \ No newline at end of file diff --git a/instat/ucrInput.vb b/instat/ucrInput.vb index 841a5d3f8ec..871806e6d99 100644 --- a/instat/ucrInput.vb +++ b/instat/ucrInput.vb @@ -42,6 +42,10 @@ Public Class ucrInput RaiseEvent NameChanged() End Sub + Public Function UserTyped() + Return bUserTyped + End Function + Public Sub SetDefaultTypeAsColumn() strDefaultType = "Column" SetDefaultName()