IRISLIB database
Base Class Reference
Inheritance diagram for Base:
Collaboration diagram for Base:

Public Member Functions

_.Library.String GetInternalName ()
 Return the internal name of the current document, including the three letter. More...
 
_.Library.String UpdateSCMenus (_.Library.Boolean showMenu)
 Update the _sourceControlMenu Javascript object representing the contents of the source control menus.
 
 appendServerOutput (data, first)
 Render the server output from source control commands on the client.
 
 canUserModify (noAlert)
 Helper method to indicate whether the user is allowed to make changes to the. More...
 
 checkTextControls ()
 Helper method for event sequencing: the onmousedown event for the menu buttons and shapes in the SVG diagram. More...
 
 chooseSCMenu (menuName, commandName, saveFlags)
 Handle a source control menu selection.
 
 chooseSCProject (projectName, isNew)
 The user has selected on of the projects listed in the dropdown.
 
 clearSCOutput ()
 Clear the source control output on the server and update the content star.
 
 createSCMenuItem (parentItem, caption, onselect)
 Helper method to create an item in the source control menu.
 
 createSCProject (projectName)
 Create a new project on the server.
 
 createSCSubMenu (parentItem, caption)
 Helper method to create a submenu in the source control menu.
 
 getClientModel ()
 Get the jsonProvider object on the client. More...
 
 getCurrentExtension ()
 Return the extension used by Studio for the class/object. More...
 
 getCurrentName ()
 Return the current name of the class/object being modified. More...
 
_.Library.String getPageTitle ()
 Get the title string to add to the locator row. More...
 
 getReadOnlyReason ()
 Callback to get the text of the reason for the current document being loaded as readonly.
 
 getSaveAction (force)
 Return the string used as the command when sending JSON content to the server. More...
 
 initializeSourceControl ()
 Function to initialize the source control hooks for a page. More...
 
 initializeTextMonitor ()
 Initialize the text monitor for the page.
 
 invokeAfterUserAction (input, userContext)
 Client-side coordinator of calls to the AfterUserAction callback in. More...
 
 invokeSourceControl (action, isFramework)
 Client-side coordinator of calls to the UserAction callback in. More...
 
 loadDocument ()
 Method to load document from the client and invoke the correct source control hooks.
 
 onDocumentLoad (when, documentName)
 Callback invoked when a document is being loaded.
 
 onDocumentLoadComplete ()
 Callback method invoked after we have successfully loaded the current document.
 
 onDocumentSave (when, documentName)
 Callback invoked when a document is being saved.
 
 onDocumentSaveComplete (contentModified)
 Callback method invoked after we successfully save the current document.
 
 onloadHandler ()
 Add check to ensure that we correctly load documents on the client when source control hooks are in use.
 
 reloadDocument ()
 Reload the current document. More...
 
 saveDocument (force)
 Save the current document using the correct source control hooks.
 
 setReadOnly (readOnly)
 Set <property>readOnly</property> to the value of readOnly. More...
 
 setSCProject (newProject)
 Notify the server that a specific project has been chosen.
 
 showSCMenu ()
 Display the source control menu based on the contents of the _sourceControlMenu data. More...
 
 showSCOutput ()
 Open a popup to display the current source control output.
 
 textControlKeyDown (zenControl)
 Key handler to record the value of text fields before the keyboard event is processed. More...
 
 textControlKeyUp (event, zenControl)
 Key handler to work out whether user keys entered in controls have. More...
 
 updateDocumentState (alertOnReadOnly)
 Helper method to ensure that the <property>readOnly</property> and. More...
 
 updateSCIndicator (haveOutput)
 Toggle the display of the star which indicates whether new. More...
 

Static Public Member Functions

_.Library.String AfterUserAction (_.ZEN.proxyObject pInputProxy, _.ZEN.proxyObject pOutputProxy, _.ZEN.proxyObject pUserData)
 Server-side wrapper around the AfterUserAction callback.
 
 AppendSourceControlOutput (_.Library.String pOutput)
 Add output to the session data on the server.
 
