home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
repchanged.tcl
< prev
next >
Wrap
Text File
|
1996-11-29
|
9KB
|
335 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)repchanged.tcl /main/hindenburg/19
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)repchanged.tcl /main/hindenburg/19 29 Nov 1996 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 ok
method checkOk
method shutdownServers
method browseDir
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 serversShutdown 0
$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
}
}
}
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"
}
PushButton new $this.shutdown \
-label "Shutdown" \
-activated "busy { $this shutdownServers }"
$this name $this.gui.change.c.name
$this moveDir $this.gui.change.c.move
$this dir $this.gui.change.c.r.d.dir
[$this name] text $name
[$this name] textModified "$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 serversShutdown 0
$this checkOk
$this RepDbDialog::popUp
}
method RepChangeDialog::ok {this {createDir 1}} {
set rep [[$this view] rep]
set name [$this origName]
set dir [$this origDir]
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 {
set dlg [QuestionDialog new [$this view].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 serversShutdown] && [$this passwordOk]} {
$this okSensitive 1
} else {
$this okSensitive 0
}
}
method RepChangeDialog::shutdownServers {this} {
set rep [[$this view] rep]
set name [$this origName]
if [$rep shutdownDbServers $name] {
$this serversShutdown 1
} else {
$this serversShutdown 0
}
$this checkOk
}
method RepChangeDialog::browseDir {this} {
if {[$this dirBrowser] == ""} {
$this dirBrowser [FileChooser new [$this view].dirbrowser \
-selectionPolicy SINGLE \
-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