Project.st
changeset 3972 efc25c2863e9
parent 3332 8014b817988b
child 3973 7065a27b136b
equal deleted inserted replaced
3971:aad506cdc5d9 3972:efc25c2863e9
    11 "
    11 "
    12 
    12 
    13 Object subclass:#Project
    13 Object subclass:#Project
    14 	instanceVariableNames:'name changeSet views directoryName properties packageName
    14 	instanceVariableNames:'name changeSet views directoryName properties packageName
    15 		repositoryDirectory repositoryModule defaultNameSpace
    15 		repositoryDirectory repositoryModule defaultNameSpace
    16 		overwrittenMethods'
    16 		overwrittenMethods subProjects prerequisites bitmapFiles
    17 	classVariableNames:'CurrentProject SystemProject NextSequential'
    17 		documentFiles otherFiles'
       
    18 	classVariableNames:'CurrentProject SystemProject NextSequential AllProjects'
    18 	poolDictionaries:''
    19 	poolDictionaries:''
    19 	category:'System-Support'
    20 	category:'System-Support'
    20 !
    21 !
    21 
    22 
    22 !Project class methodsFor:'documentation'!
    23 !Project class methodsFor:'documentation'!
    75 "
    76 "
    76 ! !
    77 ! !
    77 
    78 
    78 !Project class methodsFor:'initialization'!
    79 !Project class methodsFor:'initialization'!
    79 
    80 
       
    81 initKnownProjects
       
    82     "this is a temporary experimental kludge -
       
    83      once the ProjectBrowser is finished, this info is read from
       
    84      '.prj' files ..."
       
    85 
       
    86     |stx p|
       
    87 
       
    88     stx := self new name:'stx'.
       
    89     stx packageName:'noPackage'.
       
    90     stx changeSet:nil.
       
    91     stx type:#smalltalk.
       
    92     stx comment:'ST/X itself'.
       
    93 
       
    94     AllProjects add:stx.
       
    95 
       
    96     #(
       
    97         ('libbasic'  'Basic (non-GUI) classes. Required for all applications')
       
    98         ('libbasic2' 'More basic (non-GUI) classes. Required for most applications')
       
    99         ('libbasic3' 'More basic (non-GUI) classes. Required for development')
       
   100         ('libcomp'   'The bytecode compiler. Required for all applications')
       
   101         ('libview'   'Low level GUI classes. Required for all GUI applications')
       
   102         ('libview2'  'Additional low level GUI classes. Required for most GUI applications')
       
   103         ('libwidg'   'Basic widgets. Required for all GUI applications')
       
   104         ('libwidg2'  'More widgets. Required for most GUI applications')
       
   105         ('libwidg3'  'More (fun) widgets. Seldom required')
       
   106         ('libtool'   'Development applications. Required for program development')
       
   107         ('libtool2'  'More development applications. Required for GUI development')
       
   108         ('libui'     'UI spec classes. Required for UIPainter applications')
       
   109         ('libhtml'   'HTML related classes. Required for Web applications and the HTML browser')
       
   110     ) do:[:entry |
       
   111         |libName comment|
       
   112 
       
   113         libName := entry at:1.
       
   114         comment := entry at:2.
       
   115 
       
   116         p := self new name:libName.
       
   117         p packageName:libName.
       
   118         p type:#library.
       
   119         p comment:comment.
       
   120         stx addSubProject:p.
       
   121     ].
       
   122 
       
   123     "
       
   124      self initKnownProjects
       
   125     "
       
   126 !
       
   127 
    80 initialize
   128 initialize
    81     SystemProject isNil ifTrue:[
   129     SystemProject isNil ifTrue:[
    82         NextSequential := 1.
   130         NextSequential := 1.
    83         SystemProject := self new name:'default'.
   131         SystemProject := self new name:'default'.
    84         SystemProject packageName:'private'.
   132         SystemProject packageName:'private'.
    85         SystemProject defaultNameSpace:Smalltalk.
   133         SystemProject defaultNameSpace:Smalltalk.
       
   134         SystemProject comment:'A default (dummy) project. 
       
   135 Will be made the current project in case no real project is ever activated.'.
       
   136 
    86         "
   137         "
    87          the SystemProject does not keep a record if changes,
   138          the SystemProject does not keep a record if changes,
    88          but instead depends on the changes file - recording anything there.
   139          but instead depends on the changes file - recording anything there.
    89         "
   140         "
    90         SystemProject changeSet:nil.
   141         SystemProject changeSet:nil.
    91     ].
   142     ].
    92 
   143 
    93     CurrentProject := SystemProject.
   144     CurrentProject := SystemProject.
    94 
   145     AllProjects := OrderedCollection with:SystemProject.
    95     "
   146     self initKnownProjects.
       
   147 
       
   148     "
       
   149      SystemProject := nil.
    96      Project initialize
   150      Project initialize
    97     "
   151     "
    98 ! !
   152 ! !
    99 
   153 
   100 !Project class methodsFor:'instance creation'!
   154 !Project class methodsFor:'instance creation'!
   135 
   189 
   136 defaultProject
   190 defaultProject
   137     "return the SystemDefault project"
   191     "return the SystemDefault project"
   138 
   192 
   139     ^ SystemProject.
   193     ^ SystemProject.
       
   194 !
       
   195 
       
   196 knownProjects
       
   197     ^ AllProjects ? #()
   140 !
   198 !
   141 
   199 
   142 setDefaultProject
   200 setDefaultProject
   143     "set the currently active project to be the SystemDEfault project"
   201     "set the currently active project to be the SystemDEfault project"
   144 
   202 
   295     "Modified: / 7.3.1998 / 13:38:39 / cg"
   353     "Modified: / 7.3.1998 / 13:38:39 / cg"
   296 ! !
   354 ! !
   297 
   355 
   298 !Project methodsFor:'accessing'!
   356 !Project methodsFor:'accessing'!
   299 
   357 
       
   358 addSubProject:aProject
       
   359     subProjects isNil ifTrue:[
       
   360         subProjects := OrderedCollection new.
       
   361     ].
       
   362     subProjects add:aProject
       
   363 !
       
   364 
   300 changeSet
   365 changeSet
   301     "return the set of changes made in this project"
   366     "return the set of changes made in this project"
   302 
   367 
   303     ^ changeSet
   368     ^ changeSet
   304 
   369 
   416     ]
   481     ]
   417 
   482 
   418     "Modified: 27.1.1997 / 12:10:09 / cg"
   483     "Modified: 27.1.1997 / 12:10:09 / cg"
   419 !
   484 !
   420 
   485 
       
   486 prerequisites
       
   487     ^ prerequisites ? #()
       
   488 !
       
   489 
   421 repositoryDirectory
   490 repositoryDirectory
   422     "return the projects default repository location.
   491     "return the projects default repository location.
   423      This is offered initially, when classes are checked into the
   492      This is offered initially, when classes are checked into the
   424      source repository initially"
   493      source repository initially"
   425 
   494 
   458 
   527 
   459     repositoryModule := aString
   528     repositoryModule := aString
   460 
   529 
   461     "Created: 25.11.1995 / 18:05:06 / cg"
   530     "Created: 25.11.1995 / 18:05:06 / cg"
   462     "Modified: 27.1.1997 / 12:13:57 / cg"
   531     "Modified: 27.1.1997 / 12:13:57 / cg"
       
   532 !
       
   533 
       
   534 subProjects
       
   535     ^ subProjects ? #()
   463 !
   536 !
   464 
   537 
   465 views
   538 views
   466     "return a collection of views which were opened in this project"
   539     "return a collection of views which were opened in this project"
   467 
   540 
   517     self repositoryModule:(OperatingSystem getLoginName).
   590     self repositoryModule:(OperatingSystem getLoginName).
   518     self repositoryDirectory:'private'
   591     self repositoryDirectory:'private'
   519 
   592 
   520     "Created: 25.11.1995 / 18:05:44 / cg"
   593     "Created: 25.11.1995 / 18:05:44 / cg"
   521     "Modified: 3.1.1997 / 13:24:10 / cg"
   594     "Modified: 3.1.1997 / 13:24:10 / cg"
       
   595 ! !
       
   596 
       
   597 !Project methodsFor:'load & save'!
       
   598 
       
   599 loadFromProjectFile:aFilename
       
   600     |f s l|
       
   601 
       
   602     f := aFilename asFilename.
       
   603     self directory:(f directory pathName).
       
   604     s := f readStream.
       
   605     self loadFromProjectFileStream:s.
       
   606     s close.
       
   607 
       
   608 
       
   609     "
       
   610      Project current saveAsProjectFile.
       
   611 
       
   612      Project new loadFromProjectFile:'default.prj'
       
   613     "
       
   614 !
       
   615 
       
   616 loadFromProjectFileStream:aStream
       
   617     |s l|
       
   618 
       
   619     s := aStream.
       
   620     l := s nextLine.
       
   621     [s atEnd] whileFalse:[
       
   622         (l startsWith:';') ifTrue:[
       
   623             l := s nextLine.
       
   624         ] ifFalse:[
       
   625             l asLowercase = '[name]' ifTrue:[
       
   626                 l := s nextLine.
       
   627                 name := Object readFromString:l.
       
   628                 l := s nextLine.
       
   629             ] ifFalse:[l asLowercase = '[type]' ifTrue:[
       
   630                 l := s nextLine.
       
   631                 self type:(Object readFromString:l).
       
   632                 l := s nextLine.
       
   633             ] ifFalse:[l asLowercase = '[subprojects]' ifTrue:[
       
   634                 l := s nextLine.
       
   635                 [l notNil and:[(l startsWith:'[') not]] whileTrue:[
       
   636                     l := s nextLine.
       
   637                 ].
       
   638             ] ifFalse:[l asLowercase = '[prerequisites]' ifTrue:[
       
   639                 l := s nextLine.
       
   640                 [l notNil and:[(l startsWith:'[') not]] whileTrue:[
       
   641                     l := s nextLine.
       
   642                 ].
       
   643             ] ifFalse:[l asLowercase = '[classes]' ifTrue:[
       
   644                 l := s nextLine.
       
   645                 [l notNil and:[(l startsWith:'[') not]] whileTrue:[
       
   646                     l := s nextLine.
       
   647                 ].
       
   648             ] ifFalse:[l asLowercase = '[package]' ifTrue:[
       
   649                 l := s nextLine.
       
   650                 self packageName:(Object readFromString:l).
       
   651                 l := s nextLine.
       
   652             ] ifFalse:[
       
   653                 self halt.
       
   654             ]]]]]]
       
   655         ]
       
   656     ].
       
   657 
       
   658     "
       
   659      Project current saveOn:Transcript
       
   660     "
       
   661 !
       
   662 
       
   663 saveAsProjectFile
       
   664     |fn s|
       
   665 
       
   666     fn := self directory asFilename.
       
   667     fn := fn construct:self name.
       
   668     fn := fn withSuffix:'prj'.
       
   669 
       
   670     s := fn writeStream.
       
   671     self saveAsProjectFileOn:s.
       
   672     s close.
       
   673 
       
   674     "
       
   675      Project current saveAsProjectFile
       
   676     "
       
   677 !
       
   678 
       
   679 saveAsProjectFileOn:aStream
       
   680     |s coll|
       
   681 
       
   682     s := aStream.
       
   683 
       
   684     s nextPutLine:'[name]'. 
       
   685     s tab. s nextPutLine:(name storeString).
       
   686     s nextPutLine:'[type]'. 
       
   687     s tab. s nextPutLine:(self type storeString).
       
   688     s nextPutLine:'[package]'. 
       
   689     s tab. s nextPutLine:(self packageName storeString).
       
   690 
       
   691     coll := self subProjects.
       
   692     coll size > 0 ifTrue:[
       
   693         s nextPutLine:'[subprojects]'. 
       
   694         coll do:[:aSubProject |
       
   695             s tab. s nextPutLine:(aSubProject name soreString).
       
   696         ].
       
   697     ].
       
   698 
       
   699     coll := self prerequisites.
       
   700     coll size > 0 ifTrue:[
       
   701         s nextPutLine:'[prerequisites]'. 
       
   702         coll do:[:aProject |
       
   703             s tab. s nextPutLine:(aProject name soreString).
       
   704         ].
       
   705     ].
       
   706 
       
   707     coll := self classes.
       
   708     coll size > 0 ifTrue:[
       
   709         s nextPutLine:'[classes]'. 
       
   710         coll do:[:aClass |
       
   711             s tab. s nextPutLine:(aClass name).
       
   712        ]
       
   713     ]
       
   714 
       
   715     "
       
   716      Project current saveOn:Transcript
       
   717     "
   522 ! !
   718 ! !
   523 
   719 
   524 !Project methodsFor:'maintenance'!
   720 !Project methodsFor:'maintenance'!
   525 
   721 
   526 buildProject
   722 buildProject
   834 	]
  1030 	]
   835     ].
  1031     ].
   836     ^ topName
  1032     ^ topName
   837 ! !
  1033 ! !
   838 
  1034 
       
  1035 !Project methodsFor:'printing & storing'!
       
  1036 
       
  1037 displayString
       
  1038     ^ super displayString , '(''' , (name ? '<unnamed>') , ''')'
       
  1039 ! !
       
  1040 
   839 !Project methodsFor:'properties'!
  1041 !Project methodsFor:'properties'!
       
  1042 
       
  1043 comment
       
  1044     "return the comment of the project"
       
  1045 
       
  1046     properties isNil ifTrue:[^ ''].
       
  1047     ^ properties at:#comment ifAbsent:''
       
  1048 !
       
  1049 
       
  1050 comment:aString
       
  1051     "set the projects comment"
       
  1052 
       
  1053     properties isNil ifTrue:[
       
  1054         properties := IdentityDictionary new
       
  1055     ].
       
  1056     properties at:#comment put:aString
       
  1057 !
   840 
  1058 
   841 properties
  1059 properties
   842     ^ properties
  1060     ^ properties
   843 !
  1061 !
   844 
  1062 
   847 !
  1065 !
   848 
  1066 
   849 type
  1067 type
   850     "return the type of project"
  1068     "return the type of project"
   851 
  1069 
   852     ^ properties at:#type ifAbsent:[#application]
  1070     properties isNil ifTrue:[^ #application].
       
  1071     ^ properties at:#type ifAbsent:#application
   853 !
  1072 !
   854 
  1073 
   855 type:aSymbol
  1074 type:aSymbol
   856     "set the projects type"
  1075     "set the projects type"
   857 
  1076 
   858     (#(application library smalltalk) includes:aSymbol) ifFalse:[
  1077     (#(application library smalltalk) includes:aSymbol) ifFalse:[
   859 	self warn:'invalid project type'.
  1078         self warn:'invalid project type'.
   860 	^ self
  1079         ^ self
       
  1080     ].
       
  1081     properties isNil ifTrue:[
       
  1082         properties := IdentityDictionary new
   861     ].
  1083     ].
   862     properties at:#type put:aSymbol
  1084     properties at:#type put:aSymbol
   863 ! !
  1085 ! !
   864 
  1086 
   865 !Project methodsFor:'queries'!
  1087 !Project methodsFor:'queries'!
  1019 ! !
  1241 ! !
  1020 
  1242 
  1021 !Project class methodsFor:'documentation'!
  1243 !Project class methodsFor:'documentation'!
  1022 
  1244 
  1023 version
  1245 version
  1024     ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.59 1998-03-07 13:39:10 cg Exp $'
  1246     ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.60 1999-02-09 18:55:48 cg Exp $'
  1025 ! !
  1247 ! !
  1026 Project initialize!
  1248 Project initialize!