home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Westmount Technology 1994
- #
- # File: @(#)copyenvdia.tcl /main/titanic/3
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)copyenvdia.tcl /main/titanic/3 22 Sep 1997 Copyright 1994 Westmount Technology
-
- # Start user added include file section
- require procs.tcl
- # End user added include file section
-
- require "m4envdialo.tcl"
-
- Class CopyEnvDialog : {M4EnvDialog} {
- constructor
- method destructor
- method popUp
- method save
- attribute levelObj
- }
-
- constructor CopyEnvDialog {class this name NrOfColumns levelObj} {
- set this [M4EnvDialog::constructor $class $this $name $NrOfColumns]
- $this levelObj $levelObj
- # Start constructor user section
-
- set level [$levelObj uiClass]
- set labelText "Copy To $level Environment As ReadOnly Variable"
- $this setLabelText "$labelText"
-
- # End constructor user section
- return $this
- }
-
- method CopyEnvDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this M4EnvDialog::destructor
- }
-
- method CopyEnvDialog::popUp {this} {
- set m4VarDes [$this m4VarDes]
- m4_var foreach m4var [m4_var meta4UserEnv] {
- if [isCommand $m4VarDes] {
- set label [rmWhiteSpace [$m4VarDes getUiName $m4var]]
- if {"$label" == ""} {
- set label $m4var
- }
- } else {
- set label $m4var
- }
- set m4SortList($label) $m4var
- }
-
- if [info exists m4SortList] {
- set col 0
- foreach index [lsort [array names m4SortList]] {
- set m4var $m4SortList($index)
- $this addToggle $m4var $col $m4var
- incr col 1
- if {! [isCommand $this.top.vp.row.col$col]} {
- set col 0
- }
- }
- }
-
- $this TemplateDialog::popUp
- }
-
- method CopyEnvDialog::save {this} {
- busy {
- set tmpFile [args_file {}]
- if [[$this levelObj] isA Corporate] {
- set m4etcDir [path_name concat [m4_var get M4_home] etc]
- set m4envFile [path_name concat $m4etcDir m4env m4env]
- if {! [BasicFS::exists $m4envFile]} {
- BasicFS::makeFile $m4envFile
- }
- copy_text_file $m4envFile $tmpFile
- } else {
- set m4envFile [[$this levelObj] findCustomFileVersion m4env m4env]
- if [$m4envFile isNil] {
- set m4envFile \
- [[$this levelObj] createCustomFileVersion m4env m4env]
- }
- $m4envFile downLoad $tmpFile
- $m4envFile edit
- }
-
- # Read the old m4env file
- set fid [open $tmpFile r]
- set contents [read -nonewline $fid]
- close $fid
-
- # Write the new m4env file
- set fid [open $tmpFile w]
- set i 0
- [$this buttonSet] foreach toggle {
- set m4var [lindex [$this m4varList] $i]
- if {[$toggle state]} {
- $toggle state no
- puts $fid "${m4var}=[m4_var get $m4var];RO"
-
- # Remove old specifications of the variable
- # from the contents
- set newContents ""
- set nl ""
- foreach line [split $contents "\n"] {
- set assign [string first "=" $line]
- if {$assign > 0} {
- set var [string range $line 0 [expr $assign -1]]
- } else {
- set var ""
- }
- if {"$var" != "$m4var"} {
- append newContents "$nl$line"
- set nl "\n"
- }
- }
- set contents $newContents
- }
- incr i 1
- }
- foreach line [split $contents "\n"] {
- puts $fid $line
- }
- close $fid
-
- if [[$this levelObj] isA Corporate] {
- copy_text_file $tmpFile $m4envFile
- } else {
- $m4envFile upLoad $tmpFile
- $m4envFile quit
- }
- unlink $tmpFile
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-