Skip to content

Commit

Permalink
Merge pull request #25 from jpimbert/Story-51-ReferencesManagement
Browse files Browse the repository at this point in the history
Story 51 references management
  • Loading branch information
jpimbert committed Jun 24, 2014
2 parents 84b669d + ca9d845 commit 19db790
Show file tree
Hide file tree
Showing 25 changed files with 1,602 additions and 172 deletions.
123 changes: 72 additions & 51 deletions Project/VBAToolKit.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE vtkConf [
<!ELEMENT vtkConf (info,configuration*, module*, reference*)>
<!ELEMENT vtkConf (info, reference*, configuration*, module*)>
<!ELEMENT info (vtkConfigurationsVersion,projectName)>
<!ELEMENT vtkConfigurationsVersion (#PCDATA)>
<!ELEMENT projectName (#PCDATA)>
<!ELEMENT configuration (name,path,templatePath?,title?,comment?)>
<!ATTLIST configuration cID ID #REQUIRED>
<!ATTLIST configuration refIDs IDREFS #IMPLIED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT path (#PCDATA)>
<!ELEMENT templatePath (#PCDATA)>
Expand All @@ -16,33 +17,77 @@
<!ELEMENT modulePath (#PCDATA)>
<!ATTLIST modulePath confId IDREF #REQUIRED>
<!ELEMENT reference (name, (guid|path))>
<!ATTLIST reference confIDs IDREFS #REQUIRED>
<!ATTLIST reference refID ID #REQUIRED>
<!ELEMENT guid (#PCDATA)>
]>
<vtkConf>

<info>
<vtkConfigurationsVersion>1.0</vtkConfigurationsVersion>
<vtkConfigurationsVersion>2.0</vtkConfigurationsVersion>
<projectName>VBAToolKit</projectName>
</info>

<configuration cID="c1">
<reference refID="r1">
<name>VBA</name>
<guid>{000204EF-0000-0000-C000-000000000046}</guid>
</reference>
<reference refID="r2">
<name>Excel</name>
<guid>{00020813-0000-0000-C000-000000000046}</guid>
</reference>
<reference refID="r3">
<name>stdole</name>
<guid>{00020430-0000-0000-C000-000000000046}</guid>
</reference>
<reference refID="r4">
<name>Office</name>
<guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</guid>
</reference>
<reference refID="r5">
<name>MSForms</name>
<guid>{0D452EE1-E08F-101A-852E-02608C4D0BB4}</guid>
</reference>
<reference refID="r6">
<name>Scripting</name>
<guid>{420B2830-E718-11CF-893D-00A0C9054228}</guid>
</reference>
<reference refID="r7">
<name>VBIDE</name>
<guid>{0002E157-0000-0000-C000-000000000046}</guid>
</reference>
<reference refID="r8">
<name>Shell32</name>
<guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</guid>
</reference>
<reference refID="r9">
<name>MSXML2</name>
<guid>{F5078F18-C551-11D3-89B9-0000F81FE221}</guid>
</reference>
<reference refID="r10">
<name>ADODB</name>
<guid>{00000206-0000-0010-8000-00AA006D2EA4}</guid>
</reference>
<reference refID="r11">
<name>VBAToolKit</name>
<path>C:\Documents and Settings\Demonn\Application Data\Microsoft\AddIns\VBAToolKit.xlam</path>
</reference>
<configuration cID="c1" refIDs="r1 r2 r3 r4 r5 r6 r7 r8 r9 ">
<name>VBAToolKit</name>
<path>Delivery\VBAToolKit.xlam</path>
<title>VBAToolKit</title>
<comment>Toolkit improving IDE for VBA projects</comment>
<comment>Project VBAToolKit</comment>
</configuration>
<configuration cID="c2">
<configuration cID="c2" refIDs="r1 r2 r3 r4 r5 r6 r7 r8 r9 r11 ">
<name>VBAToolKit_DEV</name>
<path>Project\VBAToolKit_DEV.xlsm</path>
<title>VBAToolKit</title>
<comment>Toolkit improving IDE for VBA projects</comment>
<title>VBAToolKit_DEV</title>
<comment>Project VBAToolKit_DEV</comment>
</configuration>
<configuration cID="c3">
<configuration cID="c3" refIDs="r1 r2 r3 r4 r5 r6 r7 r8 r9 ">
<name>VBAToolKit_2003</name>
<path>Delivery\VBAToolKit.xla</path>
<title>VBAToolKit</title>
<comment>Toolkit improving IDE for VBA projects</comment>
<title>VBAToolKit_2003</title>
<comment>Project VBAToolKit_2003</comment>
</configuration>
<module mID="m1">
<name>vtkImportExportUtilities</name>
Expand Down Expand Up @@ -382,44 +427,20 @@
<name>vtkExcelUtilitiesTester</name>
<modulePath confId="c2">Source\ConfTest\vtkExcelUtilitiesTester.cls</modulePath>
</module>
<reference confIDs="c1 c2 c3">
<name>VBA</name>
<guid>{000204EF-0000-0000-C000-000000000046}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>Excel</name>
<guid>{00020813-0000-0000-C000-000000000046}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>stdole</name>
<guid>{00020430-0000-0000-C000-000000000046}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>Office</name>
<guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>MSForms</name>
<guid>{0D452EE1-E08F-101A-852E-02608C4D0BB4}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>Scripting</name>
<guid>{420B2830-E718-11CF-893D-00A0C9054228}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>VBIDE</name>
<guid>{0002E157-0000-0000-C000-000000000046}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>Shell32</name>
<guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</guid>
</reference>
<reference confIDs="c1 c2 c3">
<name>MSXML2</name>
<guid>{F5078F18-C551-11D3-89B9-0000F81FE221}</guid>
</reference>
<reference confIDs="c2">
<name>VBAToolKit</name>
<path>C:\Documents and Settings\Demonn\Application Data\Microsoft\AddIns\VBAToolKit.xlam</path>
</reference>
<module mID="m65">
<name>vtkReferenceManager</name>
<modulePath confId="c1">Source\ConfProd\vtkReferenceManager.cls</modulePath>
<modulePath confId="c2">Source\ConfProd\vtkReferenceManager.cls</modulePath>
<modulePath confId="c3">Source\ConfProd\vtkReferenceManager.cls</modulePath>
</module>
<module mID="m66">
<name>vtkReferenceManagerTester</name>
<modulePath confId="c2">Source\ConfTest\vtkReferenceManagerTester.cls</modulePath>
</module>
<module mID="m67">
<name>vtkReference</name>
<modulePath confId="c1">Source\ConfProd\vtkReference.cls</modulePath>
<modulePath confId="c2">Source\ConfProd\vtkReference.cls</modulePath>
<modulePath confId="c3">Source\ConfProd\vtkReference.cls</modulePath>
</module>
</vtkConf>
Binary file modified Project/VBAToolKit_DEV.xlsm
Binary file not shown.
11 changes: 10 additions & 1 deletion Source/ConfProd/VtKPathUtilities.bas
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,13 @@ Public Sub vtkDeleteTreeFolder(rootPath As String)
RmDir rootPath
End Sub


'---------------------------------------------------------------------------------------
' Function : vtkIsPathAbsolute as Boolean
' Author : Jean-Pierre Imbert
' Date : 23/06/2014
' Purpose : Return True if the path given as a parameter is absolute
'---------------------------------------------------------------------------------------
'
Public Function vtkIsPathAbsolute(path As String) As Boolean
vtkIsPathAbsolute = (UCase(Left(path, 3)) Like "[A-Z]:\") Or (Left(path, 1) = "\")
End Function
31 changes: 29 additions & 2 deletions Source/ConfProd/vtkConfiguration.cls
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ End Property
' Purpose : The ID of the configuration for XML exportation
'---------------------------------------------------------------------------------------
'
Property Get ID() As String
ID = "c" & m_number
Property Get id() As String
id = "c" & m_number
End Property

'---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -175,3 +175,30 @@ Property Get modules() As Collection
Next i
Set modules = col
End Property

'---------------------------------------------------------------------------------------
' Property : references as collection (Read Only)
' Author : Jean-Pierre Imbert
' Date : 21/06/2014
' Purpose : All references of this configuration are included in the collection
'---------------------------------------------------------------------------------------
'
Property Get references() As Collection
Set references = m_parent.getConfigurationReferencesWithNumber(m_number)
End Property

'---------------------------------------------------------------------------------------
' Subroutine : addReferencesToWorkbook as collection
' Author : Jean-Pierre Imbert
' Date : 22/06/2014
' Purpose : Add all references of this configuration to the workbook given as a parameter
'---------------------------------------------------------------------------------------
'
Public Sub addReferencesToWorkbook(Wb As Workbook)
Dim ref As vtkReference
For Each ref In Me.references
ref.addToWorkbook Wb
Next
End Sub


59 changes: 59 additions & 0 deletions Source/ConfProd/vtkConfigurationManager.cls
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,22 @@ Private m_projectName As String ' The configuration of a project is
Private m_workbook As Workbook
Private m_configurationSheet As Worksheet
Private m_rootPath As String
Private m_refManager As vtkReferenceManager
Private m_devConfiguration As Integer
Private Const sheetName As String = "vtkConfigurations"
Private Const currentVersion As String = "vtkConfigurations v1.1"
Private Const version10 As String = "vtkConfigurations v1.0"
Private m_sheetVersion As String
Private Const nbTitleColumns As Integer = 1

Private Sub Class_Initialize()
m_devConfiguration = -1
End Sub

Private Sub Class_Terminate()
Set m_configurationSheet = Nothing
Set m_workbook = Nothing
Set m_refManager = Nothing
End Sub

'---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -228,6 +235,8 @@ Private Sub initializeConfigurationSheet(ws As Worksheet)
ws.Range("C1") = vtkProjectForName(projectName).projectDEVName
ws.Range("C2") = vtkProjectForName(projectName).projectDEVStandardRelativePath

m_devConfiguration = 2

ws.Columns("A:C").ColumnWidth = 22
ws.Range("A1").Font.Size = 8
ws.Range("A3").HorizontalAlignment = xlCenter
Expand Down Expand Up @@ -531,6 +540,17 @@ Public Sub setConfigurationCommentWithNumber(n As Integer, comment As String)
End If
End Sub

'---------------------------------------------------------------------------------------
' Procedure : getConfigurationReferencesWithNumber
' Author : Jean-Pierre Imbert
' Date : 08/06/2014
' Purpose : return the n-th configuration references collection of the project, given n as integer
'---------------------------------------------------------------------------------------
'
Public Function getConfigurationReferencesWithNumber(n As Integer) As Collection
Set getConfigurationReferencesWithNumber = referenceManager.references(n)
End Function

'---------------------------------------------------------------------------------------
' Property : moduleCount as Integer - Read Only - Public
' Author : Jean-Pierre Imbert
Expand Down Expand Up @@ -664,3 +684,42 @@ Public Sub setModulePathWithNumber(path As String, numModule As Integer, numConf
configurationSheet.Cells(numModule + nbTitleRows, numConfiguration + nbTitleColumns) = s
End If
End Sub

'---------------------------------------------------------------------------------------
' Procedure : referenceManager, private
' Author : Jean-Pierre Imbert
' Date : 19/06/2014
' Purpose : Return the reference manager associated with the configuration manager
'---------------------------------------------------------------------------------------
'
Private Function referenceManager() As vtkReferenceManager
initReferences refs:=Nothing
Set referenceManager = m_refManager
End Function

'---------------------------------------------------------------------------------------
' Procedure : references
' Author : Jean-Pierre Imbert
' Date : 19/06/2014
' Purpose : Return a collection of all vtkReferences objects
'---------------------------------------------------------------------------------------
'
Public Function references() As Collection
Set references = referenceManager.allReferences
End Function

'---------------------------------------------------------------------------------------
' Procedure : initReferences
' Author : Jean-Pierre Imbert
' Date : 23/06/2014
' Purpose : Initialize the references with the collection of vtkReference
'---------------------------------------------------------------------------------------
'
Public Sub initReferences(refs As Collection)
If m_refManager Is Nothing Then
Set m_refManager = New vtkReferenceManager
m_refManager.init Wb:=Workbook, confCount:=Me.configurationCount, nbTitleColumnsInConfSheet:=nbTitleColumns, devConf:=m_devConfiguration, references:=refs
End If
End Sub


33 changes: 31 additions & 2 deletions Source/ConfProd/vtkConfigurationManagers.bas
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ End Sub
' - the suffix "_DEV" is appended to the project name
' - the Excel workbook is saved as a new file with DEV appended to the name
' - the Delivery version is described in configuration but not created
' - the reference sheet is created and initialized according to the actual references
'---------------------------------------------------------------------------------------
'
Public Sub vtkInitializeConfigurationForActiveWorkBook(Optional withBeforeSaveHandler As Boolean = False)
Expand Down Expand Up @@ -130,6 +131,9 @@ Public Sub vtkInitializeConfigurationForActiveWorkBook(Optional withBeforeSaveHa
End If
Next

' Initialize the reference sheet
cm.initReferences vtkReferencesInWorkbook(ActiveWorkbook)

' Add a BeforeSave event handler for the workbook
If withBeforeSaveHandler Then vtkAddBeforeSaveHandlerInDEVWorkbook Wb:=ActiveWorkbook, projectName:=project.projectName, confName:=project.projectDEVName

Expand All @@ -153,8 +157,6 @@ End Sub
' - All modules really present in a configuration are described in the description with non null path
' - All modules pathes are reachable
' - Each code module implemented in a configuration is the same as the source code module
'
' To be implemented later (with XML configuration files)
' - All references listed in a configuration description are existing in the configuration
' - All references really present in a configuration are described in the description
'---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -269,6 +271,33 @@ Sub vtkVerifyConfigurations()
Next i
vtkDeleteFolder testPath

' Verify that all references listed in a configuration description are existing in the configuration
' and that all references really present in a configuration are described in the description
' - for each configuration, get both collection
' - compare one list to the other whikle removing each found item
' - alert if an item is not found in the other list
' - the count of remaining items must be null at the end of the comparison
' - alert if not, and list the remaining items
Dim actualList As Collection, actualRef As vtkReference, expectedRef As vtkReference
For i = 1 To nbConf
Set actualList = vtkReferencesInWorkbook(cwb(i).Wb) ' Get the actual list, indexed by name
For Each expectedRef In cwb(i).conf.references ' the expected list is indexed by ID
On Error Resume Next
Set actualRef = actualList(expectedRef.name)
If Err.Number <> 0 Then
Debug.Print "Reference " & expectedRef.name & " is expected but not present in configuration " & cwb(i).conf.name & "."
Else
actualList.Remove expectedRef.name
End If
On Error GoTo 0
Next expectedRef
If actualList.Count <> 0 Then
For Each actualRef In actualList
Debug.Print "Reference " & actualRef.name & " is present but not expected in configuration " & cwb(i).conf.name & "."
Next actualRef
End If
Next i

' Close all Worbooks opened during this verification
For i = 1 To nbConf
If Not cwb(i).wasOpened Then cwb(i).Wb.Close saveChanges:=False
Expand Down
2 changes: 2 additions & 0 deletions Source/ConfProd/vtkConstants.bas
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Public Const VTK_WORKBOOK_NOTOPEN = 4003
Public Const VTK_WORKBOOK_ALREADY_OPEN = 4004
Public Const VTK_NO_SOURCE_FILES = 4005
Public Const VTK_OBSOLETE_CONFIGURATION_SHEET = 4006
Public Const VTK_NOTINITIALIZED = 4007
Public Const VTK_INVALID_FIELD = 4008

Public Const VTK_UNEXPECTED_CHAR = 5001
Public Const VTK_UNEXPECTED_EOS = 5002
Expand Down
Loading

0 comments on commit 19db790

Please sign in to comment.