Skip to content

Commit

Permalink
Added the list of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
N-thony committed Oct 26, 2023
1 parent aa39b4c commit 5cd452f
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 76 deletions.
97 changes: 41 additions & 56 deletions instat/dlgScript.Designer.vb

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

64 changes: 44 additions & 20 deletions instat/dlgScript.vb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ Public Class dlgScript
ucrPnlExample.AddRadioButton(rdoData)
ucrPnlExample.AddRadioButton(rdoFunction)

ucrPnlExample.AddToLinkedControls(ucrInputFunction, {rdoFunction}, bNewLinkedHideIfParameterMissing:=True)

'todo. this combobox can be a custom package control in future. Its also needed in dlgHelpVignettes
ucrComboGetPackage.SetParameter(New RParameter("package", 0))
ucrComboGetPackage.SetItems(GetPackages(), bAddConditions:=True)
Expand Down Expand Up @@ -225,7 +223,7 @@ Public Class dlgScript
End If
End Sub

Private Sub FillListView(dfDataframe As DataFrame)
Private Sub FillListViewWithDatasets(dfDataframe As DataFrame)
Dim lstItem As ListViewItem

lstCollection.Items.Clear()
Expand All @@ -239,6 +237,34 @@ Public Class dlgScript
End If
Next
lstCollection.Select()
lstCollection.Columns(0).Text = "Data"
End If
End Sub

Private Sub FillListViewWithFunctions(lstFunctions As List(Of String))
Dim lstItem As ListViewItem
lstCollection.Items.Clear()
If lstFunctions IsNot Nothing Then
For i As Integer = 0 To lstFunctions.Count - 1
lstItem = lstCollection.Items.Add(lstFunctions(i))
lstItem.SubItems.Add("")
Next
lstCollection.Select()
lstCollection.Columns(0).Text = "Functions"
End If
End Sub

Private Sub LoadFunctions(strPackage As String)
Dim expTemp As SymbolicExpression
Dim lstFunction As New List(Of String)
If strPackage IsNot Nothing Then
expTemp = frmMain.clsRLink.RunInternalScriptGetValue("ls(pos = asNamespace(" & Chr(34) & strPackage & Chr(34) & "))", bSilent:=True)
If expTemp IsNot Nothing Then
For i = 0 To expTemp.AsList.Length - 1
lstFunction.Add(expTemp.AsList.AsCharacter(i))
Next
End If
FillListViewWithFunctions(lstFunction)
End If
End Sub

Expand All @@ -252,7 +278,7 @@ Public Class dlgScript
dfPackage = expTemp.AsDataFrame
End If
End If
FillListView(dfDataframe:=dfPackage)
FillListViewWithDatasets(dfDataframe:=dfPackage)
End Sub

Private Sub ucrPnlGetData_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlGetData.ControlValueChanged, ucrDataFrameGet.ControlValueChanged
Expand Down Expand Up @@ -280,8 +306,10 @@ Public Class dlgScript
End Function

Private Sub lstCollection_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstCollection.SelectedIndexChanged
Dim strTopic = lstCollection.SelectedItems(0).SubItems(0).Text
GetExample(strTopic)
If lstCollection.SelectedItems.Count > 0 Then
Dim strTopic = lstCollection.SelectedItems(0).SubItems(0).Text
GetExample(strTopic)
End If
End Sub

Private Sub GetExample(strTopic As String)
Expand All @@ -291,11 +319,11 @@ Public Class dlgScript
If clsLibraryExpFunction IsNot Nothing Then
Dim strExampe = frmMain.clsRLink.RunInternalScriptGetValue(clsLibraryExpFunction.ToScript(), bSilent:=True).AsCharacter(0)
Dim strResult = RemoveDoubleHashD(strExampe)
ucrInputPreviewLibrary.SetText(If(String.IsNullOrEmpty(strResult), "No Example", strResult))
ucrInputPreviewLibrary.SetText(strResult)
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
MsgBox(strTopic & " has a help file but no examples.")
End Try
End Sub

Expand Down Expand Up @@ -389,27 +417,23 @@ Public Class dlgScript
SetPreviewScript(clsImportNewDataFrame, strData)
End Sub

Private Sub ucrPnlExample_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlExample.ControlContentsChanged, ucrInputFunction.ControlContentsChanged
If rdoData.Checked Then
lstCollection.Visible = True
Else
lstCollection.Visible = False
Dim strTopic = ucrInputFunction.GetText
GetExample(strTopic)
End If
End Sub

Private Sub ucrComboGetPackages_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrComboGetPackages.ControlValueChanged
Private Sub ucrComboGetPackages_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrComboGetPackages.ControlValueChanged, ucrPnlExample.ControlValueChanged
If strSelectedPackage <> ucrComboGetPackages.GetText() Then
strSelectedPackage = ucrComboGetPackages.GetText()
If strSelectedPackage <> "datasets" Then
clsLibraryExpFunction.AddParameter("package", Chr(34) & strSelectedPackage & Chr(34), iPosition:=1)
Else
clsLibraryExpFunction.RemoveParameterByName("package")
End If
LoadDatasets(strSelectedPackage)
TestOkEnabled()
End If
ucrInputPreviewLibrary.txtInput.Clear()

If rdoData.Checked Then
LoadDatasets(strSelectedPackage)
Else
LoadFunctions(strSelectedPackage)
End If
End Sub

Private Sub ucrInputDataFrame_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputDataFrame.ControlContentsChanged
Expand Down

0 comments on commit 5cd452f

Please sign in to comment.