home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
docstructd.tcl
< prev
next >
Wrap
Text File
|
1997-11-18
|
10KB
|
388 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)docstructd.tcl /main/titanic/4
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)docstructd.tcl /main/titanic/4 18 Nov 1997 Copyright 1996 Cadre Technologies Inc.
# Start user added include file section
require "docstructn.tcl"
require "docstructt.tcl"
require "wmt_util.tcl"
# End user added include file section
Class DocStructDlg : {TemplateDialog} {
method destructor
constructor
method newSection
method editSection
method load
method popUp
method removeSection
method save
method selectionChanged
method structure
attribute document
attribute editable
attribute saved
attribute _removedSectionList
attribute dsm
attribute fileInfo
attribute _structure
}
method DocStructDlg::destructor {this} {
set ref [$this _structure]
if {$ref != ""} {
$ref _dialog ""
}
# Start destructor user section
# Remove dialog box
set box [getParent $this].[nt_get_type $this]newSection
if [isCommand $box] {
$box delete
}
[$this fileInfo] quit
if [$this saved] {
$wmttoolObj updateView
}
# End destructor user section
}
constructor DocStructDlg {class this name dsm} {
set this [TemplateDialog::constructor $class $this $name]
$this dsm $dsm
$this document [[ClientContext::global] currentSystem]
$this config \
-cancelPressed {
%this delete
} \
-okPressed {
if [%this editable] {
%this save
}
if [%this autoPopDown] {
%this delete
}
}
interface DlgColumn $this.top {
NamedGroup actions {
verStretchFactor 0
label section
mnemonic s
DlgRow menu {
PushButton new {
label New...
default yes
}
PushButton edit {
label Edit...
}
PushButton delete {
label Delete
}
}
}
DocStructTree tree {
rowCount 15
columnCount 60
}
}
$this.top.actions.menu.new activated [list $this newSection]
$this.top.actions.menu.edit activated [list $this editSection]
$this.top.actions.menu.delete activated [list $this removeSection]
DocStructNode new $this.top.tree.root "[[$this document] getInfo Name]"
$this structure $this.top.tree
return $this
}
method DocStructDlg::newSection {this} {
set box [getParent $this].[nt_get_type $this]newSection
ClassMaker::extend TemplateDialog NewSectionTemplateDialog {dialog tree}
if {! [isCommand $box]} {
NewSectionTemplateDialog new $box \
-modal yes \
-title "New Section" \
-autoPopDown 0 \
-dialog $this \
-tree [$this structure] \
-helpPressed {.main helpOnName newSection} \
-okPressed {
set name [%this.top.nameList text]
set names [%this.top.nameList entrySet]
set id [lsearch -exact "$names" "$name"]
if {$id != -1} {
%this.top.nameList entrySet [lreplace $names $id $id]
}
set id [lsearch -exact \
"[%this.top.parent entrySet]" "[%this.top.parent selected]"]
set nodes [concat [%this tree].root [[%this tree].root nodes]]
set parent [lindex $nodes $id]
if {! [$parent hasChildren]} {
$parent hasChildren 1
$parent foldState 0
}
set node [$parent count]
DocStructNode new $parent.$node "$name"
$parent count [expr $node + 1]
%this popDown
}
interface DlgColumn $box.top {
Label nameLab {
text "Name:"
}
ComboBox nameList {
rowCount 5
verStretchFactor 20
}
Label parentLab {
text "Parent:"
}
DropDwnList parent {
rowCount 5
}
}
# Fill nameList with unstructured sections names
set entrySet ""
foreach section [[$this document] getChildSet sections] {
if {"[$section uiPrefix]" != "-"} continue
if [$section isA ExternalFileVersion] {
lappend entrySet "[[$section file] qualifiedName :]"
} else {
lappend entrySet "[$section name]"
}
}
$box.top.nameList config \
-entrySet $entrySet \
-textModified {
set box [getParent [getParent %this]]
set label [%this text]
if {"[rmWhiteSpace $label]" == "" ||
"[[[$box dialog] fileInfo] findComponent $label]" != ""} {
set selected 0
} else {
set selected 1
}
$box okSensitive $selected
$box okDefault $selected
$box cancelDefault [expr 1 - $selected]
}
}
# Append removed sections to nameList
$box.top.nameList entrySet \
[concat [$box.top.nameList entrySet] [$this _removedSectionList]]
$this _removedSectionList ""
# Fill parent option-menu
set entrySet \"[[$this structure].root label]\"
foreach node [[$this structure].root nodes] {
lappend entrySet [$node label]
}
set selected [$box.top.parent selected]
if {"$selected" == "" || [lsearch -exact $entrySet "$selected"] == -1} {
set selected [lindex $entrySet 0]
}
$box.top.parent config \
-entrySet $entrySet \
-selected $selected
eval [$box.top.nameList textModified]
$box popUp
}
method DocStructDlg::editSection {this} {
set section [[$this structure] selected]
if {! [isCommand [$section parent]]} return
global classCount
set box [getParent $this].[nt_get_type $this]editSection$classCount
incr classCount
ClassMaker::extend TemplateDialog EditSectionTemplateDialog \
{dialog tree section}
EditSectionTemplateDialog new $box \
-modal yes \
-title "Edit Section" \
-autoPopDown 0 \
-dialog $this \
-tree [$this structure] \
-section $section \
-helpPressed {.main helpOnName editSection} \
-okPressed {
set name [%this.top.name text]
set id [lsearch -exact \
"[%this.top.parent entrySet]" "[%this.top.parent selected]"]
set sectionNodes [concat [%this section] [[%this section] nodes]]
set nodes [%this tree].root
foreach node [[%this tree].root nodes] {
if {[lsearch -exact $sectionNodes $node] != -1} continue
lappend nodes $node
}
[%this section] setParent [lindex $nodes $id]
if {"$name" != "[[%this section] label]"} {
[%this section] label "$name"
}
%this popDown
%this delete
} \
-cancelPressed {
%this delete
}
interface DlgColumn $box.top {
Label nameLab {
text "Name:"
}
SingleLineText name {}
Label parentLab {
text "Parent:"
}
DropDwnList parent {
rowCount 5
}
}
$box.top.name config \
-text "[$section label]" \
-textModified {
set box [getParent [getParent %this]]
set label [%this text]
set origLabel [[$box section] label]
if {"[rmWhiteSpace $label]" == "" ||
("$label" != "$origLabel" &&
"[[[$box dialog] fileInfo] findComponent $label]" != "")} {
set selected 0
} else {
set selected 1
}
$box okSensitive $selected
$box okDefault $selected
$box cancelDefault [expr 1 - $selected]
}
set entrySet \"[[$this structure].root label]\"
set sectionNodes [concat $section [$section nodes]]
foreach node [[$this structure].root nodes] {
if {[lsearch -exact $sectionNodes "$node"] != -1} continue
lappend entrySet [$node label]
}
$box.top.parent config \
-entrySet $entrySet \
-selected [[$section parent] label]
eval [$box.top.name textModified]
$box popUp
}
method DocStructDlg::load {this} {
$this saved 0
set parent $this.top.tree.root
set indentation -1
set parentArray($indentation) $parent
for {set fiComponent [[$this fileInfo] firstComponent]} \
{"$fiComponent" != ""} \
{set fiComponent [$fiComponent next]} {
if {[$fiComponent indentation] != $indentation} {
set prevIndentation $indentation
set indentation [$fiComponent indentation]
if {$prevIndentation == -1} {
set parentArray($indentation) $parentArray(-1)
} elseif {($indentation > $prevIndentation) ||
(! [info exists parentArray($indentation)])} {
set parentArray($indentation) $parent.$node
}
set parent $parentArray($indentation)
}
if {! [$parent hasChildren]} {
$parent hasChildren 1
$parent foldState 0
}
set node [$parent count]
DocStructNode new $parent.$node "[$fiComponent uiName]" \
-fiComponent $fiComponent
$parent count [expr $node + 1]
}
}
method DocStructDlg::popUp {this} {
if [$this editable] {
PushButton new $this.save \
-label Save \
-activated {
set dialog [getParent %this]
$dialog autoPopDown 0
eval [$dialog okPressed]
$dialog autoPopDown 1
}
}
$this fileInfo [DocStructure new $this.fileInfo]
if [$this editable] {
[$this fileInfo] edit [$this dsm]
} else {
[$this fileInfo] load [$this dsm]
}
$this load
$this selectionChanged
$this title "[$this title] - [[$this document] getInfo Name]"
$this TemplateDialog::popUp
}
method DocStructDlg::removeSection {this} {
[[$this structure] selected] delete
$this selectionChanged
}
method DocStructDlg::save {this} {
[$this structure].root save
[$this fileInfo] save
$this saved 1
}
method DocStructDlg::selectionChanged {this} {
if [$this editable] {
$this.top.actions.menu.new sensitive 1
set section [[$this structure] selected]
if {"$section" == "" || "[$section parent]" == ""} {
$this.top.actions.menu.edit sensitive 0
$this.top.actions.menu.delete sensitive 0
} else {
$this.top.actions.menu.edit sensitive 1
$this.top.actions.menu.delete sensitive 1
}
} else {
$this.top.actions.menu.new sensitive 0
$this.top.actions.menu.edit sensitive 0
$this.top.actions.menu.delete sensitive 0
}
}
# Do not delete this line -- regeneration end marker
method DocStructDlg::structure {this args} {
if {$args == ""} {
return [$this _structure]
}
set ref [$this _structure]
if {$ref != ""} {
$ref _dialog ""
}
set obj [lindex $args 0]
if {$obj != ""} {
$obj _dialog $this
}
$this _structure $obj
}