home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
dsysvdbobj.tcl
< prev
next >
Wrap
Text File
|
1997-09-25
|
17KB
|
655 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)dsysvdbobj.tcl /main/titanic/14
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)dsysvdbobj.tcl /main/titanic/14 25 Sep 1997 Copyright 1997 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 browserType
method documentedSystemName
method editorType
method generate
method generateObjects
method importObject
method name2section
method printObjects
method removeDocDir
method sections
method updateDocDir
method unstructuredName
method removeSpecials
method changeObjects
}
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} {
global DSysVDbObj::count
set DSysVDbObj::count 0
module_promoter DSysVDbObj $this
}
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_module_file "docgenerat.tcl" docwriter
require_module_file "docstructp.tcl" docwriter
.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_module_file "newlocalse.tcl" docwriter
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}
}
method DSysVDbObj::browserObjType {this} {
return "DSysVDbObj"
}
method DSysVDbObj::browserType {this} {
return "DocumentVersion"
}
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]]
}
# find the structure templates
set docEditor [$this getInfo Editor]
if {[info exist docwriterEditors($docEditor)]} {
set elms $docwriterTemplates([$this getInfo Editor])
foreach elm $elms {
lappend entrySet "[lindex $elm 0] ([lindex $elm 1])"
}
}
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]
# strip til (
set index [string first " (" $structureFile]
if {$index != -1} {
incr index -1
set structureFile [string range $structureFile 0 $index]
}
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 0
}
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 0
}
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 1
}
# 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_module_file "docgenerat.tcl" docwriter
require_module_file "docstructp.tcl" docwriter
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
return 1
}
proc DSysVDbObj::infoProperties {} {
return [concat \
[SysVDbObj::infoProperties] \
{Editor "Documented System"} \
]
}
method DSysVDbObj::name2section {this name} {
global browserSections
foreach section [array names browserSections] {
set compareName $name
if {"$browserSections($section)" == "$compareName"} {
unset browserSections($section)
return $section
} else {
# backward compatible
if {![$section isA PropertyReference]} {
set compareName [rmWhiteSpace $name]
if {"$browserSections($section)" == "$compareName"} {
unset browserSections($section)
return $section
}
}
}
}
global DSysVDbObj::count
require_module_file "noneuiobj.tcl" docwriter
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::printDocObjects $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_module_file "docgenerat.tcl" docwriter
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 ""
}
method DSysVDbObj::removeSpecials {this} {
if {"[$this getInfo Status]" != "backGround"} {
$this removeDocDir
}
}
method DSysVDbObj::changeObjects {this status} {
case "$status" in {
{fixed} {
set operation "makeFixed"
}
{selected} {
set operation "makeSelected"
}
{snapshot} {
set operation "makeSnapshot"
}
{current} {
set operation "makeCurrent"
}
{default} {
return
}
}
set objectList [$wmttoolObj selectedObjSet]
set script ""
set sections ""
foreach obj $objectList {
if {"$script" != ""} {
append script " ;"
}
append script " $obj $operation"
if [$obj isA DocSection] {
lappend sections [$obj identity]
}
}
if [lempty $sections] {
set cmd ""
} else {
case "$status" in {
{selected current} {
set confVId [[$this getParent ConfigVersion] identity]
set sysVId [$this identity]
set argsfile [args_file $sections]
set args "updateDocDir $confVId $sysVId [list $argsfile]"
set cmd \
"$wmttoolObj startDocbatch mtool [list $args] \"\" {0 0} 0"
}
{default} {
set cmd ""
}
}
}
$wmttoolObj startCommand tcl "$script" "$cmd" "" {1 0} 1
}
# Do not delete this line -- regeneration end marker