home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
corpmanvie.tcl
< prev
next >
Wrap
Text File
|
1997-11-19
|
18KB
|
691 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)corpmanvie.tcl /main/titanic/20
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)corpmanvie.tcl /main/titanic/20 19 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require "repdbms.tcl"
require "repinfosec.tcl"
require "repnewdial.tcl"
require "repdeleted.tcl"
require "repchanged.tcl"
require "csentrydia.tcl"
require "repoptimdi.tcl"
require "repbackupd.tcl"
require "represtore.tcl"
require "repprojbro.tcl"
require "repmodelbr.tcl"
# End user added include file section
require "reptoolvie.tcl"
Class CorpManView : {RepToolView} {
method destructor
constructor
method initialize
method selectedObjSet
method selectionChanged
method update
method updateRepositories
method selectRepository
method setRepository
method reload
method makeDefault
method setFont
method getFont
method validCorporate
method fileNew
method fileDelete
method fileOpen
method fileChangeName
method fileChangeServerEntry
method fileChangeProjectStatus
method fileChangeModelReservation
method fileMakeDefault
method fileOptimize
method fileBackup
method fileRestore
method optionsArchiveCmd
method optionsUnarchiveCmd
method helpOnContext
attribute selectError
attribute repositories
attribute info
attribute infoSection
attribute newDialog
attribute deleteDialog
attribute changeDialog
attribute changeEntryDialog
attribute optimDialog
attribute restoreModelDialog
attribute restoreProjectDialog
attribute restoreCorporateDialog
attribute backupModelDialog
attribute backupProjectDialog
attribute backupCorporateDialog
attribute archive_cmdContexts
attribute unarchive_cmdContexts
}
method CorpManView::destructor {this} {
# Start destructor user section
# End destructor user section
$this RepToolView::destructor
}
constructor CorpManView {class this name} {
set this [RepToolView::constructor $class $this $name repcorp]
$this setTitle "Corporate Management" rep_corp_64
$this infoSection [RepInfoSection new $this]
$this firstExposed "$this initialize"
# Create main interface part.
#
interface DlgColumn $this.gui.col {
HorSeparator h {
}
DlgRow reps {
spaceType NONE
verStretchFactor 0
verShrinkFactor 0
Label l { text "Repository:" }
OptionMenu reps {
horStretchFactor 100
justification CENTER
entrySet "<none>"
}
}
MultiLineText info {
verStretchFactor 100
verShrinkFactor 100
editable 0
columnCount 80
rowCount 24
}
}
$this repositories $this.gui.col.reps.reps
$this info $this.gui.col.info
[$this info] font [$this getFont]
[$this repositories] selectionChanged "$this selectionChanged"
return $this
}
proc CorpManView::repToolClass {} {
return "CorpManView"
}
method CorpManView::initialize {this} {
busy {
set selected "<none>"
# No level path should be set at this point.
#
catch {set cc [ClientContext::global]}
catch {set cc [ClientContext::global]}
# Set the client context based on passed levelPath options.
# Be careful about finding the selected repository name.
#
if {[$this levelPathIds] != ""} {
if [catch {
$cc setLevelIds [$this levelPathIds]
set corp [$cc currentCorporate]
if ![$corp isNil] {
set selected [$corp name]
}
} error] {
$this warning $error
}
} elseif {[$this levelPath] != ""} {
if [catch {$cc setLevelPath [$this levelPath]} error] {
$this warning $error
}
regexp {^/([^/]*)} [$this levelPath] dummy selected
}
# Select the repository.
#
[$this repositories] entrySet \
[concat <none> [[$this rep] getAvailableRepositories]]
[$this repositories] selected $selected
$this selectionChanged
}
}
method CorpManView::selectedObjSet {this} {
set sel [[$this repositories] selected]
if {$sel == "<none>"} {
return ""
}
return $sel
}
method CorpManView::selectionChanged {this} {
busy {
$this newDialog ""
$this deleteDialog ""
$this changeDialog ""
$this changeEntryDialog ""
$this optimDialog ""
$this backupCorporateDialog ""
$this backupProjectDialog ""
$this backupModelDialog ""
$this restoreCorporateDialog ""
$this restoreProjectDialog ""
$this restoreModelDialog ""
$this reload
$this setTitle [[$this repositories] selected]
# Can only call module stuff after m4path has been set.
#
set archiveContexts {"" corporate}
if [$this projectsEnabled] {
lappend archiveContexts project
}
if [$this modelsEnabled] {
lappend archiveContexts model
}
$this setContexts archive_cmd $archiveContexts
$this setContexts unarchive_cmd $archiveContexts
$this RepToolView::selectionChanged
}
}
method CorpManView::update {this} {
busy {
$this updateRepositories
$this reload
}
}
method CorpManView::updateRepositories {this} {
set previousName [[$this repositories] selected]
[$this repositories] entrySet \
[concat <none> [[$this rep] getAvailableRepositories]]
if {$previousName != ""} {
[$this repositories] selected $previousName
}
}
method CorpManView::selectRepository {this name} {
if {$name == ""} {
[$this repositories] selected "<none>"
} else {
[$this repositories] selected $name
}
$this selectionChanged
}
method CorpManView::setRepository {this name} {
[$this rep] setCurrent ""
set error ""
if {$name != "<none>"} {
if [catch {[$this rep] setCurrent $name} error] {
$this message "Cannot access repository '$name'."
$this contextError $error
} else {
$this message "Selected repository '$name'."
$this contextError ""
}
if {$error != 1} {
$this error $error
return 0
}
catch {[$this menuHandler] levelChanged}
catch {[$this menuHandler] setCurrentContext}
return 1
} else {
$this message "No repository selected."
$this contextError ""
}
return 0
}
method CorpManView::reload {this} {
set sel [[$this repositories] selected]
$this setRepository $sel
set name [[$this rep] currentName]
set corp [[$this rep] currentCorporate]
if [$corp isNil] {
if {$name == "" || $name == "<none>"} {
[$this info] text ""
return
}
}
# Setup default values.
#
set nameInDb ""
set locationInDb ""
set location ""
set fsPath "UNKNOWN"
set owner ""
set objectId ""
set release ""
set dbVendor ""
set dbDir ""
set dbName ""
set dbUser ""
set dbPassword ""
set dbHost ""
set dbServer ""
set serverId ""
set serverVersion ""
set serverPolicy ""
set serverProtocol ""
set serverExecutable ""
set serverCmdLine ""
set serverHost ""
# Retrieve all info that can be gotten.
#
if [$corp isNil] {
set gotServer [[$this rep] getServerByName $name serverDef]
if $gotServer {
set gotOpts [[$this rep] getInfoFromCmdLine $serverDef(id) \
$serverDef(cmdline) \
cmdLine]
} else {
set gotOpts 0
}
# Get uncrypted password from passwordDialog since
# getInfoFromDatabase needs it.
#
if [RepositoryDBMS::hasPassword] {
set pwDialog [$this passwordDialog]
if {$pwDialog != ""} {
set cmdLine(dbpassword) [$pwDialog plainPassword]
}
}
if $gotOpts {
set gotDb [[$this rep] getInfoFromDatabase \
cmdLine $cmdLine(dbname) dbInfo]
} else {
set gotDb 0
}
if $gotDb {
set nameInDb $dbInfo(name)
set locationInDb [path_name concat $dbInfo(location) $nameInDb]
set location $locationInDb
set owner [BasicFS::owner $locationInDb]
if {$owner == "everyone"} {
set owner ""
}
set objectId $dbInfo(id)
set release $dbInfo(productRelease)
}
if $gotOpts {
set dbDir $cmdLine(dbdir)
set dbName $cmdLine(dbname)
set dbUser $cmdLine(dbuser)
set dbPassword [ORB::cryptPassword $cmdLine(dbpassword)]
set dbHost $cmdLine(dbhost)
set dbServer $cmdLine(dbserver)
}
if $gotServer {
set serverId $serverDef(id)
set serverVersion $serverDef(version)
set serverPolicy $serverDef(policy)
set serverProtocol $serverDef(protocol)
set serverExecutable $serverDef(executable)
set serverCmdLine $serverDef(cmdline)
set serverHost $serverDef(host)
}
} else {
set gotServer [[$this rep] getServerByObject [$corp identity] serverDef]
set gotOpts 1
set gotDb 1
set nameInDb [$corp name]
set locationInDb [path_name concat [$corp location] $nameInDb]
set location [path_name concat [$corp location] $name]
set fsPath [$corp getPropertyValue fileSystemPath]
set owner [[$this rep] currentOwner]
set objectId [$corp identity]
set release [$corp productRelease]
switch -- [$corp databaseVendor] {
informix { set dbVendor "Informix" }
oracle { set dbVendor "Oracle" }
sqlany { set dbVendor "Sybase SQL Anywhere" }
}
set dbDir [$corp databaseDirectory]
set dbName [$corp databaseName]
set dbUser [$corp databaseUser]
set dbPassword [$corp databasePassword]
set dbHost [$corp databaseHost]
set dbServer [$corp databaseServer]
if $gotServer {
set serverId $serverDef(id)
set serverVersion $serverDef(version)
set serverPolicy $serverDef(policy)
set serverProtocol $serverDef(protocol)
set serverExecutable $serverDef(executable)
set serverCmdLine $serverDef(cmdline)
set serverHost $serverDef(host)
}
}
set info [$this infoSection]
$info clear
# Repository info.
#
set locationExists ""
if {$location != "<unknown>"} {
if ![file exists $location] {
set locationExists " (NOT FOUND)"
}
}
set locationInDbExists ""
if {$locationInDb != "<unknown>"} {
if ![file exists $locationInDb] {
set locationInDbExists " (NOT FOUND)"
}
}
$info addHeader "Repository"
$info addItem "Name" $name
if {$location != ""} {
$info addItem "Directory" ${location}${locationExists}
}
if {$locationInDb != ""} {
if {$location != $locationInDb} {
$info addItem "Directory In DB" ${locationInDb}${locationInDbExists}
}
}
if {$owner != ""} {
$info addItem "Owned By User" $owner
}
if {$objectId != ""} {
$info addItem "Identity" $objectId
}
if {$fsPath != "UNKNOWN"} {
$info addItem "User Environment Root" $fsPath
}
if {$release != ""} {
$info addItem "Version" $release
}
# Database info.
#
if $gotDb {
set dbNotFound ""
} else {
if {$dbName == ""} {
set dbNotFound "(UNKNOWN)"
} else {
set dbNotFound " (NOT FOUND)"
}
}
$info addHeader "Database"
if {$dbVendor != ""} {
$info addItem "Vendor" $dbVendor
}
if {[RepositoryDBMS::shortName] == "ora"} {
set label "Connect String"
} else {
set label "Name"
}
$info addItem $label "${dbName}${dbNotFound}"
if [RepositoryDBMS::hasDirectory] {
if {$dbDir != ""} {
$info addItem "Directory" $dbDir
}
}
if [RepositoryDBMS::hasUser] {
if {$dbUser != ""} {
$info addItem "User" $dbUser
}
}
if [RepositoryDBMS::hasPassword] {
if {$dbPassword != ""} {
$info addItem "Password" $dbPassword
}
}
if [RepositoryDBMS::hasHost] {
if {$dbHost != ""} {
$info addItem "Host" $dbHost
}
}
if [RepositoryDBMS::hasServer] {
if {$dbServer != ""} {
$info addItem "Server" $dbServer
}
}
# Server Entry info.
#
$info addHeader "Server Definition"
$info addItem "Implementation Id" ${serverId}.${serverVersion}
$info addItem "Policy" $serverPolicy
$info addItem "Protocol" $serverProtocol
$info addItem "Executable Path" $serverExecutable
$info addItem "Command Line" $serverCmdLine
$info addItem "Host" $serverHost
$info format
[$this info] text [$info contents]
}
method CorpManView::setFont {this font} {
[$this info] font $font
$this RepToolView::setFont $font
}
method CorpManView::getFont {this} {
return [m4_var get M4_font -context repcorp]
}
method CorpManView::makeDefault {this repName} {
set m4env [path_name concat \
[location [m4_var get M4_home] etc] m4env m4env]
set m4add "M4_levelpath=/$repName;RW\n"
if [file exists $m4env] {
set m4old [BasicFS::readFile $m4env]
if ![regsub {M4_levelpath=[^;]*;} $m4old \
"M4_levelpath=/$repName;" m4new] {
# Not present yet, it must be added.
#
set m4new $m4add$m4new
}
# Remove any existing levelpath with ids, since it does
# no longer correspond with the new corporate object.
#
regsub "M4_levelpath_ids=\[^;]*;\[RP]\[WO]\[\n]" $m4new "" m4new
} else {
set m4new $m4add
}
BasicFS::writeFile $m4env $m4new
}
method CorpManView::validCorporate {this} {
set corp [[$this rep] currentCorporate]
if [$corp isNil] {
return 0
}
return 1
}
method CorpManView::fileNew {this} {
if {[$this newDialog] == ""} {
$this newDialog [RepNewDialog new $this.repnewdlg $this]
}
[$this newDialog] popUp
}
method CorpManView::fileDelete {this} {
if {[$this deleteDialog] == ""} {
$this deleteDialog [RepDeleteDialog new $this.repdeldlg $this]
}
[$this deleteDialog] popUp
}
method CorpManView::fileOpen {this} {
$this message "Starting browser..."
SystemUtilities::fork otk desk -c [get_comm_name]
}
method CorpManView::fileChangeName {this} {
if {[$this changeDialog] == ""} {
$this changeDialog [RepChangeDialog new $this.repchangedlg $this]
}
[$this changeDialog] popUp
}
method CorpManView::fileChangeServerEntry {this} {
if {[$this changeEntryDialog] == ""} {
set rep [$this rep]
set corp [$rep currentCorporate]
if [$corp isNil] {
if [$rep getServerByName [$rep currentName] serverDef] {
set fullId $serverDef(fullId)
} else {
$this error "Could not find server definition for\
'[$rep currentName]'."
return
}
} else {
set list [ORB::decodeObjectId [$corp identity]]
set fullId [ORB::makeImplemId [lindex $list 1] [lindex $list 2]]
}
set name entrydlg-[[$this rep] currentName]
$this changeEntryDialog [CSEntryDialog new \
$this.$name $this $fullId "" \
-helpPressed "$this helpOnName changeRepositoryEntry"]
[$this changeEntryDialog] okPressed {
%this ok
[%this view] selectionChanged
}
}
[$this changeEntryDialog] popUp
}
method CorpManView::fileChangeProjectStatus {this} {
set dlg $this.projectbrowser
if ![isCommand $dlg] {
RepProjBrowser new $dlg $this
$dlg delCancelButton
}
$dlg popUp
}
method CorpManView::fileChangeModelReservation {this} {
set dlg $this.modelbrowser
if ![isCommand $dlg] {
RepModelBrowser new $dlg $this
$dlg delCancelButton
}
$dlg popUp
}
method CorpManView::fileMakeDefault {this} {
set repName [[$this rep] currentName]
global classCount
set makeDefault $this.makedefault$classCount
incr classCount
set dlg [QuestionDialog new $makeDefault \
-title "Set Default Repository" \
-message "Should the selected repository '$repName' be made the default\
repository?\nThis will write the line\
'M4_levelpath=/$repName;RW' to the m4env.m4env file on\
corporate level." \
-okPressed "$this makeDefault $repName"]
$dlg delHelpButton
$dlg popUp
}
method CorpManView::fileOptimize {this} {
if {[$this optimDialog] == ""} {
$this optimDialog [RepOptimDialog new $this.repoptimdlg $this]
}
[$this optimDialog] popUp
}
method CorpManView::fileBackup {this object} {
set cap [string toupper [string index $object 0]][string \
range $object 1 end]
set dlg backup${cap}Dialog
if {[$this $dlg] == ""} {
$this $dlg [RepBackupDialog new $this.$dlg $this $object]
}
[$this $dlg] popUp
}
method CorpManView::fileRestore {this object} {
set cap [string toupper [string index $object 0]][string \
range $object 1 end]
set dlg restore${cap}Dialog
if {[$this $dlg] == ""} {
$this $dlg [RepRestoreDialog new $this.$dlg $this $object]
}
[$this $dlg] popUp
}
method CorpManView::optionsArchiveCmd {this} {
$this createBox archive_cmd 0
}
method CorpManView::optionsUnarchiveCmd {this} {
$this createBox unarchive_cmd 0
}
method CorpManView::helpOnContext {this} {
$this helpOnName repToolCorpManView
}
# Do not delete this line -- regeneration end marker