home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)copyeditor.tcl /main/titanic/5
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)copyeditor.tcl /main/titanic/5 9 Oct 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
- require "copydefobj.tcl"
- # End user added include file section
-
- require "custdefsar.tcl"
-
- # Editor area for the copyspecs editor.
-
- Class CopyEditorArea : {CustDefsArea} {
- constructor
- method destructor
- method read
- method processConfigLine
- method createObject
- method newObject
- method getGdrDescription
- method getGdrLevel
- method sortArea
-
- # Reflects contents of copyspecs file:
- # maps file type to gfr file.
- #
- attribute typeToGdr
-
- # Maps gdr files to a list with
- # - the level at which the file was specified
- # - the description of the file
- #
- attribute gdrToInfo
- attribute copyDefiner
- }
-
- constructor CopyEditorArea {class this name} {
- set this [CustDefsArea::constructor $class $this $name]
- # Start constructor user section
- $this typeToGdr [Dictionary new]
- $this gdrToInfo [Dictionary new]
- $this rowCount 12
- $this columnCount 136
- $this font "[m4_var get M4_font -context uce]"
- $this destinationSet "COPYSPEC dropEvent"
- $this mode DETAIL
- BrowsHeader new $this.typeHeader \
- -label "File Type" \
- -width 12
- BrowsHeader new $this.fileHeader \
- -label "Group definition rules" -width 26
- BrowsHeader new $this.levelHeader \
- -label "Level" -width 16
- BrowsHeader new $this.descHeader \
- -label "Description" \
- -width 80
-
- # End constructor user section
- return $this
- }
-
- method CopyEditorArea::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CustDefsArea::destructor
- }
-
-
- # Reads the copy spec at the specified level if it is the
- # current level.
- # Also reads the gdr files available at the specified
- # level.
- #
- method CopyEditorArea::read {this object type} {
- # special treatment for corporate and user levels
- # files contain a description
- if { $type == "corporate" } {
- set m4_home [m4_var get M4_home]
- set corporateEtc [location $m4_home "etc"]
- set corpEtcPattern [path_name concat $corporateEtc "*.gdr"]
-
- foreach gdrPathFile [otglob -nocomplain $corpEtcPattern] {
- set file [open $gdrPathFile]
- set contents [read $file]
- set description ""
- regexp {Description:([ -z]*)} $contents dummy description
- set info "corporate"
- lappend info [string trim $description]
- set gdrFile [file tail $gdrPathFile]
- [$this gdrToInfo] set $gdrFile $info
- close $file
- }
- }
-
- if { [$this _level] == "user" } {
- set icaseDir [location [M4Login::getHomeDir] "icase"]
- set icasePattern [path_name concat $icaseDir "*.gdr"]
-
- foreach gdrPathFile [otglob -nocomplain $icasePattern] {
- set gdrFile [file tail $gdrPathFile]
- set file [open $gdrPathFile]
- set contents [read $file]
- set description ""
- regexp {Description:([ -z]*)} $contents dummy description
- set info "user"
- lappend info [string trim $description]
- [$this gdrToInfo] set $gdrFile $info
- close $file
- }
- }
-
- # determine available gdr files at current level if not corporate
- if { $type != "corporate" } {
- foreach gdrFile [$object findCustomFileNames gdr] {
- regsub {\.gdr} $gdrFile "" gdrName
- set info $type
- set customFile [$object findCustomFileVersion $gdrName gdr]
- lappend info [$customFile getPropertyValue freeText]
- [$this gdrToInfo] set "$gdrFile.gdr" $info
- }
- }
-
- # read file if at final level
- set currentType [string tolower [[ClientContext::global] currentLevel]]
-
- # config level is 'configuration' in customization editors and
- # 'config' in ClientContext...
- if { [string range $type 0 5] != [string range $currentType 0 5] } {
- return
- }
-
- set specsFileName [$this _curName]
- set specsFileType [$this _curType]
-
- if { [$this _level] == "user" } {
- set file [path_name concat [path_name concat ~ icase] \
- $specsFileName.$specsFileType]
- if [file exists $file] {
- foreach specLine [readConfigurationFile $file] {
- $this processConfigLine $specLine
- }
- }
- } else {
- foreach specLine [$this readConfig $object $specsFileName $specsFileType] {
- $this processConfigLine $specLine
- }
- }
- }
-
-
- # Process given line of the copyspec file:
- # create editor object and adjust typeToGdr.
- #
- method CopyEditorArea::processConfigLine {this line} {
- set type [lindex $line 0]
- if { $type == "*" } {
- set type "default"
- }
- set gdrName [path_name base [lindex $line 1]]
- [$this typeToGdr] set $type $gdrName
- set level [$this getGdrLevel $gdrName]
- set description [$this getGdrDescription $gdrName]
- $this createObject [list \
- type $type \
- level $level \
- gdrName $gdrName \
- description $description] $type
- }
-
-
- # Create a new editor object for
- # a copy specification.
- #
- method CopyEditorArea::createObject {this objSpec level} {
- global classCount
- set object [CopyDefObject new $this.Object$classCount $objSpec]
- incr classCount
-
- $this adjustCreatedObject $object $level
-
- # update the object-details in the view
- $object updateView
-
- return $object
- }
-
- method CopyEditorArea::newObject {this type {edit 0}} {
- set gdrName "default"
- set level [$this getGdrLevel $gdrName]
- set description [$this getGdrDescription $gdrName]
- [$this typeToGdr] set $type $gdrName
- set object [$this createObject [list \
- type $type \
- level $level \
- gdrName $gdrName \
- description $description] $type]
-
- $this sortArea
-
- if $edit {
- $object open
- }
- }
-
-
- # Get description of the specified gdr file from gdrToInfo.
- #
- method CopyEditorArea::getGdrDescription {this gdrName} {
- set info [[$this gdrToInfo] set "$gdrName.gdr"]
- return [lindex $info 1]
- }
-
-
- # Get level of specified gdr file from gdrToInfo.
- #
- method CopyEditorArea::getGdrLevel {this gdrName} {
- set info [[$this gdrToInfo] set "$gdrName.gdr"]
- return [lindex $info 0]
- }
-
-
- # Sort area and adjust editbale attributes of
- # objects in the editor area.
- #
- method CopyEditorArea::sortArea {this} {
- $this sort -column $this.typeHeader
- # also readjust editable attributes
- if { ![$this isReadOnly]} {
- foreach obj [$this objectSet] {
- $obj editable 1
- }
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-