FileOperation.st
changeset 14187 fe7fa2d23b0b
parent 13738 07e534de96bd
child 14280 48dcdb213e34
equal deleted inserted replaced
14186:2ed966dc0816 14187:fe7fa2d23b0b
   177 
   177 
   178 !FileOperation methodsFor:'dialogs & helpers'!
   178 !FileOperation methodsFor:'dialogs & helpers'!
   179 
   179 
   180 checkDirectoryExists:aDirectory
   180 checkDirectoryExists:aDirectory
   181     aDirectory exists ifFalse:[
   181     aDirectory exists ifFalse:[
   182         (Dialog confirm:(FileBrowser classResources 
   182         (Dialog confirm:(AbstractFileBrowser classResources 
   183                             stringWithCRs:'Non-existing directory: %1\\Create?' 
   183                             stringWithCRs:'Non-existing directory: %1\\Create?' 
   184                             with:aDirectory asString)
   184                             with:aDirectory asString)
   185         ) ifFalse:[
   185         ) ifFalse:[
   186             ^ false
   186             ^ false
   187         ].
   187         ].
   188         aDirectory recursiveMakeDirectory.
   188         aDirectory recursiveMakeDirectory.
   189         aDirectory exists ifFalse:[
   189         aDirectory exists ifFalse:[
   190             Dialog warn:(FileBrowser classResources 
   190             Dialog warn:(AbstractFileBrowser classResources 
   191                             string:'Failed to create directory: %1').
   191                             string:'Failed to create directory: %1').
   192             ^ false
   192             ^ false
   193         ].
   193         ].
   194     ].
   194     ].
   195     aDirectory isDirectory ifFalse:[
   195     aDirectory isDirectory ifFalse:[
  1371 moveFiles:aColOfSourceFiles to:aDirectory withOverWriteWarning:overWriteWarning moveFileIfSame:move
  1371 moveFiles:aColOfSourceFiles to:aDirectory withOverWriteWarning:overWriteWarning moveFileIfSame:move
  1372 
  1372 
  1373     |newFile suffix fileString doMove doRemoveSource doRemoveDestination|
  1373     |newFile suffix fileString doMove doRemoveSource doRemoveDestination|
  1374 
  1374 
  1375     aDirectory exists ifFalse:[
  1375     aDirectory exists ifFalse:[
  1376         (Dialog confirm:(FileBrowser classResources
  1376         (Dialog confirm:(AbstractFileBrowser classResources
  1377                             stringWithCRs:'Non-existing directory "%1" .\Create ?'
  1377                             stringWithCRs:'Non-existing directory "%1" .\Create ?'
  1378                             with:aDirectory asString allBold)) ifFalse:[
  1378                             with:aDirectory asString allBold)) ifFalse:[
  1379             result := false.
  1379             result := false.
  1380             ^ self
  1380             ^ self
  1381         ].
  1381         ].
  1382         aDirectory makeDirectory.
  1382         aDirectory makeDirectory.
  1383         aDirectory exists ifFalse:[
  1383         aDirectory exists ifFalse:[
  1384             Dialog warn:(FileBrowser classResources
  1384             Dialog warn:(AbstractFileBrowser classResources
  1385                                 stringWithCRs:'Cannot create directory "%1" !!\Create ?.'
  1385                                 stringWithCRs:'Cannot create directory "%1" !!\Create ?.'
  1386                                 with:aDirectory asString allBold).
  1386                                 with:aDirectory asString allBold).
  1387             result := false.
  1387             result := false.
  1388             ^ self
  1388             ^ self
  1389         ]
  1389         ]
  1569 
  1569 
  1570     queryBox := FilenameEnterBox new.
  1570     queryBox := FilenameEnterBox new.
  1571     queryBox okText:(resources string:'Rename').
  1571     queryBox okText:(resources string:'Rename').
  1572 
  1572 
  1573     aColOfFiles size > 1 ifTrue:[
  1573     aColOfFiles size > 1 ifTrue:[
  1574 	b := queryBox addAbortButtonLabelled:(resources string:'Cancel All').
  1574         b := queryBox addAbortButtonLabelled:(resources string:'Cancel All').
  1575 	b action:[^ self].
  1575         b action:[^ self].
  1576 	queryBox addButton:(Button label:(resources string:'Rename All') action:[renameAll := true. queryBox okPressed]) before:(queryBox okButton).
  1576         queryBox addButton:(Button label:(resources string:'Rename All') action:[renameAll := true. queryBox okPressed]) before:(queryBox okButton).
  1577     ].
  1577     ].
  1578     aColOfFiles do:[:oldFile |
  1578     aColOfFiles do:[:oldFile |
  1579 	oldName := oldFile baseName asString.
  1579         oldName := oldFile baseName asString.
  1580 	lastNewName notNil ifTrue:[
  1580         lastNewName notNil ifTrue:[
  1581 	    initialText := FileBrowser goodRenameDefaultForFile:oldName lastOld:lastOldName lastNew:lastNewName.
  1581             initialText := DoWhatIMeanSupport goodRenameDefaultForFile:oldName lastOld:lastOldName lastNew:lastNewName.
  1582 	].
  1582         ].
  1583 	doRename := false.
  1583         doRename := false.
  1584 	(renameAll and:[initialText notNil]) ifTrue:[
  1584         (renameAll and:[initialText notNil]) ifTrue:[
  1585 	    doRename := true.
  1585             doRename := true.
  1586 	    newName := initialText.
  1586             newName := initialText.
  1587 	] ifFalse:[
  1587         ] ifFalse:[
  1588 	    queryBox title:(resources string:'Rename %1 to:' with:(oldName allBold)).
  1588             queryBox title:(resources string:'Rename %1 to:' with:(oldName allBold)).
  1589 	    queryBox initialText:(initialText ? oldName).
  1589             queryBox initialText:(initialText ? oldName).
  1590 	    queryBox action:[:newEnteredName | newName := newEnteredName. doRename := true.].
  1590             queryBox action:[:newEnteredName | newName := newEnteredName. doRename := true.].
  1591 	    queryBox show "showAtPointer".
  1591             queryBox show "showAtPointer".
  1592 	    "/ queryBox accepted ifFalse:[self halt].
  1592             "/ queryBox accepted ifFalse:[self halt].
  1593 	].
  1593         ].
  1594 	doRename ifTrue:[
  1594         doRename ifTrue:[
  1595 	    (self renameFile:oldFile to:newName asString) ifTrue:[
  1595             (self renameFile:oldFile to:newName asString) ifTrue:[
  1596 		result := true
  1596                 result := true
  1597 	    ].
  1597             ].
  1598 	    lastOldName := oldName.
  1598             lastOldName := oldName.
  1599 	    lastNewName := newName.
  1599             lastNewName := newName.
  1600 	].
  1600         ].
  1601     ]
  1601     ]
  1602 ! !
  1602 ! !
  1603 
  1603 
  1604 !FileOperation class methodsFor:'documentation'!
  1604 !FileOperation class methodsFor:'documentation'!
  1605 
  1605 
  1606 version
  1606 version
  1607     ^ '$Header: /cvs/stx/stx/libtool/FileOperation.st,v 1.94 2014-01-05 13:20:00 cg Exp $'
  1607     ^ '$Header: /cvs/stx/stx/libtool/FileOperation.st,v 1.95 2014-04-08 22:31:45 stefan Exp $'
  1608 !
  1608 !
  1609 
  1609 
  1610 version_CVS
  1610 version_CVS
  1611     ^ '$Header: /cvs/stx/stx/libtool/FileOperation.st,v 1.94 2014-01-05 13:20:00 cg Exp $'
  1611     ^ '$Header: /cvs/stx/stx/libtool/FileOperation.st,v 1.95 2014-04-08 22:31:45 stefan Exp $'
  1612 ! !
  1612 ! !
  1613 
  1613