Skip to content

Commit

Permalink
Merge pull request #1579 from dannyparsons/autoaddreceiver
Browse files Browse the repository at this point in the history
Updated receiver behaviour for adding items
  • Loading branch information
dannyparsons authored Aug 2, 2016
2 parents 622a12d + 7c96a8a commit f0fd7bd
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 130 deletions.
9 changes: 7 additions & 2 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,10 @@ Public Class RLink
Dim clsGetItems As New RFunction
Dim clsIncludeList As New RFunction
Dim kvpInclude As KeyValuePair(Of String, String())
Dim lstItems As New List(Of KeyValuePair(Of String, String))

kvpInclude = New KeyValuePair(Of String, String())(strProperty, strValues)

ucrCurrentReceiver.Selector.LoadList()
If bInstatObjectExists Then
clsGetItems.SetRCommand(strInstatDataObject & "$get_column_names")
clsGetItems.AddParameter("as_list", "TRUE")
Expand All @@ -480,9 +481,13 @@ Public Class RLink
ucrCurrentReceiver.Clear()
For i = 0 To vecColumns.Count - 1
chrCurrColumns = vecColumns(i).AsCharacter
ucrCurrentReceiver.Add(chrCurrColumns.ToArray())
For Each strColumn As String In chrCurrColumns
lstItems.Add(New KeyValuePair(Of String, String)(strDataFrameName, strColumn))
Next
ucrCurrentReceiver.AddMultiple(lstItems.ToArray())
Next
End If
ucrCurrentReceiver.Selector.LoadList()
End Sub

Public Function GetListAsRString(lstStrings As List(Of String), Optional bWithQuotes As Boolean = True) As String
Expand Down
60 changes: 30 additions & 30 deletions instat/dlgColumnStructures.Designer.vb

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

44 changes: 21 additions & 23 deletions instat/dlgColumnStructures.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,58 @@ Public Class dlgColumnStructure
End Sub

Private Sub InitialiseDialog()
ucrReceiverTreatment.Selector = ucrSelectorColumnStructure
ucrReceiverForLayout.Selector = ucrSelectorColumnStructure
ucrReceiverMeasurement.Selector = ucrSelectorColumnStructure
ucrReceiverForLayout.SetMeAsReceiver()
ucrReceiverForLayout.bExcludeFromSelector = True
ucrReceiverMeasurement.bExcludeFromSelector = True
ucrReceiverTreatment.bExcludeFromSelector = True
ucrReceiverType2.Selector = ucrSelectorColumnStructure
ucrReceiverType1.Selector = ucrSelectorColumnStructure
ucrReceiverType3.Selector = ucrSelectorColumnStructure
ucrReceiverType1.bExcludeFromSelector = True
ucrReceiverType3.bExcludeFromSelector = True
ucrReceiverType2.bExcludeFromSelector = True
ucrBase.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$set_structure_columns")
End Sub

Private Sub SetDefaults()
' ucrSelectorColumnStructure.Reset()
SetColumnStructureInReceiver()
ucrReceiverType1.SetMeAsReceiver()
End Sub

Private Sub ReopenDialog()

End Sub

