Skip to content

Commit a77eb60

Browse files
authored
+ GitHub Feature and Package Tag (#12)
* <package>{package name}</package> * <use>%GitHub%/{owner}/{repro}@{branch}/path/to/codemodule</use>
1 parent 6cc5a27 commit a77eb60

10 files changed

+101
-119
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Version Control Add-in Binaries
22
# (This should be built from source and not committed to version control)
33
*.mdb
4-
*.accda
5-
*.accdb
4+
*.accd[aber]
65
*.zip
76

87
# Database lock files

source/modules/GitHubTreeNodeTests.cls renamed to Tests/ACLibImportWizard/GitHubTreeNodeTests.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION 1.0 CLASS
1+
VERSION 1.0 CLASS
22
BEGIN
33
MultiUse = -1 'True
44
END

source/forms/ACLibImportWizardForm.cls

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Private Const APPFILE_PROPNAME_APPICON As String = "AppIcon"
2222
Private Const RepositorySource_GitHub As Long = 1
2323
Private Const RepositorySource_LocalRepository As Long = 2
2424

25-
2625
Private Const TEMPDB_TABNAME As String = "tRepositoryFiles"
2726
Private Const TEMPDB_TABDDL As String = "create table " & TEMPDB_TABNAME & " (LocalRepositoryPath varchar(255) primary key, ObjectName varchar(255), Description memo)"
2827
Private m_TempDb As TempDbHandler
@@ -172,7 +171,7 @@ On Error GoTo HandleErr
172171
Me.Repaint
173172

174173
Set ACLibFileMngr = CurrentACLibFileManager
175-
If Me.ogRepositorySource = 1 Then
174+
If Me.ogRepositorySource = RepositorySource_GitHub Then
176175
Set m_ACLibFileManager = ACLibFileMngr
177176
Else '
178177
Set m_ACLibFileManager = Nothing

source/modules/ACLibFileManager.cls

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Private Const SEARCHSTRING_CODELIB_BEGIN As String = "<codelib>"
4848
Private Const SEARCHSTRING_CODELIB_END As String = "</codelib>"
4949
Private Const SEARCHSTRING_FILE_BEGIN As String = "<file>"
5050
Private Const SEARCHSTRING_FILE_END As String = "</file>"
51+
Private Const SEARCHSTRING_PACKAGE_BEGIN As String = "<package>"
52+
Private Const SEARCHSTRING_PACKAGE_END As String = "</package>"
5153
Private Const SEARCHSTRING_LICENSE_BEGIN As String = "<license>"
5254
Private Const SEARCHSTRING_LICENSE_END As String = "</license>"
5355
Private Const SEARCHSTRING_DESCRIPTION_BEGIN As String = "<description>"
@@ -79,9 +81,10 @@ Private Const SEARCHSTRING_REPORTIDENTIFER As String = "Begin Report"
7981

8082
Private Const MODULNAME_CONFIG_APPLICATION As String = "_config_Application"
8183

82-
Private Const REPOSTITORY_ROOT_CODE_APPLICATIONROOT As String = "%AppFolder%"
8384
Private Const REPOSTITORY_ROOT_CODE_WithoutCodeLibInfoExportFolder As String = "source"
85+
Private Const REPOSTITORY_ROOT_CODE_APPLICATIONROOT As String = "%AppFolder%"
8486
Private Const REPOSTITORY_ROOT_CODE_PRIVATEROOT As String = "%PrivateRoot%"
87+
Private Const REPOSTITORY_ROOT_CODE_GITHUBROOT As String = "%GitHub%"
8588

8689
Private m_ImportFileCollection As Collection
8790
Private m_ReplacedFilesCollection As Collection
@@ -184,11 +187,20 @@ End Sub
184187

185188
Private Sub Dispose()
186189
On Error Resume Next
190+
RemoveTempFiles
187191
Set m_ImportFileCollection = Nothing
188192
Set m_FSO = Nothing
189193
Set m_CurrentVbProject = Nothing
190194
End Sub
191195

196+
Private Sub RemoveTempFiles()
197+
198+
If FileTools.DirExists(GitHubTempRepositoryPath) Then
199+
CreateObject("Scripting.FileSystemObject").DeleteFolder GitHubTempRepositoryPath, True
200+
End If
201+
202+
End Sub
203+
192204
Public Property Let ExportAllToApplicationSourceFolder(ByVal NewValue As Boolean)
193205
m_ExportAllToApplicationSourceFolder = NewValue
194206
End Property
@@ -309,8 +321,6 @@ Public Sub ImportRepositoryFile(ByVal RepositoryPath As String, _
309321

310322
PathString = GetRepositoryFullPath(RepositoryPath)
311323

312-
313-
314324
Dim TempFile As Object
315325
Set TempFile = fso.GetFile(PathString)
316326
AddMissingFile TempFile, ImportMode
@@ -642,7 +652,21 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
642652
End If
643653
ReleativPath = Mid$(ReleativPath, Len(REPOSTITORY_ROOT_CODE_PRIVATEROOT) + 1)
644654

655+
ElseIf Left(ReleativPath, Len(REPOSTITORY_ROOT_CODE_GITHUBROOT)) = REPOSTITORY_ROOT_CODE_GITHUBROOT Then
656+
' %GITHUB%\owner\repo@branch\Path
657+
ReleativPath = Replace(ReleativPath, "\", "/")
658+
If Not DownLoadFromGitHub(ReleativPath, RepPath) Then
659+
Err.Raise vbObjectError, "getRepositoryFullPath", "Download aus GitHub ist fehlgeschlagen"
660+
Exit Function
661+
End If
662+
663+
If Len(RepPath) = 0 Then
664+
Err.Raise vbObjectError, "getRepositoryFullPath", "Wert für lokales GitHub-Temp-Verzeichnis fehlt."
665+
Exit Function
666+
End If
667+
645668
Else
669+
646670
If m_ExportAllToApplicationSourceFolder Then
647671
RepPath = CurrentProject.Path & "\source\codelib\"
648672
Else
@@ -654,7 +678,6 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
654678
Exit Function
655679
End If
656680

657-
658681
End If
659682

660683
Do While Left$(ReleativPath, 1) = "\"
@@ -671,6 +694,48 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
671694

672695
End Function
673696

697+
Private Function DownLoadFromGitHub(ByRef ReleativPath As String, ByRef RepPath As String) As Boolean
698+
' %GITHUB%/owner/repo@branch/Path
699+
700+
Dim FullFilePath As String
701+
Dim GitHubDataCutPos As Long
702+
Dim GitHubUrlDataString As String
703+
Dim GitHubPath As String
704+
Dim GitHubUrlData() As String
705+
Dim RelativeFileUrl As String
706+
707+
'%GITHUB%/owner/repo@branch/Path
708+
GitHubPath = Mid(Replace(ReleativPath, "\", "/"), Len(REPOSTITORY_ROOT_CODE_GITHUBROOT) + 2)
709+
GitHubDataCutPos = InStr(InStr(1, GitHubPath, "@") + 1, GitHubPath, "/")
710+
GitHubUrlDataString = Left(GitHubPath, GitHubDataCutPos - 1)
711+
RelativeFileUrl = Mid(GitHubPath, GitHubDataCutPos + 1)
712+
GitHubUrlDataString = Replace(GitHubUrlDataString, "@", "/")
713+
714+
GitHubUrlData = Split(GitHubUrlDataString, "/")
715+
RepPath = GitHubTempRepositoryPath & "\"
716+
ReleativPath = Replace(RelativeFileUrl, "/", "\")
717+
FullFilePath = RepPath & ReleativPath
718+
719+
If Not FileTools.FileExists(FullFilePath) Then
720+
721+
With New ACLibGitHubImporter
722+
.RepositoryOwner = GitHubUrlData(0)
723+
.RepositoryName = GitHubUrlData(1)
724+
.BranchName = GitHubUrlData(2)
725+
CreateDirectoryIfMissing FileTools.PathFromFullFileName(FullFilePath)
726+
.DownloadACLibFileFromWeb RelativeFileUrl, FullFilePath
727+
End With
728+
729+
End If
730+
731+
DownLoadFromGitHub = True
732+
733+
End Function
734+
735+
Private Property Get GitHubTempRepositoryPath() As String
736+
GitHubTempRepositoryPath = FileTools.TempPath & "ACLibTempRepo"
737+
End Property
738+
674739
Private Sub ImportFile(ByRef ImportFile As Object, ByRef ImportMode As CodeLibImportMode, _
675740
Optional ByVal ImportTestFiles As Boolean = False)
676741

@@ -726,6 +791,8 @@ Private Sub ImportFile(ByRef ImportFile As Object, ByRef ImportMode As CodeLibIm
726791
ImportAccessObject acForm, m_CLI, ImportFile, ImportMode
727792
Case CodeLibElementType.clet_Report
728793
ImportAccessObject acReport, m_CLI, ImportFile, ImportMode
794+
Case CodeLibElementType.clet_Package
795+
' don't import package file
729796
Case Else
730797
' eventuell Fehler auslösen?
731798
End Select
@@ -1325,8 +1392,11 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
13251392
'Read CODELIB block
13261393
CheckString = FindSubString(CheckString, SEARCHSTRING_CODELIB_BEGIN, SEARCHSTRING_CODELIB_END)
13271394
If Len(CheckString) > 0 Then
1328-
GetCodeLibInfoRepositoryFile CodeLibInf, CheckString
1329-
GetCodeLibInfoRepositoryFileReplacement CodeLibInf, CheckString
1395+
GetCodeLibInfoPackage CodeLibInf, CheckString
1396+
If CodeLibInf.Type <> clet_Package Then
1397+
GetCodeLibInfoRepositoryFile CodeLibInf, CheckString
1398+
GetCodeLibInfoRepositoryFileReplacement CodeLibInf, CheckString
1399+
End If
13301400
GetCodeLibInfoLicenseFile CodeLibInf, CheckString
13311401
If FindDependency Then GetCodeLibInfoDependency CodeLibInf, CheckString
13321402
GetCodeLibInfoReferences CodeLibInf, CheckString
@@ -1337,6 +1407,15 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
13371407

13381408
End Sub
13391409

1410+
Private Sub GetCodeLibInfoPackage(ByRef CodeLibInf As CodeLibInfo, ByRef SourceString As String)
1411+
Dim PackageName As String
1412+
PackageName = Trim(FindSubString(SourceString, SEARCHSTRING_PACKAGE_BEGIN, SEARCHSTRING_PACKAGE_END))
1413+
If Len(PackageName) > 0 Then
1414+
CodeLibInf.Name = PackageName
1415+
CodeLibInf.Type = clet_Package
1416+
End If
1417+
End Sub
1418+
13401419
Private Sub GetCodeLibInfoRepositoryFile(ByRef CodeLibInf As CodeLibInfo, ByRef SourceString As String)
13411420
CodeLibInf.RepositoryFile = Replace(FindSubString(SourceString, SEARCHSTRING_FILE_BEGIN, SEARCHSTRING_FILE_END), "\", "/")
13421421
End Sub

source/modules/AccUnit_Factory.bas

Lines changed: 0 additions & 98 deletions
This file was deleted.

source/modules/AccUnit_TestClassFactory.bas

Lines changed: 0 additions & 8 deletions
This file was deleted.

source/modules/WinApiShortcutMenu.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Private Declare Function TranslateMessage _
221221
Private Declare Function GetWindowRect _
222222
Lib "user32.dll" ( _
223223
ByVal Hwnd As Long, _
224-
ByRef lpRect As RECT _
224+
ByRef lpRect As Rect _
225225
) As Long
226226

227227
Private Declare Function SetMenuDefaultItem _

source/modules/_config_Application.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Option Compare Database
1313
Option Explicit
1414

1515
'Versionsnummer
16-
Private Const APPLICATION_VERSION As String = "1.3.3"
16+
Private Const APPLICATION_VERSION As String = "1.4.0"
1717

1818
#Const USE_CLASS_ApplicationHandler_AppFile = 1
1919
#Const USE_CLASS_ApplicationHandler_DirTextbox = 1

source/modules/defGlobal_ACLibImportWizard.bas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Public Enum CodeLibElementType 'angelehnt an Enum vbext_ComponentType
2222
clet_ClassModule = 2 ' = vbext_ComponentType.vbext_ct_ClassModule
2323
clet_Form = 101 ' = vbext_ComponentType.vbext_ct_Document + 1
2424
clet_Report = 102 ' = vbext_ComponentType.vbext_ct_Document + 2
25+
clet_Package = 256 ' = Package (don't import file, only interpret codelib block)
2526
End Enum
2627

2728
Public Enum CodeLibImportMode

source/tables/L10n_Dict.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,14 @@ Marked entries can be removed from the list with {Del} key.</LngText>
393393
<KeyText>ACLib Import Wizard: Incorrect start</KeyText>
394394
<LngText>ACLib Import Wizard: Incorrect start</LngText>
395395
</L10n_Dict>
396+
<L10n_Dict>
397+
<LangCode>DE</LangCode>
398+
<KeyText>The add-in must be installed into the Access add-in directory using the add-in manager. Afterwards it has to be started via the menu entry 'ACLib Import Wizard'.</KeyText>
399+
<LngText>DE:The add-in must be installed into the Access add-in directory using the add-in manager. Afterwards it has to be started via the menu entry 'ACLib Import Wizard'.</LngText>
400+
</L10n_Dict>
401+
<L10n_Dict>
402+
<LangCode>DE</LangCode>
403+
<KeyText>ACLib Import Wizard: Incorrect start</KeyText>
404+
<LngText>DE:ACLib Import Wizard: Incorrect start</LngText>
405+
</L10n_Dict>
396406
</dataroot>

0 commit comments

Comments
 (0)