Skip to content

Commit

Permalink
Merge pull request #463 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
merge from MC
  • Loading branch information
lilyclements authored May 30, 2017
2 parents eb27c9f + eb47a67 commit 849629a
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 38 deletions.
120 changes: 97 additions & 23 deletions instat/dlgStringDistance.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 32 additions & 11 deletions instat/dlgStringDistance.vb
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,47 @@ Public Class dlgStringDistance
End Sub

Private Sub InitialiseDialog()
Dim dctMethod As New Dictionary(Of String, String)
ucrBase.iHelpTopicID = 347

'ucrReceiver
ucrReceiverStringDistance.SetParameter(New RParameter("a", 0))
ucrReceiverStringDistance.SetParameterIsRFunction()
ucrReceiverStringDistance.Selector = ucrSelectorStringDistance
ucrReceiverStringDistance.SetMeAsReceiver()

ucrReceiverColumn.SetParameter(New RParameter("b", 1))
ucrReceiverColumn.SetParameterIsRFunction()
ucrReceiverColumn.Selector = ucrSelectorStringDistance
ucrReceiverColumn.SetLinkedDisplayControl(lblColumnString)

ucrInputPatternStringDistance.SetParameter(New RParameter("b", 1))
ucrInputPatternStringDistance.SetLinkedDisplayControl(lblPattern)

ucrPnlStringDist.AddRadioButton(rdoString)
ucrPnlStringDist.AddRadioButton(rdoColumn)

