home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
mtitem.tcl
< prev
next >
Wrap
Text File
|
1997-11-13
|
4KB
|
161 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)mtitem.tcl /main/titanic/3
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)mtitem.tcl /main/titanic/3 13 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require "mergeobjec.tcl"
Class MTItem : {MergeObject} {
constructor
method destructor
method hasConflict
method getInfo
method merge
method import
method copyProperties
method copy
method overwrite
}
constructor MTItem {class this name fromRepObj toRepObj} {
set this [MergeObject::constructor $class $this $name $fromRepObj $toRepObj]
# Start constructor user section
# End constructor user section
return $this
}
method MTItem::destructor {this} {
# Start destructor user section
# End destructor user section
$this MergeObject::destructor
}
method MTItem::hasConflict {this} {
set to [$this toRepObj]
set from [$this fromRepObj]
# check if 'to' element does not exist
if {$to == ""} {
return 0
}
# check if the scope is identical
set fromScope [$from scope]
set toScope [$to scope]
if {$fromScope == $toScope} {
return 0
}
# No conflict when importing and
# there is no definition of the item in the target itemkeeper
if {[.main import] &&
$toScope == "scopePhaseRef" &&
[[[$to owner] findDefinition [$to item] [.main toConfig]] isNil]} {
return 0
}
# now it's clear there's a conflict
return 1
}
method MTItem::getInfo {this} {
set info ""
# show the scopes
lappend info "Source scope"
lappend info [[$this fromRepObj] scope]
if {[$this toRepObj] != ""} {
lappend info "Target scope"
lappend info [[$this toRepObj] scope]
}
return $info
}
method MTItem::merge {this} {
if ![$this hasConflict] {
return [$this copy]
}
# conflicting items can not be merged
return 0
}
method MTItem::import {this} {
if ![$this hasConflict] {
return [$this copy]
}
return [$this copyProperties]
}
method MTItem::copyProperties {this} {
set fromProps [[$this fromRepObj] properties]
set toProps [[$this toRepObj] properties]
# check if properties exists (PhaseRef)
if {![$fromProps isNil] && ![$toProps isNil]} {
foreach prop [$fromProps properties] {
$toProps setProperty [$prop name] [$prop value]
}
}
return 1
}
method MTItem::copy {this} {
set parentObj [MTProcs::makeToWorking [$this parent]]
if {$parentObj == ""} {
return 0
}
set workItem [$this fromRepObj]
set newWorkItem [$parentObj declareItem [$workItem item] \
[$workItem scope]]
if [$newWorkItem isNil] {
return 0
}
# update rep information
$this toRepObj $newWorkItem
# copy the properties too
return [$this copyProperties]
}
method MTItem::overwrite {this} {
# change scope of item
set itemKeeper [[$this parent] toRepObj]
set fromWorkItem [$this fromRepObj]
if {[$fromWorkItem scope] == "scopePhaseRef" ||
[$fromWorkItem scope] == "scopePhaseDef"} {
$itemKeeper export [[$this toRepObj] item] 1
} else {
$itemKeeper export [[$this toRepObj] item] 0
}
# copy the properties too
return [$this copyProperties]
}
# Do not delete this line -- regeneration end marker