home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
addreqmodh.tcl
< prev
next >
Wrap
Text File
|
1997-11-06
|
6KB
|
201 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)addreqmodh.tcl /main/titanic/6
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)addreqmodh.tcl /main/titanic/6 6 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require "selectmodu.tcl"
require "requiredmo.tcl"
# End user added include file section
Class AddReqModHandler : {GCObject} {
constructor
method destructor
method addRequiredModules
method addToReqModInfoSet
method handleNextReqMod
method getExistingReqMod
method handleSelModDlgOkPressed
method handleSelModDlgCancelPressed
method addReqModInfo
method removeReqModInfo
attribute startingObj
attribute giveWmtkInfo
attribute selModDlg
attribute reqModInfoSet
}
global AddReqModHandler::instance
set AddReqModHandler::instance ""
constructor AddReqModHandler {class this} {
set this [GCObject::constructor $class $this]
$this giveWmtkInfo 1
$this reqModInfoSet [List new]
# Start constructor user section
ClassMaker::extend SelectModuleDialog SelectReqModDialog \
"requiringObj"
$this selModDlg [SelectReqModDialog new .main.${this}selModDlg \
-autoPopDown no \
-okPressed "$this handleSelModDlgOkPressed" \
-cancelPressed "$this handleSelModDlgCancelPressed" \
-helpPressed ".main helpOnName addRequirements"]
# End constructor user section
return $this
}
method AddReqModHandler::destructor {this} {
# Start destructor user section
# End destructor user section
}
proc AddReqModHandler::global {} {
global AddReqModHandler::instance
if {${AddReqModHandler::instance} == ""} {
set AddReqModHandler::instance [AddReqModHandler new]
}
return ${AddReqModHandler::instance}
}
method AddReqModHandler::addRequiredModules {this obj {giveWmtkInfo 1}} {
if {[$obj select-state] != "on"} {
if $giveWmtkInfo {
wmtkinfo "No requirements added for module\
'[$obj longName]' with select-state 'off'."
}
return
}
# (re)initialize
[$this reqModInfoSet] contents ""
$this startingObj $obj
$this giveWmtkInfo $giveWmtkInfo
$this addToReqModInfoSet $obj
$this handleNextReqMod
}
method AddReqModHandler::addToReqModInfoSet {this requiringObj} {
set requirements [$requiringObj getRequiredElements]
set reqModules [split [lindex $requirements 0]]
set reqModuleTypes [split [lindex $requirements 1]]
foreach moduleName $reqModules {
set reqModInfo [RequiredModuleInfo new \
-requiringObj $requiringObj \
-requiredKind "name" \
-requiredMod $moduleName]
$this addReqModInfo $reqModInfo
}
foreach moduleType $reqModuleTypes {
set reqModInfo [RequiredModuleInfo new \
-requiringObj $requiringObj \
-requiredKind "type" \
-requiredMod $moduleType]
$this addReqModInfo $reqModInfo
}
}
method AddReqModHandler::handleNextReqMod {this} {
if {[[$this reqModInfoSet] length] == 0} {
if [$this giveWmtkInfo] {
wmtkinfo "All requirements for module\
'[[$this startingObj] longName]' are ok."
}
return
}
set reqModInfo [[$this reqModInfoSet] index 0]
[$this reqModInfoSet] remove 0
set requiringObj [$reqModInfo requiringObj]
set requiredKind [$reqModInfo requiredKind]
set requiredMod [$reqModInfo requiredMod]
set requiredObj [$this getExistingReqMod $requiringObj \
$requiredKind $requiredMod]
if {$requiredObj != ""} {
$this addToReqModInfoSet $requiredObj
$this handleNextReqMod
} else {
set moduleDB [ModuleDB::global]
set modDir [path_name directory [$requiringObj location]]
set filter [SelModFilter new]
$filter $requiredKind $requiredMod
set modPaths [$moduleDB getFilteredModulePaths $modDir $filter]
if {[$modPaths empty] && $modDir != [$moduleDB defaultModDir]} {
set modDir [$moduleDB defaultModDir]
set modPaths [$moduleDB \
getFilteredModulePaths $modDir $filter]
}
if {[$modPaths length] == 1} {
set newObject [lindex [[.main editorArea] insertObjects\
[list [$modPaths index 0]] $requiringObj] 0]
wmtkmessage "Added required module\
'[$newObject longName]'"
$this addToReqModInfoSet $newObject
$this handleNextReqMod
} else {
[$this selModDlg] requiringObj $requiringObj
[$this selModDlg] filter $filter
[$this selModDlg] title \
"Select Module ($requiredKind '$requiredMod')"
[$this selModDlg] popUp $modDir
}
}
}
method AddReqModHandler::getExistingReqMod {this requiringObj reqKind reqMod} {
# requiringObj is the requiring CustModObject
# reqKind is "name" or "type"
# reqMod is the name or the type of a required module
#
[[.main editorArea] getActiveObjectList] foreach obj {
if {$obj == $requiringObj} {
return ""
}
if {[$obj $reqKind] == $reqMod} {
return $obj
}
}
return ""
}
method AddReqModHandler::handleSelModDlgOkPressed {this} {
set selectedModules [[$this selModDlg] getSelectedModules]
if {[llength $selectedModules] != 0} {
set selectedModule [lindex $selectedModules 0]
set requiringObj [[$this selModDlg] requiringObj]
set newObject [lindex [[.main editorArea] insertObjects \
[list $selectedModule] $requiringObj] 0]
wmtkmessage "Added required module '[$newObject longName]'"
$this addToReqModInfoSet $newObject
}
[$this selModDlg] popDown
$this handleNextReqMod
}
method AddReqModHandler::handleSelModDlgCancelPressed {this} {
# First give warning ??
[$this selModDlg] popDown
}
# Do not delete this line -- regeneration end marker
method AddReqModHandler::addReqModInfo {this newReqModInfo} {
[$this reqModInfoSet] append $newReqModInfo
}
method AddReqModHandler::removeReqModInfo {this oldReqModInfo} {
[$this reqModInfoSet] removeValue $oldReqModInfo
}