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

Implementing undo in Reogrid #9189

Merged
merged 33 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
786bace
implementing undo
N-thony Oct 12, 2024
0c0a5fa
more changes
N-thony Oct 12, 2024
84ff435
more improvement
N-thony Oct 12, 2024
8db5ece
improved the undo to be unlimited
N-thony Oct 14, 2024
2bb3018
set the focus on the grid
N-thony Oct 14, 2024
f5c6f49
redo implementation
N-thony Oct 14, 2024
513f116
added undo feature to more operations done in data
N-thony Oct 14, 2024
0d5e856
Merge pull request #107 from IDEMSInternational/master
N-thony Oct 16, 2024
7d3efbb
added and implemented switch off undo checkbox
N-thony Oct 16, 2024
6e55c52
improvement in the switch off undo
N-thony Oct 16, 2024
08342f5
implemented Ctrl+Z under undo menu
N-thony Oct 16, 2024
66d205b
design fixes, and added a msg for the limits when exceeded
N-thony Oct 16, 2024
1a60e3b
set the deault column to 100
N-thony Oct 16, 2024
2a1d8d5
set the default to 200 for cols
N-thony Oct 16, 2024
6845c03
memory management for the undo feature
N-thony Oct 18, 2024
68a40a4
added timer
N-thony Oct 18, 2024
7654b12
added switch off undo option
N-thony Oct 18, 2024
c033eec
small design change
N-thony Oct 18, 2024
1d61315
added timing
N-thony Oct 18, 2024
c3e772f
minor design change
N-thony Oct 18, 2024
da5b9cb
extended undo to reorder columns
N-thony Oct 18, 2024
aa1bc04
minor bug and design change
N-thony Oct 18, 2024
4935089
minor design change
N-thony Oct 18, 2024
95c6751
minor change for switch off undo
N-thony Oct 21, 2024
e82885e
R code addtion
N-thony Oct 21, 2024
b89a0b5
more r code changes
N-thony Oct 22, 2024
743cec7
code change
N-thony Oct 22, 2024
d4f93dd
implemented the possibility to switch on/off undo in different datasets
N-thony Oct 22, 2024
15a8932
minor addition
N-thony Oct 22, 2024
15a35d9
Call gc() to ensure memory is freed promptly for removing/resetting i…
N-thony Oct 23, 2024
aca453a
Added the logger and code addition
N-thony Oct 23, 2024
28beaa2
minor bug fix
N-thony Oct 23, 2024
2c6a091
improved the management of metadat in undo
N-thony Oct 23, 2024
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
4 changes: 4 additions & 0 deletions instat/Interface/IDataViewGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Public Interface IDataViewGrid

Event WorksheetChanged()

Event WorksheetInserted()

Event WorksheetRemoved(worksheet As clsWorksheetAdapter)

Event FindRow()
Expand All @@ -44,6 +46,8 @@ Public Interface IDataViewGrid

Sub AdjustColumnWidthAfterWrapping(strColumn As String, Optional bApplyWrap As Boolean = False)

Sub Focus()

Function GetSelectedColumns() As List(Of clsColumnHeaderDisplay)

Function GetFirstRowHeader() As String
Expand Down
52 changes: 52 additions & 0 deletions instat/Model/DataFrame/clsDataFramePage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,58 @@ Public Class clsDataFramePage
Return Math.Ceiling(_iTotalColumnCount / iColumnIncrements)
End Function

Public Sub Undo()
Dim clsUndoRFunction As New RFunction
clsUndoRFunction.SetRCommand(_clsRLink.strInstatDataObject & "$undo_last_action")
clsUndoRFunction.AddParameter("data_name", Chr(34) & _strDataFrameName & Chr(34))
_clsRLink.RunScript(clsUndoRFunction.ToScript)

End Sub

Public Function IsUndo(strCurrentDataFrame As String)
Dim clsIsUndoFunction As New RFunction
Dim expTemp As SymbolicExpression
clsIsUndoFunction.SetRCommand(_clsRLink.strInstatDataObject & "$is_undo")
clsIsUndoFunction.AddParameter("data_name", Chr(34) & strCurrentDataFrame & Chr(34))