_.Library.Integer ClearSourceControlOutput ()
 Clear the output for the session.
 
 CreateProject (_.ZEN.proxyObject pInputProxy, _.ZEN.proxyObject pOutputProxy)
 Create a new Studio project on the server.
 
_.Library.String DocumentLoad (_.ZEN.proxyObject pInputProxy, _.ZEN.proxyObject pOutputProxy)
 Implement the correct callbacks around loading a document.
 
_.Library.String DocumentSave (_.ZEN.proxyObject pInputProxy, _.ZEN.proxyObject pOutputProxy)
 Implement the correct callbacks around saving a document.
 
_.Library.Status GetSourceControlCommands (_.Library.Boolean pDisplay, pCommands, _.Library.Boolean pNeedProject, _.Library.String pServerOutput)
 Determine which source control commands should be drawn for the current context.
 
_.Library.String GetTimestamp (_.Library.String classname)
 Get the timestamp for the current document.
 
_.Library.Boolean HaveSourceControlOutput ()
 Indicate whether there is Source Control output for the session.
 
_.Library.Status LoadProject (_.Studio.SourceControl.Base pSourceControl, _.Library.String pProject, _.Library.Boolean pRedirect)
 Load the named project in pProject using the source control object. More...
 
_.Library.String UserAction (_.ZEN.proxyObject pInputProxy, _.ZEN.proxyObject pOutputProxy)
 Server-side wrapper around the UserAction callback.
 
- Static Public Member Functions inherited from Util
_.Library.Status CreateSourceControl (_.Studio.SourceControl.Base pSourceControl, _.Library.Boolean pCreated, _.Library.String pUsername, _.ZEN.proxyObject pUserData)
 Create an instance of a Source Control object.
 
_.Library.String GetCurrentProject (_.Library.Boolean pLoaded)
 Helper method to retrieve the current project for the CSP session,. More...
 
 GetFullProjectName (_.Library.String pProjectName)
 Return a project's full name, including a ".PRJ" extension.
 
_.Library.String GetSourceControlClass ()
 Return the source control class which is to be used in the current namespace. More...
 
_.Library.Boolean IsEnabled (_.Library.String pNamespace)
 Determine whether source control is enabled for the Management. More...
 
_.Library.Boolean IsProjectRequired ()
 Helper method to indicate whether the source control hooks in the current. More...
 
 SetCurrentProject (_.Library.String pProjectName, _.Library.Boolean pLoaded)
 Helper method to save the name of the current project and whether its. More...
 
_.Library.Status SetProjectRequired (_.Library.Boolean pNewValue, _.Library.Boolean pOldValue)
 Enable or disable the flag indicating whether the source control class. More...
 

Public Attributes

 canEdit
 Flag to indicate whether the user is permitted to make any changes on a given page. More...
 
 currentNamespace
 The current namespace. More...
 
 currentProject
 The name of the currently active/selected project. More...
 
 currentUser
 The current user's username. More...
 
 hasSCOutput
 Flag to indicate whether source control output is present in the current session. More...
 
 msgNotPermitted
 Message to inform the user they may not perform a given action. More...
 
 needProject
 Flag to indicate whether a project is needed for the current source control hooks. More...
 
 readOnly
 If true, user cannot modify the current document. More...
 
 readOnlyReason
 Indicator for why a document was marked as readOnly. More...
 
 renamed
 Flag to indicate whether the document has been renamed via "Save As". More...
 
 sourceControlEnabled
 Flag to indicate whether source control hooks are enabled for the current namespace. More...
 
 sourceControlManagerDialog
 Name of the manager page to use for managing popups requested by the source control class. More...
 
 sourceControlNewlineFormat
 Flag to control what newline format should be used for reporting data from the server. More...
 
 sourceControlOutputDialog
 Name of the output dialog to use. More...
 
 sourceControlVisible
 Flag to indicate whether the source control output is currently visible. More...
 

