home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)lockmanvie.tcl /main/hindenburg/27
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)lockmanvie.tcl /main/hindenburg/27 3 Jun 1997 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
- require "browstable.tcl"
- require "lockbrobje.tcl"
- require "lockbrtabl.tcl"
- require "lockfilter.tcl"
- require "lockfiltdi.tcl"
- require "setlockdia.tcl"
- # End user added include file section
-
- require "reptoolvie.tcl"
-
- Class LockManView : {RepToolView} {
- method destructor
- constructor
- method initialize
- method selectedObjSet
- method selectionChanged
- method update
- method reload
- method getLockLabel
- method getLockDetails
- method removeLocks
- method lockServerNotOperable
- method lockServerRunning
- method setFont
- method getFont
- method fileNew
- method fileDelete
- method fileMakeOperable
- method fileShutdown
- method editSelectAll
- method editDeselectAll
- method editInvertSelection
- method optionsLockFilter
- method helpOnContext
- attribute locksLoaded
- attribute setLockPoppedUp
- attribute lockList
- attribute filterDialog
- attribute setLockDialog
- attribute shutdownDialog
- attribute filter
- }
-
- method LockManView::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this RepToolView::destructor
- }
-
- constructor LockManView {class this name} {
- set this [RepToolView::constructor $class $this $name replock]
-
- $this setTitle "Lock Management" rep_lock_64
- $this firstExposed "$this initialize"
- $this filter [LockFilter new]
- [$this filter] load
- $this setLockPoppedUp 0
-
- [$this rep] quickTimeOut 5000
-
- # Create main interface part.
- #
- interface DlgColumn $this.gui.locks {
- spaceType NONE
- LockBrTable locks {
- columnCount 72
- rowCount 15
- }
- }
- $this lockList $this.gui.locks.locks
- [$this lockList] view $this
- [$this lockList] font [m4_var get M4_font -context replock]
- [$this lockList] selectionChanged "$this selectionChanged"
- [$this lockList] setHeaderLabels \
- {Object Type User Host Pid Date Reason}
-
- return $this
- }
-
- proc LockManView::repToolClass {} {
- return "LockManView"
- }
-
- method LockManView::initialize {this} {
- busy {
- $this viewRefresh
- }
- }
-
- method LockManView::selectedObjSet {this} {
- return [[$this lockList] selectedSet]
- }
-
- method LockManView::selectionChanged {this} {
- $this RepToolView::selectionChanged
-
- set ls [[$this rep] getLockServer 0]
- if ![$ls isNil] {
- catch {$ls disconnect}
- }
- }
-
- method LockManView::update {this} {
- busy {
- $this reload
-
- # To update the "Make Lockserver Operable" menu entry:
- $this selectionChanged
- }
- }
-
- method LockManView::reload {this} {
- set lockList [$this lockList]
-
- $lockList removeAllObjects
- $lockList format
-
- set filter [$this filter]
- set locks [[$this rep] getLocks [$filter description] \
- [$filter lockHanging]]
- if {$locks == "NO_LOCKSERVER"} {
- return
- }
-
- set i 0
- foreach lock [osort type -asc objectId -asc date -int $locks] {
- LockBrObject new $lockList.lock$i $lock \
- -label [$this getLockLabel $lock] \
- -details [$this getLockDetails $lock]
- incr i
- }
- $lockList format
-
- set count [llength $locks]
- if {$count != 1} {
- set s "s"
- } else {
- set s ""
- }
- $this message "Selected $count lock$s."
- }
-
- method LockManView::getLockLabel {this lock} {
- return [[$this rep] describeLock $lock]
- }
-
- method LockManView::getLockDetails {this lock} {
- return [list \
- [$lock type] \
- [$lock user] \
- [$lock host] \
- [$lock pid] \
- [fmtclock [$lock date]] \
- [$lock reason] ]
- }
-
- method LockManView::removeLocks {this locks} {
- global errorCode
- set errorCode 0
-
- set count 0
- foreach lock $locks {
- set n [[$this rep] removeLock $lock]
- if {$n > 0} {
- incr count $n
- }
- }
-
- if {$count > 0} {
- $this message "Removed $count lock[expr {$count == 1 ? "" : "s"}]."
- } else {
- $this message "No locks were removed."
- }
-
- busy { $this viewRefresh }
- }
-
- method LockManView::lockServerNotOperable {this} {
- set ls [[$this rep] getLockServer 0]
- if [$ls isNil] {
- return 0
- }
-
- if [catch {set operable [$ls isOperable]}] {
- return 1
- }
-
- if $operable {
- return 0
- }
- return 1
- }
-
- method LockManView::lockServerRunning {this} {
- set ls [[$this rep] getLockServer 0]
- if [$ls isNil] {
- return 0
- }
- return 1
- }
-
- method LockManView::setFont {this font} {
- [$this lockList] font $font
-
- $this RepToolView::setFont $font
- }
-
- method LockManView::getFont {this} {
- return [[$this lockList] font]
- }
-
- method LockManView::fileNew {this {objectId ""} {clientCtx ""}} {
- if {[$this setLockDialog] == ""} {
- $this setLockDialog [SetLockDialog new $this.setlockdlg $this]
- }
-
- # These are set when called by LockBrTable on which an object was
- # dropped.
- #
- if {$objectId != ""} {
- [$this setLockDialog] setObject $objectId
- }
- if {$clientCtx != ""} {
- [$this setLockDialog] setClient $clientCtx
- }
-
- if ![$this setLockPoppedUp] {
- [$this setLockDialog] popUp
- $this setLockPoppedUp 1
- }
- }
-
- method LockManView::fileDelete {this} {
- foreach obj [[$this lockList] selectedSet] {
- lappend locks [$obj lock]
- }
-
- set cnt [llength $locks]
- if {$cnt == 1} {
- set lock [lindex $locks 0]
- if ![[$this rep] checkLock $lock] {
- busy { $this viewRefresh }
- return
- }
-
- set lock [lindex $locks 0]
- set obj [$lock objectId]
- set type [LockFilter::lock2descType [$lock type]]
- set user [$lock user]
- set host [$lock host]
- set what "the $type lock on\n'[[$this rep] describeLock $lock]'\
- set by '$user' on host '$host'"
- } else {
- set what "these $cnt locks"
- }
-
- set dlg [YesNoWarningDialog new $this.removelockdlg \
- -title "Remove Locks" \
- -message "Do you really want to remove $what?" \
- -yesPressed "busy { $this removeLocks [list $locks] }" \
- -helpPressed "$this helpOnName deleteLock"]
-
- $dlg delCancelButton
- $dlg popUp
- }
-
- method LockManView::fileMakeOperable {this} {
- set ls [[$this rep] getLockServer]
- if [$ls isNil] {
- $this warning "Lockserver is not running."
- return
- }
-
- if [catch {$ls makeOperable} error] {
- $this error $error
- }
- $this selectionChanged
- }
-
- method LockManView::fileShutdown {this {confirm 1}} {
- if $confirm {
- if {[$this shutdownDialog] == ""} {
- $this shutdownDialog [WarningDialog new \
- $this.shutdowndlg-lockserver \
- -title "Shutdown Lockserver" \
- -message "Are you sure you want to shutdown the lockserver?" \
- -okPressed "busy { $this fileShutdown 0 }" \
- -helpPressed "$this helpOnName shutdownLockServer"]
- }
- [$this shutdownDialog] popUp
- return
- }
-
- set ls [[$this rep] getLockServer 0]
- if [$ls isNil] {
- return
- }
- if [catch {$ls shutdown} error] {
- $this error $error
- }
- $this selectionChanged
- }
-
- method LockManView::editSelectAll {this} {
- [$this lockList] selectedSet [[$this lockList] objectSet]
- $this selectionChanged
- }
-
- method LockManView::editDeselectAll {this} {
- [$this lockList] selectedSet {}
- $this selectionChanged
- }
-
- method LockManView::editInvertSelection {this} {
- set selected [[$this lockList] selectedSet]
- set inverse {}
- foreach obj [[$this lockList] objectSet] {
- if {[lsearch $selected $obj] == -1} {
- lappend inverse $obj
- }
- }
- [$this lockList] selectedSet $inverse
- $this selectionChanged
- }
-
- method LockManView::optionsLockFilter {this} {
- if {[$this filterDialog] == ""} {
- $this filterDialog [LockFiltDialog new $this.lockfiltdlg $this]
- }
- [$this filterDialog] popUp
- }
-
- method LockManView::helpOnContext {this} {
- set selected [[$this lockList] selectedSet]
- if ![lempty $selected] {
- $this helpOnName selectedLock
- } else {
- $this helpOnName repToolLockManView
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-