home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / cbfindfeat.tcl < prev    next >
Text File  |  1996-09-23  |  6KB  |  201 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Westmount Technology    1994
  4. #
  5. #      File:           @(#)cbfindfeat.tcl    /main/titanic/2
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)cbfindfeat.tcl    /main/titanic/2   23 Sep 1996 Copyright 1994 Westmount Technology
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14.  
  15. Class CBFindFeatureDialog : {TemplateDialog} {
  16.     constructor
  17.     method destructor
  18.     method handleFindAttributesChanged
  19.     method handleFindOperationsChanged
  20.     method handleCaseSensitiveChanged
  21.     method handleUseFeatureFiltersChanged
  22.     method handleOkPressed
  23.     method handleNextPressed
  24.     method findMatchingFeature
  25.     method initialisedView
  26.     attribute nextFeatureClassIndex
  27.     attribute featureNameWildCard
  28.     attribute findAttributes
  29.     attribute findOperations
  30. }
  31.  
  32. constructor CBFindFeatureDialog {class this name} {
  33.     set this [TemplateDialog::constructor $class $this $name]
  34.     $this nextFeatureClassIndex 0
  35.     $this featureNameWildCard ""
  36.     $this findAttributes 1
  37.     $this findOperations 1
  38.     # Start constructor user section
  39.     $this config -title "Find Feature" \
  40.         -okPressed "%this handleOkPressed" \
  41.         -helpPressed "$classBrowser helpOnName findFeature"
  42.  
  43.     interface DlgColumn $this.c {
  44.         Label message {text "Feature Name:"}
  45.         SingleLineText featureNameWildCard {columnCount 15}
  46.         NamedGroup g {
  47.             label "Find"
  48.             DlgRow r {
  49.                 CheckButton findAttributes {
  50.                     label "Attributes"
  51.                     state yes
  52.                 }
  53.                 CheckButton findOperations {
  54.                     label "Operations"
  55.                     state yes
  56.                 }
  57.             }
  58.         }
  59.         CheckButton findCaseSensitive {label "Case Sensitive"}
  60.         CheckButton useFeatureFilters {label "Use Feature Filters"}
  61.     }
  62.     $this.c.g.r.findAttributes config \
  63.         -stateChanged "$this handleFindAttributesChanged"
  64.     $this.c.g.r.findOperations config \
  65.         -stateChanged "$this handleFindOperationsChanged"
  66.     $this.c.findCaseSensitive config \
  67.         -state [expr {([m4_var get M4_find_case_sensitive] == "1") \
  68.             ? "yes" : "no"}] \
  69.         -stateChanged "$this handleCaseSensitiveChanged"
  70.     $this.c.useFeatureFilters config \
  71.         -state [expr {([m4_var get M4_find_using_filters] == "1") \
  72.             ? "yes" : "no"}] \
  73.         -stateChanged "$this handleUseFeatureFiltersChanged"
  74.  
  75.     PushButton new $this.next -label Next \
  76.         -activated "$this handleNextPressed"
  77.     # End constructor user section
  78.     return $this
  79. }
  80.  
  81. method CBFindFeatureDialog::destructor {this} {
  82.     # Start destructor user section
  83.     # End destructor user section
  84. }
  85.  
  86. method CBFindFeatureDialog::handleFindAttributesChanged {this} {
  87.     if {![$this.c.g.r.findAttributes state]} {
  88.         $this.c.g.r.findOperations state yes
  89.     }
  90. }
  91.  
  92. method CBFindFeatureDialog::handleFindOperationsChanged {this} {
  93.     if {![$this.c.g.r.findOperations state]} {
  94.         $this.c.g.r.findAttributes state yes
  95.     }
  96. }
  97.  
  98. method CBFindFeatureDialog::handleCaseSensitiveChanged {this} {
  99.     catch {m4_var set M4_find_case_sensitive \
  100.         [$this.c.findCaseSensitive state]}
  101. }
  102.  
  103. method CBFindFeatureDialog::handleUseFeatureFiltersChanged {this} {
  104.     catch {m4_var set M4_find_using_filters \
  105.         [$this.c.useFeatureFilters state]}
  106. }
  107.  
  108. method CBFindFeatureDialog::handleOkPressed {this} {
  109.     busy {
  110.         wmtkmessage "Finding first matching feature ..."
  111.         $this nextFeatureClassIndex 0
  112.         $this featureNameWildCard [$this.c.featureNameWildCard text]
  113.         $this findAttributes [$this.c.g.r.findAttributes state]
  114.         $this findOperations [$this.c.g.r.findOperations state]
  115.         if {[$this findMatchingFeature]} {
  116.             wmtkmessage ""
  117.         }
  118.     }
  119. }
  120.  
  121. method CBFindFeatureDialog::handleNextPressed {this} {
  122.     set nameChanged [expr {([$this.c.featureNameWildCard text] != \
  123.         [$this featureNameWildCard]) ? 1 : 0}]
  124.     set attrChanged [expr {([$this.c.g.r.findAttributes state] != \
  125.         [$this findAttributes]) ? 1 : 0}]
  126.     set operChanged [expr {([$this.c.g.r.findOperations state] != \
  127.         [$this findOperations]) ? 1 : 0}]
  128.  
  129.     if {$nameChanged || $attrChanged || $operChanged} {
  130.         $this handleOkPressed
  131.     } else {
  132.         busy {
  133.             wmtkmessage "Finding next matching feature ..."
  134.             if {[$this findMatchingFeature]} {
  135.                 wmtkmessage ""
  136.             }
  137.         }
  138.     }
  139. }
  140.  
  141. method CBFindFeatureDialog::findMatchingFeature {this} {
  142.     if {[string length [$this featureNameWildCard]] == 0} {
  143.         wmtkmessage "No match found for ''"
  144.         return 0
  145.     }
  146.     set classList [[[$classBrowser classTL] textListEntrySet] contents]
  147.     set idx [$this nextFeatureClassIndex]
  148.     set found 0
  149.     while {$idx < [llength $classList] && !$found} {
  150.         set class [lindex $classList $idx]
  151.         $class load
  152.         [$class featureSet] foreach feat {
  153.             if {[$feat isA CBAttribute] &&
  154.                     ![$this findAttributes]} {
  155.                 continue
  156.             }
  157.             if {[$feat isA CBMethod] && ![$this findOperations]} {
  158.                 continue
  159.             }
  160.             if {[$this.c.useFeatureFilters state] &&
  161.                     ![[$feat getFilter] letsPass $feat]} {
  162.                 continue
  163.             }
  164.  
  165.             if {[$this.c.findCaseSensitive state]} {
  166.                 set found [string match \
  167.                     [$this featureNameWildCard] \
  168.                     [$feat name]]
  169.             } else {
  170.                 set found [string match \
  171.                 [string tolower [$this featureNameWildCard]] \
  172.                 [string tolower [$feat name]]]
  173.             }
  174.             if {$found} {
  175.                 # skip to next class immediately
  176.                 $this nextFeatureClassIndex [expr {$idx + 1}]
  177.                 $class open
  178.                 break
  179.             }
  180.         }
  181.         incr idx
  182.     }
  183.     if {!$found} {
  184.         if {[$this nextFeatureClassIndex] == 0} {
  185.             set featureNameWildCard [$this featureNameWildCard]
  186.             wmtkmessage "No match found for '$featureNameWildCard'"
  187.         } else {
  188.             $this nextFeatureClassIndex 0
  189.             return [$this findMatchingFeature]
  190.         }
  191.     }
  192.     return $found
  193. }
  194.  
  195. method CBFindFeatureDialog::initialisedView {this} {
  196.     $this nextFeatureClassIndex 0
  197. }
  198.  
  199. # Do not delete this line -- regeneration end marker
  200.  
  201.