@@ -11,6 +11,16 @@ import { importAndCompile } from "./compile";
1111
1212export let documentBeingProcessed : vscode . TextDocument = null ;
1313
14+ export enum OtherStudioAction {
15+ AttemptedEdit = 0 ,
16+ CreatedNewDocument = 1 ,
17+ DeletedDocument = 2 ,
18+ OpenedDocument = 3 ,
19+ ClosedDocument = 4 ,
20+ ConnectedToNewNamespace = 5 ,
21+ FirstTimeDocumentSave = 7 ,
22+ }
23+
1424interface StudioAction extends vscode . QuickPickItem {
1525 name : string ;
1626 id : string ;
@@ -277,28 +287,23 @@ class StudioActions {
277287 . then ( action => this . userAction ( action ) ) ;
278288 }
279289
280- public attemptedEdit ( ) {
281- const query = "select * from %Atelier_v1_Utils.Extension_GetStatus(?)" ;
282- this . api . actionQuery ( query , [ this . name ] ) . then ( statusObj => {
283- const docStatus = statusObj . result . content . pop ( ) ;
284- // if(!docStatus.editable && docStatus.inSourceControl && !docStatus.isCheckedOut) {
285- if ( ! docStatus . editable ) {
286- const attemptedEditAction = {
287- id : "0" ,
288- label : "Attempted Edit"
289- } ;
290- vscode . commands . executeCommand ( 'undo' ) ;
291- this . userAction ( attemptedEditAction , false , "" , "" , 1 ) ;
292- } // else if(!docStatus.editable && docStatus.in)
293- } ) ;
294- }
295-
296- public changedNamespace ( ) {
297- const changedNamespaceAction = {
298- id : "5" ,
299- label : "Changed Namespace"
290+ public fireOtherStudioAction ( action : OtherStudioAction ) {
291+ if ( action === OtherStudioAction . AttemptedEdit ) {
292+ const query = "select * from %Atelier_v1_Utils.Extension_GetStatus(?)" ;
293+ this . api . actionQuery ( query , [ this . name ] ) . then ( statusObj => {
294+ const docStatus = statusObj . result . content . pop ( ) ;
295+ if ( ! docStatus . editable ) {
296+ vscode . commands . executeCommand ( 'undo' ) ;
297+ } else {
298+ return ;
299+ }
300+ } ) ;
301+ }
302+ const actionObject = {
303+ id : action . toString ( ) ,
304+ label : getOtherStudioActionLabel ( action )
300305 } ;
301- this . userAction ( changedNamespaceAction , false , "" , "" , 1 ) ;
306+ this . userAction ( actionObject , false , "" , "" , 1 ) ;
302307 }
303308
304309 private async processSaveFlag ( saveFlag : number ) {
@@ -341,14 +346,6 @@ export async function mainMenu(uri: vscode.Uri) {
341346 return studioActions && studioActions . getMenu ( "" ) ;
342347}
343348
344- export async function fireAttemptedEdit ( uri : vscode . Uri ) {
345- if ( ! uri || uri . scheme !== FILESYSTEM_SCHEMA ) {
346- return ;
347- }
348- const studioActions = new StudioActions ( uri ) ;
349- studioActions . attemptedEdit ( ) ;
350- }
351-
352349export async function contextMenu ( node : PackageNode | ClassNode | RoutineNode ) : Promise < any > {
353350 const nodeOrUri = node || vscode . window . activeTextEditor . document . uri ;
354351 if ( ! nodeOrUri || ( nodeOrUri instanceof vscode . Uri && nodeOrUri . scheme !== FILESYSTEM_SCHEMA ) ) {
@@ -358,7 +355,28 @@ export async function contextMenu(node: PackageNode | ClassNode | RoutineNode):
358355 return studioActions && studioActions . getMenu ( "" , true ) ;
359356}
360357
361- export async function fireChangedNamespace ( ) {
362- const studioActions = new StudioActions ( ) ;
363- return studioActions && studioActions . changedNamespace ( ) ;
364- }
358+ export async function fireOtherStudioAction ( action : OtherStudioAction , uri ?: vscode . Uri ) {
359+ const studioActions = new StudioActions ( uri ) ;
360+ return studioActions && studioActions . fireOtherStudioAction ( action ) ;
361+ }
362+
363+ function getOtherStudioActionLabel ( action : OtherStudioAction ) : string {
364+ let label = "" ;
365+ switch ( action ) {
366+ case OtherStudioAction . AttemptedEdit :
367+ label = "Attempted Edit" ;
368+ case OtherStudioAction . CreatedNewDocument :
369+ label = "Created New Document" ;
370+ case OtherStudioAction . DeletedDocument :
371+ label = "Deleted Document" ;
372+ case OtherStudioAction . OpenedDocument :
373+ label = "Opened Document" ;
374+ case OtherStudioAction . ClosedDocument :
375+ label = "Closed Document" ;
376+ case OtherStudioAction . ConnectedToNewNamespace :
377+ label = "Changed Namespace" ;
378+ case OtherStudioAction . FirstTimeDocumentSave :
379+ label = "Saved Document to Server for the First Time"
380+ }
381+ return label ;
382+ }
0 commit comments