home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
repnewdial.tcl
< prev
next >
Wrap
Text File
|
1996-11-28
|
6KB
|
216 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)repnewdial.tcl /main/hindenburg/13
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)repnewdial.tcl /main/hindenburg/13 28 Nov 1996 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "repdbms.tcl"
require "repository.tcl"
# End user added include file section
require "repdbdialo.tcl"
Class RepNewDialog : {RepDbDialog} {
constructor
method destructor
method popUp
method ok
method checkOk
method startCreate
method createFinished
method browseDir
attribute dirBrowser
attribute name
attribute dir
}
constructor RepNewDialog {class this name view} {
set this [RepDbDialog::constructor $class $this $name $view]
# Start constructor user section
$this config \
-title "New Repository" \
-okPressed { busy { %this ok } } \
-helpPressed { [%this view] helpOnName newRepository }
interface DlgColumn $this.gui {
DlgColumn name {
Label l { text "Corporate Name" }
SingleLineText name {
columnCount 30
}
}
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
}
}
}
}
NamedGroup db {
label "Database"
DlgColumn attr { }
}
}
if !$win95 {
interface DlgColumn $this.gui.dir.r.b {
horStretchFactor 0
spaceType EVEN
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
$this.gui.dir.r.b.browse activated "$this browseDir"
}
$this name $this.gui.name.name
$this dir $this.gui.dir.r.d.dir
$this createDbInterface $this.gui.db.attr
$this setDbFields
[$this name] textModified "$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} {
$this checkOk
$this RepDbDialog::popUp
}
method RepNewDialog::ok {this} {
# Some sanity checks.
#
if {[string length [[$this name] text]] == 0} {
[$this view] error "No repository name specified."
[$this view] message "Repository not created."
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."
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."
return
}
if ![file writable $repDir] {
[$this view] error "Directory '$repDir' is not writable."
[$this view] message "Repository not created."
return
}
} else {
set dlg [QuestionDialog new [$this view].createdir \
-title "Create Directory" \
-message "Directory '$repDir' does not exist.\nCreate it?" \
-okPressed "$this startCreate 1" \
-cancelPressed "return"]
$dlg delHelpButton
$dlg popUp
return
}
$this startCreate 0
}
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 okSensitive 1
} else {
$this okSensitive 0
}
}
method RepNewDialog::startCreate {this makeDir} {
if ![$this getDbFields cmdInfo] {
return
}
if $makeDir {
set repDir [[$this dir] text]
if [catch {BasicFS::makeDir $repDir} error] {
[$this view] error $error
return
}
}
[[$this view] rep] createRepository "$this createFinished" cmdInfo \
[[$this name] text] \
[[$this dir] text]
}
method RepNewDialog::createFinished {this exitCode} {
if {$exitCode == 0} {
# Try to select the new repository.
#
[$this view] updateRepositories
[$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] == ""} {
$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