Static Public Attributes

 EDITRESOURCE = None
 Resource for subclasses to indicate whether further resources are needed to perform actions on pages.
 
 MANAGERDIALOG = None
 Page to use for managing popups requested by the source control framework.
 
 OUTPUTDIALOG = None
 Page to use for displaying output from the server.
 

Private Member Functions

_.Library.Status DrawSourceControlCommands ()
 This is a helper method to render the default HTML for the source control options in the ribbon,. More...
 
_.Library.Status DrawSourceControlHead ()
 The subclass should invoke this method from its own OnDrawHTMLHead() method.
 
_.Library.Status DrawSourceControlJS ()
 Ensure that zenMenus.js and zenCSLM.js are included in the page.
 
_.Library.Status DrawSourceControlStyle ()
 Render the CSS needed for the source control icons.
 

Detailed Description

This class is for internal InterSystems use only. The class is subject to change and should not be used by user applications.

Template for portal pages which need to be able to interact with Source Control hooks. This class implements various interfaces and behaviours into the standard Studio patterns used for <class>Studio.SourceControl.Base</class>. Note that the browser environment is inherently stateless, so the object implementing the source control hooks needs to be created from scratch every time the browser makes a request back to the server. Source control hooks written for the Studio environment will need to adjust for this situation. To assist in this migration, the hooks can should override the OnPortalCreate() callback that is inherited from <class>Studio.SourceControl.Base</class> to ensure that the Source Control object is correctly initialised whenever it is created.

Users should also modify the behaviour of any Studio templates invoked from their source control hooks.

It is critical that pages which extend this class implement a number of callbacks. The following methods MUST be overridden:

  • <method>GetInternalName</method>()
  • <method>getCurrentName</method>()
  • <method>getClientModel</method>()
  • <method>setReadOnly</method>()

The following methods may also need to be overridden depending on the page:

  • <method>getCurrentExtension</method>()
  • <method>getSaveAction</method>()
  • <method>canUserModify</method>()
  • <method>getReadOnlyReason</method>()

Furthermore, the user MUST ensure that the following methods are called from the subclass:

  • <method>initializeSourceControl</method>() must be called from the subclass's <method>onloadHandler</method>() method.
  • <method>DrawSourceControlHead</method>() must be called from the subclass's <method>OnDrawHTMLHead</method>() method.
  • <method>DrawSourceControlCommands</method>() must be called from the subclass's <method>OnDrawRibbon</method>() method.

It is also assumed that a Zen jsonProvider instance is used to represent the data model in the page. The object used for the model MUST extend <class>CSP.Portal.AbstractPortalModel</class> OR include a Timestamp property and a ReadOnly property as per the interface defined in <class>CSP.Portal.AbstractPortalModel</class> if custom JSON is sent from the server to the client. These two properties are used to ensure that the client and server versions of the document model are synchronised. Furthermore, the OnSubmitContent callback implemented in the page MUST perform a number of actions.

First, it must support two save modes. The first such mode is a standard save mode. The value of the command string for this mode should be specified in the <method>getSaveAction</method>() callback. When this standard save mode is specified, the server method must check whether the timestamp of the model on disk matches the Timestamp property of the submitted model. If they don't match, the error property of the supplied jsonProvider instance should be set to the string "timestamp". When the page sees this error, the user will be prompted to decide if they want to overwrite the data on the server. If the user does choose to overwrite the data, then <method>getSaveAction</method>() will be invoked to get the force save action. In this case, the OnSubmitContent callback should NOT perform any timestamp checks – the model should be saved to disk.

If the timestamps match, or the force command is supplied, and the model is saved to disk, the method should then ensure that an updated model is sent back to the client in the output object argument of the callback. The updated model should include both the new Timestamp for the document as well as a valid ReadOnly value. In this case, a valid ReadOnly value should be determined as follows:

  • Call <method>IsSourceControlReadOnly</method>() to determine whether the document is marked as read only by the current source control hooks. If so, set the ReadOnly property to 2.
  • Otherwise check if the document has been locked by another user. If so, set the ReadOnly property to 1.
  • Otherwise set the ReadOnly property to 0.

