From 21ca025230a5a43ea7f5771f93734f9cad8417a1 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Mon, 2 Dec 2024 16:17:57 +0000 Subject: [PATCH 01/23] Adding option to rename labels --- instat/static/InstatObject/R/data_object_R6.R | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 2bea3ede08..31bc20285a 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1011,6 +1011,25 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne self$data_changed <- TRUE self$variables_metadata_changed <- TRUE } + } else if (type == "rename_labels"){ + # to rename column labels. Here, instead of renaming a column name, we're giving new values in a column. + curr_metadata <- self$get_variables_metadata() + curr_col_names <- names(curr_data) + + new_metadata <- curr_metadata |> + dplyr::mutate( + dplyr::across( + {{ .cols }}, + ~ .fn(., ...) + ) + ) + if(self$column_selection_applied()) self$remove_current_column_selection() + new_label_names <- new_metadata[!("Name" %in% curr_col_names)]$label + for (i in seq_along(new_label_names)) { + self$append_to_variables_metadata(curr_col_names[i], property = "label", new_val = new_label_names[i]) + } + self$data_changed <- TRUE + self$variables_metadata_changed <- TRUE } }) From 1d34edd6c805c37379661c7403282df8d205bc44 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Wed, 4 Dec 2024 09:54:01 +0300 Subject: [PATCH 02/23] changes to the code --- instat/dlgName.Designer.vb | 32 +++++++++++++++++++++++++++----- instat/dlgName.vb | 22 ++++++++++++++++++---- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/instat/dlgName.Designer.vb b/instat/dlgName.Designer.vb index 343d0eee9b..222e51d490 100644 --- a/instat/dlgName.Designer.vb +++ b/instat/dlgName.Designer.vb @@ -71,6 +71,7 @@ Partial Class dlgName Me.ucrPnlOptions = New instat.UcrPanel() Me.ucrReceiverColumns = New instat.ucrReceiverMultiple() Me.ucrPnlSelectData = New instat.UcrPanel() + Me.rdoLabels = New System.Windows.Forms.RadioButton() Me.grpOptions.SuspendLayout() Me.SuspendLayout() ' @@ -109,7 +110,7 @@ Partial Class dlgName Me.rdoMultiple.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption Me.rdoMultiple.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.rdoMultiple.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.rdoMultiple.Location = New System.Drawing.Point(218, 10) + Me.rdoMultiple.Location = New System.Drawing.Point(178, 10) Me.rdoMultiple.Name = "rdoMultiple" Me.rdoMultiple.Size = New System.Drawing.Size(110, 28) Me.rdoMultiple.TabIndex = 2 @@ -128,7 +129,7 @@ Partial Class dlgName Me.rdoSingle.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption Me.rdoSingle.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.rdoSingle.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.rdoSingle.Location = New System.Drawing.Point(108, 10) + Me.rdoSingle.Location = New System.Drawing.Point(70, 10) Me.rdoSingle.Name = "rdoSingle" Me.rdoSingle.Size = New System.Drawing.Size(110, 28) Me.rdoSingle.TabIndex = 1 @@ -312,7 +313,7 @@ Partial Class dlgName Me.rdoRenameWith.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption Me.rdoRenameWith.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.rdoRenameWith.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.rdoRenameWith.Location = New System.Drawing.Point(328, 10) + Me.rdoRenameWith.Location = New System.Drawing.Point(286, 10) Me.rdoRenameWith.Name = "rdoRenameWith" Me.rdoRenameWith.Size = New System.Drawing.Size(110, 28) Me.rdoRenameWith.TabIndex = 13 @@ -429,9 +430,9 @@ Partial Class dlgName 'ucrPnlOptions ' Me.ucrPnlOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlOptions.Location = New System.Drawing.Point(97, 2) + Me.ucrPnlOptions.Location = New System.Drawing.Point(62, 2) Me.ucrPnlOptions.Name = "ucrPnlOptions" - Me.ucrPnlOptions.Size = New System.Drawing.Size(355, 44) + Me.ucrPnlOptions.Size = New System.Drawing.Size(448, 44) Me.ucrPnlOptions.TabIndex = 0 ' 'ucrReceiverColumns @@ -455,12 +456,32 @@ Partial Class dlgName Me.ucrPnlSelectData.Size = New System.Drawing.Size(315, 51) Me.ucrPnlSelectData.TabIndex = 19 ' + 'rdoLabels + ' + Me.rdoLabels.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoLabels.BackColor = System.Drawing.SystemColors.Control + Me.rdoLabels.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoLabels.FlatAppearance.BorderSize = 2 + Me.rdoLabels.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoLabels.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoLabels.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoLabels.Location = New System.Drawing.Point(394, 10) + Me.rdoLabels.Name = "rdoLabels" + Me.rdoLabels.Size = New System.Drawing.Size(110, 28) + Me.rdoLabels.TabIndex = 22 + Me.rdoLabels.TabStop = True + Me.rdoLabels.Tag = "" + Me.rdoLabels.Text = "Labels With" + Me.rdoLabels.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoLabels.UseVisualStyleBackColor = False + ' 'dlgName ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True Me.ClientSize = New System.Drawing.Size(545, 540) + Me.Controls.Add(Me.rdoLabels) Me.Controls.Add(Me.grdRenameColumns) Me.Controls.Add(Me.ucrChkIncludeVariable) Me.Controls.Add(Me.rdoRenameWith) @@ -527,4 +548,5 @@ Partial Class dlgName Friend WithEvents rdoSelectedColumn As RadioButton Friend WithEvents rdoWholeDataFrame As RadioButton Friend WithEvents ucrPnlSelectData As UcrPanel + Friend WithEvents rdoLabels As RadioButton End Class diff --git a/instat/dlgName.vb b/instat/dlgName.vb index b108de0f7e..b345413a36 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -83,6 +83,7 @@ Public Class dlgName ucrPnlOptions.AddRadioButton(rdoSingle, Chr(34) & "single" & Chr(34)) ucrPnlOptions.AddRadioButton(rdoMultiple, Chr(34) & "multiple" & Chr(34)) ucrPnlOptions.AddRadioButton(rdoRenameWith, Chr(34) & "rename_with" & Chr(34)) + ucrPnlOptions.AddRadioButton(rdoLabels, Chr(34) & "labels_with" & Chr(34)) ucrPnlOptions.SetRDefault(Chr(34) & "single" & Chr(34)) ucrNudAbbreviate.SetParameter(New RParameter("minlength", 10)) @@ -142,7 +143,7 @@ Public Class dlgName ucrPnlOptions.AddToLinkedControls({ucrReceiverName, ucrInputNewName, ucrInputVariableLabel}, {rdoSingle}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls(ucrChkIncludeVariable, {rdoMultiple}, bNewLinkedHideIfParameterMissing:=True) - ucrPnlOptions.AddToLinkedControls({ucrPnlCase, ucrPnlSelectData}, {rdoRenameWith}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls({ucrPnlCase, ucrPnlSelectData}, {rdoRenameWith, rdoLabels}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlCase.AddToLinkedControls(ucrInputCase, {rdoMakeCleanNames}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Snake") ucrPnlCase.AddToLinkedControls(ucrNudAbbreviate, {rdoAbbreviate}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="8") ucrPnlCase.AddToLinkedControls(ucrInputReplace, {rdoReplace}, bNewLinkedHideIfParameterMissing:=True) @@ -569,7 +570,7 @@ Public Class dlgName Private Sub ucrPnlOptions_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlOptions.ControlValueChanged, ucrPnlCase.ControlValueChanged, ucrPnlSelectData.ControlValueChanged, ucrInputCase.ControlValueChanged, ucrNudAbbreviate.ControlValueChanged, ucrReceiverColumns.ControlValueChanged If rdoSingle.Checked Then ucrReceiverName.SetMeAsReceiver() - ElseIf rdoRenameWith.Checked Then + ElseIf rdoRenameWith.Checked OrElse rdoLabels.Checked Then ucrInputBy.Visible = rdoWholeDataFrame.Checked AndAlso rdoReplace.Checked ucrInputEdit.Visible = ucrInputBy.Visible ucrInputReplace.Visible = ucrInputBy.Visible @@ -584,12 +585,14 @@ Public Class dlgName End If End If ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoRenameWith.Checked AndAlso rdoSelectedColumn.Checked) + ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoLabels.Checked AndAlso rdoSelectedColumn.Checked) ucrSelectVariables.btnAdd.Visible = ucrSelectVariables.lstAvailableVariable.Visible ucrSelectVariables.btnDataOptions.Visible = ucrSelectVariables.lstAvailableVariable.Visible UpdateGrid() RemoveParameters() DialogueSize() RemovePattern() + AddTypeParm() End Sub Private Sub DialogueSize() @@ -660,8 +663,7 @@ Public Class dlgName Private Sub RemovePattern() If rdoWholeDataFrame.Checked Then - If rdoRenameWith.Checked AndAlso rdoReplace.Checked Then - clsDefaultRFunction.AddParameter("type", Chr(34) & "rename_with" & Chr(34), iPosition:=1) + If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) clsDefaultRFunction.RemoveParameterByName("label") @@ -687,7 +689,19 @@ Public Class dlgName End If End Sub + Private Sub AddTypeParm() + If rdoLabels.Checked Then + clsDefaultRFunction.AddParameter("type", Chr(34) & "rename_labels" & Chr(34), iPosition:=1) + + ElseIf rdoRenameWith.Checked Then + clsDefaultRFunction.AddParameter("type", Chr(34) & "rename_with" & Chr(34), iPosition:=1) + Else + + End If + End Sub + Private Sub ucrInputEdit_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputEdit.ControlValueChanged, ucrInputBy.ControlValueChanged, ucrInputReplace.ControlValueChanged RemovePattern() + AddTypeParm() End Sub End Class From 8e3f2ae80cf1a854fa4f7543e31d37a912af96cc Mon Sep 17 00:00:00 2001 From: lilyclements Date: Wed, 4 Dec 2024 11:23:29 +0000 Subject: [PATCH 03/23] Update data_object_R6.R --- instat/static/InstatObject/R/data_object_R6.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 31bc20285a..66b9678ae4 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1019,7 +1019,7 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne new_metadata <- curr_metadata |> dplyr::mutate( dplyr::across( - {{ .cols }}, + Name, ~ .fn(., ...) ) ) From 622805ac157c5dfb73c0275b2f1e2dc883a507f9 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Wed, 4 Dec 2024 11:36:52 +0000 Subject: [PATCH 04/23] Update data_object_R6.R --- instat/static/InstatObject/R/data_object_R6.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 66b9678ae4..9d148f4e61 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1014,16 +1014,20 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne } else if (type == "rename_labels"){ # to rename column labels. Here, instead of renaming a column name, we're giving new values in a column. curr_metadata <- self$get_variables_metadata() - curr_col_names <- names(curr_data) - + curr_col_names <- names(curr_data %>% dplyr::select(.cols)) + + # create a new data frame containing the changes - but only apply to those that we actually plan to change for efficiency. new_metadata <- curr_metadata |> + dplyr::filter(Name %in% curr_col_names) %>% dplyr::mutate( dplyr::across( - Name, + label, ~ .fn(., ...) ) ) + if(self$column_selection_applied()) self$remove_current_column_selection() + # apply the changes new_label_names <- new_metadata[!("Name" %in% curr_col_names)]$label for (i in seq_along(new_label_names)) { self$append_to_variables_metadata(curr_col_names[i], property = "label", new_val = new_label_names[i]) From f4c86e9a5e2bc4cae5fe0f91d492e99deb24f2a6 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Wed, 4 Dec 2024 14:41:13 +0300 Subject: [PATCH 05/23] changes --- instat/dlgName.vb | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index b345413a36..179e8a74dd 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -80,11 +80,17 @@ Public Class dlgName ucrInputVariableLabel.SetParameter(New RParameter("label", 3)) ucrPnlOptions.SetParameter(New RParameter("type", 4)) - ucrPnlOptions.AddRadioButton(rdoSingle, Chr(34) & "single" & Chr(34)) - ucrPnlOptions.AddRadioButton(rdoMultiple, Chr(34) & "multiple" & Chr(34)) - ucrPnlOptions.AddRadioButton(rdoRenameWith, Chr(34) & "rename_with" & Chr(34)) - ucrPnlOptions.AddRadioButton(rdoLabels, Chr(34) & "labels_with" & Chr(34)) - ucrPnlOptions.SetRDefault(Chr(34) & "single" & Chr(34)) + ucrPnlOptions.AddRadioButton(rdoSingle) + ucrPnlOptions.AddRadioButton(rdoMultiple) + ucrPnlOptions.AddRadioButton(rdoRenameWith) + ucrPnlOptions.AddRadioButton(rdoLabels) + ucrPnlOptions.AddParameterValuesCondition(rdoSingle, "name", "single") + ucrPnlOptions.AddParameterValuesCondition(rdoMultiple, "name", "multiple") + ucrPnlOptions.AddParameterValuesCondition(rdoRenameWith, "name", "rename") + ucrPnlOptions.AddParameterValuesCondition(rdoLabels, "name", "labels") + + + 'ucrPnlOptions.SetRDefault(Chr(34) & "single" & Chr(34)) ucrNudAbbreviate.SetParameter(New RParameter("minlength", 10)) ucrNudAbbreviate.SetMinMax(Integer.MinValue, Integer.MaxValue) @@ -183,6 +189,7 @@ Public Class dlgName clsDummyFunction.AddParameter("checked", "FALSE", iPosition:=0) clsDummyFunction.AddParameter("checked", "whole", iPosition:=1) + clsDummyFunction.AddParameter("name", "single", iPosition:=2) clsDefaultRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$rename_column_in_data") clsDefaultRFunction.AddParameter("type", Chr(34) & "single" & Chr(34), iPosition:=4) @@ -223,12 +230,12 @@ Public Class dlgName ucrPnlCase.SetRCode(clsDefaultRFunction, bReset) ucrInputReplace.SetRCode(clsDefaultRFunction, bReset) ucrChkIncludeVariable.SetRCode(clsDummyFunction, bReset) + ucrPnlSelectData.SetRCode(clsDummyFunction, bReset) + ucrPnlOptions.SetRCode(clsDummyFunction, bReset) End If ucrInputCase.SetRCode(clsDefaultRFunction, bReset) ucrNudAbbreviate.SetRCode(clsDefaultRFunction, bReset) - ucrPnlOptions.SetRCode(clsDefaultRFunction, bReset) ucrInputBy.SetRCode(clsDefaultRFunction, bReset) - ucrPnlSelectData.SetRCode(clsDummyFunction, bReset) End Sub Private Sub TestOKEnabled() @@ -584,8 +591,13 @@ Public Class dlgName End If End If End If - ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoRenameWith.Checked AndAlso rdoSelectedColumn.Checked) - ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoLabels.Checked AndAlso rdoSelectedColumn.Checked) + + ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse + (rdoRenameWith.Checked AndAlso rdoSelectedColumn.Checked) OrElse + (rdoLabels.Checked AndAlso rdoSelectedColumn.Checked) + + 'ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoRenameWith.Checked AndAlso rdoSelectedColumn.Checked) + 'ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoLabels.Checked AndAlso rdoSelectedColumn.Checked) ucrSelectVariables.btnAdd.Visible = ucrSelectVariables.lstAvailableVariable.Visible ucrSelectVariables.btnDataOptions.Visible = ucrSelectVariables.lstAvailableVariable.Visible UpdateGrid() From 088d3c1b3d3edda34c37448814a84c744aec165f Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Wed, 4 Dec 2024 16:09:40 +0300 Subject: [PATCH 06/23] changes to the code --- instat/dlgName.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 179e8a74dd..e7f0049245 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -189,7 +189,8 @@ Public Class dlgName clsDummyFunction.AddParameter("checked", "FALSE", iPosition:=0) clsDummyFunction.AddParameter("checked", "whole", iPosition:=1) - clsDummyFunction.AddParameter("name", "single", iPosition:=2) + clsDummyFunction.AddParameter("name", "single", iPosition:=1) + clsDefaultRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$rename_column_in_data") clsDefaultRFunction.AddParameter("type", Chr(34) & "single" & Chr(34), iPosition:=4) From fc4a9ad115b5473acd046f0f73ccf52272c3cfc4 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Fri, 6 Dec 2024 10:55:41 +0300 Subject: [PATCH 07/23] changes to the code --- instat/dlgName.vb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index e7f0049245..acaf499757 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -597,8 +597,6 @@ Public Class dlgName (rdoRenameWith.Checked AndAlso rdoSelectedColumn.Checked) OrElse (rdoLabels.Checked AndAlso rdoSelectedColumn.Checked) - 'ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoRenameWith.Checked AndAlso rdoSelectedColumn.Checked) - 'ucrSelectVariables.lstAvailableVariable.Visible = rdoSingle.Checked OrElse (rdoLabels.Checked AndAlso rdoSelectedColumn.Checked) ucrSelectVariables.btnAdd.Visible = ucrSelectVariables.lstAvailableVariable.Visible ucrSelectVariables.btnDataOptions.Visible = ucrSelectVariables.lstAvailableVariable.Visible UpdateGrid() @@ -708,8 +706,13 @@ Public Class dlgName ElseIf rdoRenameWith.Checked Then clsDefaultRFunction.AddParameter("type", Chr(34) & "rename_with" & Chr(34), iPosition:=1) - Else + ElseIf rdoMultiple.Checked Then + clsDefaultRFunction.AddParameter("type", Chr(34) & "multiple" & Chr(34), iPosition:=1) + + ElseIf rdoSingle.Checked Then + + clsDefaultRFunction.AddParameter("type", Chr(34) & "single" & Chr(34), iPosition:=1) End If End Sub From eeca0acf7117f6b81dc3da3d10bcf0ce720408c5 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:18:07 +0100 Subject: [PATCH 08/23] Update One Variable Summarise and changing the Format options to Table Options. --- instat/dlgOneVariableSummarise.Designer.vb | 42 +++++++++++----------- instat/dlgOneVariableSummarise.vb | 16 +++------ 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/instat/dlgOneVariableSummarise.Designer.vb b/instat/dlgOneVariableSummarise.Designer.vb index 69e5965877..6554ebb703 100644 --- a/instat/dlgOneVariableSummarise.Designer.vb +++ b/instat/dlgOneVariableSummarise.Designer.vb @@ -48,7 +48,7 @@ Partial Class dlgOneVariableSummarise Me.rdoVariable = New System.Windows.Forms.RadioButton() Me.rdoSummary = New System.Windows.Forms.RadioButton() Me.grpColumns = New System.Windows.Forms.GroupBox() - Me.cmdFormatTable = New System.Windows.Forms.Button() + Me.ucrPnlColumnFactor = New instat.UcrPanel() Me.ucrReorderSummary = New instat.ucrReorder() Me.ucrSaveSummary = New instat.ucrSave() Me.ucrPnlSummaries = New instat.UcrPanel() @@ -57,9 +57,9 @@ Partial Class dlgOneVariableSummarise Me.ucrSelectorOneVarSummarise = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrReceiverOneVarSummarise = New instat.ucrReceiverMultiple() Me.ucrBase = New instat.ucrButtons() - Me.ucrPnlColumnFactor = New instat.UcrPanel() Me.ucrChkDisplayMissing = New instat.ucrCheck() Me.ucrInputDisplayMissing = New instat.ucrInputComboBox() + Me.cmdTableOptions = New System.Windows.Forms.Button() Me.grpColumns.SuspendLayout() Me.SuspendLayout() ' @@ -203,15 +203,13 @@ Partial Class dlgOneVariableSummarise Me.grpColumns.TabStop = False Me.grpColumns.Text = "Columns:" ' - 'cmdFormatTable + 'ucrPnlColumnFactor ' - Me.cmdFormatTable.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdFormatTable.Location = New System.Drawing.Point(317, 393) - Me.cmdFormatTable.Name = "cmdFormatTable" - Me.cmdFormatTable.Size = New System.Drawing.Size(104, 23) - Me.cmdFormatTable.TabIndex = 37 - Me.cmdFormatTable.Text = "Format Table..." - Me.cmdFormatTable.UseVisualStyleBackColor = True + Me.ucrPnlColumnFactor.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlColumnFactor.Location = New System.Drawing.Point(6, 12) + Me.ucrPnlColumnFactor.Name = "ucrPnlColumnFactor" + Me.ucrPnlColumnFactor.Size = New System.Drawing.Size(137, 65) + Me.ucrPnlColumnFactor.TabIndex = 29 ' 'ucrReorderSummary ' @@ -296,14 +294,6 @@ Partial Class dlgOneVariableSummarise Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 11 ' - 'ucrPnlColumnFactor - ' - Me.ucrPnlColumnFactor.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlColumnFactor.Location = New System.Drawing.Point(6, 12) - Me.ucrPnlColumnFactor.Name = "ucrPnlColumnFactor" - Me.ucrPnlColumnFactor.Size = New System.Drawing.Size(137, 65) - Me.ucrPnlColumnFactor.TabIndex = 29 - ' 'ucrChkDisplayMissing ' Me.ucrChkDisplayMissing.AutoSize = True @@ -325,13 +315,25 @@ Partial Class dlgOneVariableSummarise Me.ucrInputDisplayMissing.Size = New System.Drawing.Size(74, 21) Me.ucrInputDisplayMissing.TabIndex = 35 ' + 'cmdTableOptions + ' + Me.cmdTableOptions.AutoSize = True + Me.cmdTableOptions.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.cmdTableOptions.Location = New System.Drawing.Point(302, 393) + Me.cmdTableOptions.Name = "cmdTableOptions" + Me.cmdTableOptions.Size = New System.Drawing.Size(114, 23) + Me.cmdTableOptions.TabIndex = 38 + Me.cmdTableOptions.Tag = "Format Table" + Me.cmdTableOptions.Text = "Table Options..." + Me.cmdTableOptions.UseVisualStyleBackColor = True + ' 'dlgOneVariableSummarise ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True Me.ClientSize = New System.Drawing.Size(470, 495) - Me.Controls.Add(Me.cmdFormatTable) + Me.Controls.Add(Me.cmdTableOptions) Me.Controls.Add(Me.ucrReorderSummary) Me.Controls.Add(Me.ucrSaveSummary) Me.Controls.Add(Me.cmdMissingOptions) @@ -386,5 +388,5 @@ Partial Class dlgOneVariableSummarise Friend WithEvents ucrChkDisplayMissing As ucrCheck Friend WithEvents grpColumns As GroupBox Friend WithEvents ucrReorderSummary As ucrReorder - Friend WithEvents cmdFormatTable As Button + Friend WithEvents cmdTableOptions As Button End Class \ No newline at end of file diff --git a/instat/dlgOneVariableSummarise.vb b/instat/dlgOneVariableSummarise.vb index c973af6015..56a6de3949 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -234,6 +234,7 @@ Public Class dlgOneVariableSummarise clsGtFunction.SetPackageName("gt") clsGtFunction.SetRCommand("gt") + clsPipeOperator.AddParameter(strParameterName:="gt", clsRFunctionParameter:=clsGtFunction, iPosition:=2, bIncludeArgumentName:=False) clsSummaryOperator.SetOperation("%>%") clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsSummaryTableFunction, iPosition:=0) @@ -399,7 +400,7 @@ Public Class dlgOneVariableSummarise ucrSaveSummary.SetCheckBoxText("Store Summary") End If cmdSummaries.Visible = rdoCustomised.Checked - cmdFormatTable.Visible = rdoCustomised.Checked + cmdTableOptions.Visible = rdoCustomised.Checked End Sub Private Sub FillListView() @@ -432,16 +433,9 @@ Public Class dlgOneVariableSummarise Next End Sub - Private Sub cmdFormatTable_Click(sender As Object, e As EventArgs) Handles cmdFormatTable.Click - sdgFormatSummaryTables.SetRCode(clsNewTableTitleFunction:=clsTableTitleFunction, clsNewTabFootnoteTitleFunction:=clsTabFootnoteTitleFunction, clsNewTableSourcenoteFunction:=clsTableSourcenoteFunction, clsNewDummyFunction:=clsDummyFunction, - clsNewFootnoteCellFunction:=clsFootnoteCellFunction, clsNewSecondFootnoteCellBodyFunction:=clsSecondFootnoteCellBodyFunction, - clsNewPipeOperator:=clsPipeOperator, clsNewFootnoteTitleLocationFunction:=clsFootnoteTitleLocationFunction, clsNewFootnoteCellBodyFunction:=clsFootnoteCellBodyFunction, - clsNewFootnoteSubtitleLocationFunction:=clsFootnoteSubtitleLocationFunction, clsNewTabFootnoteSubtitleFunction:=clsTabFootnoteSubtitleFunction, clsNewJoiningOperator:=clsJoiningPipeOperator, - clsNewMutableOperator:=clsSummaryOperator, clsNewSecondFootnoteCellFunction:=clsSecondFootnoteCellFunction, - clsNewTabStyleCellTextFunction:=clsTabStyleCellTextFunction, clsNewTabStyleFunction:=clsTabStyleFunction, clsNewTabStylePxFunction:=clsTabStylePxFunction, clsNewThemesTabOptionFunction:=clsThemesTabOptionsFunction, - clsNewgtExtraThemesFunction:=clsgtExtraThemesFunction, bReset:=bResetFormatSubdialog) - - sdgFormatSummaryTables.ShowDialog() + Private Sub cmdTableOptions_Click(sender As Object, e As EventArgs) Handles cmdTableOptions.Click + sdgTableOptions.Setup(ucrSelectorOneVarSummarise.strCurrentDataFrame, clsPipeOperator) + sdgTableOptions.ShowDialog(Me) bResetFormatSubdialog = False End Sub From 0ead47296ff522802b32e4fee42259fa30aa19a1 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Mon, 9 Dec 2024 11:28:42 +0100 Subject: [PATCH 09/23] Hided Model, Structured, experiments, and Procuremen menus --- instat/frmMain.Designer.vb | 5 +++-- instat/frmMain.vb | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index 1ace18cf46..97c28d30c0 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -1057,6 +1057,7 @@ Partial Class frmMain Me.mnuModel.Size = New System.Drawing.Size(53, 22) Me.mnuModel.Tag = "Model" Me.mnuModel.Text = "Model" + Me.mnuModel.Visible = False ' 'mnuModelProbabilityDistributions ' @@ -3215,7 +3216,7 @@ Partial Class frmMain ' Me.mnuDataViewWindow.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None Me.mnuDataViewWindow.Name = "mnuDataViewWindow" - Me.mnuDataViewWindow.Size = New System.Drawing.Size(180, 22) + Me.mnuDataViewWindow.Size = New System.Drawing.Size(148, 22) Me.mnuDataViewWindow.Text = "Data View" ' 'mnuRDataViewerWindow @@ -3223,7 +3224,7 @@ Partial Class frmMain Me.mnuRDataViewerWindow.Enabled = False Me.mnuRDataViewerWindow.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None Me.mnuRDataViewerWindow.Name = "mnuRDataViewerWindow" - Me.mnuRDataViewerWindow.Size = New System.Drawing.Size(180, 22) + Me.mnuRDataViewerWindow.Size = New System.Drawing.Size(148, 22) Me.mnuRDataViewerWindow.Text = "R-Data Viewer" ' 'mnuTbOutput diff --git a/instat/frmMain.vb b/instat/frmMain.vb index d5c70d0953..0f2e0c86ff 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -1863,11 +1863,13 @@ Public Class frmMain Public Sub SetShowProcurementMenu(bNewShowProcurementMenu As Boolean) mnuProcurement.Visible = bNewShowProcurementMenu mnuViewProcurementMenu.Checked = bNewShowProcurementMenu + mnuProcurement.Visible = False End Sub Public Sub SetShowStructuredMenu(bNewShowStructuredMenu As Boolean) mnuStructured.Visible = bNewShowStructuredMenu mnuViewStructuredMenu.Checked = bNewShowStructuredMenu + mnuStructured.Visible = False End Sub Public Sub SetShowClimaticMenu(bNewShowClimaticMenu As Boolean) mnuClimatic.Visible = bNewShowClimaticMenu @@ -1877,6 +1879,7 @@ Public Class frmMain Public Sub SetShowOptionsByContextMenu(bNewShowOptionsByContextMenu As Boolean) mnuOptionsByContext.Visible = bNewShowOptionsByContextMenu mnuViewOptionsByContextMenu.Checked = bNewShowOptionsByContextMenu + mnuOptionsByContext.Visible = False End Sub Private Sub mnuViewStructuredMenu_Click(sender As Object, e As EventArgs) Handles mnuViewStructuredMenu.Click From c69acbcbb46dc883c8d9fc6393a261ffbf14fd49 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Tue, 10 Dec 2024 14:24:41 +0100 Subject: [PATCH 10/23] Change made --- instat/frmMain.Designer.vb | 1 - instat/frmMain.vb | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index 97c28d30c0..e9119897dc 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -1057,7 +1057,6 @@ Partial Class frmMain Me.mnuModel.Size = New System.Drawing.Size(53, 22) Me.mnuModel.Tag = "Model" Me.mnuModel.Text = "Model" - Me.mnuModel.Visible = False ' 'mnuModelProbabilityDistributions ' diff --git a/instat/frmMain.vb b/instat/frmMain.vb index 0f2e0c86ff..4f9beeceec 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -227,6 +227,7 @@ Public Class frmMain '------------------------------------- SetAppVersionNumber() isMaximised = True 'Need to get the windowstate when the application is loaded + SetHideMenus() End Sub Private Sub CheckForUpdates() @@ -595,6 +596,13 @@ Public Class frmMain My.Application.Info.Version.Build.ToString() End Sub + Public Sub SetHideMenus() + mnuViewProcurementMenu.Checked = False + mnuProcurement.Visible = False + mnuViewOptionsByContextMenu.Checked = False + mnuOptionsByContext.Visible = False + End Sub + Private Sub SetMainMenusEnabled(bEnabled As Boolean) mnuFile.Enabled = bEnabled mnuEdit.Enabled = bEnabled @@ -1863,13 +1871,11 @@ Public Class frmMain Public Sub SetShowProcurementMenu(bNewShowProcurementMenu As Boolean) mnuProcurement.Visible = bNewShowProcurementMenu mnuViewProcurementMenu.Checked = bNewShowProcurementMenu - mnuProcurement.Visible = False End Sub Public Sub SetShowStructuredMenu(bNewShowStructuredMenu As Boolean) mnuStructured.Visible = bNewShowStructuredMenu mnuViewStructuredMenu.Checked = bNewShowStructuredMenu - mnuStructured.Visible = False End Sub Public Sub SetShowClimaticMenu(bNewShowClimaticMenu As Boolean) mnuClimatic.Visible = bNewShowClimaticMenu @@ -1879,7 +1885,6 @@ Public Class frmMain Public Sub SetShowOptionsByContextMenu(bNewShowOptionsByContextMenu As Boolean) mnuOptionsByContext.Visible = bNewShowOptionsByContextMenu mnuViewOptionsByContextMenu.Checked = bNewShowOptionsByContextMenu - mnuOptionsByContext.Visible = False End Sub Private Sub mnuViewStructuredMenu_Click(sender As Object, e As EventArgs) Handles mnuViewStructuredMenu.Click From 4f091a211674edd24f59db1494217daf3e67424e Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Wed, 11 Dec 2024 11:58:02 +0300 Subject: [PATCH 11/23] changes to the code --- instat/dlgName.Designer.vb | 24 +++++++++++++ instat/dlgName.vb | 72 +++++++++++++++++++++++++++----------- 2 files changed, 76 insertions(+), 20 deletions(-) diff --git a/instat/dlgName.Designer.vb b/instat/dlgName.Designer.vb index 222e51d490..cf7070ee6c 100644 --- a/instat/dlgName.Designer.vb +++ b/instat/dlgName.Designer.vb @@ -72,6 +72,8 @@ Partial Class dlgName Me.ucrReceiverColumns = New instat.ucrReceiverMultiple() Me.ucrPnlSelectData = New instat.UcrPanel() Me.rdoLabels = New System.Windows.Forms.RadioButton() + Me.cmdAddkeyboard = New System.Windows.Forms.Button() + Me.ucrChkIncludeRegularExpressions = New instat.ucrCheck() Me.grpOptions.SuspendLayout() Me.SuspendLayout() ' @@ -475,6 +477,24 @@ Partial Class dlgName Me.rdoLabels.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.rdoLabels.UseVisualStyleBackColor = False ' + 'cmdAddkeyboard + ' + Me.cmdAddkeyboard.Location = New System.Drawing.Point(315, 315) + Me.cmdAddkeyboard.Name = "cmdAddkeyboard" + Me.cmdAddkeyboard.Size = New System.Drawing.Size(100, 23) + Me.cmdAddkeyboard.TabIndex = 35 + Me.cmdAddkeyboard.Text = "Add Keyboard" + Me.cmdAddkeyboard.UseVisualStyleBackColor = True + ' + 'ucrChkIncludeRegularExpressions + ' + Me.ucrChkIncludeRegularExpressions.AutoSize = True + Me.ucrChkIncludeRegularExpressions.Checked = False + Me.ucrChkIncludeRegularExpressions.Location = New System.Drawing.Point(71, 316) + Me.ucrChkIncludeRegularExpressions.Name = "ucrChkIncludeRegularExpressions" + Me.ucrChkIncludeRegularExpressions.Size = New System.Drawing.Size(239, 23) + Me.ucrChkIncludeRegularExpressions.TabIndex = 34 + ' 'dlgName ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) @@ -502,6 +522,8 @@ Partial Class dlgName Me.Controls.Add(Me.rdoSelectedColumn) Me.Controls.Add(Me.rdoWholeDataFrame) Me.Controls.Add(Me.ucrPnlSelectData) + Me.Controls.Add(Me.cmdAddkeyboard) + Me.Controls.Add(Me.ucrChkIncludeRegularExpressions) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False @@ -549,4 +571,6 @@ Partial Class dlgName Friend WithEvents rdoWholeDataFrame As RadioButton Friend WithEvents ucrPnlSelectData As UcrPanel Friend WithEvents rdoLabels As RadioButton + Friend WithEvents cmdAddkeyboard As Button + Friend WithEvents ucrChkIncludeRegularExpressions As ucrCheck End Class diff --git a/instat/dlgName.vb b/instat/dlgName.vb index acaf499757..883ffc38a8 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -30,7 +30,7 @@ Public Class dlgName Private clsNewColNameDataframeFunction As New RFunction Private clsNewLabelDataframeFunction As New RFunction Private clsDummyFunction As New RFunction - Private clsStartwithFunction, clsEndswithFunction, clsMatchesFunction, clsContainsFunction As New RFunction + Private clsStartwithFunction, clsRegexFunction, clsEndswithFunction, clsMatchesFunction, clsContainsFunction As New RFunction Private WithEvents grdCurrentWorkSheet As Worksheet Private dctRowsNewNameChanged As New Dictionary(Of Integer, String) Private dctRowsNewLabelChanged As New Dictionary(Of Integer, String) @@ -147,12 +147,17 @@ Public Class dlgName ucrInputReplace.SetParameter(New RParameter("pattern", 2)) ucrInputReplace.SetLinkedDisplayControl(lblReplace) + ucrChkIncludeRegularExpressions.SetText("Include Regular Expressions") + + ucrChkIncludeRegularExpressions.SetParameter(New RParameter("check", 0)) + ucrChkIncludeRegularExpressions.SetValuesCheckedAndUnchecked(True, False) + ucrPnlOptions.AddToLinkedControls({ucrReceiverName, ucrInputNewName, ucrInputVariableLabel}, {rdoSingle}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls(ucrChkIncludeVariable, {rdoMultiple}, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls({ucrPnlCase, ucrPnlSelectData}, {rdoRenameWith, rdoLabels}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlCase.AddToLinkedControls(ucrInputCase, {rdoMakeCleanNames}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Snake") ucrPnlCase.AddToLinkedControls(ucrNudAbbreviate, {rdoAbbreviate}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="8") - ucrPnlCase.AddToLinkedControls(ucrInputReplace, {rdoReplace}, bNewLinkedHideIfParameterMissing:=True) + ucrPnlCase.AddToLinkedControls({ucrInputReplace, ucrChkIncludeRegularExpressions}, {rdoReplace}, bNewLinkedHideIfParameterMissing:=True) ucrPnlCase.AddToLinkedControls(ucrInputBy, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="") ucrPnlCase.AddToLinkedControls(ucrInputEdit, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Starts With") ucrPnlSelectData.AddToLinkedControls(ucrReceiverColumns, {rdoSelectedColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) @@ -178,6 +183,7 @@ Public Class dlgName clsEndswithFunction = New RFunction clsMatchesFunction = New RFunction clsContainsFunction = New RFunction + clsRegexFunction = New RFunction ucrSelectVariables.Reset() dctRowsNewNameChanged.Clear() @@ -189,8 +195,8 @@ Public Class dlgName clsDummyFunction.AddParameter("checked", "FALSE", iPosition:=0) clsDummyFunction.AddParameter("checked", "whole", iPosition:=1) - clsDummyFunction.AddParameter("name", "single", iPosition:=1) - + clsDummyFunction.AddParameter("name", "single", iPosition:=2) + clsDummyFunction.AddParameter("check", False, iPosition:=3) clsDefaultRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$rename_column_in_data") clsDefaultRFunction.AddParameter("type", Chr(34) & "single" & Chr(34), iPosition:=4) @@ -214,6 +220,12 @@ Public Class dlgName clsStartwithFunction.SetRCommand("starts_with") clsStartwithFunction.AddParameter("match", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=0) + clsRegexFunction.SetPackageName("stringr") + clsRegexFunction.SetRCommand("regex") + clsRegexFunction.AddParameter("ignore_case", "FALSE", bIncludeArgumentName:=False, iPosition:=3) + clsRegexFunction.AddParameter("multiline", "FALSE", iPosition:=4) + clsRegexFunction.AddParameter("comments", "FALSE", iPosition:=5) + ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultRFunction) End Sub @@ -227,6 +239,7 @@ Public Class dlgName ucrReceiverName.SetRCode(clsDefaultRFunction, bReset) ucrInputNewName.SetRCode(clsDefaultRFunction, bReset) ucrInputVariableLabel.SetRCode(clsDefaultRFunction, bReset) + ucrChkIncludeRegularExpressions.SetRCode(clsDummyFunction, bReset) If bReset Then ucrPnlCase.SetRCode(clsDefaultRFunction, bReset) ucrInputReplace.SetRCode(clsDefaultRFunction, bReset) @@ -641,10 +654,6 @@ Public Class dlgName MakeLabelColumnVisible() End Sub - Private Sub cmdAddkeyboard_Click(sender As Object, e As EventArgs) - sdgConstructRegexExpression.ShowDialog() - End Sub - Private Sub ucrSelectVariables_DataFrameChanged() Handles ucrSelectVariables.DataFrameChanged RemoveLabelsParams() UpdateGrid() @@ -673,23 +682,34 @@ Public Class dlgName End Sub Private Sub RemovePattern() + cmdAddkeyboard.Visible = False + If rdoWholeDataFrame.Checked Then If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) - clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) clsDefaultRFunction.RemoveParameterByName("label") clsDefaultRFunction.AddParameter("replacement", Chr(34) & ucrInputBy.GetText() & Chr(34), iPosition:=5) - Select Case ucrInputEdit.GetText - Case "Starts With" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsStartwithFunction, iPosition:=3) - Case "Ends With" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsEndswithFunction, iPosition:=3) - Case "Matches" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) - Case "Contains" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) - End Select + If ucrChkIncludeRegularExpressions.Checked Then + cmdAddkeyboard.Visible = True + clsDefaultRFunction.RemoveParameterByName(".cols") + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) + clsRegexFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=1) + clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) + Else + clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) + cmdAddkeyboard.Visible = False + Select Case ucrInputEdit.GetText + Case "Starts With" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsStartwithFunction, iPosition:=3) + Case "Ends With" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsEndswithFunction, iPosition:=3) + Case "Matches" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) + Case "Contains" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) + End Select + End If Else clsDefaultRFunction.RemoveParameterByName("pattern") clsDefaultRFunction.RemoveParameterByName("replacement") @@ -697,7 +717,9 @@ Public Class dlgName End If Else clsDefaultRFunction.AddParameter(".cols", ucrReceiverColumns.GetVariableNames, iPosition:=3) + clsDefaultRFunction.RemoveParameterByName("pattern") End If + End Sub Private Sub AddTypeParm() @@ -720,4 +742,14 @@ Public Class dlgName RemovePattern() AddTypeParm() End Sub + + Private Sub cmdAddkeyboard_Click(sender As Object, e As EventArgs) Handles cmdAddkeyboard.Click + sdgConstructRegexExpression.ShowDialog() + ucrInputReplace.SetName(sdgConstructRegexExpression.ucrReceiverForRegex.GetText()) + End Sub + + Private Sub ucrChkIncludeRegularExpressions_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkIncludeRegularExpressions.ControlValueChanged + RemovePattern() + cmdAddkeyboard.Visible = If(ucrChkIncludeRegularExpressions.Checked, True, False) + End Sub End Class From 8db6d3c8b24e3ad090350ba1d5d1c1b0c5261783 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Wed, 11 Dec 2024 12:29:14 +0300 Subject: [PATCH 12/23] changes --- instat/dlgName.vb | 3 --- 1 file changed, 3 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 883ffc38a8..d419668a2a 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -89,9 +89,6 @@ Public Class dlgName ucrPnlOptions.AddParameterValuesCondition(rdoRenameWith, "name", "rename") ucrPnlOptions.AddParameterValuesCondition(rdoLabels, "name", "labels") - - 'ucrPnlOptions.SetRDefault(Chr(34) & "single" & Chr(34)) - ucrNudAbbreviate.SetParameter(New RParameter("minlength", 10)) ucrNudAbbreviate.SetMinMax(Integer.MinValue, Integer.MaxValue) From 43aaadb4af0726a146545d4c6be92b3271888d8d Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Thu, 12 Dec 2024 09:04:09 +0100 Subject: [PATCH 13/23] minor change made --- instat/frmMain.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/frmMain.vb b/instat/frmMain.vb index 4f9beeceec..bb91d80a05 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -596,7 +596,7 @@ Public Class frmMain My.Application.Info.Version.Build.ToString() End Sub - Public Sub SetHideMenus() + Private Sub SetHideMenus() mnuViewProcurementMenu.Checked = False mnuProcurement.Visible = False mnuViewOptionsByContextMenu.Checked = False From 5337369223dcb36bcd1b38b934eb8ad6274d9134 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Thu, 12 Dec 2024 11:54:03 +0300 Subject: [PATCH 14/23] changes --- instat/dlgName.vb | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index d419668a2a..ee1154a7ae 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -135,6 +135,8 @@ Public Class dlgName dctReplace.Add("Ends With", Chr(34) & "ends_with" & Chr(34)) dctReplace.Add("Matches", Chr(34) & "matches" & Chr(34)) dctReplace.Add("Contains", Chr(34) & "contains" & Chr(34)) + dctReplace.Add("Matches All", Chr(34) & "contains" & Chr(34)) + dctReplace.Add("Contains All", Chr(34) & "contains" & Chr(34)) ucrInputEdit.SetDropDownStyleAsNonEditable() ucrInputEdit.SetItems(dctReplace) @@ -154,11 +156,13 @@ Public Class dlgName ucrPnlOptions.AddToLinkedControls({ucrPnlCase, ucrPnlSelectData}, {rdoRenameWith, rdoLabels}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlCase.AddToLinkedControls(ucrInputCase, {rdoMakeCleanNames}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Snake") ucrPnlCase.AddToLinkedControls(ucrNudAbbreviate, {rdoAbbreviate}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="8") - ucrPnlCase.AddToLinkedControls({ucrInputReplace, ucrChkIncludeRegularExpressions}, {rdoReplace}, bNewLinkedHideIfParameterMissing:=True) + ucrPnlCase.AddToLinkedControls(ucrInputReplace, {rdoReplace}, bNewLinkedHideIfParameterMissing:=True) ucrPnlCase.AddToLinkedControls(ucrInputBy, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="") ucrPnlCase.AddToLinkedControls(ucrInputEdit, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Starts With") ucrPnlSelectData.AddToLinkedControls(ucrReceiverColumns, {rdoSelectedColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrInputReplace.AddToLinkedControls(ucrChkIncludeRegularExpressions, {"Matches All", "Matches"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrReceiverName.SetLinkedDisplayControl(lblCurrentName) ucrInputNewName.SetLinkedDisplayControl(lblName) ucrInputVariableLabel.SetLinkedDisplayControl(lblVariableLabel) @@ -694,17 +698,26 @@ Public Class dlgName clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) Else clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) cmdAddkeyboard.Visible = False Select Case ucrInputEdit.GetText Case "Starts With" clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsStartwithFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) Case "Ends With" clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsEndswithFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) Case "Matches" clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) Case "Contains" clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) + Case "Matches All" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) + Case "Contains All" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) End Select End If Else @@ -719,6 +732,22 @@ Public Class dlgName End Sub + Private Sub AddRegexPar() + + If ucrChkIncludeRegularExpressions.Checked Then + Select Case ucrInputEdit.GetText + Case "Contains All" + + Case "Contains" + + Case Else + End Select + Else + + End If + + End Sub + Private Sub AddTypeParm() If rdoLabels.Checked Then clsDefaultRFunction.AddParameter("type", Chr(34) & "rename_labels" & Chr(34), iPosition:=1) From b4e0b0bf5825aec692fc09e5a0f0e71006395ab1 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Thu, 12 Dec 2024 10:08:44 +0100 Subject: [PATCH 15/23] minor change made --- instat/frmMain.vb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instat/frmMain.vb b/instat/frmMain.vb index bb91d80a05..e20a724234 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -596,11 +596,13 @@ Public Class frmMain My.Application.Info.Version.Build.ToString() End Sub - Private Sub SetHideMenus() + Public Sub SetHideMenus() mnuViewProcurementMenu.Checked = False mnuProcurement.Visible = False mnuViewOptionsByContextMenu.Checked = False mnuOptionsByContext.Visible = False + mnuViewStructuredMenu.Checked = False + mnuStructured.Visible = False End Sub Private Sub SetMainMenusEnabled(bEnabled As Boolean) From 9009932f837a9f71333e734b9450703fc1149e42 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:18:08 +0100 Subject: [PATCH 16/23] Code changes to the tables function --- instat/dlgOneVariableSummarise.vb | 97 +++++++++---------------------- 1 file changed, 27 insertions(+), 70 deletions(-) diff --git a/instat/dlgOneVariableSummarise.vb b/instat/dlgOneVariableSummarise.vb index 56a6de3949..b8f7d0138d 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -31,11 +31,9 @@ Public Class dlgOneVariableSummarise clsConcFunction, clsSummaryTableFunction, clsDummyFunction, clsSkimrFunction, clsPivotWiderFunction As New RFunction - Private clsTableTitleFunction, clsTabFootnoteTitleFunction, clsTableSourcenoteFunction, clsFootnoteTitleLocationFunction, - clsFootnoteSubtitleLocationFunction, clsTabFootnoteSubtitleFunction, clsFootnoteCellFunction, clsFootnoteCellBodyFunction, - clsSecondFootnoteCellFunction, clsSecondFootnoteCellBodyFunction, clsTabStyleFunction, clsTabStyleCellTextFunction, - clsTabStylePxFunction, clsTabStyleCellTitleFunction, clsThemesTabOptionsFunction, clsgtExtraThemesFunction As New RFunction Private clsPipeOperator, clsJoiningPipeOperator As New ROperator + Private clsGetGtTableFunction, clsSaveGtRFunction As New RFunction + Private clsGtTableROperator, clsBaseOperator As New ROperator Private clsSummaryOperator As New ROperator Private bResetSubdialog As Boolean = False Private bResetFormatSubdialog As Boolean = False @@ -136,81 +134,35 @@ Public Class dlgOneVariableSummarise clsSummaryOperator = New ROperator clsPivotWiderFunction = New RFunction - clsTableTitleFunction = New RFunction - clsTabFootnoteTitleFunction = New RFunction - clsTableSourcenoteFunction = New RFunction - clsFootnoteTitleLocationFunction = New RFunction - clsFootnoteSubtitleLocationFunction = New RFunction + clsPipeOperator = New ROperator - clsTabFootnoteSubtitleFunction = New RFunction - clsFootnoteCellBodyFunction = New RFunction - clsSecondFootnoteCellBodyFunction = New RFunction - clsFootnoteCellFunction = New RFunction - clsSecondFootnoteCellFunction = New RFunction - clsTabStyleFunction = New RFunction - clsTabStyleCellTextFunction = New RFunction - clsTabStylePxFunction = New RFunction - clsTabStyleCellTitleFunction = New RFunction - clsJoiningPipeOperator = New ROperator - clsThemesTabOptionsFunction = New RFunction - clsgtExtraThemesFunction = New RFunction + + clsGtTableROperator = New ROperator + clsBaseOperator = New ROperator + clsGetGtTableFunction = New RFunction + clsSaveGtRFunction = New RFunction ucrSelectorOneVarSummarise.Reset() clsPipeOperator.SetOperation("%>%") clsPipeOperator.bBrackets = False - clsThemesTabOptionsFunction.SetPackageName("gt") - clsThemesTabOptionsFunction.SetRCommand("tab_options") - - clsgtExtraThemesFunction.SetPackageName("gtExtras") - - clsTabStyleFunction.SetRCommand("tab_style") - clsTabStyleFunction.SetPackageName("gt") - clsTabStyleFunction.AddParameter("style", clsRFunctionParameter:=clsTabStyleCellTextFunction, iPosition:=0) - clsTabStyleFunction.AddParameter("location", clsRFunctionParameter:=clsTabStyleCellTitleFunction, iPosition:=1) - - clsTabStyleCellTitleFunction.SetPackageName("gt") - clsTabStyleCellTitleFunction.SetRCommand("cells_title") - clsTabStyleCellTitleFunction.AddParameter("groups", Chr(34) & "title" & Chr(34), iPosition:=0) - - clsTabStyleCellTextFunction.SetPackageName("gt") - clsTabStyleCellTextFunction.SetRCommand("cell_text") - clsTabStyleCellTextFunction.AddParameter("size", clsRFunctionParameter:=clsTabStylePxFunction, iPosition:=0) - - clsTabStylePxFunction.SetPackageName("gt") - clsTabStylePxFunction.SetRCommand("px") - clsTabStylePxFunction.AddParameter("size", "18", bIncludeArgumentName:=False, iPosition:=0) - - clsTableTitleFunction.SetPackageName("gt") - clsTableTitleFunction.SetRCommand("tab_header") - - clsTabFootnoteTitleFunction.SetPackageName("gt") - clsTabFootnoteTitleFunction.SetRCommand("tab_footnote") - - clsTabFootnoteSubtitleFunction.SetPackageName("gt") - clsTabFootnoteSubtitleFunction.SetRCommand("tab_footnote") - - clsFootnoteCellFunction.SetPackageName("gt") - clsFootnoteCellFunction.SetRCommand("tab_footnote") - - clsSecondFootnoteCellFunction.SetPackageName("gt") - clsSecondFootnoteCellFunction.SetRCommand("tab_footnote") + clsGetGtTableFunction.SetPackageName("gt") + clsGetGtTableFunction.SetRCommand("gt") - clsFootnoteTitleLocationFunction.SetPackageName("gt") - clsFootnoteTitleLocationFunction.SetRCommand("cells_title") - clsFootnoteSubtitleLocationFunction.SetPackageName("gt") - clsFootnoteSubtitleLocationFunction.SetRCommand("cells_title") + clsBaseOperator.SetOperation("%>%") + clsBaseOperator.bBrackets = False + clsBaseOperator.AddParameter(strParameterName:="gt_tbl_operator", clsROperatorParameter:=clsGtTableROperator, iPosition:=0, bIncludeArgumentName:=False) + clsBaseOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", + strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, + strRObjectFormatToAssignTo:=RObjectFormat.Html, + strRDataFrameNameToAddObjectTo:=ucrSelectorOneVarSummarise.strCurrentDataFrame, + strObjectName:="last_table") - clsTableSourcenoteFunction.SetPackageName("gt") - clsTableSourcenoteFunction.SetRCommand("tab_source_note") + ucrBase.clsRsyntax.SetBaseROperator(clsBaseOperator) - clsFootnoteCellBodyFunction.SetPackageName("gt") - clsFootnoteCellBodyFunction.SetRCommand("cells_body") - clsSecondFootnoteCellBodyFunction.SetPackageName("gt") - clsSecondFootnoteCellBodyFunction.SetRCommand("cells_body") clsSkimrFunction.SetPackageName("skimr") clsSkimrFunction.SetRCommand("skim_without_charts") @@ -234,14 +186,17 @@ Public Class dlgOneVariableSummarise clsGtFunction.SetPackageName("gt") clsGtFunction.SetRCommand("gt") - clsPipeOperator.AddParameter(strParameterName:="gt", clsRFunctionParameter:=clsGtFunction, iPosition:=2, bIncludeArgumentName:=False) + clsGtTableROperator.SetOperation("%>%") + clsGtTableROperator.bBrackets = False + clsGtTableROperator.AddParameter("tableFun", clsRFunctionParameter:=clsSummaryTableFunction, iPosition:=0) + clsGtTableROperator.AddParameter(strParameterName:="gt_tbl", clsRFunctionParameter:=clsGtFunction, iPosition:=1, bIncludeArgumentName:=False) clsSummaryOperator.SetOperation("%>%") clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsSummaryTableFunction, iPosition:=0) clsSummaryOperator.AddParameter("gttbl", clsRFunctionParameter:=clsGtFunction, iPosition:=2) clsJoiningPipeOperator.SetOperation("%>%") - clsJoiningPipeOperator.AddParameter("mutable", clsROperatorParameter:=clsSummaryOperator, iPosition:=0) + clsJoiningPipeOperator.AddParameter("mutable", clsROperatorParameter:=clsGtTableROperator, iPosition:=0) clsJoiningPipeOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, strRObjectFormatToAssignTo:=RObjectFormat.Html, @@ -286,6 +241,8 @@ Public Class dlgOneVariableSummarise ucrSelectorOneVarSummarise.SetRCode(clsSummaryTableFunction, bReset) ucrInputDisplayMissing.SetRCode(clsSummaryTableFunction, bReset) ucrSaveSummary.SetRCode(clsSkimrFunction, bReset) + ucrSelectorOneVarSummarise.SetRCode(clsGetGtTableFunction, bReset) + ucrReceiverOneVarSummarise.SetRCode(clsGetGtTableFunction, bReset) If bReset Then ucrChkDisplayMissing.SetRCode(clsDummyFunction, bReset) @@ -434,7 +391,7 @@ Public Class dlgOneVariableSummarise End Sub Private Sub cmdTableOptions_Click(sender As Object, e As EventArgs) Handles cmdTableOptions.Click - sdgTableOptions.Setup(ucrSelectorOneVarSummarise.strCurrentDataFrame, clsPipeOperator) + sdgTableOptions.Setup(ucrSelectorOneVarSummarise.strCurrentDataFrame, clsGtTableROperator) sdgTableOptions.ShowDialog(Me) bResetFormatSubdialog = False End Sub From e25034813d840c1458670e801c691d1c4827ee18 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:22:18 +0100 Subject: [PATCH 17/23] Removing unwanted code --- instat/dlgOneVariableSummarise.vb | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/instat/dlgOneVariableSummarise.vb b/instat/dlgOneVariableSummarise.vb index b8f7d0138d..6887cde8cf 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -32,8 +32,8 @@ Public Class dlgOneVariableSummarise clsSkimrFunction, clsPivotWiderFunction As New RFunction Private clsPipeOperator, clsJoiningPipeOperator As New ROperator - Private clsGetGtTableFunction, clsSaveGtRFunction As New RFunction - Private clsGtTableROperator, clsBaseOperator As New ROperator + Private clsGetGtTableFunction As New RFunction + Private clsGtTableROperator As New ROperator Private clsSummaryOperator As New ROperator Private bResetSubdialog As Boolean = False Private bResetFormatSubdialog As Boolean = False @@ -138,9 +138,7 @@ Public Class dlgOneVariableSummarise clsPipeOperator = New ROperator clsGtTableROperator = New ROperator - clsBaseOperator = New ROperator clsGetGtTableFunction = New RFunction - clsSaveGtRFunction = New RFunction ucrSelectorOneVarSummarise.Reset() @@ -150,20 +148,6 @@ Public Class dlgOneVariableSummarise clsGetGtTableFunction.SetPackageName("gt") clsGetGtTableFunction.SetRCommand("gt") - - clsBaseOperator.SetOperation("%>%") - clsBaseOperator.bBrackets = False - clsBaseOperator.AddParameter(strParameterName:="gt_tbl_operator", clsROperatorParameter:=clsGtTableROperator, iPosition:=0, bIncludeArgumentName:=False) - clsBaseOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", - strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, - strRObjectFormatToAssignTo:=RObjectFormat.Html, - strRDataFrameNameToAddObjectTo:=ucrSelectorOneVarSummarise.strCurrentDataFrame, - strObjectName:="last_table") - - ucrBase.clsRsyntax.SetBaseROperator(clsBaseOperator) - - - clsSkimrFunction.SetPackageName("skimr") clsSkimrFunction.SetRCommand("skim_without_charts") clsSkimrFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorOneVarSummarise.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0) From db934a05299f53bcd57a24ddb8ab6feebb81a268 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Thu, 12 Dec 2024 13:22:21 +0300 Subject: [PATCH 18/23] changes to the code --- instat/dlgName.vb | 112 ++++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 49 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index ee1154a7ae..4840ee3f02 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -161,8 +161,6 @@ Public Class dlgName ucrPnlCase.AddToLinkedControls(ucrInputEdit, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Starts With") ucrPnlSelectData.AddToLinkedControls(ucrReceiverColumns, {rdoSelectedColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrInputReplace.AddToLinkedControls(ucrChkIncludeRegularExpressions, {"Matches All", "Matches"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrReceiverName.SetLinkedDisplayControl(lblCurrentName) ucrInputNewName.SetLinkedDisplayControl(lblName) ucrInputVariableLabel.SetLinkedDisplayControl(lblVariableLabel) @@ -618,6 +616,8 @@ Public Class dlgName DialogueSize() RemovePattern() AddTypeParm() + AddRegexPar() + SetRegexControlVisibility() End Sub Private Sub DialogueSize() @@ -683,69 +683,64 @@ Public Class dlgName End Sub Private Sub RemovePattern() - cmdAddkeyboard.Visible = False - If rdoWholeDataFrame.Checked Then If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then clsDefaultRFunction.RemoveParameterByName("label") clsDefaultRFunction.AddParameter("replacement", Chr(34) & ucrInputBy.GetText() & Chr(34), iPosition:=5) - If ucrChkIncludeRegularExpressions.Checked Then - cmdAddkeyboard.Visible = True - clsDefaultRFunction.RemoveParameterByName(".cols") - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) - clsRegexFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=1) - clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) - Else - clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) - cmdAddkeyboard.Visible = False - Select Case ucrInputEdit.GetText - Case "Starts With" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsStartwithFunction, iPosition:=3) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) - Case "Ends With" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsEndswithFunction, iPosition:=3) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) - Case "Matches" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) - Case "Contains" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) - Case "Matches All" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) - Case "Contains All" - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) - End Select - End If + Select Case ucrInputEdit.GetText + Case "Starts With" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsStartwithFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) + Case "Ends With" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsEndswithFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) + Case "Matches" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) + Case "Contains" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) + Case "Matches All" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) + Case "Contains All" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) + clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace_all", iPosition:=2) + End Select Else - clsDefaultRFunction.RemoveParameterByName("pattern") clsDefaultRFunction.RemoveParameterByName("replacement") clsDefaultRFunction.RemoveParameterByName(".cols") End If Else clsDefaultRFunction.AddParameter(".cols", ucrReceiverColumns.GetVariableNames, iPosition:=3) - clsDefaultRFunction.RemoveParameterByName("pattern") End If - End Sub Private Sub AddRegexPar() - - If ucrChkIncludeRegularExpressions.Checked Then - Select Case ucrInputEdit.GetText - Case "Contains All" - - Case "Contains" - - Case Else - End Select + If rdoWholeDataFrame.Checked Then + If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then + If ucrChkIncludeRegularExpressions.Checked Then + Select Case ucrInputEdit.GetText + Case "Matches All" + clsRegexFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=1) + clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) + Case "Matches" + cmdAddkeyboard.Visible = True + clsRegexFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=1) + clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) + Case Else + clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) + End Select + Else + clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) + End If + Else + clsDefaultRFunction.RemoveParameterByName("pattern") + End If Else - + clsDefaultRFunction.RemoveParameterByName("pattern") End If - End Sub Private Sub AddTypeParm() @@ -767,6 +762,8 @@ Public Class dlgName Private Sub ucrInputEdit_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputEdit.ControlValueChanged, ucrInputBy.ControlValueChanged, ucrInputReplace.ControlValueChanged RemovePattern() AddTypeParm() + AddRegexPar() + SetRegexControlVisibility() End Sub Private Sub cmdAddkeyboard_Click(sender As Object, e As EventArgs) Handles cmdAddkeyboard.Click @@ -776,6 +773,23 @@ Public Class dlgName Private Sub ucrChkIncludeRegularExpressions_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkIncludeRegularExpressions.ControlValueChanged RemovePattern() - cmdAddkeyboard.Visible = If(ucrChkIncludeRegularExpressions.Checked, True, False) + AddRegexPar() + SetRegexControlVisibility() + End Sub + + Private Sub SetRegexControlVisibility() + ucrChkIncludeRegularExpressions.Visible = False + cmdAddkeyboard.Visible = False + + If rdoWholeDataFrame.Checked Then + If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then + Select Case ucrInputEdit.GetText + Case "Matches All", "Matches" + cmdAddkeyboard.Visible = If(ucrChkIncludeRegularExpressions.Checked, True, False) + ucrChkIncludeRegularExpressions.Visible = True + End Select + End If + End If End Sub + End Class From 42e161e05d9a2137fe418110b76f9a4d742bbc62 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:43:29 +0100 Subject: [PATCH 19/23] Code Changes --- instat/dlgOneVariableSummarise.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/dlgOneVariableSummarise.vb b/instat/dlgOneVariableSummarise.vb index 6887cde8cf..b9a22455bc 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -383,10 +383,10 @@ Public Class dlgOneVariableSummarise Private Sub Display_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlColumnFactor.ControlValueChanged 'If bRCodeSet Then If rdoNoColumnFactor.Checked Then - clsSummaryOperator.RemoveParameterByName("col_factor") + clsGtTableROperator.RemoveParameterByName("col_factor") clsDummyFunction.AddParameter("factor_cols", "NoColFactor", iPosition:=1) Else - clsSummaryOperator.AddParameter("col_factor", clsRFunctionParameter:=clsPivotWiderFunction, iPosition:=1) + clsGtTableROperator.AddParameter("col_factor", clsRFunctionParameter:=clsPivotWiderFunction, iPosition:=1) If rdoSummary.Checked Then clsDummyFunction.AddParameter("factor_cols", "Sum", iPosition:=1) clsPivotWiderFunction.AddParameter("names_from", "summary", iPosition:=0) From fc270fda419ed0922fb36d94f47dc3b889a2acb8 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:51:01 +0100 Subject: [PATCH 20/23] Code Change --- instat/dlgOneVariableSummarise.vb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/instat/dlgOneVariableSummarise.vb b/instat/dlgOneVariableSummarise.vb index b9a22455bc..d91b5a62f9 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -34,7 +34,6 @@ Public Class dlgOneVariableSummarise Private clsPipeOperator, clsJoiningPipeOperator As New ROperator Private clsGetGtTableFunction As New RFunction Private clsGtTableROperator As New ROperator - Private clsSummaryOperator As New ROperator Private bResetSubdialog As Boolean = False Private bResetFormatSubdialog As Boolean = False Public strDefaultDataFrame As String = "" @@ -131,10 +130,8 @@ Public Class dlgOneVariableSummarise clsGtFunction = New RFunction clsDummyFunction = New RFunction clsSkimrFunction = New RFunction - clsSummaryOperator = New ROperator clsPivotWiderFunction = New RFunction - clsPipeOperator = New ROperator clsGtTableROperator = New ROperator @@ -175,10 +172,6 @@ Public Class dlgOneVariableSummarise clsGtTableROperator.AddParameter("tableFun", clsRFunctionParameter:=clsSummaryTableFunction, iPosition:=0) clsGtTableROperator.AddParameter(strParameterName:="gt_tbl", clsRFunctionParameter:=clsGtFunction, iPosition:=1, bIncludeArgumentName:=False) - clsSummaryOperator.SetOperation("%>%") - clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsSummaryTableFunction, iPosition:=0) - clsSummaryOperator.AddParameter("gttbl", clsRFunctionParameter:=clsGtFunction, iPosition:=2) - clsJoiningPipeOperator.SetOperation("%>%") clsJoiningPipeOperator.AddParameter("mutable", clsROperatorParameter:=clsGtTableROperator, iPosition:=0) clsJoiningPipeOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", From b745f6d74cdf653f929b98f9126d6ded315cbdda Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Thu, 12 Dec 2024 13:23:24 +0100 Subject: [PATCH 21/23] minor change --- instat/frmMain.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/frmMain.vb b/instat/frmMain.vb index e20a724234..6b37bf3c29 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -596,7 +596,7 @@ Public Class frmMain My.Application.Info.Version.Build.ToString() End Sub - Public Sub SetHideMenus() + Private Sub SetHideMenus() mnuViewProcurementMenu.Checked = False mnuProcurement.Visible = False mnuViewOptionsByContextMenu.Checked = False From f9405dfc771e574aff289bfae46b3f3b2d8dbb88 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Thu, 12 Dec 2024 16:58:18 +0300 Subject: [PATCH 22/23] changes to the code --- instat/dlgName.vb | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 4840ee3f02..6d8c83a4ac 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -30,6 +30,7 @@ Public Class dlgName Private clsNewColNameDataframeFunction As New RFunction Private clsNewLabelDataframeFunction As New RFunction Private clsDummyFunction As New RFunction + Private clsFixedFunction As New RFunction Private clsStartwithFunction, clsRegexFunction, clsEndswithFunction, clsMatchesFunction, clsContainsFunction As New RFunction Private WithEvents grdCurrentWorkSheet As Worksheet Private dctRowsNewNameChanged As New Dictionary(Of Integer, String) @@ -183,6 +184,7 @@ Public Class dlgName clsMatchesFunction = New RFunction clsContainsFunction = New RFunction clsRegexFunction = New RFunction + clsFixedFunction = New RFunction ucrSelectVariables.Reset() dctRowsNewNameChanged.Clear() @@ -219,6 +221,9 @@ Public Class dlgName clsStartwithFunction.SetRCommand("starts_with") clsStartwithFunction.AddParameter("match", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=0) + clsFixedFunction.SetPackageName("stringr") + clsFixedFunction.SetRCommand("fixed") + clsRegexFunction.SetPackageName("stringr") clsRegexFunction.SetRCommand("regex") clsRegexFunction.AddParameter("ignore_case", "FALSE", bIncludeArgumentName:=False, iPosition:=3) @@ -682,6 +687,10 @@ Public Class dlgName End If End Sub + Private Function IsRegexApplicable() As Boolean + Return (ucrInputEdit.GetText = "Matches All" OrElse ucrInputEdit.GetText = "Matches") + End Function + Private Sub RemovePattern() If rdoWholeDataFrame.Checked Then If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then @@ -718,25 +727,19 @@ Public Class dlgName End Sub Private Sub AddRegexPar() - If rdoWholeDataFrame.Checked Then - If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then - If ucrChkIncludeRegularExpressions.Checked Then - Select Case ucrInputEdit.GetText - Case "Matches All" - clsRegexFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=1) - clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) - Case "Matches" - cmdAddkeyboard.Visible = True - clsRegexFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText & Chr(34), bIncludeArgumentName:=False, iPosition:=1) - clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) - Case Else - clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) - End Select - Else - clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) - End If + If rdoWholeDataFrame.Checked AndAlso (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then + Dim patternValue As String = Chr(34) & ucrInputReplace.GetText & Chr(34) + If ucrChkIncludeRegularExpressions.Checked AndAlso IsRegexApplicable() Then + clsRegexFunction.AddParameter("pattern", patternValue, bIncludeArgumentName:=False, iPosition:=1) + clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) Else - clsDefaultRFunction.RemoveParameterByName("pattern") + Select Case ucrInputEdit.GetText + Case "Contains", "Contains All" + clsFixedFunction.AddParameter("pattern", patternValue, bIncludeArgumentName:=False, iPosition:=1) + clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsFixedFunction, bIncludeArgumentName:=False, iPosition:=4) + Case Else + clsDefaultRFunction.AddParameter("pattern", patternValue, iPosition:=4) + End Select End If Else clsDefaultRFunction.RemoveParameterByName("pattern") From 309931d1fa9039184a811f0e10655eb25547f216 Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Fri, 13 Dec 2024 10:15:48 +0300 Subject: [PATCH 23/23] changes to the code --- instat/dlgName.vb | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 6d8c83a4ac..0be8141d4a 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -620,8 +620,8 @@ Public Class dlgName RemoveParameters() DialogueSize() RemovePattern() - AddTypeParm() - AddRegexPar() + ConfigureTypeParameter() + ConfigurePatternParameter() SetRegexControlVisibility() End Sub @@ -687,10 +687,6 @@ Public Class dlgName End If End Sub - Private Function IsRegexApplicable() As Boolean - Return (ucrInputEdit.GetText = "Matches All" OrElse ucrInputEdit.GetText = "Matches") - End Function - Private Sub RemovePattern() If rdoWholeDataFrame.Checked Then If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then @@ -726,10 +722,11 @@ Public Class dlgName End If End Sub - Private Sub AddRegexPar() + Private Sub ConfigurePatternParameter() If rdoWholeDataFrame.Checked AndAlso (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then Dim patternValue As String = Chr(34) & ucrInputReplace.GetText & Chr(34) - If ucrChkIncludeRegularExpressions.Checked AndAlso IsRegexApplicable() Then + If ucrChkIncludeRegularExpressions.Checked AndAlso (ucrInputEdit.GetText = "Matches All" OrElse ucrInputEdit.GetText = "Matches") Then + clsRegexFunction.AddParameter("pattern", patternValue, bIncludeArgumentName:=False, iPosition:=1) clsDefaultRFunction.AddParameter("pattern", clsRFunctionParameter:=clsRegexFunction, bIncludeArgumentName:=False, iPosition:=4) Else @@ -746,7 +743,7 @@ Public Class dlgName End If End Sub - Private Sub AddTypeParm() + Private Sub ConfigureTypeParameter() If rdoLabels.Checked Then clsDefaultRFunction.AddParameter("type", Chr(34) & "rename_labels" & Chr(34), iPosition:=1) @@ -764,8 +761,8 @@ Public Class dlgName Private Sub ucrInputEdit_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputEdit.ControlValueChanged, ucrInputBy.ControlValueChanged, ucrInputReplace.ControlValueChanged RemovePattern() - AddTypeParm() - AddRegexPar() + ConfigureTypeParameter() + ConfigurePatternParameter() SetRegexControlVisibility() End Sub @@ -776,7 +773,7 @@ Public Class dlgName Private Sub ucrChkIncludeRegularExpressions_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkIncludeRegularExpressions.ControlValueChanged RemovePattern() - AddRegexPar() + ConfigurePatternParameter() SetRegexControlVisibility() End Sub @@ -784,15 +781,13 @@ Public Class dlgName ucrChkIncludeRegularExpressions.Visible = False cmdAddkeyboard.Visible = False - If rdoWholeDataFrame.Checked Then - If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then - Select Case ucrInputEdit.GetText - Case "Matches All", "Matches" - cmdAddkeyboard.Visible = If(ucrChkIncludeRegularExpressions.Checked, True, False) - ucrChkIncludeRegularExpressions.Visible = True - End Select - End If + If rdoWholeDataFrame.Checked AndAlso + (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso + rdoReplace.Checked AndAlso + (ucrInputEdit.GetText = "Matches All" OrElse ucrInputEdit.GetText = "Matches") Then + + ucrChkIncludeRegularExpressions.Visible = True + cmdAddkeyboard.Visible = ucrChkIncludeRegularExpressions.Checked End If End Sub - End Class