!
! $Id: stripTrailing_UI.pvc.pvt 3093 2022-06-16 16:27:03Z fmcguirk $
! Copyright (c) 2011 Sage Software. All Rights Reserved
! ** @Author fmcguirk
! ** @Date 2011.04.25 18 at 04:10:34 PM EDT
/*
! ** This observer will scan the source files selected in the Navigator view and
! ** remove all trailing white space from each source line.
*/
def class "stripTrailing_UI"
like "com.pvx.util.progress"
! ** Set the caption for the user interface window
local theCaption$ = "Strip Trailing Whitespace"
! ** Override Description
local theDescription$="Strip trailing white space"
! ** Override NotificationFlag
local theNotificationFlag=_pvxConstants'_idePrePostProcess
! ** A private method that performs the tasks required by the contributed tool
function local doWork() do_work
end def
do_work:
local isModified, oPvxUtility, oResList, oStrip, oUtility, resource, \
resList, resLocation$, resName$, resPath$, tempWorkFile$, theStatus$
/* Process resources selected in Navigation View */
oResList=new("ecWorkspaceResourceReader",2)
if oResList<>0 {
resource=oResList'resource_getNext()
if not(resource) {
info$=msg("nav_view_no_resource")
_obj'writeLog(info$)
}
} else {
info$=msg("nav_view_no_resource")
_obj'writeLog(info$)
}
/* Get auto-build state and disable if necessary */
if resource {
oPvxUtility=new("pvx_utility")
oUtility=new("ecUtility")
autoBuild=oUtility'isAutoBuilding()
if autoBuild {
oUtility'setAutoBuilding(0)
}
_obj'enable_cancel()
}
oStrip = new("stripTrailing")
while resource<>0
oResList'resource_getInfo(resource,resName$,resLocation$,resPath$)
! Process this Source File to remove remarks and place modified version into the tempSourceFile$
isModified=oStrip'processFile(resLocation$,altSource$)
if isModified {
bEraseOK = 1, \
bSkipRefresh = 1
oUtils = new("pvx_utility")
oUtils'copyFile(altSource$, resLocation$, bEraseOK, bSkipRefresh)
drop object oUtils, err=*proceed; oUtils= 0
theStatus$ = "Updated"
coReqClient'resource_refresh(resLocation$)
} else {
theStatus$ = "No change"
}
_obj'writeLog(resName$+"... "+theStatus$)
! Allow for CANCEL of processing
isCancelled = _obj'checkCancel()
if isCancelled {
tmpCANCEL = 1
break
}
! Get the next resource to process
resource=oResList'resource_getNext()
wend
/* Turn auto-build back on, if necessary */
if autoBuild {
oUtility'setAutoBuilding(1)
}
if oStrip { drop object oStrip; oStrip = 0 }
if oUtility { drop object oUtility; oUtility = 0 }
if oPvxUtility { drop object oPvxUtility; oPvxUtility = 0 }
drop object oResList; oResList=0
return 0
end