home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
repchanged.tcl
< prev
next >
Wrap
Text File
|
1997-10-06
|
9KB
|
358 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)repchanged.tcl /main/titanic/10
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)repchanged.tcl /main/titanic/10 6 Oct 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require "repdbdialo.tcl"
Class RepChangeDialog : {RepDbDialog} {
constructor
method destructor
method setFields
method getFields
method popUp
method checkName
method ok
method checkOk
method shutdownServers
method browseDir
attribute goodName
attribute origName
attribute origDir
attribute nameInDb
attribute serversShutdown
attribute name
attribute dir
attribute moveDir
attribute dirBrowser
}
constructor RepChangeDialog {class this name view} {
set this [RepDbDialog::constructor $class $this $name $view]
# Start constructor user section
set rep [[$this view] rep]
set name [$rep currentName]
$this origName $name
$this config \
-title "Change Repository '$name'" \
-okPressed { busy { %this ok } } \
-autoPopDown 0 \
-helpPressed { [%this view] helpOnName changeRepositoryName }
interface DlgColumn $this.gui {
verStretchFactor 0
NamedGroup change {
label "Change Repository"
DlgColumn c {
verStretchFactor 0
Label nl { text "Name" }
SingleLineText name { }
Label dl {
text "Parent Directory"
alignment LEFT
horStretchFactor 100
}
DlgRow r {
spaceType NONE
DlgColumn d {
spaceType EVEN
horStretchFactor 100
SingleLineText dir {
columnCount 30
horStretchFactor 100
}
}
}
CheckButton move {
label "Move repository directory to correspond with name"
state 1
}
}
}
CheckButton shut {
label "Shutdown dbservers before name change."
state 1
}
NamedGroup db {
label "Database"
DlgColumn attr {
verStretchFactor 0
}
}
}
if !$win95 {
interface DlgColumn $this.gui.change.c.r.b {
spaceType EVEN
horStretchFactor 0
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
$this.gui.change.c.r.b.browse activated "$this browseDir"
}
$this name $this.gui.change.c.name
$this moveDir $this.gui.change.c.move
$this dir $this.gui.change.c.r.d.dir
$this serversShutdown $this.gui.shut
[$this name] text $name
[$this name] textModified "if \[$this checkName] { $this checkOk }"
[$this dir] textModified "$this checkOk"
$this createDbInterface $this.gui.db.attr 30
$this setDbFields
$this setupForPassword
# End constructor user section
return $this
}
method RepChangeDialog::destructor {this} {
# Start destructor user section
# End destructor user section
$this RepDbDialog::destructor
}
method RepChangeDialog::setFields {this} {
set rep [[$this view] rep]
set name [$rep currentName]
set corp [$rep currentCorporate]
if [$corp isNil] {
if ![$rep getServerByName $name serverDef] {
[$this view] message \
"Server definition of server '$name' not found."
return 0
}
set id $serverDef(id)
if ![$rep getInfoFromCmdLine $id $serverDef(cmdline) cmdInfo] {
[$this view] message "Command line of server '$name' not parsed."
return 0
}
# Get uncrypted password from passwordDialog since
# getInfoFromDatabase needs it.
#
if [RepositoryDBMS::hasPassword] {
set pwDialog [[$this view] passwordDialog]
if {$pwDialog != ""} {
set cmdInfo(dbpassword) [$pwDialog plainPassword]
}
}
if ![$rep getInfoFromDatabase cmdInfo $cmdInfo(dbname) repInfo] {
[$this view] message "Database '$cmdInfo(dbname)' not read."
return 0
}
[$this dir] text $repInfo(location)
$this origDir $repInfo(location)
$this nameInDb $repInfo(name)
} else {
[$this dir] text [$corp location]
$this origDir [$corp location]
$this nameInDb [$corp name]
}
return 1
}
method RepChangeDialog::getFields {this cmdInfoRef nameRef dirRef} {
upvar $cmdInfoRef cmdInfo
upvar $nameRef name
upvar $dirRef dir
if ![$this getDbFields cmdInfo] {
return 0
}
set name [[$this name] text]
if {$name == ""} {
[$this view] error "No repository name specified."
return 0
}
set dir [Repository::expandDirName [[$this dir] text]]
if {$dir == ""} {
[$this view] error "No repository directory specified."
return 0
}
return 1
}
method RepChangeDialog::popUp {this} {
if {[$this origDir] == "" && ![$this setFields]} {
return
}
$this goodName [[$this name] text]
$this checkOk
$this RepDbDialog::popUp
}
method RepChangeDialog::checkName {this} {
set name [[$this name] text]
set curs [[$this name] cursorIndex]
incr curs -1
if ![Repository::goodRepositoryName $name] {
[$this name] text [$this goodName]
[$this name] cursorIndex $curs
return 0
}
$this goodName $name
return 1
}
method RepChangeDialog::ok {this {createDir 1}} {
set rep [[$this view] rep]
set name [$this origName]
set dir [$this origDir]
if {[[$this serversShutdown] state] && ![$this shutdownServers]} {
[$this view] message "Repository not changed."
return
}
if ![$this getFields cmdInfo newName newDir] {
[$this view] message "Repository not changed."
$this popDown
return
}
if {$newName == $name} {
set newName ""
} else {
if ![$rep checkRepositoryName $newName] {
return
}
}
if {$newDir == $dir} {
set newDir ""
}
set moveDir [[$this moveDir] state]
if {$newName != "" || $newDir != ""} {
if {$newDir != "" && ![file exists $newDir]} {
if $createDir {
global classCount
set createdir [$this view].createdir$classCount
incr classCount
set dlg [QuestionDialog new $createdir \
-title "Create Directory" \
-message "Parent directory '$newDir' does not\
exist.\nCreate it?" \
-okPressed "BasicFS::makeDir $newDir; $this ok 0" \
-cancelPressed "return"]
$dlg delHelpButton
$dlg popUp
return
}
if ![file exists $newDir] {
[$this view] error "Parent directory '$newDir' does not exist."
return
}
}
$this popDown
if ![$rep changeRepository cmdInfo \
$name $dir $newName $newDir $moveDir] {
[$this view] message "Repository not changed."
return
}
if {$newName != ""} {
# This forces this client's cached corporate object to be
# made out of date. If this is not done, the corporate's
# name() method returns the previously cached name.
#
catch {
set corp [$rep currentCorporate]
if ![$corp isNil] {
$corp setProperty __changeName__ 1
$corp removeProperty __changeName__
}
}
}
} elseif {$moveDir} {
$this popDown
if ![$rep fixRepositoryDir cmdInfo \
$dir $name [$this nameInDb]] {
[$this view] message "Repository not changed."
return
}
} else {
[$this view] warning "Nothing to change."
return
}
if {$newName == ""} {
set name [$this origName]
} else {
set name $newName
}
[$this view] selectRepository ""
[$this view] updateRepositories
[$this view] selectRepository $name
[$this view] message "Changed repository successfully."
}
method RepChangeDialog::checkOk {this} {
if {[string length [[$this name] text]] > 0 &&
[string length [[$this dir] text]] > 0 &&
[$this passwordOk]} {
$this okSensitive 1
} else {
$this okSensitive 0
}
}
method RepChangeDialog::shutdownServers {this} {
set rep [[$this view] rep]
set name [$this origName]
return [$rep shutdownDbServers $name]
}
method RepChangeDialog::browseDir {this} {
if {[$this dirBrowser] == ""} {
global classCount
set dirbrowser [$this view].dirbrowser$classCount
incr classCount
$this dirBrowser [FileChooser new $dirbrowser \
-selectionPolicy BROWSE \
-title "Select Corporate Directory" \
-okPressed "[$this dir] text \[%this directory]"]
[$this dirBrowser] delHelpButton
}
set dir [Repository::expandDirName [[$this dir] text] existingDir]
[$this dirBrowser] selectedSet $dir
[$this dirBrowser] directory $existingDir
[$this dirBrowser] popUp
}
# Do not delete this line -- regeneration end marker