If clsIsUndoFunction IsNot Nothing Then
expTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsIsUndoFunction.ToScript(), bSilent:=True)
If expTemp IsNot Nothing AndAlso expTemp.AsCharacter(0) = "TRUE" Then
Return True
End If
End If

Return False
End Function

Public Sub DisableEnableUndo(bDisable As Boolean, strCurrentDataFrame As String)
Dim clsEnableDisableUndoRFunction As New RFunction
clsEnableDisableUndoRFunction.SetRCommand(_clsRLink.strInstatDataObject & "$set_enable_disable_undo")
clsEnableDisableUndoRFunction.AddParameter("data_name", Chr(34) & strCurrentDataFrame & Chr(34))

Dim strDisable As String = If(bDisable, "TRUE", "FALSE")
clsEnableDisableUndoRFunction.AddParameter("disable_undo", strDisable)
_clsRLink.RunScript(clsEnableDisableUndoRFunction.ToScript)

End Sub

Public Function HasUndoHistory()
Dim expTemp As SymbolicExpression
Dim bHasHistory As Boolean = False
Dim clsHasHistoryFunction As New RFunction

clsHasHistoryFunction.SetRCommand(_clsRLink.strInstatDataObject & "$has_undo_history")
clsHasHistoryFunction.AddParameter("data_name", Chr(34) & _strDataFrameName & Chr(34))
If clsHasHistoryFunction IsNot Nothing Then
expTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsHasHistoryFunction.ToScript(), bSilent:=True)
If expTemp IsNot Nothing AndAlso expTemp.AsCharacter(0) = "TRUE" Then
bHasHistory = True
End If
End If

Return bHasHistory
End Function

Private Function GetDataFrameFromRCommand() As DataFrame
Dim clsGetDataFrameRFunction As New RFunction
Dim expTemp As SymbolicExpression
Expand Down
6 changes: 6 additions & 0 deletions instat/UserControls/DataGrid/Linux/ucrDataViewLinuxGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Public Class ucrDataViewLinuxGrid

Public Event WorksheetChanged() Implements IDataViewGrid.WorksheetChanged

Public Event WorksheetInserted() Implements IDataViewGrid.WorksheetInserted

Public Event WorksheetRemoved(worksheet As clsWorksheetAdapter) Implements IDataViewGrid.WorksheetRemoved

Public Sub AddColumns(visiblePage As clsDataFramePage) Implements IDataViewGrid.AddColumns
Expand Down Expand Up @@ -69,6 +71,10 @@ Public Class ucrDataViewLinuxGrid
Next
End Sub

Public Sub FocusGrid() Implements IDataViewGrid.Focus
Me.Focus()
End Sub

Public Function SelectedTab() As String
If tcTabs.SelectedTab Is Nothing Then
Return ""
Expand Down
12 changes: 12 additions & 0 deletions instat/UserControls/DataGrid/ReoGrid/ucrDataViewReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Public Class ucrDataViewReoGrid

Public Event WorksheetChanged() Implements IDataViewGrid.WorksheetChanged

Public Event WorksheetInserted() Implements IDataViewGrid.WorksheetInserted

Public Event WorksheetRemoved(worksheet As clsWorksheetAdapter) Implements IDataViewGrid.WorksheetRemoved

Public Sub AddColumns(visiblePage As clsDataFramePage) Implements IDataViewGrid.AddColumns
Expand All @@ -57,6 +59,11 @@ Public Class ucrDataViewReoGrid
Next
End Sub

Public Sub FocusGrid() Implements IDataViewGrid.Focus
grdData.Focus()
grdData.CurrentWorksheet.FocusPos = grdData.CurrentWorksheet.FocusPos
End Sub

Public Sub AddRowData(dataFrame As clsDataFrame) Implements IDataViewGrid.AddRowData
Dim textColour As Color
Dim strRowNames As String()
Expand Down Expand Up @@ -217,6 +224,11 @@ Public Class ucrDataViewReoGrid
RaiseEvent WorksheetChanged()
End Sub