Private Sub SetColumnStructureInReceiver()
'ucrSelectorColumnStructure.Reset()
ucrSelectorColumnStructure.AddItemsWithMetadataProperty("Structure", {Chr(34) & "Treatment" & Chr(34), Chr(34) & "Measurement" & Chr(34), Chr(34) & "Layout" & Chr(34)})
ucrReceiverType1.AddItemsWithMetadataProperty(ucrSelectorColumnStructure.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Structure", {"structure_type_1_label"})
ucrReceiverType2.AddItemsWithMetadataProperty(ucrSelectorColumnStructure.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Structure", {"structure_type_2_label"})
ucrReceiverType3.AddItemsWithMetadataProperty(ucrSelectorColumnStructure.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Structure", {"structure_type_3_label"})
ucrReceiverType1.SetMeAsReceiver()
End Sub

Private Sub TestOKEnabled()
If ucrReceiverForLayout.IsEmpty() = False Or ucrReceiverMeasurement.IsEmpty() = False Or ucrReceiverTreatment.IsEmpty() = False Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
ucrBase.OKEnabled(True)
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
SetColumnStructureInReceiver()
TestOKEnabled()
End Sub

Private Sub ucrReceiverForColumnStructure_SelectionChanged() Handles ucrReceiverForLayout.SelectionChanged, ucrReceiverMeasurement.SelectionChanged, ucrReceiverTreatment.SelectionChanged
Private Sub ucrReceiverForColumnStructure_SelectionChanged() Handles ucrReceiverType1.SelectionChanged, ucrReceiverType3.SelectionChanged, ucrReceiverType2.SelectionChanged
StructureParameters()
End Sub

Private Sub StructureParameters()
If ucrReceiverForLayout.IsEmpty = False Then
ucrBase.clsRsyntax.AddParameter("struc_type_2", ucrReceiverTreatment.GetVariableNames)
If ucrReceiverType1.IsEmpty = False Then
ucrBase.clsRsyntax.AddParameter("struc_type_2", ucrReceiverType2.GetVariableNames)
Else
ucrBase.clsRsyntax.RemoveParameter("struc_type_2")
End If
If ucrReceiverMeasurement.IsEmpty = False Then
ucrBase.clsRsyntax.AddParameter("struc_type_3", ucrReceiverMeasurement.GetVariableNames)
If ucrReceiverType3.IsEmpty = False Then
ucrBase.clsRsyntax.AddParameter("struc_type_3", ucrReceiverType3.GetVariableNames)
Else
ucrBase.clsRsyntax.RemoveParameter("struc_type_3")
End If

If ucrReceiverTreatment.IsEmpty = False Then
ucrBase.clsRsyntax.AddParameter("struc_type_1", ucrReceiverForLayout.GetVariableNames)
If ucrReceiverType2.IsEmpty = False Then
ucrBase.clsRsyntax.AddParameter("struc_type_1", ucrReceiverType1.GetVariableNames)
Else
ucrBase.clsRsyntax.RemoveParameter("struc_type_1")
End If
Expand All @@ -94,5 +91,6 @@ Public Class dlgColumnStructure

Private Sub ucrSelectorColumnStructure_DataFrameChanged() Handles ucrSelectorColumnStructure.DataFrameChanged
ucrBase.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectorColumnStructure.ucrAvailableDataFrames.cboAvailableDataFrames.SelectedItem & Chr(34))
SetColumnStructureInReceiver()
End Sub
End Class
9 changes: 3 additions & 6 deletions instat/dlgHideShowColumns.vb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Public Class dlgHideShowColumns
TestOKEnabled()
bFirstLoad = False
End If
ucrSelectorForHiddenColumns.strAddOnLoad = New KeyValuePair(Of String, String())("Is_Hidden", {"TRUE"})
SetHiddenColumnsInReceiver()
End Sub

Expand All @@ -48,13 +47,11 @@ Public Class dlgHideShowColumns
End Sub

Private Sub SetHiddenColumnsInReceiver()
ucrSelectorForHiddenColumns.Reset()
ucrSelectorForHiddenColumns.strAddOnLoad = New KeyValuePair(Of String, String())("Is_Hidden", {"TRUE"})
ucrSelectorForHiddenColumns.AddItemsWithMetadataProperty("Is_Hidden", {"TRUE"})
ucrReceiverHiddenColumns.AddItemsWithMetadataProperty(ucrSelectorForHiddenColumns.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Is_Hidden", {"TRUE"})
End Sub

Private Sub SetDefaults()
'SetHiddenColumnsInReceiver()
SetHiddenColumnsInReceiver()
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
Expand All @@ -64,8 +61,8 @@ Public Class dlgHideShowColumns
End Sub

Private Sub ucrSelectorForHiddenColumns_DataFrameChanged() Handles ucrSelectorForHiddenColumns.DataFrameChanged

ucrBase.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectorForHiddenColumns.ucrAvailableDataFrames.cboAvailableDataFrames.SelectedItem & Chr(34))
SetHiddenColumnsInReceiver()
End Sub

Private Sub ucrReceiverHiddenColumns_SelectionChanged() Handles ucrReceiverHiddenColumns.SelectionChanged
Expand Down
2 changes: 1 addition & 1 deletion instat/dlgName.vb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Public Class dlgName

Private Sub SetDefaultColumn()
ucrSelectVariables.ucrAvailableDataFrames.cboAvailableDataFrames.SelectedItem = strSelectedDataFrame
ucrReceiverName.SetSelected(strSelectedColumn, strSelectedDataFrame)
ucrReceiverName.Add(strSelectedColumn, strSelectedDataFrame)
bUseSelectedColumn = False
End Sub

Expand Down
3 changes: 2 additions & 1 deletion instat/dlgRenameDescriptive.vb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ Public Class dlgRenameDescriptive

Private Sub SetDefaultOject()
ucrSelectorForRenameObject.ucrAvailableDataFrames.cboAvailableDataFrames.SelectedItem = strSelectedDataFrame
ucrReceiverCurrentName.SetSelected(strSelectedOject, strSelectedDataFrame)
ucrReceiverCurrentName.Add(strSelectedOject, strSelectedDataFrame)
bUseSelectedObject = False
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
TestOKEnabled()
Expand Down
26 changes: 15 additions & 11 deletions instat/ucrReceiver.vb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Public Class ucrReceiver
End If
End Sub

Public Overridable Sub Remove(strItems As String())

End Sub

Public Overridable Sub Clear()

End Sub
Expand Down Expand Up @@ -226,16 +230,16 @@ Public Class ucrReceiver
bTypeSet = True
End Sub

Public Sub Add(strItem As String)
SetMeAsReceiver()
For i = 0 To Selector.lstAvailableVariable.Items.Count - 1
If Selector.lstAvailableVariable.Items(i).Text = strItem Then
Selector.lstAvailableVariable.SelectedItems.Clear()
Selector.lstAvailableVariable.Items(i).Selected = True
AddSelected()
Selector.lstAvailableVariable.SelectedItems.Clear()
Exit For
End If
Next
Public Overridable Sub Add(strItem As String, Optional strDataFrame As String = "")
'SetMeAsReceiver()
'For i = 0 To Selector.lstAvailableVariable.Items.Count - 1
' If Selector.lstAvailableVariable.Items(i).Text = strItem Then
' Selector.lstAvailableVariable.SelectedItems.Clear()
' Selector.lstAvailableVariable.Items(i).Selected = True
' AddSelected()
' Selector.lstAvailableVariable.SelectedItems.Clear()
' Exit For
' End If
'Next
End Sub
End Class
1 change: 1 addition & 0 deletions instat/ucrReceiverMultiple.designer.vb

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

Loading

0 comments on commit f0fd7bd

Please sign in to comment.