home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
lockmanvie.tcl
< prev
next >
Wrap
Text File
|
1997-10-08
|
10KB
|
399 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)lockmanvie.tcl /main/titanic/19
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)lockmanvie.tcl /main/titanic/19 8 Oct 1997 Copyright 1997 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 getLockDetails
method removeLocks
method removeLock
method lockServerRunning
method setFont
method getFont
method fileNew
method fileDelete
method editSelectAll
method editDeselectAll
method editInvertSelection
method optionsLockFilter
method helpOnContext
attribute locksLoaded
attribute setLockPoppedUp
attribute badServers
attribute lastSelection
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 [$this getFont]
[$this lockList] selectionChanged "$this selectionChanged"
[$this lockList] setHeaderLabels {
Id Object Type User Host Pid Count Date Reason
}
ViewPopUpMenu new [$this lockList].pop -poppedUp {
[.main lockList].pop entrySet [[.main menuHandler] validPopUpEntrySet]
}
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
}
}
method LockManView::reload {this} {
set lockList [$this lockList]
set currSel {}
foreach s [$lockList selectedSet] {
lappend currSel [$s label]
}
set newSel {}
$lockList removeAllObjects
$lockList format
set filter [$this filter]
set locks [[$this rep] getLocks [$filter description] \
[$filter lockHanging]]
if {$locks == "NO_LOCKSERVER"} {
return
}
set ls [[$this rep] getLockServer 0]
set list [List new]
foreach lock $locks {
set desc [LockDescription new]
if ![catch {$ls describeLock $lock $desc}] {
$list append $desc
}
}
set count 0
foreach desc [osort id -int [$list contents]] {
set label [$desc id]
LockBrObject new $lockList.lock$count $desc \
-label $label \
-details [$this getLockDetails $desc]
if {[lsearch -exact $currSel $label] != -1} {
lappend newSel $lockList.lock$count
}
incr count
}
$lockList format
$lockList selectedSet $newSel
if {$count != 1} {
set s "s"
} else {
set s ""
}
$this message "Found $count lock$s."
}
method LockManView::getLockDetails {this desc} {
set date "-"
if {[$desc date] != 0} {
set date [clock format [$desc date] -format "%b %d, %T"]
}
return [list \
[[$this rep] describeLock [$desc id]] \
[$desc types] \
[$desc user] \
[$desc host] \
[$desc pid] \
[$desc count] \
$date \
[$desc reason] ]
}
method LockManView::removeLocks {this lockIds} {
global errorCode
set errorCode 0
set count 0
foreach lock $lockIds {
set n [$this removeLock $lock]
if {$n > 0} {
incr count $n
}
}
busy { $this viewRefresh }
}
method LockManView::removeLock {this lockId {checkHanging 1}} {
set rep [$this rep]
set ls [$rep getLockServer 0]
set desc [LockDescription new]
if [catch {$ls describeLock $lockId $desc}] {
busy { $this viewRefresh }
return 0
}
if {$checkHanging && ![$rep isHangingLock $lockId]} {
set cnt [$desc count]
if {$cnt == 1} {
set lockDesc "Lock"
set is "is"
set these "this lock"
} else {
set lockDesc "Locks"
set is "are"
set these "these locks"
}
set msg "$lockDesc on '[$rep describeLock $lockId]' $is not hanging.\
\nOwning process [$desc pid] of '[$desc user]'\
is still running on host '[$desc host]',\
\nor was terminated abnormally, possibly due to a system reboot.\
\n\nDo you want to delete $these anyway?"
set dlg [YesNoWarningDialog new $this.removehangingdlg \
-title "Confirm Non-hanging Lock Delete" \
-message $msg \
-yesPressed "busy \"$this removeLock $lockId 0\"" \
-helpPressed "$this helpOnName deleteNonHangingLock"]
$dlg delCancelButton
$dlg popUp
return
}
busy {
set r 0
set count [$desc count]
while {$count > 0} {
incr r [$rep removeLock $lockId 0]
incr count -1
}
$this viewRefresh
set selected {}
foreach sel [$this lastSelection] {
if [isCommand $sel] {
lappend selected $sel
}
}
[$this lockList] selectedSet $selected
$this selectionChanged
}
if {$r > 0} {
$this message "Removed $r lock[expr {$r == 1 ? "" : "s"}]."
} else {
$this message "No locks were removed."
}
return $r
}
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 [m4_var get M4_font -context replock]
}
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} {
$this lastSelection [[$this lockList] selectedSet]
foreach obj [$this lastSelection] {
lappend lockIds [$obj lock]
}
set cnt [llength $lockIds]
if {$cnt == 1} {
set lock [lindex $lockIds 0]
set desc [LockDescription new]
set ls [[$this rep] getLockServer 0]
if [catch { $ls describeLock $lock $desc }] {
busy { $this viewRefresh }
return 0
}
set obj [$desc object]
set type [$desc types]
set user [$desc user]
set host [$desc host]
set cnt [$desc count]
if {$cnt == 1} {
set typeDesc "${type}Lock"
} else {
set typeDesc "$cnt ${type}Locks"
}
set what "the $typeDesc 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 "Confirm Lock Delete" \
-message "Are you sure you want to delete $what?" \
-yesPressed "busy { $this removeLocks [list $lockIds] }" \
-helpPressed "$this helpOnName deleteLock"]
$dlg delCancelButton
$dlg popUp
}
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