SourceCodeManagerUtilities.st
changeset 992 83f257a4fa0c
parent 990 edf1dd382621
child 996 551841dd0105
equal deleted inserted replaced
991:8d7083231ed9 992:83f257a4fa0c
    13 
    13 
    14 "{ Package: 'stx:libbasic3' }"
    14 "{ Package: 'stx:libbasic3' }"
    15 
    15 
    16 Object subclass:#SourceCodeManagerUtilities
    16 Object subclass:#SourceCodeManagerUtilities
    17 	instanceVariableNames:''
    17 	instanceVariableNames:''
    18 	classVariableNames:'LastSourceLogMessage LastModule LastPackage'
    18 	classVariableNames:'LastSourceLogMessage LastModule LastPackage YesToAllQuery
       
    19 		YesToAllNotification'
    19 	poolDictionaries:''
    20 	poolDictionaries:''
    20 	category:'System-SourceCodeManagement'
    21 	category:'System-SourceCodeManagement'
    21 !
    22 !
    22 
    23 
    23 !SourceCodeManagerUtilities class methodsFor:'documentation'!
    24 !SourceCodeManagerUtilities class methodsFor:'documentation'!
    49 
    50 
    50     [instance variables:]
    51     [instance variables:]
    51 
    52 
    52     [class variables:]
    53     [class variables:]
    53 "
    54 "
       
    55 ! !
       
    56 
       
    57 !SourceCodeManagerUtilities class methodsFor:'Signal constants'!
       
    58 
       
    59 yesToAllNotification
       
    60     YesToAllNotification isNil ifTrue:[
       
    61         YesToAllNotification := QuerySignal new.
       
    62     ].
       
    63     ^ YesToAllNotification
       
    64 !
       
    65 
       
    66 yesToAllQuery
       
    67     YesToAllQuery isNil ifTrue:[
       
    68         YesToAllQuery := QuerySignal new.
       
    69     ].
       
    70     ^ YesToAllQuery
    54 ! !
    71 ! !
    55 
    72 
    56 !SourceCodeManagerUtilities class methodsFor:'utilities'!
    73 !SourceCodeManagerUtilities class methodsFor:'utilities'!
    57 
    74 
    58 askForContainer:boxText title:title note:notice initialModule:initialModule initialPackage:initialPackage initialFileName:initialFileName
    75 askForContainer:boxText title:title note:notice initialModule:initialModule initialPackage:initialPackage initialFileName:initialFileName
   304     "check if a class contains message-sends to:
   321     "check if a class contains message-sends to:
   305         #halt
   322         #halt
   306         #error
   323         #error
   307         (and maybe more in the future)"
   324         (and maybe more in the future)"
   308 
   325 
   309     |badStuff whatIsBad msg|
   326     |badStuff whatIsBad msg answer|
   310 
   327 
   311     badStuff := #(
   328     badStuff := #(
   312         ( #halt         'sent of #halt without descriptive message - better use halt:''some message''' )
   329         ( #halt         'sent of #halt without descriptive message - better use halt:''some message''' )
   313         ( #error        'sent of #error without descriptive message - better use error:''some message''' )
   330         ( #error        'sent of #error without descriptive message - better use error:''some message''' )
   314     ).
   331     ).
   323                 whatIsBad add:eachEntry second
   340                 whatIsBad add:eachEntry second
   324             ]
   341             ]
   325         ].
   342         ].
   326     ].
   343     ].
   327     whatIsBad notEmpty ifTrue:[
   344     whatIsBad notEmpty ifTrue:[
       
   345         (YesToAllQuery notNil and:[YesToAllQuery isHandled]) ifTrue:[
       
   346             answer := YesToAllQuery query.
       
   347             answer notNil ifTrue:[ ^ answer ].
       
   348         ].
       
   349 
   328         msg := 'Your class contains the following  (considered bad style) message sends:\\'.
   350         msg := 'Your class contains the following  (considered bad style) message sends:\\'.
   329         whatIsBad do:[:each |
   351         whatIsBad do:[:each |
   330             msg := msg , '   ' , each , '\'
   352             msg := msg , '   ' , each , '\'
   331         ].
   353         ].
   332         msg := msg , '\\' , 'Do you really want to check in this class ?'.
   354         msg := msg , '\\' , 'Do you really want to check in this class ?'.
   333         ^ self confirm:msg withCRs
   355         (YesToAllNotification notNil and:[YesToAllNotification isHandled]) ifTrue:[
       
   356             answer := OptionBox 
       
   357                           request:msg withCRs
       
   358                           label:'Really checkIn ?'
       
   359                           form:(InfoBox iconBitmap)
       
   360                           buttonLabels:#('yes' 'yes to all' 'no' 'no to all')
       
   361                           values:#(true #yesToAll false #noToAll).
       
   362             answer == #yesToAll ifTrue:[
       
   363                 YesToAllNotification raiseWith:true.
       
   364                 ^ true
       
   365             ].
       
   366             answer == #noToAll ifTrue:[
       
   367                 YesToAllNotification raiseWith:false.
       
   368                 ^ false
       
   369             ].
       
   370             ^ answer
       
   371         ] ifFalse:[
       
   372             ^ self confirm:msg withCRs
       
   373         ]
   334     ].
   374     ].
   335     ^ true.
   375     ^ true.
   336 
   376 
   337     "
   377     "
   338      self checkAndWarnAboutBadMessagesInClass:(SourceCodeManagerUtilities)  
   378      self checkAndWarnAboutBadMessagesInClass:(SourceCodeManagerUtilities)  
   453 
   493 
   454 checkinClasses:aCollectionOfClasses withLog:aLogMessageOrNil
   494 checkinClasses:aCollectionOfClasses withLog:aLogMessageOrNil
   455     "check a bunch of classes into the source repository.
   495     "check a bunch of classes into the source repository.
   456      If the argument, aLogMessageOrNil isNil, ask interactively for log-message."
   496      If the argument, aLogMessageOrNil isNil, ask interactively for log-message."
   457 
   497 
   458     |classes logMessage resources|
   498     ^ self
       
   499         checkinClasses:aCollectionOfClasses withLog:aLogMessageOrNil withCheck:true
       
   500 !
       
   501 
       
   502 checkinClasses:aCollectionOfClasses withLog:aLogMessageOrNil withCheck:doCheckClasses
       
   503     "check a bunch of classes into the source repository.
       
   504      If the argument, aLogMessageOrNil isNil, ask interactively for log-message."
       
   505 
       
   506     |classes logMessage resources yesOrNoToAll|
   459 
   507 
   460     "/ ignore private classes
   508     "/ ignore private classes
   461     classes := aCollectionOfClasses select:[:aClass | aClass owningClass isNil].
   509     classes := aCollectionOfClasses select:[:aClass | aClass owningClass isNil].
   462     classes isEmpty ifTrue:[
   510     classes isEmpty ifTrue:[
   463         self information:'Only private classes given - nothing checked in.'.
   511         self information:'Only private classes given - nothing checked in.'.
   467     classes isEmpty ifTrue:[
   515     classes isEmpty ifTrue:[
   468         self information:'Only unloaded classes given - nothing checked in.'.
   516         self information:'Only unloaded classes given - nothing checked in.'.
   469         ^ self
   517         ^ self
   470     ].
   518     ].
   471     classes size == 1 ifTrue:[
   519     classes size == 1 ifTrue:[
   472         ^ self checkinClass:classes first withLog:aLogMessageOrNil.
   520         ^ self checkinClass:classes first withLog:aLogMessageOrNil withCheck:doCheckClasses.
   473     ].
   521     ].
   474 
   522 
   475     resources := ResourcePack for:self.
   523     resources := ResourcePack for:self.
   476 
   524 
   477     (logMessage := aLogMessageOrNil) isNil ifTrue:[
   525     (logMessage := aLogMessageOrNil) isNil ifTrue:[
   480         logMessage isNil ifTrue:[
   528         logMessage isNil ifTrue:[
   481             ^ self
   529             ^ self
   482         ].
   530         ].
   483     ].
   531     ].
   484 
   532 
   485     classes do:[:aClass |
   533     self yesToAllNotification handle:[:ex |
   486         (self checkAndWarnAboutBadMessagesInClass:aClass) ifTrue:[
   534         yesOrNoToAll := ex parameter.
   487             self activityNotification:(resources string:'checking in %1' with:aClass name).
   535         ex proceed
   488             "/ ca does not want boxes to pop up all over ...
   536     ] do:[
   489             InformationSignal handle:[:ex |
   537         self yesToAllQuery handle:[:ex |
   490                 Transcript showCR:ex errorString
   538             ex proceedWith:yesOrNoToAll
   491             ] do:[
   539         ] do:[
   492                 self checkinClass:aClass withLog:logMessage
   540             classes do:[:aClass |
   493             ].
   541                 (self checkAndWarnAboutBadMessagesInClass:aClass) ifTrue:[
   494         ].
   542                     self activityNotification:(resources string:'checking in %1' with:aClass name).
   495     ]
   543                     "/ ca does not want boxes to pop up all over ...
       
   544                     InformationSignal handle:[:ex |
       
   545                         Transcript showCR:ex errorString
       
   546                     ] do:[
       
   547                         self checkinClass:aClass withLog:logMessage withCheck:doCheckClasses
       
   548                     ].
       
   549                 ].
       
   550             ]
       
   551         ]
       
   552     ].
   496 !
   553 !
   497 
   554 
   498 checkinExtensionMethods:aCollectionOfMethods forPackage:aPackageID withLog:aLogMessageOrNil
   555 checkinExtensionMethods:aCollectionOfMethods forPackage:aPackageID withLog:aLogMessageOrNil
   499     "checkin a projects extensions into the source repository.
   556     "checkin a projects extensions into the source repository.
   500      If the argument, aLogMessageOrNil isNil, ask interactively for log-message."
   557      If the argument, aLogMessageOrNil isNil, ask interactively for log-message."
  1467 ! !
  1524 ! !
  1468 
  1525 
  1469 !SourceCodeManagerUtilities class methodsFor:'documentation'!
  1526 !SourceCodeManagerUtilities class methodsFor:'documentation'!
  1470 
  1527 
  1471 version
  1528 version
  1472     ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.31 2000-11-14 19:11:06 cg Exp $'
  1529     ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.32 2000-11-16 11:55:32 cg Exp $'
  1473 ! !
  1530 ! !