home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cadre Technologies Inc. 1995
- #
- # File: @(#)t_component.tcl /main/hindenburg/1
- # Author: Challenger
- # Description: Implementation of old Report Writer table Component
- #
- #---------------------------------------------------------------------------
- # SccsId = @(#)t_component.tcl /main/hindenburg/1 22 Nov 1996 Copyright 1995 Cadre Technologies Inc.
-
-
- constructor ComponentRecord {class this configVersion phaseVersion \
- systemVersion component} {
- set this [GCObject::constructor $class $this]
-
- set system [$systemVersion system]
- set phase [$phaseVersion phase]
- set fileVersion [$component diagram]
- set file [$fileVersion file]
-
- $this _component $component
- $this _configVersion $configVersion
- $this _fileVersion $fileVersion
- $this _item ""
- $this _workitem ""
- $this _from_role ""
- $this _to_role ""
- $this _qual_label ""
- $this _type_label ""
- $this _free_label ""
-
- $this project_version [$configVersion versionNumber]
- $this phase_version [$phaseVersion versionNumber]
- $this phase_id [$phase identity]
- $this system_version [$systemVersion versionNumber]
- $this system_id [$system identity]
- $this file_version [$fileVersion versionNumber]
- $this file_id [$file identity]
- $this file_type [$file type]
-
- $this component_id [$component identity]
-
- switch [$component objType] {
- Connector { $this component_kind connector }
- Node { $this component_kind node }
- ConnectedNode { $this component_kind noco }
- Row { $this component_kind row }
- Cell { $this component_kind cell }
- default { $this component_kind unknown }
- }
-
- $this component_type [short2longname [$component type]]
- set type [$component type]
- $this short_type $type
-
- switch $type {
- etd_object { $this _itemlabel type }
- etd_initiator { $this _itemlabel type }
- etd_event { $this _itemlabel event }
- transition { $this _itemlabel event }
- event_msg { $this _itemlabel event }
- default { $this _itemlabel name }
- }
-
- set labels [$this labels]
- if ![llength $labels] {
- $this name ""
- } else {
- $this name [query -s value "type == [$this _itemlabel]" $labels]
- }
-
- $this index ""
- $this data_part "unknown"
- $this sequence_nr -1
- $this cardinality ""
- $this prompt "unknown"
-
- return $this
- }
-
-
- method ComponentRecord::item_id {this} {
- set item [$this item]
- if [$item isNil] {
- return 0
- }
-
- return [$item identity]
- }
-
-
- method ComponentRecord::item_type {this} {
- set item [$this item]
- if [$item isNil] {
- return 0
- }
-
- return [short2longname [$item type]]
- }
-
-
- method ComponentRecord::scope {this} {
- set wi [$this workitem]
- if [$wi isNil] {
- return 0
- }
-
- return [old2newscope [$wi scope]]
- }
-
-
- method ComponentRecord::qualifier {this} {
- set item [$this item]
- if [$item isNil] {
- return 0
- }
- set qual [$item qualifier]
- if [$qual isNil] {
- return 0
- }
-
- return [$qual name]
- }
-
-
- method ComponentRecord::qualifier_id {this} {
- set item [$this item]
- if [$item isNil] {
- return 0
- }
- set qual [$item qualifier]
- if [$qual isNil] {
- return 0
- }
-
- return [$qual identity]
- }
-
-
- method ComponentRecord::data_type {this} {
- return [[$this workitem] getPropertyValue data_type]
- }
-
-
- method ComponentRecord::from_role {this} {
- if { [$this _from_role] == ""} {
- set cir [$this findCompItemRef role_start de]
- if ![$cir isNil] {
- $this _from_role [$cir item]
- } else {
- $this _from_role [ORB::nil]
- }
- }
-
- if [[$this _from_role] isNil] {
- return 0
- }
-
- return [[$this _from_role] name]
- }
-
-
- method ComponentRecord::from_role_id {this} {
- # fill _from_role by calling from_role
- $this from_role
-
- if [[$this _from_role] isNil] {
- return 0
- }
-
- return [[$this _from_role] identity]
- }
-
-
- method ComponentRecord::to_role {this} {
- if { [$this _to_role] == ""} {
- set cir [$this findCompItemRef role_end de]
- if ![$cir isNil] {
- $this _to_role [$cir item]
- } else {
- $this _to_role [ORB::nil]
- }
- }
-
- if [[$this _to_role] isNil] {
- return 0
- }
-
- return [[$this _to_role] name]
- }
-
-
- method ComponentRecord::to_role_id {this} {
- # fill _to_role by calling to_role
- $this to_role
-
- if [[$this _to_role] isNil] {
- return 0
- }
-
- return [[$this _to_role] identity]
- }
-
-
- method ComponentRecord::qual_label {this} {
- if { [$this _qual_label] == ""} {
- set cir [$this findCompItemRef qualifier de]
- if ![$cir isNil] {
- $this _qual_label [$cir item]
- } else {
- $this _qual_label [ORB::nil]
- }
- }
-
- if [[$this _qual_label] isNil] {
- return 0
- }
-
- return [[$this _qual_label] name]
- }
-
-
- method ComponentRecord::qual_label_id {this} {
- # fill _qual_label by calling qual_label
- $this qual_label
-
- if [[$this _qual_label] isNil] {
- return 0
- }
-
- return [[$this _qual_label] identity]
- }
-
-
- method ComponentRecord::type_label {this} {
- if { [$this _type_label] == ""} {
- if { [$this short_type] != "link_attrib" } {
- $this _type_label [ORB::nil]
- return 0
- }
- set cir [$this findCompItemRef type cl]
- if ![$cir isNil] {
- $this _type_label [$cir item]
- } else {
- $this _type_label [ORB::nil]
- }
- }
-
- if [[$this _type_label] isNil] {
- return 0
- }
-
- return [[$this _type_label] name]
- }
-
-
- method ComponentRecord::type_label_id {this} {
- # fill _type_label by calling type_label
- $this type_label
-
- if [[$this _type_label] isNil] {
- return 0
- }
-
- return [[$this _type_label] identity]
- }
-
-
- method ComponentRecord::free_label {this} {
- if { [[$this _component] objType] != "Cell" } {
- return 0
- }
-
- if { [$this _free_label] == "" } {
- set label [lindex [[$this _component] labels] 0]
- if { $label == "" } {
- return 0
- }
-
- $this _free_label [$label value]
- }
-
- return [$this _free_label]
- }
-
-
- method ComponentRecord::from_id {this} {
- if { [[$this _component] objType] != "Connector" } {
- return 0
- }
- return [query -s _component.from.identity $this]
- }
-
-
- method ComponentRecord::to_id {this} {
- if { [[$this _component] objType] != "Connector" } {
- return 0
- }
- return [query -s _component.to.identity $this]
- }
-
-
- method ComponentRecord::related_id {this} {
- if { [[$this _component] objType] != "ConnectedNode" } {
- return 0
- }
- return [query -s _component.from.identity $this]
- }
-
-
- method ComponentRecord::row_id {this} {
- if { [[$this _component] objType] != "Cell" } {
- return 0
- }
- return [query -s _component.row.identity $this]
- }
-
-
- method ComponentRecord::key {this} {
- if { [[$this _component] getPropertyValue COMP_KEY] == "1" } {
- return 1
- } else {
- return 0
- }
- }
-
-
- #
- # Extra methods
- #
- method ComponentRecord::labels {this} {
- if { [$this _labels] == "" } {
- set component [$this _component]
- if { [$component isA Connector] &&
- [$component type] != "transition" } {
- $this _labels [query $component.segments.labels]
- } else {
- $this _labels [$component labels]
- }
- }
-
- return [$this _labels]
- }
-
-
- method ComponentRecord::item {this} {
- if { [$this _item] == ""} {
- set comptype [comptype2itemtype [$this short_type]]
- set cir [$this findCompItemRef [$this _itemlabel] $comptype]
- if ![$cir isNil] {
- $this _item [$cir item]
- } else {
- $this _item [ORB::nil]
- }
- }
-
- return [$this _item]
- }
-
-
- method ComponentRecord::workitem {this} {
- if { [$this _workitem] == "" } {
- set item [$this item]
- if [$item isNil] {
- return [ORB::nil]
- }
- set name [$item name]
- set type [$item type]
- set ctx [$this _configVersion]
- $this _workitem [[$this _fileVersion] findDeclaration $name $type $ctx]
- }
-
- return [$this _workitem]
- }
-
-
- method ComponentRecord::findCompItemRef {this labelname itemtype} {
- set complabels [$this labels]
- set result ""
- if ![llength $complabels] {
- return [ORB::nil]
- }
- set complabel [query "type == $labelname" $complabels]
- if { $complabel == "" } {
- # check name_type label
- if { $labelname == "name" || $labelname == "type" } {
- set complabel [query "type == name_type" $complabels]
- set short_type [$this short_type]
- if ![info exists labelPartName($short_type,name_type,$labelname)] {
- return [ORB::nil]
- }
- set it $labelPartName($short_type,name_type,$labelname)
- set result [query "item != [ORB::nil] && item.type == $it" \
- $complabels.itemRefs]
- }
- if ![lempty $result] {
- return [lindex $result 0]
- }
- return [ORB::nil]
- }
- set itemrefs [$complabel itemRefs]
- if { $itemrefs == "" } {
- return [ORB::nil]
- }
- set result [lindex [query "item.isNil == 0 && item.type == $itemtype" \
- $itemrefs] 0]
- if { $result == "" } {
- return [ORB::nil]
- }
-
- return $result
- }
-
-
- global labelPartName
-
- set labelPartName(attribute,name_type,name) de
- set labelPartName(attribute,name_type,type) cl
- set labelPartName(method,name_type,name) pe
- set labelPartName(method,name_type,type) cl
- set labelPartName(parameter,name_type,name) de
- set labelPartName(parameter,name_type,type) cl
- set labelPartName(link_attrib,name_type,name) de
- set labelPartName(link_attrib,name_type,type) cl
-
- set labelPartName(etd_object,name_type,name) de
- set labelPartName(etd_object,name_type,type) cl
- set labelPartName(etd_initiator,name_type,name) de
- set labelPartName(etd_initiator,name_type,type) cl
- set labelPartName(etd_event,event,name) pe
- set labelPartName(etd_event,event,type) de
-