generate_skeletons.tcl 1.85 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package provide generate_skeletons 0.1 

lappend auto_path .
namespace eval generate_skeletons {
    
    # Graphical name of the operation
    proc getLabel {} {
        return "Generate code skeletons"
    }
    
    # Name of the application this script can be used with
    # shall be either InterfaceView or DeploymentView
    proc getApplication {} {
        return "InterfaceView"
    }
    
    # Names of  the object this script can be used on
    # FIXME - it should be active all the time
    proc getApplyTo {} {
Arnaud Schach's avatar
Arnaud Schach committed
20
        return [list "allContext" ]
Maxime Perrotin's avatar
Maxime Perrotin committed
21 22 23 24 25
    }
    
    # List of way to manage output in the Framework
    # Could be an empty list or one or both of 'dialogBox' and 'statusBar'
    proc getOutputManagement {} {
26 27
		## Ticket mantis 0000625
        return [list statusBar dialogBoxOnError]
Maxime Perrotin's avatar
Maxime Perrotin committed
28 29 30 31 32 33 34 35 36 37 38
    }
    
    proc generate_skeletons { args } {
        set params [lindex $args 0]
        set aadlFilePath [Parameter::getParameter $params aadlFilePath]
        set aadlId [Parameter::getParameter $params id]
        return [generate_skeletons_internal $aadlFilePath $aadlId]
    }
    
    # synchronous call
    proc generate_skeletons_internal { aadlFilePath aadlId } {    
39
		## Ticket mantis 0000625
Maxime Perrotin's avatar
Maxime Perrotin committed
40 41 42 43
        set initialPath [pwd]
        cd [file dirname $aadlFilePath]
        set msg ""
        set ::env(FORCE) 1
44 45 46 47 48 49 50
        set scriptPath [auto_execok "taste-generate-skeletons"]
        if { $scriptPath != "" } {
			set errNumb [catch { exec -ignorestderr {*}$scriptPath 2>@1 } errMsg]
		} else {
			set errNumb -1
			set errMsg "Unknown command taste-generate-skeletons."
		}
Maxime Perrotin's avatar
Maxime Perrotin committed
51
        if { $errNumb == 0 } {
52
           set msg [list "Everything went fine!" ]
Maxime Perrotin's avatar
Maxime Perrotin committed
53 54
           unset ::env(FORCE)
        } else {
55
           set msg [list "Some errors were reported: $errMsg" ]
Maxime Perrotin's avatar
Maxime Perrotin committed
56 57 58 59 60 61 62
        }
                
        cd $initialPath
        return [list $errNumb $msg]
    } 
    
}