home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
dsysvdbobj.tcl
< prev
next >
Wrap
Text File
|
1996-11-22
|
16KB
|
577 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)dsysvdbobj.tcl /main/hindenburg/15
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)dsysvdbobj.tcl /main/hindenburg/15 22 Nov 1996 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "ssysvdbobj.tcl"
# End user added include file section
require "sysvdbobj.tcl"
Class DSysVDbObj : {SysVDbObj} {
constructor
method destructor
method promoter
method addDocStructure
method addFileSections
method addPropertySection
method addLocalSection
method allowsDrop
method browserObjType
method documentedSystemName
method editorType
method generate
method generateObjects
method importObject
method name2section
method printObjects
method removeDocDir
method sections
method updateDocDir
method unstructuredName
}
global DSysVDbObj::dsmName
set DSysVDbObj::dsmName "DocumentStructureMatrix"
constructor DSysVDbObj {class this name} {
set this [SysVDbObj::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method DSysVDbObj::destructor {this} {
# Start destructor user section
# End destructor user section
$this SysVDbObj::destructor
}
method DSysVDbObj::promoter {this} {
$this SysVDbObj::promoter
global DSysVDbObj::count
set DSysVDbObj::count 0
}
method DSysVDbObj::addDocStructure {this} {
if {! [[$this findFileVersion "${DSysVDbObj::dsmName}" dsm] isNil]} {
wmtkinfo "${DSysVDbObj::dsmName} already exists"
return
}
set configV [$this getParent ConfigVersion]
set script "$this createFileVersion \
[list ${DSysVDbObj::dsmName}] doc 0 dsm matrix $configV"
.main startCommand tcl \
"$script" "" \
"Creating dsm file version '${DSysVDbObj::dsmName}'..." \
{1 0} 1
}
method DSysVDbObj::addFileSections {this} {
busy {
set docSys [$this docSys]
set docSysName [$this setGetProp doc_sys]
if {"$docSys" == "" || [$docSys isNil]} {
wmtkerror \
"Documented system '$docSysName' does not exist\
within the current PhaseVersion"
return
}
set headerSpecList {
{Name 25 ascii {increasing 2}}
{Version 25 ascii {increasing 3}}
{Type 18 ascii {increasing 1}}
}
set fileVList ""
set objectSpecList ""
foreach fileV [$docSys localFileVersions] {
set fileType [[$fileV file] type]
if {"$fileType" == "cdm"} continue
set typeSpec [getObjectSpec [.main objectHdlr] \
[$fileV uiClass] [$fileV browserType] \
]
if {"$typeSpec" != ""} {
set icon [$typeSpec smallIcon]
} else {
set icon ""
}
lappend fileVList $fileV
lappend objectSpecList [list $icon \
[$fileV name] \
[$fileV versionName] \
[$fileV browserType] \
]
}
if [lempty $fileVList] {
wmtkinfo \
"There are no files in system '$docSysName'\
to create a reference to"
return
}
if [[$this findFileVersion "${DSysVDbObj::dsmName}" dsm] isNil] {
$this addDocStructure
}
require "browsviewd.tcl"
set box .main.newFileSection
ClassMaker::extend BrowsViewDialog NewFileSectionBrowsViewDialog dbObj
NewFileSectionBrowsViewDialog new $box \
-title "New File Section" \
-message "Select FileVersion(s) to create a link to" \
-headerSpecList $headerSpecList \
-objectSpecList $objectSpecList \
-objectList $fileVList \
-dbObj $this \
-cancelPressed {%this delete} \
-okPressed {
set script ""
set dbObj [%this dbObj]
foreach object [[%this view] selectedSet] {
set fileV [$object object]
set file [$fileV file]
if {"$script" != ""} {
append script " ;"
}
append script \
" DocStructPart new .docStrucPart \
-documentVersion $dbObj \
-sectionName \
\"[$file qualifiedName :]_[$file type]\" \
-sectionType \"[$file type]\" \
-fileVersion $fileV"
append script " ;"
append script " DocGenerator::createSection .docStrucPart"
append script " ;"
append script " .docStrucPart delete"
}
require "docgenerat.tcl"
require "docstructp.tcl"
.main startCommand tcl \
"$script" "" "Creating file section(s)..." {1 0} 1
%this delete
}
$box popUp
}
}
method DSysVDbObj::addPropertySection {this} {
busy {
if [[$this findFileVersion "${DSysVDbObj::dsmName}" dsm] isNil] {
$this addDocStructure
}
set dlg .main.newPropertySection
if [[$this documentedSystem] isNil] {
wmtkerror "Invalid documented system specified"
} else {
require "propsecdlg.tcl"
PropSecDlg new $dlg $this "" -title "New Property Section"
$dlg popUp
}
}
}
method DSysVDbObj::addLocalSection {this} {
busy {
if [[$this findFileVersion "${DSysVDbObj::dsmName}" dsm] isNil] {
$this addDocStructure
}
set box .main.newLocalSection
if {! [isCommand $box]} {
require "newlocalse.tcl"
NewLocalSectionDlg new $box
}
$box dbObj $this
$box popUp
}
}
method DSysVDbObj::allowsDrop {this uiClass} {
case "$uiClass" in {
{ExternalFileVersion Graph} {
return 1
}
{default} {
return 0
}
}
}
proc DSysVDbObj::associations {} {
return {\
sections customFileVersionSet workItemSet \
controlledListSet accessRuleSet\
}
}
method DSysVDbObj::browserObjType {this} {
return "DSysVDbObj"
}
proc DSysVDbObj::childTypes {assoc} {
if {[lsearch -exact "[DSysVDbObj::associations]" "$assoc"] == -1} {
return ""
}
return [SysVDbObj::childTypes "$assoc"]
}
proc DSysVDbObj::controlledLists {} {
return [concat \
[SysVDbObj::controlledLists] \
{"[$this fileVersionReferenceList]"
"[$this propertyReferenceList]"} \
]
}
method DSysVDbObj::documentedSystemName {this} {
return [$this getPropertyValue doc_sys]
}
method DSysVDbObj::editorType {this} {
return [$this getPropertyValue editor]
}
method DSysVDbObj::generate {this} {
if {[$this getPropertyValue structFile] == "" } {
set entrySet {}
} else {
set entrySet [list [$this getPropertyValue structFile]]
}
set crntPath [pwd]
cd [path_name concat [m4_var get M4_home] etc]
catch {set entrySet [concat $entrySet [glob [string tolower \
[$this getInfo Editor]]*.str]]}
cd $crntPath
ClassMaker::extend ListDialog GenerateDocListDialog dbObj
GenerateDocListDialog new .main.generateDoc \
-modal yes \
-title "Generate Document" \
-message "Document Structure File:" \
-selectionPolicy BROWSE \
-entrySet $entrySet \
-rowCount [llength $entrySet] \
-dbObj $this \
-helpPressed {.main helpOnName generateDoc} \
-cancelPressed {%this delete} \
-okPressed {
set dbObj [%this dbObj]
set structureFile [lindex [%this selectedSet] 0]
if {"$structureFile" != "[$dbObj getPropertyValue structFile]"} {
set structureFile [path_name concat \
[path_name concat [m4_var get M4_home] etc] \
$structureFile \
]
}
set confVId [[$dbObj getParent ConfigVersion] identity]
set sysVId [$dbObj identity]
set args "generateDocument $confVId $sysVId \
[quoteIf $structureFile]"
.main startDocbatch mtool "$args" "" {0 0} 0
%this delete
}
.main.generateDoc popUp
}
method DSysVDbObj::generateObjects {this what} {
# Determine list of involved objects
set objectList ""
foreach obj [.main selectedObjSet] {
lappend objectList [$obj identity]
}
if [lempty $objectList] {
return
}
# Start docbatch
set confVId [[$this getParent ConfigVersion] identity]
set sysVId [$this identity]
set argsfile [args_file $objectList]
case "$what" in {
{structure} {
set args "generateStructure $confVId $sysVId [list $argsfile]"
}
{structureandcontents} {
set args \
"generateStructureAndContents $confVId $sysVId [list $argsfile]"
}
{contents} {
set args "generateContents $confVId $sysVId [list $argsfile]"
}
}
.main startDocbatch mtool "$args" "" {1 0} 0
}
method DSysVDbObj::importObject {this context node} {
set projId [lindex $context 0]
if {"[[$this project] identity]" != "$projId"} {
wmtkmessage "Can not import from another Project"
if [isCommand [.main undoCommand]] {
[.main undoCommand] delete
}
return
}
set phaseVId [lindex $context 2]
set myPhaseVId [[$node getParent PhaseVersion] identity]
if {"$myPhaseVId" != "$phaseVId"} {
wmtkmessage "Can not import from another PhaseVersion"
if [isCommand [.main undoCommand]] {
[.main undoCommand] delete
}
return
}
set fileVId [lindex $context 4]
set fileV [BrowserProcs::id2obj $fileVId FileVersion $node]
# Make sure FileVersion exists
if [catch {$fileV file}] {
wmtkinfo "Can not import [lindex $context 5] because it is removed"
if [isCommand [.main undoCommand]] {
[.main undoCommand] delete
}
return
}
# Make sure that document is initialized
$this initialize [$node getParent ConfigVersion]
# Remove imported object in case of a cut operation
if {[.main undoCommandBusy EditPasteCmd] &&
"[[.main undoCommand] operation]" == "cut"} {
set sysVId [lindex $context 3]
set sysV [BrowserProcs::id2obj $sysVId SystemVersion $node]
$sysV cutVersion $fileV
}
if [[$this findFileVersion "${DSysVDbObj::dsmName}" dsm] isNil] {
$this addDocStructure
}
set script ""
set sectName [[$fileV file] qualifiedName :]
set sectType [lindex $context 5]
append script \
" DocStructPart new .docStrucPart \
-documentVersion $this \
-sectionName \"${sectName}_$sectType\" \
-sectionType \"$sectType\" \
-fileVersion $fileV"
append script " ;"
append script " set section \[DocGenerator::createSection .docStrucPart\]"
append script " ;"
append script " .docStrucPart delete"
if [.main undoCommandBusy EditPasteCmd] {
append script " ;"
append script " [.main undoCommand] addObject \$section"
}
require "docgenerat.tcl"
require "docstructp.tcl"
if {$this == [[.main currentObj] browsUiObj]} {
set update 1
} else {
set update 0
}
.main startCommand tcl \
"$script" "" \
"Creating file section '${sectName}_$sectType'..." \
[list $update 0] 1
}
proc DSysVDbObj::infoProperties {} {
return [concat \
[SysVDbObj::infoProperties] \
{Editor "Documented System"} \
]
}
method DSysVDbObj::name2section {this name} {
global browserSections
foreach section [array names browserSections] {
if [$section isA PropertyReference] {
set compareName $name
} else {
set compareName [rmWhiteSpace $name]
}
if {"$browserSections($section)" == "$compareName"} {
unset browserSections($section)
return $section
}
}
global DSysVDbObj::count
set noneObjId $this.${NoneUiObj::uiClass}:${DSysVDbObj::count}
set noneObj [NoneUiObj new $noneObjId \
-uiName "$name" \
-parent $this \
]
incr DSysVDbObj::count 1
return $noneObj
}
method DSysVDbObj::printObjects {this} {
set docbatchObjects ""
set skipList {NoneUiObj}
if {"[[$this editor] printsIncluded]" == "y"} {
lappend skipList FileRefSection
}
foreach obj [.main selectedObjSet] {
lappend docbatchObjects [$obj identity]
}
BrowserProcs::printObjects "" $docbatchObjects ""
}
method DSysVDbObj::removeDocDir {this} {
set errorStack [$this initializeChildSet sections]
if {"$errorStack" != ""} {
wmtkerror $errorStack
return
}
foreach section [$this getChildSet sections] {
if {! [$section isA DocSection]} continue
BasicFS::removeFile [$section docLocation] 1
}
catch {BasicFS::removeDir [$this path]}
}
method DSysVDbObj::sections {this} {
global browserSections
set sections ""
foreach section [concat \
[$this localFileVersions] \
[$this fileVersionReferences] \
[$this propertyReferences] \
] {
# Do not use 'getInfo Name' :
# is not always up-to-date (e.g. after name change)
set browserSections($section) "[$section name]"
}
set dsm [$this findFileVersion "${DSysVDbObj::dsmName}" dsm]
if {! [$dsm isNil]} {
if [info exists browserSections($dsm)] {
unset browserSections($dsm)
}
$dsm setIndentation 0
lappend sections $dsm
set fileInfo [DocStructure new $this.fileInfo]
$fileInfo load $dsm
for {set component [$fileInfo firstComponent]} \
{"$component" != ""} \
{set component [$component next]} {
set componentName [$component uiName]
set section [$this name2section "$componentName"]
$section setIndentation [$component indentation]
lappend sections $section
}
$fileInfo quit
$fileInfo delete
}
# Sort the unstructured sections by name and type
if {! [catch {set nonDsmSections [array names browserSections]}]} {
foreach section $nonDsmSections {
set type [$section getInfo Type]
set nonDsmSectionNames($browserSections($section),$type) $section
}
if [info exists nonDsmSectionNames] {
foreach tuple [lsort [array names nonDsmSectionNames]] {
set section $nonDsmSectionNames($tuple)
$section setIndentation -1
lappend sections $section
unset browserSections($section)
}
}
}
return "$sections"
}
method DSysVDbObj::updateDocDir {this mode {ifNeeded 1}} {
set sections ""
set skipped 0
case "$mode" in {
{all} {
set errorStack [$this initializeChildSet sections]
if {"$errorStack" != ""} {
wmtkerror $errorStack
return
}
foreach section [$this getChildSet sections] {
if {! [$section isA DocSection]} continue
if {$ifNeeded && [$section isDocDirUpToDate]} {
set skipped 1
continue
}
lappend sections [$section identity]
}
}
{selected} {
# Determine list of involved objects
foreach obj [.main selectedObjSet] {
lappend sections [$obj identity]
}
}
}
if [lempty $sections] {
set box .main.updateDocDirInfo
set name [$this getInfo Name]
if $skipped {
set msg "All sections within document '$name' are up to date"
} else {
set msg "There are no sections within document '$name'"
}
wmtkinfo $msg
return
}
set confVId [[$this getParent ConfigVersion] identity]
set sysVId [$this identity]
set argsfile [args_file $sections]
set args "updateDocDir $confVId $sysVId [list $argsfile]"
.main startDocbatch mtool "$args" "" {1 0} 0
}
method DSysVDbObj::unstructuredName {this name type} {
require "docgenerat.tcl"
foreach section [$this getChildSet sections] {
if {"[$section uiPrefix]" != "-"} continue
if {"[$section getInfo Type]" != "$type"} continue
set sectionName [$section getInfo Name]
set id [string last ${DocGenerator::double} $sectionName]
if {$id == 0} {
set compareName ""
} elseif {$id > 0} {
incr id -1
set compareName [string range $sectionName 0 $id]
} else {
set compareName $sectionName
}
if {"$compareName" == "$name"} {
return "$sectionName"
}
}
return ""
}
# Do not delete this line -- regeneration end marker