@@ -11,6 +11,16 @@ import { importAndCompile } from "./compile";
11
11
12
12
export let documentBeingProcessed : vscode . TextDocument = null ;
13
13
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
+
14
24
interface StudioAction extends vscode . QuickPickItem {
15
25
name : string ;
16
26
id : string ;
@@ -277,28 +287,23 @@ class StudioActions {
277
287
. then ( action => this . userAction ( action ) ) ;
278
288
}
279
289
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 )
300
305
} ;
301
- this . userAction ( changedNamespaceAction , false , "" , "" , 1 ) ;
306
+ this . userAction ( actionObject , false , "" , "" , 1 ) ;
302
307
}
303
308
304
309
private async processSaveFlag ( saveFlag : number ) {
@@ -341,14 +346,6 @@ export async function mainMenu(uri: vscode.Uri) {
341
346
return studioActions && studioActions . getMenu ( "" ) ;
342
347
}
343
348
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
-
352
349
export async function contextMenu ( node : PackageNode | ClassNode | RoutineNode ) : Promise < any > {
353
350
const nodeOrUri = node || vscode . window . activeTextEditor . document . uri ;
354
351
if ( ! nodeOrUri || ( nodeOrUri instanceof vscode . Uri && nodeOrUri . scheme !== FILESYSTEM_SCHEMA ) ) {
@@ -358,7 +355,28 @@ export async function contextMenu(node: PackageNode | ClassNode | RoutineNode):
358
355
return studioActions && studioActions . getMenu ( "" , true ) ;
359
356
}
360
357
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