opengeode.tcl 3.04 KB
Newer Older
Jerome Legrand's avatar
Jerome Legrand committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
package provide opengeode 0.1 

lappend auto_path .
namespace eval opengeode {
    
    # Graphical name of the operation
    proc getLabel {} {
        return "Launch SDL Editor"
    }
    
    # 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
    proc getApplyTo {} {
19
		## Ticket mantis 0000625
Jerome Legrand's avatar
Jerome Legrand committed
20 21 22 23 24 25
        return [list { "Function" {"Source_Language" "SDL"} }  ]
    }
    
    # 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
        return [list statusBar dialogBoxOnError]
Jerome Legrand's avatar
Jerome Legrand committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    }
    
    proc opengeode { args } {
        set params [lindex $args 0]
        set aadlFilePath [Parameter::getParameter $params aadlFilePath]
        set aadlId [Parameter::getParameter $params id]
        return [opengeode_internal $aadlFilePath $aadlId]
    }
    
    #  the line "exec {*}[auto_execok $::installationPath/config/externalTools/test.bat]"
    #  ask the current OS which software is to be used to open the file test.bat
    #  to launch using the absolute path, read the template2.tcl_
    
    # synchronous call
    proc opengeode_internal { aadlFilePath aadlId } {    
42
		## Ticket mantis 0000625
Jerome Legrand's avatar
Jerome Legrand committed
43 44 45 46
        set initialPath [pwd]
        cd [file dirname $aadlFilePath]
        set msg ""
        
47 48 49 50 51 52 53 54
        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."
		}
        ## Ticket mantis 0000632
Jerome Legrand's avatar
Jerome Legrand committed
55
        set aadlId [string tolower $aadlId 0 end]
56 57 58 59 60 61 62 63 64 65 66 67 68
        set fileBaseName [file normalize "[pwd]/$aadlId" ]
        if { $errNumb == 0 && [file exists $fileBaseName ] } {
            if { [auto_execok opengeode] == "" } {
				set errNumb -1
				set msg [list "Error in execution of \"opengeode system_structure.pr ${fileBaseName}/${aadlId}.pr: unknown file opengeode" ]
			} else {
				ToolsOthers::execAsynchronouslyWithResponse [list "[auto_execok opengeode] ${fileBaseName}/system_structure.pr ${fileBaseName}/${aadlId}.pr " \
					"[auto_execok opengeode] --toAda ${fileBaseName}/system_structure.pr ${fileBaseName}/${aadlId}.pr" ] \
					"::opengeoderes" "Opengeode error report" "The execution of opengeode stopped with error"
			}
        } elseif { $errNumb != 0 } {
			set errNumb -1
            set msg [list "Error in execution of \"taste-generate-skeletons $aadlFilePath\": $errMsg" ]
Jerome Legrand's avatar
Jerome Legrand committed
69
        } else {
70 71
			set errNumb -1
            set msg [list "Cannot find file:\n-${fileBaseName}/${aadlId}.pr" ]
Jerome Legrand's avatar
Jerome Legrand committed
72 73 74 75 76 77 78 79 80 81 82 83 84
        }
        
        cd $initialPath
        return [list $errNumb $msg]
    } 
    
    # asynchronous call
    #proc template_internal { aadlFilePath aadlId } {        
    #    exec {*}[auto_execok $::installationPath/config/externalTools/test.bat] $aadlFilePath $aadlId &
    #    return ""
    #} 
    
}