Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bugs in replace dialog and bug in removing all items in multiple receiver #1618

Merged
merged 3 commits into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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