Skip to content

Commit

Permalink
Still needs discussion to finalise but so far the refresh on the fly …
Browse files Browse the repository at this point in the history
…is working for the import Dataset
  • Loading branch information
deaspo committed Feb 12, 2016
1 parent 3b80f5b commit 435d575
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 15 deletions.
31 changes: 20 additions & 11 deletions instat/dlgImportDataset.Designer.vb

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

53 changes: 51 additions & 2 deletions instat/dlgImportDataset.vb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@
' along with this program. If not, see <http://www.gnu.org/licenses/>.
Imports instat.Translations
Imports System.IO
Imports RDotNet

Public Class dlgImportDataset

Dim dfTemp As DataFrame
Public strDataName As String = ""
Public strFilePath As String = ""
Private Sub dlgImportDataset_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ucrBase.clsRsyntax.SetFunction("read.csv")
autoTranslate(Me)
cboEncoding.Text = "Automatic"
'Needs discussion for this
rdoHeadingsYes.Checked = True

ucrBase.clsRsyntax.AddParameter("header", "TRUE")
cboRowNames.Text = "Automatic"

ucrBase.clsRsyntax.AddParameter("row.names", "NULL")

cboSeparator.Text = "Comma"
ucrBase.clsRsyntax.AddParameter("sep", Chr(34) & "," & Chr(34))

Expand All @@ -40,13 +48,19 @@ Public Class dlgImportDataset
txtNAStrings.Text = "NA"
ucrBase.clsRsyntax.AddParameter("na.strings", "NA")

SetName(strDataName)
SetFilePath(strFilePath)
'defaults for the preview data frame
dataFrame.SetSettings(unvell.ReoGrid.WorkbookSettings.View_ShowSheetTabControl, False)
refreshFrameView()
End Sub

Public Sub SetName(strName As String)
strName = Replace(strName, " ", "")
strName = Replace(strName, "-", "")
txtName.Text = strName
ucrBase.clsRsyntax.SetAssignTo(txtName.Text, strTempDataframe:=txtName.Text)
strDataName = strName
End Sub

Public Sub SetFilePath(strFilePath As String)
Expand All @@ -57,11 +71,13 @@ Public Class dlgImportDataset

Private Sub txtName_Leave(sender As Object, e As EventArgs) Handles txtName.Leave
SetName(txtName.Text)
refreshFrameView()
End Sub

Private Sub cboEncoding_Leave(sender As Object, e As EventArgs) Handles cboEncoding.Leave
If cboEncoding.Text <> "Automatic" Then
ucrBase.clsRsyntax.AddParameter("encoding", cboEncoding.Text)
refreshFrameView()
End If
End Sub

Expand All @@ -74,6 +90,7 @@ Public Class dlgImportDataset
ucrBase.clsRsyntax.AddParameter("row.names", "NULL")
End Select
End If
refreshFrameView()
End Sub

Private Sub cboSeparator_Leave(sender As Object, e As EventArgs) Handles cboSeparator.Leave
Expand All @@ -85,6 +102,7 @@ Public Class dlgImportDataset
Case "Semicolon"
ucrBase.clsRsyntax.AddParameter("sep", Chr(34) & ";" & Chr(34))
End Select
refreshFrameView()
End Sub

Private Sub cboDecimal_Leave(sender As Object, e As EventArgs) Handles cboDecimal.Leave
Expand All @@ -94,6 +112,7 @@ Public Class dlgImportDataset
Case "Comma"
ucrBase.clsRsyntax.AddParameter("dec", Chr(34) & "," & Chr(34))
End Select
refreshFrameView()
End Sub

Private Sub cboQuote_Leave(sender As Object, e As EventArgs) Handles cboQuote.Leave
Expand All @@ -105,6 +124,7 @@ Public Class dlgImportDataset
ucrBase.clsRsyntax.AddParameter("quote", Chr(34) & "\" & Chr(39) & Chr(34))
End Select
End If
refreshFrameView()
End Sub

Private Sub cboComment_Leave(sender As Object, e As EventArgs) Handles cboComment.Leave
Expand All @@ -113,7 +133,7 @@ Public Class dlgImportDataset
Else
ucrBase.clsRsyntax.AddParameter("comment.char", Chr(34) & cboComment.Text & Chr(34))
End If

refreshFrameView()
End Sub

Private Sub txtNAStrings_Leave(sender As Object, e As EventArgs) Handles txtNAStrings.Leave
Expand All @@ -122,6 +142,35 @@ Public Class dlgImportDataset
Else
ucrBase.clsRsyntax.AddParameter("na.strings", Chr(34) & txtNAStrings.Text & Chr(34))
End If
refreshFrameView()
End Sub

Private Sub refreshFrameView()
'Needs discusion
ucrBase.clsRsyntax.SetAssignTo(strDataName, "")
frmMain.clsRLink.clsEngine.Evaluate(ucrBase.clsRsyntax.GetScript())
'ucrBase.clsRsyntax.SetAssignTo(strDataName, strDataName)
dfTemp = frmMain.clsRLink.clsEngine.GetSymbol(txtName.Text).AsDataFrame
frmMain.clsGrids.FillSheet(dfTemp, txtName.Text, dataFrame)
End Sub

Private Sub rdoHeadingsYes_CheckedChanged(sender As Object, e As EventArgs) Handles rdoHeadingsYes.CheckedChanged
If rdoHeadingsYes.Checked Then
ucrBase.clsRsyntax.AddParameter("header", "TRUE")
End If
End Sub

Private Sub rdoHeadingsYes_Leave(sender As Object, e As EventArgs) Handles rdoHeadingsYes.Leave
refreshFrameView()
End Sub

Private Sub rdoHeadingsNo_Leave(sender As Object, e As EventArgs) Handles rdoHeadingsNo.Leave
refreshFrameView()
End Sub

Private Sub rdoHeadingsNo_CheckedChanged(sender As Object, e As EventArgs) Handles rdoHeadingsNo.CheckedChanged
If rdoHeadingsNo.Checked Then
ucrBase.clsRsyntax.AddParameter("header", "FALSE")
End If
End Sub
End Class
4 changes: 2 additions & 2 deletions instat/frmMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ Public Class frmMain
If Not clsRLink.bInstatObjectExists Then
clsRLink.CreateNewInstatObject()
End If
dlgImportDataset.SetName(pair.Key)
dlgImportDataset.SetFilePath(pair.Value)
dlgImportDataset.strDataName = pair.Key
dlgImportDataset.strFilePath = pair.Value
dlgImportDataset.ShowDialog()
End Select
End If
Expand Down

0 comments on commit 435d575

Please sign in to comment.