A sample OnSubmitContent callback method could look like the following:

Method SubmitModel( pCommand As String, pProvider As ZEN.Auxiliary.jsonProvider, pSubmitObject As RegisteredObject, ByRef pResponseObject As RegisteredObject) As Status { Set tSC = $$$OK Try { Set tReadOnly = 0 If (pCommand '= "forcesave") && ##class(Dictionary.ClassDefinition).ExistsId(..modelClassName) { // Note that 1 is passed in for the pExclusiveOnly argument as we need an exclusive lock Set tSC = ..LoadClassDefinition(..modelClassName,.tModelDef,.tReadOnly,1) If $$$ISERR(tSC) Quit If $zdatetime(tModelDef.TimeChanged,3,,6) '= pSubmitObject.Timestamp { Set pProvider.error = "timestamp" Quit } }

Set tSC = pSubmitObject.SaveToClass() If $$$ISERR(tSC) Quit

// send up-to-date model back to client, this should include updated timestamp Set pResponseObject = pSubmitObject // correct the ReadOnly flag on the response object If ..IsSourceControlReadOnly(..GetInternalName()) { Set pResponseObject.ReadOnly = 2 } Else { Set pResponseObject.ReadOnly = tReadOnly } } Catch(ex) { Set tSC = ex.AsStatus() } Quit tSC }

Member Function Documentation

◆ DrawSourceControlCommands()

_.Library.Status DrawSourceControlCommands ( )
private

This is a helper method to render the default HTML for the source control options in the ribbon,.

and should be called from the OnDrawRibbon() callback. This content should be wrapped within a td element.

◆ GetInternalName()

_.Library.String GetInternalName ( )

Return the internal name of the current document, including the three letter.

extension in upper-case. For example, MyPackage.MyClass.CLS would be the internal name for the class MyPackage.MyClass. Subclasses MUST override this method.

Reimplemented in DashboardViewer, QualityMeasures, ArchitectSA, and Architect.

◆ LoadProject()

_.Library.Status LoadProject ( _.Studio.SourceControl.Base  pSourceControl,
_.Library.String  pProject,
_.Library.Boolean  pRedirect 
)
static

Load the named project in pProject using the source control object.

supplied in pSourceControl. The pRedirect flag controls whether a local redirect should be created.

◆ canUserModify()

canUserModify (   noAlert)

Helper method to indicate whether the user is allowed to make changes to the.

current document. It should check whether the user is allowed to make changes in general (which should be indicated by <property>canEdit</property>), as well as whether the current document has been opened in read only mode (which should be indicated by <property>canEdit</property>). noAlert is a flag to indicate that the check should not raise an alert.

◆ checkTextControls()

checkTextControls ( )

Helper method for event sequencing: the onmousedown event for the menu buttons and shapes in the SVG diagram.

may be executed before the onchange event for controls in the editor pane. This helper function will call the onchange event for any controls which have had their value changed. (There should only be one such control in most cases as the onchange event would be triggered when shifting focus to a second control.)

◆ getClientModel()

getClientModel ( )

Get the jsonProvider object on the client.

Subclasses MUST override this method to return the jsonProvider.

Reimplemented in DashboardViewer, QualityMeasures, ArchitectSA, and Architect.

◆ getCurrentExtension()

getCurrentExtension ( )

Return the extension used by Studio for the class/object.

This is ".CLS" by default, but subclasses should override this method if a different extension is in use.

Reimplemented in DashboardViewer.

◆ getCurrentName()

getCurrentName ( )

Return the current name of the class/object being modified.

Subclasses MUST override this method to return the correct name.

Reimplemented in DashboardViewer, QualityMeasures, ArchitectSA, and Architect.

◆ getPageTitle()

_.Library.String getPageTitle ( )

Get the title string to add to the locator row.

This should be implemented in a subclass.

Reimplemented in QualityMeasures, and Architect.

◆ getSaveAction()

getSaveAction (   force)

Return the string used as the command when sending JSON content to the server.

The OnSubmitContent handler for the jsonProvider MUST support two action types.

Reimplemented in DashboardViewer.

◆ initializeSourceControl()

initializeSourceControl ( )

Function to initialize the source control hooks for a page.

The function should be called from the subclass's <method>onloadHandler</method>() method.

◆ invokeAfterUserAction()

invokeAfterUserAction (   input,
  userContext 
)

Client-side coordinator of calls to the AfterUserAction callback in.

the core source control class.

◆ invokeSourceControl()

invokeSourceControl (   action,
  isFramework 
)

Client-side coordinator of calls to the UserAction callback in.

the core source control class.

◆ reloadDocument()

reloadDocument ( )

Reload the current document.

Returns a boolean to indicate whether a full page reload has been triggered.

◆ setReadOnly()

setReadOnly (   readOnly)

Set <property>readOnly</property> to the value of readOnly.

Subclasses MUST implement this method to update the controls on the page so that the page's behaviour actually matches the value of the readOnly flag.

Reimplemented in DashboardViewer, QualityMeasures, ArchitectSA, and Architect.

◆ showSCMenu()

showSCMenu ( )

Display the source control menu based on the contents of the _sourceControlMenu data.

created by <method>UpdateSCMenu</method>().

◆ textControlKeyDown()

textControlKeyDown (   zenControl)

Key handler to record the value of text fields before the keyboard event is processed.

Works in conjunction with <method>textControlKeyUp</method>() to determine whether any text fields are modified.

◆ textControlKeyUp()

textControlKeyUp (   event,
  zenControl 
)

Key handler to work out whether user keys entered in controls have.

changed the content of the text field. This is to deal with situations where the onchange event for a text control is only triggered after the onmousedown event for another shape has already occurred.

◆ updateDocumentState()

updateDocumentState (   alertOnReadOnly)

Helper method to ensure that the <property>readOnly</property> and.

<property>readOnlyReason</property> properties are up to date on the client, and that the user knows about any change that has rendered the document read only.

◆ updateSCIndicator()

updateSCIndicator (   haveOutput)

Toggle the display of the star which indicates whether new.

source control output is available.

Member Data Documentation

◆ canEdit

canEdit

Flag to indicate whether the user is permitted to make any changes on a given page.

 

◆ currentNamespace

currentNamespace

The current namespace.

 

◆ currentProject

currentProject

The name of the currently active/selected project.

 

◆ currentUser

currentUser

The current user's username.

 

◆ hasSCOutput

hasSCOutput

Flag to indicate whether source control output is present in the current session.

 

◆ msgNotPermitted

msgNotPermitted

Message to inform the user they may not perform a given action.

 

◆ needProject

needProject

Flag to indicate whether a project is needed for the current source control hooks.

 

◆ readOnly

readOnly

If true, user cannot modify the current document.

 

◆ readOnlyReason

readOnlyReason

Indicator for why a document was marked as readOnly.

When <property>readOnly</property>

is true, the <method>updateDocumentState</method>() is responsible for ensuring that the property should either have a value of "sourcecontrol" or "lock".  

◆ renamed

renamed

Flag to indicate whether the document has been renamed via "Save As".

 

◆ sourceControlEnabled

sourceControlEnabled

Flag to indicate whether source control hooks are enabled for the current namespace.

 

◆ sourceControlManagerDialog

sourceControlManagerDialog

Name of the manager page to use for managing popups requested by the source control class.

 

◆ sourceControlNewlineFormat

sourceControlNewlineFormat

Flag to control what newline format should be used for reporting data from the server.

The default output is HTML.  

◆ sourceControlOutputDialog

sourceControlOutputDialog

Name of the output dialog to use.

 

◆ sourceControlVisible

sourceControlVisible

Flag to indicate whether the source control output is currently visible.