home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
editpastec.tcl
< prev
next >
Wrap
Text File
|
1996-11-05
|
6KB
|
243 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)editpastec.tcl /main/hindenburg/5
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)editpastec.tcl /main/hindenburg/5 5 Nov 1996 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require "undocomman.tcl"
Class EditPasteCmd : {UndoCommand} {
constructor
method destructor
method do
method redo
method undo
method doCut
method undoCut
method addDeselected
method removeDeselected
method addSource
method removeSource
attribute operation
attribute deselectedSet
attribute sourceObj
attribute sourceSet
}
constructor EditPasteCmd {class this name} {
set this [UndoCommand::constructor $class $this $name]
$this deselectedSet [List new]
$this sourceSet [List new]
# Start constructor user section
# End constructor user section
return $this
}
method EditPasteCmd::destructor {this} {
# Start destructor user section
# End destructor user section
$this UndoCommand::destructor
}
method EditPasteCmd::do {this} {
busy {
set currentObj [.main currentObj]
if {! [isCommand $currentObj]} {
set currentObj [lindex [[.main treeView] rootSet] 0]
}
$this currentObj $currentObj
# DocGenerator requires the ClientContext
# to be at least at Config level...
$this validAfterLevelChange \
[expr 1 - [[$currentObj browsUiObj] isA Document]]
if {! [[.main treeView] requestClipboardValue]} {
$this currentObj ""
wmtkinfo "Can not paste because clipboard is empty"
}
}
}
method EditPasteCmd::redo {this} {
if {! [isCommand [$this currentObj]]} {
return
}
set errorStack ""
busy {
if {"[$this operation]" == "cut"} {
set errorStack [$this doCut]
}
set currentObj [$this currentObj]
set browsUiObj [$currentObj browsUiObj]
[$this deselectedSet] foreach obj {
if [catch {$browsUiObj deselectVersion $obj} msg] {
if {"$errorStack" != ""} {
append errorStack "\n"
}
append errorStack $msg
}
}
set confV [$currentObj getParent ConfigVersion]
set sectionList ""
set removeList ""
[$this objectSet] foreach obj {
if [$obj isA SystemFileReference] {
set catched [catch {
set fileV [[$obj info] set FileVersion]
set file [$fileV file]
require "docgenerat.tcl"
require "docstructp.tcl"
DocStructPart new .docStrucPart \
-documentVersion $browsUiObj \
-sectionName "[$file qualifiedName :]_[$file type]" \
-sectionType "[$file type]" \
-fileVersion $fileV
set section [DocGenerator::createSection .docStrucPart]
.docStrucPart delete
lappend removeList $obj
lappend sectionList $section
} msg]
} else {
set catched [catch {$browsUiObj selectVersion $obj $confV} msg]
}
if $catched {
if {"$errorStack" != ""} {
append errorStack "\n"
}
append errorStack $msg
}
}
foreach obj $removeList {
$this removeObject $obj
}
foreach obj $sectionList {
$this addObject $obj
}
}
if {"$errorStack" != ""} {
wmtkerror $errorStack
}
.main updateView
wmtkmessage ""
}
method EditPasteCmd::undo {this} {
if {! [isCommand [$this currentObj]]} {
return
}
set errorStack ""
busy {
if {"[$this operation]" == "cut"} {
set errorStack [$this undoCut]
}
set currentObj [$this currentObj]
set browsUiObj [$currentObj browsUiObj]
[$this objectSet] foreach obj {
if [$obj isA SystemFileReference] {
set catched [catch {
$obj setInfo FileVersion [$obj referredFileVersion]
$browsUiObj removeObject $obj
} msg]
} else {
set catched [catch {$browsUiObj deselectVersion $obj} msg]
}
if $catched {
if {"$errorStack" != ""} {
append errorStack "\n"
}
append errorStack $msg
}
}
set confV [$currentObj getParent ConfigVersion]
[$this deselectedSet] foreach obj {
if [catch {$browsUiObj selectVersion $obj $confV} msg] {
if {"$errorStack" != ""} {
append errorStack "\n"
}
append errorStack $msg
}
}
}
if {"$errorStack" != ""} {
wmtkerror $errorStack
}
.main updateView
wmtkmessage ""
}
method EditPasteCmd::doCut {this} {
if {! [isCommand [$this sourceObj]]} {
return
}
set errorStack ""
set sourceObj [$this sourceObj]
set sourceName [$sourceObj getInfo Name]
set sourceType [$sourceObj getInfo Type]
[$this sourceSet] foreach obj {
if [catch {$sourceObj deselectVersion $obj} msg] {
if {"$errorStack" != ""} {
append errorStack "\n"
}
append errorStack $msg
} else {
wmtkmessage "\
Deselected [$obj getInfo Type] '[$obj getInfo Name]'\
from $sourceType '$sourceName'"
}
}
return $errorStack
}
method EditPasteCmd::undoCut {this} {
if {! [isCommand [$this sourceObj]]} {
return
}
set errorStack ""
set sourceObj [$this sourceObj]
[$this sourceSet] foreach obj {
if [catch {$sourceObj selectVersion $obj} msg] {
if {"$errorStack" != ""} {
append errorStack "\n"
}
append errorStack $msg
}
}
return $errorStack
}
# Do not delete this line -- regeneration end marker
method EditPasteCmd::addDeselected {this newDeselected} {
[$this deselectedSet] append $newDeselected
}
method EditPasteCmd::removeDeselected {this oldDeselected} {
[$this deselectedSet] removeValue $oldDeselected
}
method EditPasteCmd::addSource {this newSource} {
[$this sourceSet] append $newSource
}
method EditPasteCmd::removeSource {this oldSource} {
[$this sourceSet] removeValue $oldSource
}