Skip to content

Commit

Permalink
Merge pull request #1618 from dannyparsons/replace
Browse files Browse the repository at this point in the history
fixed bugs in replace dialog and bug in removing all items in multiple receiver
  • Loading branch information
dannyparsons authored Aug 12, 2016
2 parents d50ec90 + 05ff3a7 commit 5c8be5c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
53 changes: 34 additions & 19 deletions instat/dlgReplace.vb
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,45 @@ Public Class dlgReplace
End Sub

Private Sub CheckType()
If (Not ucrReceiverReplace.IsEmpty() And ucrReceiverReplace.lstSelectedVariables.Items.Count = 1) Then
Dim strVariableTypes As List(Of String)
Dim strOldType As String
strOldType = strVarType
If (Not ucrReceiverReplace.IsEmpty()) Then
clsGetDataType.AddParameter("data_name", Chr(34) & ucrSelectorReplace.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34))
clsGetDataType.AddParameter("column", ucrReceiverReplace.GetVariableNames())
strVarType = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataType.ToScript()).AsCharacter(0)
If (strVarType = "numeric" OrElse strVarType = "integer") Then
ucrReceiverReplace.SetDataType("numeric")
End If
If (strVarType = "character") Then
ucrReceiverReplace.SetDataType("character")
End If
If (strVarType = "factor") Then
ucrReceiverReplace.SetDataType("factor")
End If
If (strVarType = "logical") Then
ucrReceiverReplace.SetDataType("logical")
End If
If (strVarType = "Date") Then
ucrReceiverReplace.SetDataType("Date")
If ucrReceiverReplace.lstSelectedVariables.Items.Count = 1 Then
strVarType = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataType.ToScript()).AsCharacter(0)
If (strVarType = "numeric" OrElse strVarType = "integer") Then
ucrReceiverReplace.SetDataType("numeric")
Else
ucrReceiverReplace.SetDataType(strVarType)
End If
ElseIf strVarType = "" AndAlso ucrReceiverReplace.lstSelectedVariables.Items.Count > 1 Then
strVariableTypes = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataType.ToScript()).AsCharacter.ToList()
If strVariableTypes.Distinct().Count > 1 AndAlso Not (strVariableTypes.Distinct().Count = 2 AndAlso strVariableTypes.Distinct().Contains("numeric") AndAlso strVariableTypes.Distinct().Contains("integer")) Then
MsgBox("Cannot add these variables. All variables must be of the same data type.", MsgBoxStyle.OkOnly, "Cannot add variables.")
ucrReceiverReplace.Clear()
Else
If strVariableTypes.Distinct().Count = 1 Then
strVarType = strVariableTypes(0)
Else
strVarType = "numeric"
End If
ucrReceiverReplace.SetDataType(strVarType)
End If
End If
ElseIf ucrReceiverReplace.IsEmpty() Then
Else
strVarType = ""
ucrReceiverReplace.RemoveIncludedMetadataProperty(strProperty:="class")
End If
If rdoOldValue.Checked Then
rdoOldValue.Checked = False
rdoOldValue.Checked = True
End If
If rdoNewValue.Checked Then
rdoNewValue.Checked = False
rdoNewValue.Checked = True
End If
End Sub

Private Sub ucrBaseReplace_ClickReset(sender As Object, e As EventArgs) Handles ucrBaseReplace.ClickReset
Expand All @@ -106,7 +122,6 @@ Public Class dlgReplace
End Sub

Private Sub ucrSelectorReplace_DataFrameChanged() Handles ucrSelectorReplace.DataFrameChanged
CheckType()
ucrBaseReplace.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectorReplace.ucrAvailableDataFrames.cboAvailableDataFrames.SelectedItem & Chr(34))
TestOKEnabled()
End Sub
Expand Down Expand Up @@ -135,7 +150,7 @@ Public Class dlgReplace
ucrBaseReplace.clsRsyntax.RemoveParameter("new_value")
Else
If (strVarType = "numeric" OrElse strVarType = "integer") Then
ucrBaseReplace.clsRsyntax.AddParameter("new_value", ucrInputNewValue.GetText)
ucrBaseReplace.clsRsyntax.AddParameter("new_value", ucrInputNewValue.GetText())
Else
ucrBaseReplace.clsRsyntax.AddParameter("new_value", Chr(34) & ucrInputNewValue.GetText & Chr(34))
End If
Expand Down
1 change: 1 addition & 0 deletions instat/ucrReceiverMultiple.vb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Public Class ucrReceiverMultiple
lstSelectedVariables.Items.RemoveByKey(strTempItem)
Selector.RemoveFromVariablesList(strTempItem)
Next
OnSelectionChanged()
End Sub

Public Overrides Sub Clear()
Expand Down

0 comments on commit 5c8be5c

Please sign in to comment.