Private Sub grdData_WorksheetInserted(sender As Object, e As EventArgs) Handles grdData.WorksheetInserted
RaiseEvent WorksheetInserted()
End Sub


Private Sub grdData_WorksheetRemoved(sender As Object, e As WorksheetRemovedEventArgs) Handles grdData.WorksheetRemoved
RaiseEvent WorksheetRemoved(New clsWorksheetAdapter(e.Worksheet))
End Sub
Expand Down
37 changes: 37 additions & 0 deletions instat/clsInstatOptions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Imports RDotNet
Public iPreviewRows As Nullable(Of Integer)
Public iMaxRows As Nullable(Of Integer)
Public iMaxCols As Nullable(Of Integer)
Public iUndoColLimit As Nullable(Of Integer)
Public iUndoRowLimit As Nullable(Of Integer)
Public lstColourPalette As List(Of Color)
Public strGraphDisplayOption As String
Public bCommandsinOutput As Nullable(Of Boolean)
Expand All @@ -43,6 +45,8 @@ Imports RDotNet
Public bShowSignifStars As Nullable(Of Boolean)
Public bChangeDataFrame As Nullable(Of Boolean)
Public bAutoSaveData As Nullable(Of Boolean)
Public bSwitchOffUndo As Nullable(Of Boolean)
Public bUndoSwitchAction As Nullable(Of Boolean)
Public iAutoSaveDataMinutes As Nullable(Of Integer)
Public bShowWaitDialog As Nullable(Of Boolean)
Public iWaitTimeDelaySeconds As Nullable(Of Integer)
Expand Down Expand Up @@ -75,6 +79,8 @@ Imports RDotNet
iPreviewRows = clsInstatOptionsDefaults.DEFAULTiPreviewRows
iMaxRows = clsInstatOptionsDefaults.DEFAULTiMaxRows
iMaxCols = clsInstatOptionsDefaults.DEFAULTiMaxCols
iUndoColLimit = clsInstatOptionsDefaults.DEFAULTiUndoColLimit
iUndoRowLimit = clsInstatOptionsDefaults.DEFAULTiUndoRowLimit
strComment = Translations.GetTranslation(clsInstatOptionsDefaults.DEFAULTstrComment)
strGraphDisplayOption = clsInstatOptionsDefaults.DEFAULTstrGraphDisplayOption
strLanguageCultureCode = clsInstatOptionsDefaults.DEFAULTstrLanguageCultureCode
Expand All @@ -84,6 +90,7 @@ Imports RDotNet
bShowSignifStars = clsInstatOptionsDefaults.DEFAULTbShowSignifStars
bChangeDataFrame = clsInstatOptionsDefaults.DEFAULTbChangeDataFrame
bAutoSaveData = clsInstatOptionsDefaults.DEFAULTbAutoSaveData
bSwitchOffUndo = clsInstatOptionsDefaults.DEFAULTbSwitchOffUndo
iAutoSaveDataMinutes = clsInstatOptionsDefaults.DEFAULTiAutoSaveDataMinutes
bShowWaitDialog = clsInstatOptionsDefaults.DEFAULTbShowWaitDialog
iWaitTimeDelaySeconds = clsInstatOptionsDefaults.DEFAULTiWaitTimeDelaySeconds
Expand Down Expand Up @@ -144,6 +151,18 @@ Imports RDotNet
SetMaxCols(clsInstatOptionsDefaults.DEFAULTiMaxCols)
End If

If iUndoColLimit.HasValue Then
SetUndoColLimit(iUndoColLimit)
Else
SetUndoColLimit(clsInstatOptionsDefaults.DEFAULTiUndoColLimit)
End If

If iUndoRowLimit.HasValue Then
SetUndoRowLimit(iUndoRowLimit)
Else
SetUndoRowLimit(clsInstatOptionsDefaults.DEFAULTiUndoRowLimit)
End If

If bCommandsinOutput.HasValue Then
SetCommandInOutpt(bCommandsinOutput)
Else
Expand Down Expand Up @@ -244,6 +263,12 @@ Imports RDotNet
SetAutoSaveData(clsInstatOptionsDefaults.DEFAULTbAutoSaveData)
End If

