Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug when colour is applied in the dataset from Data View window #7355

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion instat/Model/DataFrame/clsDataFramePage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Public Class clsDataFramePage

For i = 0 To _clsDataFrame.ColumnNames.ToList.Count - 1
columnHeader = GetColumnDispayDetails(_clsDataFrame.ColumnNames.ToList(i), vecColumnDataTypes(i))
If bApplyBackGroundColumnColours AndAlso vecColumnColours IsNot Nothing Then
If bApplyBackGroundColumnColours AndAlso vecColumnColours(i) > 0 Then
columnHeader.clsBackGroundColour = GetColumnBackGroundColor(i, vecColumnColours(i).ToString())
End If
_lstColumns.Add(columnHeader)
Expand Down
6 changes: 3 additions & 3 deletions instat/dlgColourbyProperty.Designer.vb

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

30 changes: 28 additions & 2 deletions instat/dlgColourbyProperty.vb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
' along with this program. If not, see <http://www.gnu.org/licenses/>.

Imports instat.Translations
Imports RDotNet
Public Class dlgColourbyProperty
Public bFirstLoad As Boolean = True
Private clsColourByMetadata As New RFunction
Expand All @@ -32,6 +33,7 @@ Public Class dlgColourbyProperty
SetRCodeForControls(bReset)
bReset = False
TestOKEnabled()
AutoFill()
autoTranslate(Me)
End Sub

Expand All @@ -48,6 +50,9 @@ Public Class dlgColourbyProperty
ucrReceiverMetadataProperty.SetItemType("metadata")
ucrReceiverMetadataProperty.strSelectorHeading = "Metadata Property"

ucrChkRemoveColours.AddToLinkedControls(ucrReceiverMetadataProperty, {Not True}, bNewLinkedHideIfParameterMissing:=True)
ucrReceiverMetadataProperty.SetLinkedDisplayControl(lblMetadataProp)

ucrChkRemoveColours.SetText("Remove Colour")
ucrChkRemoveColours.AddFunctionNamesCondition(True, frmMain.clsRLink.strInstatDataObject & "$remove_column_colours")
ucrChkRemoveColours.AddFunctionNamesCondition(False, frmMain.clsRLink.strInstatDataObject & "$set_column_colours_by_metadata")
Expand All @@ -61,7 +66,6 @@ Public Class dlgColourbyProperty

clsColourByMetadata.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$set_column_colours_by_metadata")
clsRemoveColour.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$remove_column_colours")

ucrBase.clsRsyntax.SetBaseRFunction(clsColourByMetadata)
End Sub

Expand All @@ -73,7 +77,7 @@ Public Class dlgColourbyProperty
End Sub

Private Sub TestOKEnabled()
If Not ucrReceiverMetadataProperty.IsEmpty Then
If Not ucrReceiverMetadataProperty.IsEmpty OrElse ucrChkRemoveColours.Checked Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
Expand All @@ -94,6 +98,28 @@ Public Class dlgColourbyProperty
End If
End Sub

Private Sub AutoFill()
If ucrSelectorColourByMetadata.lstAvailableVariable.Items.Count > 0 Then
Dim clsHasColoursFunc As New RFunction
Dim bApplyColumnColours As Boolean
clsHasColoursFunc.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$has_colours")
clsHasColoursFunc.AddParameter("data_name", Chr(34) & ucrSelectorColourByMetadata.ucrAvailableDataFrames.strCurrDataFrame & Chr(34))
bApplyColumnColours = frmMain.clsRLink.RunInternalScriptGetValue(clsHasColoursFunc.ToScript()).AsLogical(0)
If Not bApplyColumnColours Then
For Each lviItem As ListViewItem In ucrSelectorColourByMetadata.lstAvailableVariable.Items
If lviItem.Text = "class" Then
ucrReceiverMetadataProperty.Add(lviItem.Text, ucrSelectorColourByMetadata.ucrAvailableDataFrames.strCurrDataFrame)
Exit For
End If
Next
End If
End If
End Sub

Private Sub ucrSelectorColourByMetadata_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorColourByMetadata.ControlValueChanged
AutoFill()
End Sub

Private Sub Controls_ControContententsChanged(ucrChangedControl As ucrCore) Handles ucrSelectorColourByMetadata.ControlContentsChanged, ucrReceiverMetadataProperty.ControlContentsChanged, ucrChkRemoveColours.ControlContentsChanged
TestOKEnabled()
End Sub
Expand Down
1 change: 1 addition & 0 deletions instat/dlgMergeAdditionalData.vb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ Public Class dlgMergeAdditionalData
Private Sub ucrInputMergingBy_TextChanged(sender As Object, e As EventArgs) Handles ucrInputMergingBy.TextChanged
AddColumns()
CheckUnique()
SetDataFrameAssign()
SetInputCheckVisibility(False)
End Sub

Expand Down
8 changes: 4 additions & 4 deletions instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,8 @@ DataSheet$set("public", "append_to_variables_metadata", function(col_names, prop
for (curr_col in col_names) {
#see comments in PR #7247 to understand why ' property == labels_label && new_val == "" ' check was added
#see comments in issue #7337 to understand why the !is.null(new_val) check was added.
if (property == labels_label && !is.null(new_val) && new_val == "") {
#reset the column labels property
if (((property == labels_label && new_val == "") || (property == colour_label && new_val == -1)) && !is.null(new_val)) {
#reset the column labels or colour property
attr(private$data[[curr_col]], property) <- NULL
} else {
attr(private$data[[curr_col]], property) <- new_val
Expand All @@ -1079,8 +1079,8 @@ DataSheet$set("public", "append_to_variables_metadata", function(col_names, prop
for (col_name in self$get_column_names()) {
#see comments in PR #7247 to understand why ' property == labels_label && new_val == "" ' check was added
#see comments in issue #7337 to understand why the !is.null(new_val) check was added.
if (property == labels_label && !is.null(new_val) && new_val == "") {
#reset the column labels property
if (((property == labels_label && new_val == "") || (property == colour_label && new_val == -1)) && !is.null(new_val)) {
#reset the column labels or colour property
attr(private$data[[col_name]], property) <- NULL
} else {
attr(private$data[[col_name]], property) <- new_val
Expand Down
1 change: 0 additions & 1 deletion instat/ucrDataView.vb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ Public Class ucrDataView
_grid.CurrentWorksheet = fillWorkSheet
_grid.AddColumns(dataFrame.clsVisiblePage)
_grid.AddRowData(dataFrame)
_grid.UpdateWorksheetStyle(fillWorkSheet)
lloyddewit marked this conversation as resolved.
Show resolved Hide resolved
dataFrame.clsVisiblePage.HasChanged = False
RefreshDisplayInformation()
End Sub
Expand Down