home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cadre Technologies Inc. 1996
- #
- # File: @(#)stinterfac.tcl /main/hindenburg/3
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)stinterfac.tcl /main/hindenburg/3 23 Aug 1996 Copyright 1996 Cadre Technologies Inc.
-
- # Start user added include file section
- require platform.tcl
- # End user added include file section
-
-
- # This class is the interface to a Smalltalk
- # system. It is responsible for: code generation settings,
- # creating dialogs, generating special files and
- # starting Smalltalk.
-
- Class STInterface : {Object} {
- constructor
- method destructor
- method generateImport
- method generateExport
- method getSelectedFiles
- method readFiles
- method addSuperClasses
- method createSettingsDialog
-
- # All files of type smalltalk in the current system.
- #
- attribute allFiles
-
- # The selected files in the current system.
- #
- attribute selectedFiles
-
- # The selected classes in the current system.
- #
- attribute selectedClasses
-
- # Mapping from class name to file name.
- #
- attribute classToFile
-
- # Mapping from classes to super classes.
- #
- attribute classToSuper
-
- # The filehandler instance used by this interface.
- #
- attribute fileHandler
-
- # Generator used by this interface.
- #
- attribute generator
- }
-
- constructor STInterface {class this name} {
- set this [Object::constructor $class $this $name]
- # Start constructor user section
- $this classToSuper [Dictionary new]
- $this classToFile [Dictionary new]
- $this selectedClasses [List new]
- $this selectedFiles [List new]
- $this allFiles [List new]
- $this createSettingsDialog
- # End constructor user section
- return $this
- }
-
- method STInterface::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
-
- # Generates the import script: determines the files to be included,
- # reads the class hierarchy from all files and calls the generator. <selection>
- # indicates whether selected or all was chosen in
- # the Smalltalk menu.
- #
- method STInterface::generateImport {this selection} {
- $this getSelectedFiles
- if { $selection == "all" } {
- [$this selectedFiles] contents [[$this allFiles] contents]
- }
- if [[$this selectedFiles] empty] {
- wmtkerror "No class files selected"
- return
- }
- $this readFiles
- $this addSuperClasses
-
- [$this generator] generateImport [$this selectedClasses] [$this classToSuper] [$this classToFile]
- }
-
-
- # Generates the export script for the classes in <selection>: determines the files to be
- # included, reads all files to find the corresponding classes
- # and calls the generator.
- # <selection> indicates whether all or selected was chosen in the
- # Smalltalk menu.
- #
- method STInterface::generateExport {this selection} {
- $this getSelectedFiles
- if { $selection == "all" } {
- [$this selectedFiles] contents [[$this allFiles] contents]
- }
- if [[$this selectedFiles] empty] {
- wmtkerror "No class files selected"
- return
- }
- $this readFiles
-
- [$this generator] generateExport [$this selectedClasses] [$this classToFile]
- }
-
-
- # Gets the selected files from the browser
- # and sets selectedFiles.
- #
- method STInterface::getSelectedFiles {this} {
- set stType [[$this fileHandler] stType]
- if { ![[$this selectedFiles] empty] } {
- [$this selectedFiles] remove 0 end
- }
-
- foreach obj [$wmttoolObj selectedObjSet] {
- if [$obj isA SystemFileReference] {
- set fileV [$obj getInfo "File Version"]
- if {"$fileV" != ""} {
- set type [[$fileV file] type]
- if { $type == $stType } {
- [$this selectedFiles] append "[[$fileV file] name].$type"
- }
- }
- } elseif [$obj isA FileVersion] {
- set type [[$obj file] type]
- if { $type == $stType } {
- [$this selectedFiles] append "[[$obj file] name].$type"
- }
- }
- }
-
- [$this allFiles] contents [fstorage::dir [[$this fileHandler] stType]]
-
- # import and export scripts are discarded
- [[$this fileHandler] getSpecialFiles] foreach fileName {
- [$this allFiles] removeValue $fileName
- [$this selectedFiles] removeValue $fileName
- }
- }
-
-
- # Reads all files and fills classToSuper,
- # classToFile and selectedClasses.
- #
- method STInterface::readFiles {this} {
- if { ![[$this selectedClasses] empty] } {
- [$this selectedClasses] remove 0 end
- }
-
- [$this allFiles] foreach fileName {
- set fd [fstorage::open $fileName r]
- while {[gets $fd line] >= 0} {
- set wordList [split $line " "]
- # check if second word is subclass keyword
- if [regexp ubclass: [lindex $wordList 1]] {
- regsub -all # [lindex $wordList 2] "" className
- set superName [lindex $wordList 0]
- [$this classToFile] set $className $fileName
- [$this classToSuper] set $className $superName
- if { [[$this selectedFiles] search $fileName] != -1 } {
- [$this selectedClasses] append $className
- }
- break
- }
- }
- fstorage::close $fd
- }
- }
-
-
- # Adds the superclasses of the classes
- # selectedClasses to selectedClasses.
- #
- method STInterface::addSuperClasses {this} {
- [$this selectedClasses] foreach className {
- if [[$this classToSuper] exists $className] {
- set super [[$this classToSuper] set $className]
- if [[$this classToFile] exists $super] {
- if { [[$this selectedClasses] search $super] == - 1} {
- [$this selectedClasses] append $super
- }
- }
- }
- }
- }
-
-
- # Creates the dialog for the code generation
- # settings.
- #
- method STInterface::createSettingsDialog {this} {
- TemplateDialog new .main.stconfig \
- -title "Smalltalk code generation settings" \
- -okPressed {
- m4_var set M4_st_generate_print \
- [%this.column.print.printCB state]
- m4_var set M4_st_default_category \
- [%this.column.category.categoryRG selected]
- %this popDown
- }
- DlgColumn new .main.stconfig.column
-
- # OT for NT does not do line spacing so add some lines in this case
- # to make it look acceptable
- if $win95 {
- DlgRow new .main.stconfig.column.empty1
- Label new .main.stconfig.column.empty1.emptylabel \
- -text " "
- }
-
- DlgRow new .main.stconfig.column.print
-
- if $win95 {
- DlgRow new .main.stconfig.column.empty2
- Label new .main.stconfig.column.empty2.emptylabel \
- -text " "
- }
-
- DlgRow new .main.stconfig.column.category
- OptionMenu new .main.stconfig.column.category.categoryRG \
- -entrySet {System Diagram} \
- -selected [m4_var get M4_st_default_category]
- Label new .main.stconfig.column.category.label \
- -text "name is default category name"
- CheckButton new .main.stconfig.column.print.printCB \
- -label "Generate Print Methods" \
- -state [expr {[m4_var get M4_st_generate_print] == 1}]
- }
-
- # Do not delete this line -- regeneration end marker
-
-