home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
repnewdial.tcl
< prev
next >
Wrap
Text File
|
1997-11-28
|
12KB
|
413 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)repnewdial.tcl /main/titanic/20
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)repnewdial.tcl /main/titanic/20 28 Nov 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "repdbms.tcl"
require "repository.tcl"
require "repdirbrow.tcl"
# End user added include file section
require "repdbdialo.tcl"
Class RepNewDialog : {RepDbDialog} {
constructor
method destructor
method popUp
method checkName
method ok
method checkOk
method startCreate1
method startCreate2
method startCreate3
method createFinished
method browseDir
method browseExternalDir
attribute goodName
attribute dirBrowser
attribute externalDirBrowser
attribute name
attribute dir
attribute externalDir
}
constructor RepNewDialog {class this name view} {
set this [RepDbDialog::constructor $class $this $name $view]
# Start constructor user section
$this config \
-title "New Repository" \
-okPressed { %this ok } \
-autoPopDown 0 \
-helpPressed { [%this view] helpOnName newRepository }
interface DlgColumn $this.gui {
DlgColumn name {
Label l { text "Corporate Name" }
SingleLineText name {
columnCount 30
}
}
CheckButton setDefault {
label "Make this repository the default repository."
}
DlgColumn dir {
Label l {
text "Directory in which to create repository"
alignment LEFT
horStretchFactor 100
}
DlgRow r {
spaceType NONE
DlgColumn d {
horStretchFactor 100
spaceType EVEN
SingleLineText dir {
columnCount 30
horStretchFactor 100
}
}
DlgColumn b {
horStretchFactor 0
spaceType EVEN
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
}
Label l {
text "User Environment Root directory\
(defaults to repository directory)"
alignment LEFT
horStretchFactor 100
}
DlgRow e {
spaceType NONE
DlgColumn d {
horStretchFactor 100
spaceType EVEN
SingleLineText dir {
columnCount 30
horStretchFactor 100
}
}
DlgColumn b {
horStretchFactor 0
spaceType EVEN
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
}
}
NamedGroup db {
label "Database"
DlgColumn attr { }
}
}
$this.gui.dir.r.b.browse activated "$this browseDir"
$this.gui.dir.e.b.browse activated "$this browseExternalDir"
$this name $this.gui.name.name
$this dir $this.gui.dir.r.d.dir
$this externalDir $this.gui.dir.e.d.dir
if $win95 {
$this createDbInterface $this.gui.db.attr 35
} else {
$this createDbInterface $this.gui.db.attr
}
$this setDbFields
[$this name] textModified "if \[$this checkName] { $this checkOk }"
[$this dir] textModified "$this checkOk"
[$this dbname] text ""
[$this dbname] textModified "$this checkOk"
set rep [[$this view] rep]
set corp [$rep currentCorporate]
if ![$corp isNil] {
[$this dir] text [$corp location]
}
# End constructor user section
return $this
}
method RepNewDialog::destructor {this} {
# Start destructor user section
# End destructor user section
$this RepDbDialog::destructor
}
method RepNewDialog::popUp {this} {
# Enable "Set default..." only if no repositories have been
# created yet. Makes starting the browser during installation
# unnecessary.
#
set rep [[$this view] rep]
set repCount [llength [$rep getAvailableRepositories]]
if {$repCount == 0} {
$this.gui.setDefault state 1
} else {
$this.gui.setDefault state 0
}
$this goodName [[$this name] text]
$this checkOk
$this RepDbDialog::popUp
}
method RepNewDialog::checkName {this} {
set name [[$this name] text]
set curs [[$this name] cursorIndex]
incr curs -1
# Prepend with "x" to prevent Tcl from thinking the name is a number.
if {"x$name" != "x" && ![Repository::goodRepositoryName $name]} {
[$this name] text [$this goodName]
[$this name] cursorIndex $curs
return 0
}
$this goodName $name
return 1
}
method RepNewDialog::checkOk {this} {
if {[string length [[$this name] text]] > 0 &&
[string length [[$this dir] text]] > 0 &&
[string length [[$this dbname] text]] > 0 &&
[$this passwordOk] &&
[$this directoryOk]} {
$this okSensitive 1
} else {
$this okSensitive 0
}
}
method RepNewDialog::ok {this} {
$this busy 1
set rep [[$this view] rep]
# Some sanity checks.
#
if ![$rep checkRepositoryName [[$this name] text]] {
$this busy 0
return
}
if {[string length [[$this name] text]] == 0} {
[$this view] error "No repository name specified."
[$this view] message "Repository not created."
$this busy 0
return
}
set repDir [Repository::expandDirName [[$this dir] text]]
if {[string length $repDir] == 0} {
[$this view] error "No repository directory specified."
[$this view] message "Repository not created."
$this busy 0
return
}
[$this dir] text $repDir
if [file exists $repDir] {
if ![file isdirectory $repDir] {
[$this view] error "Directory '$repDir' is not a directory."
[$this view] message "Repository not created."
$this busy 0
return
}
if ![file writable $repDir] {
[$this view] error "Directory '$repDir' is not writable."
[$this view] message "Repository not created."
$this busy 0
return
}
set createDir 0
} else {
set createDir 1
}
if $createDir {
global classCount
set createdir [$this view].createdir$classCount
incr classCount
set dlg [QuestionDialog new $createdir \
-title "Create Directory" \
-message "Repository directory '$repDir' does not exist.\
\nCreate it?" \
-okPressed "$this startCreate1 1" \
-cancelPressed "$this busy 0; return"]
$dlg delHelpButton
$dlg popUp
return
}
$this startCreate1 0
}
method RepNewDialog::startCreate1 {this makeDir} {
if ![$this getDbFields cmdInfo] {
$this busy 0
return
}
set repDir [[$this dir] text]
if $makeDir {
if [catch {BasicFS::makeDir $repDir} error] {
[$this view] error $error
$this busy 0
return
}
}
set extDir [Repository::expandDirName [[$this externalDir] text]]
[$this externalDir] text $extDir
set corpName [[$this name] text]
set corpDir [location $repDir $corpName]
if {$extDir != "" && $extDir != $corpDir && ![file exists $extDir]} {
set dlg [QuestionDialog new [$this view].createextdir \
-title "Create Directory" \
-message "User environment directory '$extDir' does not exist.\
\nCreate it?" \
-okPressed "$this startCreate2 1" \
-cancelPressed "$this busy 0; return"]
# Might not want to create it now, since this is done on the
# server, while this directory is meant for clients. The
# user environment mechanism will automatically create the
# path when needed anyway.
#
PushButton new $dlg.no \
-label "No" \
-activated "$dlg popDown; $this startCreate2 0"
$dlg delHelpButton
$dlg popUp
return
}
$this startCreate2 0
}
method RepNewDialog::startCreate2 {this makeExtDir} {
if ![$this getDbFields cmdInfo] {
$this busy 0
return
}
if $makeExtDir {
set extDir [[$this externalDir] text]
if [catch {BasicFS::makeDir $extDir} error] {
[$this view] error $error
$this busy 0
return
}
}
$this RepDbDialog::ok "$this startCreate3"
}
method RepNewDialog::startCreate3 {this} {
if ![$this getDbFields cmdInfo] {
$this busy 0
return
}
[[$this view] rep] createRepository "$this createFinished" cmdInfo \
[[$this name] text] \
[[$this dir] text]
$this busy 0
}
method RepNewDialog::createFinished {this exitCode} {
$this busy 0
if {$exitCode == 0} {
$this popDown
[$this view] updateRepositories
# Try to select the new repository.
#
set repName [[$this name] text]
set rep [[$this view] rep]
$rep setCurrent $repName
# Set the fileSystemPath property, if specified.
#
set corp [$rep currentCorporate]
if {![$corp isNil] && [$corp name] == [[$this name] text]} {
set extDir [[$this externalDir] text]
if {$extDir != ""} {
$corp setProperty fileSystemPath $extDir
}
}
# Store the new repository name in the m4env.m4env file at
# corporate level if needed.
#
if [$this.gui.setDefault state] {
[$this view] makeDefault $repName
}
[$this view] selectRepository [[$this name] text]
[$this view] message "Repository created successfully."
} else {
[$this view] message "Repository not created."
}
}
method RepNewDialog::browseDir {this} {
if {[$this dirBrowser] == ""} {
global classCount
set dirbrowser [$this view].dirbrowser$classCount
incr classCount
$this dirBrowser [RepDirBrowser new $dirbrowser 1 0 \
-title "Select Corporate Directory" \
-okPressed "%this handleOk ; [$this dir] text \[%this selected]"]
}
set cur [[$this dir] text]
if {$cur == ""} {
set cur [pwd]
}
set dir [Repository::expandDirName $cur existingDir]
[$this dirBrowser] selected $existingDir
[$this dirBrowser] popUp
}
method RepNewDialog::browseExternalDir {this} {
if {[$this externalDirBrowser] == ""} {
global classCount
set extdirbr [$this view].extdirbr$classCount
incr classCount
$this externalDirBrowser [RepDirBrowser new $extdirbr 1 0 \
-title "Select ExternalFileVersion Root Directory" \
-okPressed \
"%this handleOk ; [$this externalDir] text \[%this selected]"]
}
set dir [[$this externalDir] text]
if {$dir == ""} {
set dir [location [[$this dir] text] [[$this name] text]]
}
[$this externalDirBrowser] selected $dir
[$this externalDirBrowser] popUp
}
# Do not delete this line -- regeneration end marker