Replies:

Ok, this is a test i wrote to add some basic source control (auto save of class and manually exporting the current project). It shows how you can add 2 menu items.
Don't  forget to activate the source control class for a namespace in the portal (admin-config-additional settings-source control)
 

Class Studio.Extension Extends %Studio.Extension.Base
{ XData Menu
{
<MenuBase>
<Menu Name="GIT" Type="0">
<MenuItem Name="Directory Setting"/>
<MenuItem Name="Export Current Project"/>
</Menu>
</MenuBase>
} /// Perform any login step here.
Method Login(Name As %String, Password As %String) As %Status
{
Write "==============================================================================================",!
Write "= Welcome ",$Get(Name),", this namespace is under source control by class Studio.Extension",!
Write "= Source files are saved in ",$Get(^SourceControl(0,$UserName,"GIT_Dir")),!
Write "==============================================================================================",!
Set ^SourceControl($J,"currentProject")=""
Quit $$$OK
} Method UserAction(Type As %Integer, Name As %String, InternalName As %String, SelectedText As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String, ByRef Reload As %Boolean) As %Status
{
If $Piece($Get(InternalName),".",*)="PRJ" {
Set ^SourceControl($J,"currentProject")=$Piece(InternalName,".",1,*-1)
}
;Write "StudioExtension: Loading ",$Get(InternalName)," (",$Get(Type),"-",$Get(Name),"), current project is ",$Get(^sourcecontrol($J,"currentProject")),!
If Type=0 Do ..ExecuteMenu(Name, .Action, .Target, .Msg)
Quit $$$OK
} Method ExecuteMenu(Name As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String)
{
If Name="GIT,Directory Setting" {
Set Target="Directory for GIT source control"
Set Msg=$Get(^SourceControl(0,$UserName,"GIT_Dir"))
Set Action=7
ElseIf Name="GIT,Export Current Project" {
Set Target="Export Current Project"
Set Msg=$Get(^SourceControl($J,"currentProject"))
Set Action=7
}
} Method AfterUserAction(Type As %Integer, Name As %String, InternalName As %String, Answer As %Integer, Msg As %String = "", ByRef Reload As %Boolean) As %Status
{
#Dim project, dir as %String ;Write Type,Name,InternalName," : "
;Write "You answered ",$Get(Answer) ;1=yes, 0=no, 2=cancel
;Write "with message ",$Get(Msg),!
If Answer=1,Type=0 {
If Name="GIT,Export Current Project" {
Set project = Msg
Set objProject = ##class(%Studio.Project).%OpenId(project)
If objProject'="" {
Set dir = $Get(^SourceControl(0,$UserName,"GIT_Dir"))
If dir="" {
Write !,"StudioExtension: Please set GIT directory first"
else {
If $E(dir,*)'="\" Set dir=dir_"\"
Do objProject.Export(dir_project_$ZDate($H,8)_".xml")
}
else {
Write !,"StudioExtension: Project does not exist !"
}
Set objProject = ""
ElseIf Name="GIT,Directory Setting" {
Set ^SourceControl(0,$UserName,"GIT_Dir") = Msg
Write !,"StudioExtension: GIT Directory Saved"
}
} Quit $$$OK
} /// Called after the compile of the item is done.
Method OnAfterCompile(InternalName As %String) As %Status
{
#Dim dir, separator, items, extension, fullFileName as %String Set dir = $Get(^SourceControl(0,$UserName,"GIT_Dir"))
If dir="" {
Write !,"StudioExtension: ","No directory setup to save source code"
else {
Set separator = $Select($ZV["Windows":"\",1:"/")
If dir'="", $E(dir,*)'=separator Set dir=dir_separator
Set extension=$Piece(InternalName,".",*)
Set dir=dir_extension_separator
Set fullFileName=dir_$Replace($Piece(InternalName,".",1,*-1),".",separator)_".xml"
Do ##class(%File).CreateDirectoryChain($Piece(fullFileName,separator,1,*-1)) If 0 {  ;do not export as .xml file for Git :
Set items(InternalName)=""
Do $system.OBJ.Export(.items,fullFileName)
Write !,"StudioExtension: ",InternalName_" saved as "_fullFileName
} If $Piece(InternalName,".",*)="CLS" {
Set $Piece(fullFileName,".",*) = "cls"
If $system.OBJ.ExportUDL(InternalName,$Replace(fullFileName,".xml",".cls")) {
Write !,"StudioExtension: ",$Piece(InternalName,".",1,*-1)," saved as ",fullFileName
else {
Write !,"StudioExtension: ","Error while saving "_$Piece(InternalName,".",1,*-1)," as ",fullFileName
}
}
}
Quit $$$OK
} }
 

I wrote a class to extend %Studio.Extension.Base, i don't see any other way to add items in Studio.
If you want, i can post a skeleton class where you can start with.

Followers:
Following:
Danny has not followed anybody yet.
Global Masters badges: