home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Komunikace
/
Comanche
/
htmlfrontend
/
nodeTree.tcl
Wrap
Text File
|
2000-11-02
|
4KB
|
159 lines
# ::webfe::
# Web front end
# webfe::nodeManagement
#
# Node Management object used by the web front end to store information about the nodes
# of the namespace. The web module has a simple API and webfe::nodeManagement handles all the
# callbacks with the Namespace.
#
# It will store the following properties of the nodes:
# Icon, text, parent node, children nodes, last time the node was modified (property page posted to it)
#
# It should be possible to do a [resolvePath network_services/apache_installation/server_management]
# and will give us the corresponding node. This is useful for bookmarking, although not perfect (nodes with
# same name, etc. that will have to be handled as special cases)
# If the URL was bookmarked some time ago and the server was restarted, the nodeManagement would interate
# and return the node
#
# webfe::nodeManagement public functions
#
# resolveNodeFromPath path
# Figure out a node from a certain URL
#
# populatePage pageObject node
# The nodeManagement will call then $pageObject addUpperMenu -icon icon -image image -url url
# and addLeftMenu
#
# Internal functions:
# getNodeProperties node
# getNodeChildren parentNode
# addNodeInfo parentNode nodeToAdd args (properties)
class nodeManagement {
variable namespace
variable plugIn
variable nameMapping
variable containerMapping
variable childrenMapping
variable parentMapping
variable addData
variable addStructure
variable addNode
variable addNewNode
variable queryData
variable queryStructure
variable queryNode
variable queryNewNode
constructor { ns webfeview } {
set namespace $ns
set view $webfeview
set queryData [xuiStructure ::#auto]
set queryStructure [xuiStructure ::#auto]
$queryStructure setName data
set queryCaller [xuiLabel ::#auto]
$queryCaller setName caller
$queryCaller setValue $view
set queryNode [xuiNode ::#auto]
$queryNode setName node
$queryData addComponent $queryCaller
$queryData addComponent $queryStructure
$queryStructure addComponent $queryNode
}
method addNode
method removeNode
method setContainer
method getNodeName
method getContainer
method getChildrenByClass
method getPlugInNodeChildren
method getPlugInNodeChildrenByNodeName
method getRootNode
method getParentNode
}
body nodeManagement::addNodeInfo { parentNode node args } {
array set options {\
-openIcon openFolder \
-closedIcon closedFolder \
-label {default label} \
-classes container \
-container {} \
-nodeName {} }
array set options $args
foreach arrayOption [array names options] {
}
set nameMapping($node) $options(-nodeName)
set containerMapping($node) $options(-container)
lappend childrenMapping($parentNode) $node
set childrenMapping($node) {}
set parentMapping($node) $parentNode
return $node
}
body nodeManagement::removeNode { node } {
::plugInUtils::removeNode $plugIn $namespace $node
unset nameMapping($node)
unset containerMapping($node)
# lsearch and remove from list of parent node
set parentNode $parentMapping($node)
lremove childrenMapping($parentNode) $node
unset childrenMapping($node)
unset parentMapping($node)
return
}
body nodeManagement::getContainer { node } {
return $containerMapping($node)
}
body nodeManagement::getNodeName { node } {
return $nameMapping($node)
}
body nodeManagement::getChildrenByClass {parentNode class} {
$queryNode setId $parentNode
set childList [$ns getChildren $queryData]
}
body nodeManagement::getParentNode { node } {
return $parentMapping($node)
}
body nodeManagement::getPlugInNodeChildrenByNodeName {parentNode nodeName} {
set result {}
foreach child [ getPlugInNodeChildren $parentNode] {
if { [getNodeName $child] == $nodeName } {
lappend result $child
}
}
return $result
}
body nodeManagement::getPlugInNodeChildren {parentNode} {
return $childrenMapping($parentNode)
}
body nodeManagement::getRootNode {} {
return root
}