If bSwitchOffUndo.HasValue Then
SetOffUndo(bSwitchOffUndo)
Else
SetOffUndo(clsInstatOptionsDefaults.DEFAULTbSwitchOffUndo)
End If

If iAutoSaveDataMinutes.HasValue Then
SetAutoSaveDataMinutes(iAutoSaveDataMinutes)
Else
Expand Down Expand Up @@ -356,6 +381,14 @@ Imports RDotNet
Return If(expression Is Nothing OrElse expression.Type = Internals.SymbolicExpressionType.Null, Nothing, expression.AsCharacter(0))
End Function

Public Sub SetUndoColLimit(iNewUndoColLimit As Integer)
iUndoColLimit = iNewUndoColLimit
End Sub

Public Sub SetUndoRowLimit(iNewUndoRowLimit As Integer)
iUndoRowLimit = iNewUndoRowLimit
End Sub

Public Sub SetMaxRows(iRows As Integer)
iMaxRows = iRows
frmMain.UpdateAllGrids()
Expand Down Expand Up @@ -530,6 +563,10 @@ Imports RDotNet
bAutoSaveData = bNewAutoSave
End Sub

Public Sub SetOffUndo(bNewSwitchOffUndo As Boolean)
bSwitchOffUndo = bNewSwitchOffUndo
End Sub

Public Sub SetAutoSaveDataMinutes(iNewMinutes As Integer)
iAutoSaveDataMinutes = iNewMinutes
frmMain.ResetTimer()
Expand Down
3 changes: 3 additions & 0 deletions instat/clsInstatOptionsDefaults.vb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Public Class clsInstatOptionsDefaults
Public Shared ReadOnly DEFAULTiPreviewRows As Integer = 10
Public Shared ReadOnly DEFAULTiMaxRows As Integer = 1000
Public Shared ReadOnly DEFAULTiMaxCols As Integer = 50
Public Shared ReadOnly DEFAULTiUndoColLimit As Integer = 200
Public Shared ReadOnly DEFAULTiUndoRowLimit As Integer = 200000
Public Shared ReadOnly DEFAULTstrComment As String = "Dialog:"
Public Shared ReadOnly DEFAULTstrGraphDisplayOption As String = "view_output_window"
Public Shared ReadOnly DEFAULTbChangeDataFrame As Boolean = False
Expand All @@ -45,6 +47,7 @@ Public Class clsInstatOptionsDefaults
Public Shared ReadOnly DEFAULTiDigits As Integer = 4
Public Shared ReadOnly DEFAULTbShowSignifStars As Boolean = False
Public Shared ReadOnly DEFAULTbAutoSaveData As Boolean = True
Public Shared ReadOnly DEFAULTbSwitchOffUndo As Boolean = False
Public Shared ReadOnly DEFAULTiAutoSaveDataMinutes As Integer = 10
Public Shared ReadOnly DEFAULTbShowWaitDialog As Boolean = True
Public Shared ReadOnly DEFAULTiWaitTimeDelaySeconds As Integer = 2
Expand Down
7 changes: 7 additions & 0 deletions instat/dlgCalculator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ Public Class dlgCalculator
Private strDefaultKeyboard As String
' Note: This list needs to be updated when a new keyboard is added.
Private strKeyboards() As String = {"Basic", "Maths", "Logical and Symbols", "Transform", "Summary", "Probability", "Factor", "Text/Strings (Character Columns)", "Dates/Times", "Circular", "Wakefield", "Goodness of Fit", "List", "Complex", "Integer", "Functions"}
Private Shared ReadOnly Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger()


Private Sub dlgCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim start = DateTime.Now
If bFirstLoad Then
InitialiseDialog()
iBasicWidth = Me.Width
Expand All @@ -48,6 +51,10 @@ Public Class dlgCalculator
ReopenDialog()
TestOKEnabled()
autoTranslate(Me)

Logger.Debug("This is in the load")
Logger.Debug(Process.GetCurrentProcess().WorkingSet64)
Logger.Debug("Time", DateTime.Now - start)
End Sub

Private Sub TestOKEnabled()
Expand Down
Loading
Loading