ucrPnlStringDist.AddParameterIsRFunctionCondition(rdoColumn, "b")
ucrPnlStringDist.AddParameterIsStringCondition(rdoString, "b")
ucrPnlStringDist.AddToLinkedControls(ucrReceiverColumn, {rdoColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlStringDist.AddToLinkedControls(ucrInputPatternStringDistance, {rdoString}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)

ucrInputComboBoxMethod.SetParameter(New RParameter("method", 2))
ucrInputComboBoxMethod.SetDropDownStyleAsNonEditable()

Dim dctMethod As New Dictionary(Of String, String)
dctMethod.Add("Optimal String Alignment", Chr(34) & "osa" & Chr(34))
dctMethod.Add("Levenshtein Distance", Chr(34) & "lv" & Chr(34))
dctMethod.Add("Cosine Distance between q-Gram Profiles", Chr(34) & "cosine" & Chr(34))
dctMethod.Add("Distance based on Soundex Encoding", Chr(34) & "soundex" & Chr(34))
dctMethod.Add("Full Damerau-Levenshtein Distance", Chr(34) & "dl" & Chr(34))
dctMethod.Add("Hamming Distance", Chr(34) & "hamming" & Chr(34))
dctMethod.Add("Longest Common Substring Distance", Chr(34) & "lcs" & Chr(34))
dctMethod.Add("q-Gram Distance", Chr(34) & "qgram" & Chr(34))
dctMethod.Add("Cosine Distance between q-Gram Profiles", Chr(34) & "cosine" & Chr(34))
dctMethod.Add("Jaccard Distance between q-Gram Profiles", Chr(34) & "jaccard" & Chr(34))
dctMethod.Add("Jaro or Jaro-Winker Distance", Chr(34) & "jw" & Chr(34))
dctMethod.Add("Distance based on Soundex Encoding", Chr(34) & "soundex" & Chr(34))
dctMethod.Add("Levenshtein Distance", Chr(34) & "lv" & Chr(34))
dctMethod.Add("Longest Common Substring Distance", Chr(34) & "lcs" & Chr(34))
dctMethod.Add("Optimal String Alignment", Chr(34) & "osa" & Chr(34))
dctMethod.Add("q-Gram Distance", Chr(34) & "qgram" & Chr(34))
ucrInputComboBoxMethod.SetItems(dctMethod)
ucrInputComboBoxMethod.SetRDefault(Chr(34) & "osa" & Chr(34))
'ucrSave

ucrSaveStringDistance.SetPrefix("Dist")
ucrSaveStringDistance.SetSaveTypeAsColumn()
ucrSaveStringDistance.SetDataFrameSelector(ucrSelectorStringDistance.ucrAvailableDataFrames)
Expand All @@ -67,14 +83,17 @@ Public Class dlgStringDistance

Private Sub SetDefaults()
clsStringDistFunction = New RFunction

ucrInputPatternStringDistance.SetName("")
ucrSelectorStringDistance.Reset()
ucrSaveStringDistance.Reset()
ucrInputComboBoxMethod.Reset()
ucrInputPatternStringDistance.Reset()

clsStringDistFunction.SetPackageName("stringdist")
clsStringDistFunction.SetRCommand("stringdist")
ucrInputPatternStringDistance.Reset()
clsStringDistFunction.AddParameter("method", Chr(34) & "osa" & Chr(34))
clsStringDistFunction.AddParameter("b", Chr(34) & Chr(34))
ucrBase.clsRsyntax.SetBaseRFunction(clsStringDistFunction)
End Sub

Expand All @@ -83,7 +102,9 @@ Public Class dlgStringDistance
End Sub

Private Sub TestOkEnabled()
If Not ucrReceiverStringDistance.IsEmpty() AndAlso Not ucrInputPatternStringDistance.IsEmpty() AndAlso Not ucrInputComboBoxMethod.IsEmpty AndAlso ucrSaveStringDistance.IsComplete() Then
If rdoColumn.Checked AndAlso Not ucrReceiverColumn.IsEmpty() AndAlso Not ucrReceiverStringDistance.IsEmpty() AndAlso ucrSaveStringDistance.IsComplete() AndAlso Not ucrInputComboBoxMethod.IsEmpty Then
ucrBase.OKEnabled(True)
ElseIf rdoString.Checked AndAlso Not ucrReceiverStringDistance.IsEmpty() AndAlso Not ucrInputPatternStringDistance.IsEmpty() AndAlso ucrSaveStringDistance.IsComplete() AndAlso Not ucrInputComboBoxMethod.IsEmpty Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
Expand All @@ -96,7 +117,7 @@ Public Class dlgStringDistance
TestOkEnabled()
End Sub

Private Sub UcrReceiverStringDistance_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverStringDistance.ControlContentsChanged, ucrSaveStringDistance.ControlContentsChanged, ucrInputPatternStringDistance.ControlContentsChanged, ucrInputComboBoxMethod.ControlContentsChanged
Private Sub ucrReceiverStringDistance_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverStringDistance.ControlContentsChanged, ucrReceiverColumn.ControlContentsChanged, ucrSaveStringDistance.ControlContentsChanged, ucrInputPatternStringDistance.ControlContentsChanged, ucrInputComboBoxMethod.ControlContentsChanged
TestOkEnabled()
End Sub
End Class
2 changes: 1 addition & 1 deletion instat/ucrInput.vb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Public Class ucrInput
Private bLastSilent As Boolean = False
Private bPrivateAddQuotesIfUnrecognised As Boolean = True
Protected dctDisplayParameterValues As New Dictionary(Of String, String)
Protected bFirstLoad As Boolean = True

Public Sub New()

Expand Down Expand Up @@ -391,7 +392,6 @@ Public Class ucrInput
If Not bUserTyped Then
SetDefaultName()
End If
'RaiseEvent NameChanged()
End Sub

Private Sub ucrInput_TextChanged(sender As Object, e As EventArgs) Handles Me.TextChanged
Expand Down
24 changes: 23 additions & 1 deletion instat/ucrInputComboBox.vb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ Public Class ucrInputComboBox
Private Sub ucrInputComboBox_Load(sender As Object, e As EventArgs) Handles Me.Load
bAllowNonConditionValues = False
FillItemTypes()
If bFirstLoad Then
SetDropDownStyleAsEditable(True)
bFirstLoad = False
End If
End Sub

Private Sub cboInput_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboInput.SelectedIndexChanged
Expand Down Expand Up @@ -218,4 +222,22 @@ Public Class ucrInputComboBox
Public Overrides Sub UpdateControl(Optional bReset As Boolean = False)
MyBase.UpdateControl(bReset)
End Sub
End Class

Public Sub SetDropDownStyleAsNonEditable()
cboInput.DropDownStyle = ComboBoxStyle.DropDownList
cboInput.AutoCompleteMode = AutoCompleteMode.None
cboInput.AutoCompleteSource = AutoCompleteSource.None
End Sub

Public Sub SetDropDownStyleAsEditable(bAdditionsAllowed As Boolean)
cboInput.DropDownStyle = ComboBoxStyle.DropDown
cboInput.AutoCompleteMode = AutoCompleteMode.Append
cboInput.AutoCompleteSource = AutoCompleteSource.ListItems
'TODO implement validation settings for this
If bAdditionsAllowed Then

Else

End If
End Sub
End Class
10 changes: 8 additions & 2 deletions instat/ucrInputTextBox.vb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ Public Class ucrInputTextBox

Private Sub mnuRightClickCopy_Click(sender As Object, e As EventArgs) Handles mnuRightClickCopy.Click
txtInput.Copy()
End Sub

End Sub

Private Sub ucrInputTextBox_Load(sender As Object, e As EventArgs) Handles Me.Load
If bFirstLoad Then
bFirstLoad = False
End If
End Sub

Public Overrides Property IsReadOnly As Boolean
Get
Return MyBase.IsReadOnly
Expand Down

0 comments on commit 849629a

Please sign in to comment.