home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)repdbdialo.tcl /main/hindenburg/10
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)repdbdialo.tcl /main/hindenburg/10 28 Nov 1996 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 passwordOk
- method getDbFields
- method setDbFields
- method changePassword
- method passwordChanged
- attribute dbname
- attribute dbuser
- attribute dbpassword
- attribute dbdirectory
- 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 {
- Label l { text "Name" }
- SingleLineText name { }
- }
- 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 {
- Label l { text "Directory" }
- SingleLineText dir { }
- }
- $this dbdirectory $parent.dir.dir
- [$this dbdirectory] columnCount $fieldWidth
- }
-
- if [RepositoryDBMS::hasUser] {
- interface DlgRow $parent.user {
- Label l { text "User" }
- SingleLineText user { }
- }
- $this dbuser $parent.user.user
- [$this dbuser] columnCount $fieldWidth
- }
-
- if [RepositoryDBMS::hasPassword] {
- interface DlgRow $parent.password {
- Label l {
- text "Password"
- justification CENTER
- }
- DlgRow row {
- spaceType NONE
- horStretchFactor 0
- PushButton b { label "Enter..." }
- SingleLineText password {
- editable 0
- 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 {
- Label l { text "Host" }
- SingleLineText host { }
- }
- $this dbhost $parent.host.host
- [$this dbhost] columnCount $fieldWidth
- }
-
- if [RepositoryDBMS::hasServer] {
- interface DlgRow $parent.server {
- Label l { text "Server" }
- SingleLineText server { }
- }
- $this dbserver $parent.server.server
- [$this dbserver] columnCount $fieldWidth
- }
- }
-
- method RepDbDialog::setupForPassword {this} {
- [$this dbname] editable 0
-
- if [RepositoryDBMS::hasDirectory] {
- [$this dbdirectory] editable 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::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)
- }
- }
- }
- }
- }
-
- 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
-
-