home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)extfuiobj.tcl /main/hindenburg/2
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)extfuiobj.tcl /main/hindenburg/2 2 Dec 1996 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
- # End user added include file section
-
- require "browsuiobj.tcl"
-
- Class ExtFUiObj : {BrowsUiObj} {
- constructor
- method destructor
- method addExternalFile
- method browserType
- method editFile
- method externalFiles
- method hasChildren
- method initializeInfo
- method openFile
- method printObjects
- method referredFile
- method removeObjects
- method showFile
- attribute directory
- attribute isAscii
- attribute isDirectory
- attribute pattern
- }
-
- global ExtFUiObj::uiClass
- set ExtFUiObj::uiClass "ExternalFile"
-
-
- constructor ExtFUiObj {class this name} {
- set this [BrowsUiObj::constructor $class $this $name]
- $this isAscii 1
- $this isDirectory 0
- $this pattern "*"
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method ExtFUiObj::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this BrowsUiObj::destructor
- }
-
- method ExtFUiObj::addExternalFile {this} {
- if {! [$this isDirectory]} {
- return
- }
-
- foreach childType [HCustFUiObj::externalFileNames] {
- set externalFileList($childType) 1
- }
- foreach externalFile [$this getChildSet externalFiles] {
- set type [$externalFile uiName]
- if [info exists externalFileList($type)] {
- unset externalFileList($type)
- }
- }
- if [info exists externalFileList] {
- set entrySet [lsort [array names externalFileList]]
- } else {
- set entrySet ""
- }
-
- require "editseldia.tcl"
- set box .main.newExternalF
- ClassMaker::extend EditSelDialog NewExternalFileEditSelDialog uiObj
- NewExternalFileEditSelDialog new $box \
- -title "New External File" \
- -message "External File:" \
- -entrySet $entrySet \
- -uiObj $this \
- -okPressed {
- set dir ""
- set uiObj [%this uiObj]
- while {"$uiObj" != ""} {
- if {! [$uiObj isA ExtFUiObj]} break
- if {"$dir" == ""} {
- set dir [$uiObj getInfo Name]
- } else {
- set dir [path_name concat [$uiObj getInfo Name] $dir]
- }
- set uiObj [$uiObj parent]
- }
- set file [%this text]
- set selection [splitFileName $file]
- set name [lindex $selection 0]
- set type [lindex $selection 1]
- set script "global HCustFUiObj:custF"
- append script " ;"
- append script " set HCustFUiObj:custF \[CustFileUtilities::make \
- [.main corporateObj] \
- [list $name] [list $type] [list $dir] \
- \]"
- require "custfileut.tcl"
- .main startCommand tcl \
- "$script" "" \
- "Creating external file '$file'" \
- {1 0} 1
- %this delete
- } \
- -editPressed {
- if [info exists HCustFUiObj:custF] {
- if [file isfile ${HCustFUiObj:custF}] {
- regsub -all " |\\." "[$this text]" "_" fileId
- [$this uiObj].ExternalFile:$fileId editFile
- }
- }
- }
- $box popUp
- }
-
- proc ExtFUiObj::associations {} {
- return {externalFiles}
- }
-
- method ExtFUiObj::browserType {this} {
- if [$this isDirectory] {
- return ExternalDirectory
- } else {
- return [$this BrowsUiObj::browserType]
- }
- }
-
- proc ExtFUiObj::childTypes {assoc} {
- if {[lsearch -exact "[ExtFUiObj::associations]" "$assoc"] == -1} {
- return ""
- }
- set childTypes [BrowserProcs::childTypes $assoc]
- case "$childTypes" in {
- {ExternalFile} {
- return {ExternalDirectory ExternalFile}
- }
- {default} {
- return "$childTypes"
- }
- }
- }
-
- method ExtFUiObj::editFile {this} {
- if [$this isDirectory] {
- return
- }
-
- set path [$this getInfo Path]
- if {! [file writable $path]} {
- $this showFile
- return
- }
-
- set file [splitFileName "[$this uiName]"]
- set name [lindex "$file" 0]
- set type [lindex "$file" 1]
- if [[$this parent] isA UCustFUiObj] {
- set level "user"
- } else {
- set level "corporate"
- }
- case "$type" in {
- {mnu vie objtype} {
- if {"[$this referredFile]" != "$path"} {
- .main startM4Command editor "$path" "" "[$this uiName]"
- return
- }
- set script "SystemUtilities::fork otk uce \
- -c [list [get_comm_name]] \
- -fi $level [list $name] [list $type]"
- .main startCommand tcl \
- "$script" "" \
- "Starting uce for '$name.$type'" \
- {0 0} 1
- }
- {opendefs openlocs propdefs proplocs} {
- if {$level == "user" || "[$this referredFile]" != "$path"} {
- .main startM4Command editor "$path" "" "[$this uiName]"
- return
- }
- set script "SystemUtilities::fork otk uce \
- -c [list [get_comm_name]] \
- -fi $level [list $name] [list $type]"
- .main startCommand tcl \
- "$script" "" \
- "Starting uce for '$name.$type'" \
- {0 0} 1
- }
- {pnl} {
- if {"[$this referredFile]" != "$path"} {
- .main startM4Command editor "$path" "" "[$this uiName]"
- return
- }
- require "ctrlpnldia.tcl"
- global classCount
- incr classCount
- set dlgName .main.ctrlPnlDialog$classCount
- CtrlPnlDialog new $dlgName \
- -helpPressed ".main helpOnName ctrlPnlDialog" \
- -lvlObj [$this getParent Corporate] \
- -fileName $name \
- -fileType $type \
- -editable 1
- $dlgName popUp
- }
- {default} {
- case "$name" in {
- {checkconfig} {
- if {"[$this referredFile]" != "$path"} {
- .main startM4Command editor "$path" "" "[$this uiName]"
- return
- }
- require "custcheckd.tcl"
- global classCount
- incr classCount
- set dlgName .main.custCheckDialog$classCount
- CustCheckDialog new $dlgName
- $dlgName edit [$this getParent CustomLevelVersion]
- }
- {default} {
- .main startM4Command editor "$path" "" "[$this uiName]"
- }
- }
- }
- }
- }
-
- method ExtFUiObj::externalFiles {this} {
- if {! [$this isDirectory]} {
- return ""
- }
-
- set externalFiles ""
- set externalDirectories ""
- set directory [$this getInfo Path]
- set crntPath [pwd]
- cd $directory
- if [catch {set files [glob [$this pattern]]}] {
- set files ""
- }
- cd $crntPath
-
- foreach file [lsort $files] {
- regsub -all " |\\." "$file" "_" fileId
- set externalFile $this.${ExtFUiObj::uiClass}:$fileId
- set isDirectory [file isdirectory [path_name concat $directory $file]]
- if {! [isCommand $externalFile]} {
- ExtFUiObj new $externalFile \
- -parent $this \
- -uiName "$file" \
- -directory "$directory" \
- -isDirectory $isDirectory
- }
- if $isDirectory {
- lappend externalDirectories $externalFile
- } else {
- lappend externalFiles $externalFile
- }
- }
- return [concat $externalDirectories $externalFiles]
- }
-
- method ExtFUiObj::hasChildren {this} {
- if [$this isDirectory] {
- return 1
- } else {
- return 0
- }
- }
-
- proc ExtFUiObj::infoProperties {} {
- return [concat \
- [BrowserProcs::infoProperties] \
- {Directory Path} \
- ]
- }
-
- method ExtFUiObj::initializeInfo {this dummy} {
- set directory [$this directory]
- set file [$this uiName]
- set path [path_name concat $directory $file]
- if {! [file exists $path]} {
- set path $file
- $this directory [path_name directory $path]
- $this uiName [path_name file $path]
- }
-
- case "[lindex [splitFileName [$this uiName]] 1]" in {
- {dot con tlb} {
- $this isAscii 0
- }
- }
-
- $this BrowsUiObj::initializeInfo $dummy
- $this setInfo Text "external file '$path'"
- $this setInfo Directory "[$this directory]"
- $this setInfo Path "$path"
- }
-
- method ExtFUiObj::openFile {this} {
- if {[$this isDirectory] || (! [$this isAscii])} {
- BrowserProcs::showInfo
- } elseif {! [file writable [$this getInfo Path]]} {
- $this showFile
- } else {
- $this editFile
- }
- }
-
- method ExtFUiObj::printObjects {this} {
- if {! [$this isDirectory]} {
- return
- }
-
- set parent [$this getParent HCustFUiObj]
- if {"$parent" == ""} {
- set parent [$this getParent UCustFUiObj]
- }
- $parent printObjects
- }
-
- method ExtFUiObj::referredFile {this {showWarning 0}} {
- set path [$this getInfo Path]
- if {[$this getParent UCustFUiObj] != ""} {
- return $path
- }
-
- set file [splitFileName "[$this uiName]"]
- set name [lindex "$file" 0]
- set type [lindex "$file" 1]
- set uiObj [$this parent]
- set dir ""
- while {"$uiObj" != ""} {
- if {! [$uiObj isA ExtFUiObj]} break
- set dir [$uiObj getInfo Name]
- set uiObj [$uiObj parent]
- }
- if {"$dir" == ""} {
- return $path
- }
-
- require "custfileut.tcl"
- set custF "[CustFileUtilities::find \
- [.main corporateObj] [list $name] [list $type] [list $dir]]"
- if {"$custF" == ""} {
- return $path
- }
- if {$showWarning && ("$path" != "$custF")} {
- wmtkwarning "\
- Customization file '$name.$type' already exists in \
- the intallation directory.\nUsing file '$custF'"
- }
- return $custF
- }
-
- method ExtFUiObj::removeObjects {this} {
- if {! [$this isDirectory]} {
- return
- }
-
- set parent [$this getParent HCustFUiObj]
- if {"$parent" == ""} {
- set parent [$this getParent UCustFUiObj]
- }
- $parent removeObjects
- }
-
- method ExtFUiObj::showFile {this} {
- if [$this isDirectory] {
- return
- }
-
- set path [$this getInfo Path]
- set file [splitFileName "[$this uiName]"]
- set name [lindex "$file" 0]
- set type [lindex "$file" 1]
- if [[$this parent] isA UCustFUiObj] {
- set level "user"
- } else {
- set level "corporate"
- }
- case "$type" in {
- {mnu vie objtype} {
- if {"[$this referredFile]" != "$path"} {
- .main startM4Command viewer "$path" "" "[$this uiName]"
- return
- }
- set script "SystemUtilities::fork otk uce -r \
- -c [list [get_comm_name]] \
- -fi $level [list $name] [list $type]"
- .main startCommand tcl \
- "$script" "" \
- "Starting uce for '$name.$type'" \
- {0 0} 1
- }
- {opendefs openlocs propdefs proplocs} {
- if {$level == "user" || "[$this referredFile]" != "$path"} {
- .main startM4Command viewer "$path" "" "[$this uiName]"
- return
- }
- set script "SystemUtilities::fork otk uce -r \
- -c [list [get_comm_name]] \
- -fi $level [list $name] [list $type]"
- .main startCommand tcl \
- "$script" "" \
- "Starting uce for '$name.$type'" \
- {0 0} 1
- }
- {pnl} {
- if {"[$this referredFile]" != "$path"} {
- .main startM4Command viewer "$path" "" "[$this uiName]"
- return
- }
- require "ctrlpnldia.tcl"
- global classCount
- incr classCount
- set dlgName .main.ctrlPnlDialog$classCount
- CtrlPnlDialog new $dlgName \
- -helpPressed ".main helpOnName ctrlPnlDialog" \
- -lvlObj [$this getParent Corporate] \
- -fileName $name \
- -fileType $type \
- -editable 0
- $dlgName popUp
- }
- {default} {
- case "$name" in {
- {checkconfig} {
- if {"[$this referredFile]" != "$path"} {
- .main startM4Command viewer "$path" "" "[$this uiName]"
- return
- }
- require "custcheckd.tcl"
- global classCount
- incr classCount
- set dlgName .main.custCheckDialog$classCount
- CustCheckDialog new $dlgName
- $dlgName show [$this getParent CustomLevelVersion]
- }
- {default} {
- .main startM4Command viewer "$path" "" "[$this uiName]"
- }
- }
- }
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-