diff --git a/instat/dlgName.Designer.vb b/instat/dlgName.Designer.vb index 343d0eee9b..cf7070ee6c 100644 --- a/instat/dlgName.Designer.vb +++ b/instat/dlgName.Designer.vb @@ -71,6 +71,9 @@ 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.cmdAddkeyboard = New System.Windows.Forms.Button() + Me.ucrChkIncludeRegularExpressions = New instat.ucrCheck() Me.grpOptions.SuspendLayout() Me.SuspendLayout() ' @@ -109,7 +112,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 +131,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 +315,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 +432,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 +458,50 @@ 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 + ' + '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!) 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) @@ -481,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 @@ -527,4 +570,7 @@ Partial Class dlgName Friend WithEvents rdoSelectedColumn As RadioButton 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 b108de0f7e..0be8141d4a 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -30,7 +30,8 @@ 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 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) Private dctRowsNewLabelChanged As New Dictionary(Of Integer, String) @@ -80,10 +81,14 @@ 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.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") ucrNudAbbreviate.SetParameter(New RParameter("minlength", 10)) ucrNudAbbreviate.SetMinMax(Integer.MinValue, Integer.MaxValue) @@ -131,6 +136,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) @@ -140,9 +147,14 @@ 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}, 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) @@ -171,6 +183,8 @@ Public Class dlgName clsEndswithFunction = New RFunction clsMatchesFunction = New RFunction clsContainsFunction = New RFunction + clsRegexFunction = New RFunction + clsFixedFunction = New RFunction ucrSelectVariables.Reset() dctRowsNewNameChanged.Clear() @@ -182,6 +196,8 @@ Public Class dlgName clsDummyFunction.AddParameter("checked", "FALSE", iPosition:=0) clsDummyFunction.AddParameter("checked", "whole", 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) @@ -205,6 +221,15 @@ 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) + clsRegexFunction.AddParameter("multiline", "FALSE", iPosition:=4) + clsRegexFunction.AddParameter("comments", "FALSE", iPosition:=5) + ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultRFunction) End Sub @@ -218,16 +243,17 @@ 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) 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() @@ -569,7 +595,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 @@ -583,13 +609,20 @@ 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 + (rdoRenameWith.Checked AndAlso rdoSelectedColumn.Checked) OrElse + (rdoLabels.Checked AndAlso rdoSelectedColumn.Checked) + ucrSelectVariables.btnAdd.Visible = ucrSelectVariables.lstAvailableVariable.Visible ucrSelectVariables.btnDataOptions.Visible = ucrSelectVariables.lstAvailableVariable.Visible UpdateGrid() RemoveParameters() DialogueSize() RemovePattern() + ConfigureTypeParameter() + ConfigurePatternParameter() + SetRegexControlVisibility() End Sub Private Sub DialogueSize() @@ -627,10 +660,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() @@ -660,25 +689,31 @@ 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) - clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) - clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) + If (rdoRenameWith.Checked OrElse rdoLabels.Checked) AndAlso rdoReplace.Checked Then 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) + 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 @@ -687,7 +722,72 @@ Public Class dlgName End If End Sub + 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 (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 + 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") + End If + End Sub + + Private Sub ConfigureTypeParameter() + 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) + + 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 + Private Sub ucrInputEdit_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputEdit.ControlValueChanged, ucrInputBy.ControlValueChanged, ucrInputReplace.ControlValueChanged RemovePattern() + ConfigureTypeParameter() + ConfigurePatternParameter() + SetRegexControlVisibility() + 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() + ConfigurePatternParameter() + SetRegexControlVisibility() + End Sub + + Private Sub SetRegexControlVisibility() + ucrChkIncludeRegularExpressions.Visible = False + cmdAddkeyboard.Visible = False + + 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 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..d91b5a62f9 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -31,12 +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 clsSummaryOperator As New ROperator + Private clsGetGtTableFunction As New RFunction + Private clsGtTableROperator As New ROperator Private bResetSubdialog As Boolean = False Private bResetFormatSubdialog As Boolean = False Public strDefaultDataFrame As String = "" @@ -133,84 +130,20 @@ Public Class dlgOneVariableSummarise clsGtFunction = New RFunction clsDummyFunction = New RFunction clsSkimrFunction = New RFunction - 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 + clsGetGtTableFunction = 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") - - clsFootnoteTitleLocationFunction.SetPackageName("gt") - clsFootnoteTitleLocationFunction.SetRCommand("cells_title") - - clsFootnoteSubtitleLocationFunction.SetPackageName("gt") - clsFootnoteSubtitleLocationFunction.SetRCommand("cells_title") - - clsTableSourcenoteFunction.SetPackageName("gt") - clsTableSourcenoteFunction.SetRCommand("tab_source_note") - - clsFootnoteCellBodyFunction.SetPackageName("gt") - clsFootnoteCellBodyFunction.SetRCommand("cells_body") - - clsSecondFootnoteCellBodyFunction.SetPackageName("gt") - clsSecondFootnoteCellBodyFunction.SetRCommand("cells_body") + clsGetGtTableFunction.SetPackageName("gt") + clsGetGtTableFunction.SetRCommand("gt") clsSkimrFunction.SetPackageName("skimr") clsSkimrFunction.SetRCommand("skim_without_charts") @@ -234,13 +167,13 @@ Public Class dlgOneVariableSummarise clsGtFunction.SetPackageName("gt") clsGtFunction.SetRCommand("gt") - - clsSummaryOperator.SetOperation("%>%") - clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsSummaryTableFunction, iPosition:=0) - clsSummaryOperator.AddParameter("gttbl", clsRFunctionParameter:=clsGtFunction, iPosition:=2) + clsGtTableROperator.SetOperation("%>%") + clsGtTableROperator.bBrackets = False + clsGtTableROperator.AddParameter("tableFun", clsRFunctionParameter:=clsSummaryTableFunction, iPosition:=0) + clsGtTableROperator.AddParameter(strParameterName:="gt_tbl", clsRFunctionParameter:=clsGtFunction, iPosition:=1, bIncludeArgumentName:=False) 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, @@ -285,6 +218,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) @@ -399,7 +334,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,26 +367,19 @@ 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, clsGtTableROperator) + sdgTableOptions.ShowDialog(Me) bResetFormatSubdialog = False End Sub 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) diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index 001fd93e97..8047aa0ebe 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -3217,6 +3217,7 @@ Partial Class frmMain Me.mnuDataViewWindow.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None Me.mnuDataViewWindow.Name = "mnuDataViewWindow" Me.mnuDataViewWindow.Size = New System.Drawing.Size(226, 34) + Me.mnuDataViewWindow.Size = New System.Drawing.Size(148, 22) Me.mnuDataViewWindow.Text = "Data View" ' 'mnuRDataViewerWindow @@ -3225,6 +3226,7 @@ Partial Class frmMain Me.mnuRDataViewerWindow.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None Me.mnuRDataViewerWindow.Name = "mnuRDataViewerWindow" Me.mnuRDataViewerWindow.Size = New System.Drawing.Size(226, 34) + 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 7fdf47625e..0cd1865bd1 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() @@ -608,6 +609,15 @@ Public Class frmMain My.Application.Info.Version.Build.ToString() End Sub + Private 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) mnuFile.Enabled = bEnabled mnuEdit.Enabled = bEnabled diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index be37377a70..2ef35f8ac2 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1011,6 +1011,29 @@ 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 %>% 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( + 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]) + } + self$data_changed <- TRUE + self$variables_metadata_changed <- TRUE } })