home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
repdbdialo.tcl
< prev
next >
Wrap
Text File
|
1997-11-05
|
12KB
|
435 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)repdbdialo.tcl /main/titanic/10
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)repdbdialo.tcl /main/titanic/10 5 Nov 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "repdbms.tcl"
require "repository.tcl"
require "reppasswor.tcl"
# End user added include file section
require "reptooldia.tcl"
Class RepDbDialog : {RepToolDialog} {
constructor
method destructor
method createDbInterface
method setupForPassword
method popUp
method ok
method passwordOk
method directoryOk
method getDbFields
method setDbFields
method browseDbDirectory
method setDbDirectory
method changePassword
method passwordChanged
attribute dbname
attribute dbuser
attribute dbpassword
attribute dbdirectory
attribute dbdirbrowse
attribute dbserver
attribute dbhost
attribute plainPassword
attribute cryptedPassword
attribute passwordButton
}
constructor RepDbDialog {class this name view} {
set this [RepToolDialog::constructor $class $this $name $view]
# Start constructor user section
# End constructor user section
return $this
}
method RepDbDialog::destructor {this} {
# Start destructor user section
# End destructor user section
$this RepToolDialog::destructor
}
method RepDbDialog::createDbInterface {this parent {fieldWidth 25}} {
interface DlgRow $parent.name {
verStretchFactor 0
Label l { text "Name" }
SingleLineText name {
text ""
verStretchFactor 0
}
}
if {[RepositoryDBMS::shortName] == "ora"} {
$parent.name.l text "Connect String"
}
$this dbname $parent.name.name
[$this dbname] columnCount $fieldWidth
if [RepositoryDBMS::hasDirectory] {
interface DlgRow $parent.dir {
verStretchFactor 0
Label l {
text "Directory"
justification CENTER
}
DlgRow r {
verStretchFactor 0
spaceType NONE
horStretchFactor 0
PushButton browse { label "Browse..." }
SingleLineText dir {
text ""
justification CENTER
horStretchFactor 100
}
}
}
$this dbdirectory $parent.dir.r.dir
$this dbdirbrowse $parent.dir.r.browse
[$this dbdirectory] columnCount $fieldWidth
[$this dbdirectory] textModified "$this checkOk"
[$this dbdirbrowse] activated "$this browseDbDirectory"
}
if [RepositoryDBMS::hasUser] {
interface DlgRow $parent.user {
verStretchFactor 0
Label l { text "User" }
SingleLineText user {
text ""
verStretchFactor 0
}
}
$this dbuser $parent.user.user
[$this dbuser] columnCount $fieldWidth
}
if [RepositoryDBMS::hasPassword] {
interface DlgRow $parent.password {
verStretchFactor 0
Label l {
text "Password"
justification CENTER
}
DlgRow row {
verStretchFactor 0
spaceType NONE
horStretchFactor 0
PushButton b { label "Enter..." }
SingleLineText password {
editable 0
text ""
justification CENTER
verStretchFactor 0
}
}
}
$this dbpassword $parent.password.row.password
[$this dbpassword] columnCount $fieldWidth
$this passwordButton $parent.password.row.b
[$this passwordButton] activated "$this changePassword"
$this passwordChanged
}
if [RepositoryDBMS::hasHost] {
interface DlgRow $parent.host {
verStretchFactor 0
Label l { text "Host" }
SingleLineText host {
text ""
verStretchFactor 0
}
}
$this dbhost $parent.host.host
[$this dbhost] columnCount $fieldWidth
}
if [RepositoryDBMS::hasServer] {
interface DlgRow $parent.server {
verStretchFactor 0
Label l { text "Server" }
SingleLineText server {
text ""
verStretchFactor 0
}
}
$this dbserver $parent.server.server
[$this dbserver] columnCount $fieldWidth
}
}
method RepDbDialog::setupForPassword {this} {
[$this dbname] editable 0
if [RepositoryDBMS::hasDirectory] {
[$this dbdirectory] editable 0
[$this dbdirbrowse] sensitive 0
}
if [RepositoryDBMS::hasUser] {
[$this dbuser] editable 0
}
if [RepositoryDBMS::hasHost] {
[$this dbhost] editable 0
}
if [RepositoryDBMS::hasServer] {
[$this dbserver] editable 0
}
}
method RepDbDialog::popUp {this} {
$this passwordChanged
$this RepToolDialog::popUp
}
method RepDbDialog::passwordOk {this} {
if [RepositoryDBMS::hasPassword] {
if {[$this plainPassword] == ""} {
return 0
}
}
return 1
}
method RepDbDialog::directoryOk {this} {
if [RepositoryDBMS::hasDirectory] {
if {[[$this dbdirectory] text] == ""} {
return 0
}
}
return 1
}
method RepDbDialog::ok {this continueScript {createDir 0}} {
if [RepositoryDBMS::hasDirectory] {
if ![$this getDbFields cmdInfo] {
$this busy 0
return 0
}
set dbDir $cmdInfo(dbdir)
if $createDir {
if [catch {BasicFS::makeDir $dbDir} error] {
$this busy 0
error $error
return
}
eval $continueScript
} elseif ![file exists $dbDir] {
global classCount
set createdir [$this view].createdir$classCount
incr classCount
set dlg [QuestionDialog new $createdir \
-title "Create Directory" \
-message "Database directory '$dbDir' does not exist.\
\nCreate it?" \
-okPressed "$this RepDbDialog::ok \"$continueScript\" 1" \
-cancelPressed "$this busy 0; return"]
$dlg delHelpButton
$dlg popUp
} else {
eval $continueScript
}
} else {
eval $continueScript
}
}
method RepDbDialog::getDbFields {this cmdInfoRef {requirePassword 1}} {
upvar $cmdInfoRef cmdInfo
set cmdInfo(dbname) [[$this dbname] text]
if {[string length $cmdInfo(dbname)] == 0} {
[$this view] error "No database name specified."
return 0
}
if [RepositoryDBMS::hasUser] {
set cmdInfo(dbuser) [[$this dbuser] text]
}
if [RepositoryDBMS::hasPassword] {
set cmdInfo(dbpassword) ""
if {[$this plainPassword] != ""} {
set cmdInfo(dbpassword) [$this plainPassword]
}
set cmdInfo(dbcryptedpassword) ""
if {[$this cryptedPassword] != ""} {
set cmdInfo(dbcryptedpassword) [$this cryptedPassword]
}
if {$requirePassword && $cmdInfo(dbpassword) == ""} {
[$this view] error "No password specified."
return 0
}
}
if [RepositoryDBMS::hasDirectory] {
set cmdInfo(dbdir) [Repository::expandDirName \
[[$this dbdirectory] text]]
}
if [RepositoryDBMS::hasServer] {
set cmdInfo(dbserver) [[$this dbserver] text]
}
if [RepositoryDBMS::hasHost] {
set cmdInfo(dbhost) [[$this dbhost] text]
}
# Allow empty values for fields other than name. Assume
# dbtool knows proper default.
#
return 1
}
method RepDbDialog::setDbFields {this} {
set rep [[$this view] rep]
set name [$rep currentName]
set corp [$rep currentCorporate]
if ![$corp isNil] {
[$this dbname] text [$corp databaseName]
if [RepositoryDBMS::hasDirectory] {
[$this dbdirectory] text [$corp databaseDirectory]
}
if [RepositoryDBMS::hasUser] {
[$this dbuser] text [$corp databaseUser]
}
if [RepositoryDBMS::hasPassword] {
if {[$this plainPassword] == ""} {
$this cryptedPassword [$corp databasePassword]
regsub -all {.} [$this cryptedPassword] {*} hiddenPassword
} else {
$this cryptedPassword [ORB::cryptPassword [$this plainPassword]]
regsub -all {.} [$this plainPassword] {*} hiddenPassword
}
[$this dbpassword] text $hiddenPassword
}
if [RepositoryDBMS::hasHost] {
[$this dbhost] text [$corp databaseHost]
}
if [RepositoryDBMS::hasServer] {
[$this dbserver] text [$corp databaseServer]
}
} elseif {$name != ""} {
if [$rep getServerByName $name serverDef] {
set cmdLine $serverDef(cmdline)
if [$rep getInfoFromCmdLine $serverDef(id) $cmdLine cmdInfo] {
[$this dbname] text $cmdInfo(dbname)
if [RepositoryDBMS::hasDirectory] {
[$this dbdirectory] text $cmdInfo(dbdir)
}
if [RepositoryDBMS::hasUser] {
[$this dbuser] text $cmdInfo(dbuser)
}
if [RepositoryDBMS::hasPassword] {
if {[$this plainPassword] == ""} {
if [string length $cmdInfo(dbpassword)] {
$this plainPassword $cmdInfo(dbpassword)
$this cryptedPassword [ORB::cryptPassword \
[$this plainPassword]]
regsub -all {.} [$this plainPassword] {*} \
hiddenPassword
} elseif [string length $cmdInfo(dbcryptedpassword)] {
$this plainPassword ""
$this cryptedPassword $cmdInfo(dbcryptedpassword)
regsub -all {.} [$this cryptedPassword] {*} \
hiddenPassword
}
} else {
$this cryptedPassword [ORB::cryptPassword \
[$this plainPassword]]
regsub -all {.} [$this plainPassword] {*} \
hiddenPassword
}
[$this dbpassword] text $hiddenPassword
}
if [RepositoryDBMS::hasHost] {
[$this dbhost] text $cmdInfo(dbhost)
}
if [RepositoryDBMS::hasServer] {
[$this dbserver] text $cmdInfo(dbserver)
}
} else {
[$this dbname] text <unknown>
if [RepositoryDBMS::hasDirectory] {
[$this dbdirectory] text <unknown>
}
if [RepositoryDBMS::hasUser] {
[$this dbuser] text <unknown>
}
if [RepositoryDBMS::hasPassword] {
[$this dbpassword] text <unknown>
}
if [RepositoryDBMS::hasHost] {
[$this dbhost] text <unknown>
}
if [RepositoryDBMS::hasServer] {
[$this dbserver] text <unknown>
}
}
}
}
}
method RepDbDialog::browseDbDirectory {this} {
set dlg [$this view].dbdirbrowser
if ![isCommand $dlg] {
RepDirBrowser new $dlg 1 0 \
-title "Select Database Directory" \
-okPressed "%this handleOk ; $this setDbDirectory \[%this selected]"
}
$dlg selected [[$this dbdirectory] text]
$dlg popUp
}
method RepDbDialog::setDbDirectory {this dir} {
[$this dbdirectory] text $dir
$this checkOk
}
method RepDbDialog::changePassword {this} {
[$this view] changePassword "$this passwordChanged"
}
method RepDbDialog::passwordChanged {this} {
if ![RepositoryDBMS::hasPassword] {
return
}
set dlg [[$this view] passwordDialog]
if {$dlg != ""} {
$this plainPassword [$dlg plainPassword]
$this cryptedPassword [$dlg cryptedPassword]
regsub -all {.} [$this plainPassword] {*} hiddenPassword
[$this dbpassword] text $hiddenPassword
} else {
[$this dbpassword] text ""
}
$this checkOk
}
# Do not delete this line -- regeneration end marker