home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)editpastec.tcl /main/titanic/11
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)editpastec.tcl /main/titanic/11 7 Oct 1997 Copyright 1997 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 operation
- method selectVersion
- method levelValidate
- method operatesOn
- method addObject
- method removeObject
- 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
-
- global editPasteObjects
- if [info exists editPasteObjects] {
- unset editPasteObjects
- }
-
- # 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
-
- $this levelValidate $currentObj
-
- if {! [[.main flatView] requestClipboardValue]} {
- $this currentObj ""
- wmtkinfo "No matching clipboard format found."
- }
- }
- }
-
- 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 {
- set catched [$this selectVersion $browsUiObj $obj 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
- }
-
-
- # Sets _operation to value if value is specified,
- # otherwise returns _operation.
- #
- method EditPasteCmd::operation {this {value ""}} {
- if { $value == "" } {
- return [$this _operation]
- }
-
- $this _operation $value
- if { $value == "cut" } {
- $this commandName "Move"
- } else {
- $this commandName "Copy"
- }
-
- $this setUndoLabel undo
- }
-
- method EditPasteCmd::selectVersion {this currentObj obj msg} {
- upvar $msg message
- if [$obj isA SystemFileReference] {
- # ignore (must be handled by a module)
- set catched 0
- } else {
- set catched [catch {$currentObj selectVersion $obj $confV} message]
- }
-
- return $catched
- }
-
- method EditPasteCmd::levelValidate {this currentObj} {
- # empty
- }
-
- method EditPasteCmd::operatesOn {this object} {
- if {! [isCommand $object]} {
- return 0
- }
-
- global editPasteObjects
- if [info exists editPasteObjects($object)] {
- return 1
- }
-
- set sourceObj [$this sourceObj]
- if {[isCommand $sourceObj] && $object == $sourceObj} {
- return 1
- }
-
- set currentObj [$this currentObj]
- if {[isCommand $currentObj] && $object == $currentObj} {
- return 1
- }
-
- return 0
- }
-
- method EditPasteCmd::addObject {this newObject} {
- $this UndoCommand::addObject $newObject
- global editPasteObjects
- set editPasteObjects($newObject) 1
- }
-
- method EditPasteCmd::removeObject {this oldObject} {
- $this UndoCommand::removeObject $oldObject
- global editPasteObjects
- if [info exists editPasteObjects($oldObject)] {
- unset editPasteObjects($oldObject)
- }
- }
-
- method EditPasteCmd::addDeselected {this newDeselected} {
- [$this deselectedSet] append $newDeselected
- global editPasteObjects
- set editPasteObjects($newDeselected) 1
- }
-
- method EditPasteCmd::removeDeselected {this oldDeselected} {
- [$this deselectedSet] removeValue $oldDeselected
- global editPasteObjects
- if [info exists editPasteObjects($oldDeselected)] {
- unset editPasteObjects($oldDeselected)
- }
- }
-
- method EditPasteCmd::addSource {this newSource} {
- [$this sourceSet] append $newSource
- global editPasteObjects
- set editPasteObjects($newSource) 1
- }
-
- method EditPasteCmd::removeSource {this oldSource} {
- [$this sourceSet] removeValue $oldSource
- global editPasteObjects
- if [info exists editPasteObjects($oldSource)] {
- unset editPasteObjects($oldSource)
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-