@@ -44,9 +44,9 @@ const itemIcons = {
44
44
export default class schemaBrowser {
45
45
emitter : vscode . EventEmitter < any | undefined | null | void > ;
46
46
onDidChangeTreeData : vscode . Event < any | undefined | null | void > ;
47
- cache : { [ key : string ] : object [ ] } ;
47
+ cache : { [ key : string ] : object [ ] } ;
48
48
49
- filters : { [ schema : string ] : string } = { } ;
49
+ filters : { [ schema : string ] : string } = { } ;
50
50
51
51
/**
52
52
* @param {vscode.ExtensionContext } context
@@ -138,13 +138,15 @@ export default class schemaBrowser {
138
138
139
139
vscode . commands . registerCommand ( `vscode-db2i.generateSQL` , async ( object : SQLObject ) => {
140
140
if ( object ) {
141
- try {
142
- const content = await Schemas . generateSQL ( object . schema , object . uniqueName ( ) , object . type . toUpperCase ( ) ) ;
143
- const textDoc = await vscode . workspace . openTextDocument ( { language : `sql` , content} ) ;
144
- await vscode . window . showTextDocument ( textDoc ) ;
145
- } catch ( e ) {
146
- vscode . window . showErrorMessage ( e . message ) ;
147
- }
141
+ vscode . window . withProgress ( { location : vscode . ProgressLocation . Window , title : `Generating SQL` } , async ( ) => {
142
+ try {
143
+ const content = await Schemas . generateSQL ( object . schema , object . uniqueName ( ) , object . type . toUpperCase ( ) ) ;
144
+ const textDoc = await vscode . workspace . openTextDocument ( { language : `sql` , content } ) ;
145
+ await vscode . window . showTextDocument ( textDoc ) ;
146
+ } catch ( e ) {
147
+ vscode . window . showErrorMessage ( e . message ) ;
148
+ }
149
+ } ) ;
148
150
}
149
151
} ) ,
150
152
@@ -162,10 +164,10 @@ export default class schemaBrowser {
162
164
}
163
165
} ) ,
164
166
165
- vscode . commands . registerCommand ( `vscode-db2i.getMTIs` , async ( object : SQLObject | SchemaItem ) => {
167
+ vscode . commands . registerCommand ( `vscode-db2i.getMTIs` , async ( object : SQLObject | SchemaItem ) => {
166
168
if ( object ) {
167
169
const content = getMTIStatement ( object . schema , ( `name` in object ? object . name : undefined ) ) ;
168
-
170
+
169
171
if ( content ) {
170
172
vscode . commands . executeCommand ( `vscode-db2i.runEditorStatement` , {
171
173
content,
@@ -186,7 +188,7 @@ export default class schemaBrowser {
186
188
} ) ;
187
189
}
188
190
} ) ,
189
-
191
+
190
192
vscode . commands . registerCommand ( `vscode-db2i.getAuthorities` , async ( object : SQLObject ) => {
191
193
if ( object ) {
192
194
const content = getAuthoritiesStatement ( object . schema , object . name , object . type . toUpperCase ( ) , object . tableType ) ;
@@ -209,16 +211,16 @@ export default class schemaBrowser {
209
211
}
210
212
} ) ,
211
213
212
- vscode . commands . registerCommand ( `vscode-db2i.advisedIndexes` , async ( object : SQLObject | SchemaItem ) => { //table
214
+ vscode . commands . registerCommand ( `vscode-db2i.advisedIndexes` , async ( object : SQLObject | SchemaItem ) => { //table
213
215
if ( object ) {
214
- let content : string | undefined ;
216
+ let content : string | undefined ;
215
217
if ( `name` in object ) {
216
218
content = getAdvisedIndexesStatement ( object . schema , object . name ) ;
217
219
}
218
220
else {
219
221
content = getAdvisedIndexesStatement ( object . schema ) ;
220
222
}
221
-
223
+
222
224
if ( content ) {
223
225
vscode . commands . executeCommand ( `vscode-db2i.runEditorStatement` , {
224
226
content,
@@ -229,16 +231,16 @@ export default class schemaBrowser {
229
231
}
230
232
} ) ,
231
233
232
- vscode . commands . registerCommand ( `vscode-db2i.clearAdvisedIndexes` , async ( object : SQLObject | SchemaItem ) => {
234
+ vscode . commands . registerCommand ( `vscode-db2i.clearAdvisedIndexes` , async ( object : SQLObject | SchemaItem ) => {
233
235
if ( object ) {
234
236
const isObject = `name` in object ;
235
237
let result ;
236
238
237
- result = await vscode . window . showWarningMessage ( `Are you sure you want to clear all of the advised index rows from the Index Advisor for ${ object . schema } ${ isObject ? `${ object . name } ` : '' } ?` , {
239
+ result = await vscode . window . showWarningMessage ( `Are you sure you want to clear all of the advised index rows from the Index Advisor for ${ object . schema } ${ isObject ? `${ object . name } ` : '' } ?` , {
238
240
modal : true ,
239
241
} , 'No' , 'Yes' ) ;
240
-
241
- if ( result === 'Yes' ) {
242
+
243
+ if ( result === 'Yes' ) {
242
244
try {
243
245
await Schemas . clearAdvisedIndexes ( object . schema , isObject ? object . name : undefined ) ;
244
246
} catch ( e ) {
@@ -254,7 +256,7 @@ export default class schemaBrowser {
254
256
modal : true ,
255
257
} , 'No' , 'Yes' ) ;
256
258
257
- if ( result === 'Yes' ) {
259
+ if ( result === 'Yes' ) {
258
260
try {
259
261
await vscode . window . withProgress ( {
260
262
location : vscode . ProgressLocation . Notification ,
@@ -289,7 +291,7 @@ export default class schemaBrowser {
289
291
} , async ( ) => {
290
292
await Schemas . renameObject ( object . schema , object . name , name , object . type ) ;
291
293
} ) ;
292
-
294
+
293
295
vscode . window . showInformationMessage ( `Renamed ${ object . name } to ${ name } ` ) ;
294
296
this . clearCacheAndRefresh ( ) ;
295
297
} catch ( e ) {
@@ -301,14 +303,14 @@ export default class schemaBrowser {
301
303
}
302
304
}
303
305
} ) ,
304
-
306
+
305
307
vscode . commands . registerCommand ( `vscode-db2i.clearData` , async ( object : SQLObject ) => {
306
308
if ( object ) {
307
309
const result = await vscode . window . showWarningMessage ( `Are you sure you want to clear ${ object . name } ?` , {
308
310
modal : true ,
309
311
} , 'No' , 'Yes' ) ;
310
312
311
- if ( result === 'Yes' ) {
313
+ if ( result === 'Yes' ) {
312
314
try {
313
315
await vscode . window . withProgress ( {
314
316
location : vscode . ProgressLocation . Notification ,
@@ -328,8 +330,8 @@ export default class schemaBrowser {
328
330
vscode . commands . registerCommand ( `vscode-db2i.copyData` , async ( object : SQLObject ) => {
329
331
if ( object ) {
330
332
const page = await getCopyUi ( ) . loadPage < any > ( ( `Copy File - ${ object . schema } .${ object . name } ` ) ) ;
331
-
332
- if ( page && page . data ) {
333
+
334
+ if ( page && page . data ) {
333
335
const data = page . data ;
334
336
page . panel . dispose ( ) ;
335
337
@@ -341,7 +343,7 @@ export default class schemaBrowser {
341
343
} , async ( ) => {
342
344
await Table . copyFile ( object . system . schema , object . system . name , data ) ;
343
345
} ) ;
344
-
346
+
345
347
vscode . window . showInformationMessage ( `Table copied` ) ;
346
348
this . clearCacheAndRefresh ( ) ;
347
349
} catch ( e ) {
@@ -369,7 +371,7 @@ export default class schemaBrowser {
369
371
370
372
const config = getInstance ( ) . getConfig ( ) ;
371
373
const currentLibrary = config . currentLibrary . toUpperCase ( ) ;
372
-
374
+
373
375
if ( schema && schema !== currentLibrary ) {
374
376
config . currentLibrary = schema ;
375
377
await getInstance ( ) . setConfig ( config ) ;
@@ -477,7 +479,7 @@ export default class schemaBrowser {
477
479
return element ;
478
480
}
479
481
480
- async getChildren ( element ?: Schema | SchemaItem | SQLObject ) {
482
+ async getChildren ( element ?: Schema | SchemaItem | SQLObject ) {
481
483
let items = [ ] ;
482
484
483
485
if ( element ) {
@@ -489,7 +491,7 @@ export default class schemaBrowser {
489
491
let filterValue = this . filters [ element . schema ] ;
490
492
if ( filterValue ) {
491
493
const validSchemaName = Statement . noQuotes ( element . schema ) ;
492
- const filteredObjects = await Schemas . getObjects ( validSchemaName , AllSQLTypes , { filter : filterValue } ) ;
494
+ const filteredObjects = await Schemas . getObjects ( validSchemaName , AllSQLTypes , { filter : filterValue } ) ;
493
495
items = filteredObjects . map ( obj => new SQLObject ( obj ) ) ;
494
496
495
497
} else {
@@ -499,16 +501,16 @@ export default class schemaBrowser {
499
501
500
502
501
503
} else
502
- if ( element instanceof SchemaItem ) {
503
- items = await this . fetchData ( element . schema , contextValue as SQLType , false ) ;
504
- } else
505
- if ( element instanceof SQLObject ) {
506
- const type = element . type ;
507
-
508
- if ( Types [ type ] ) {
509
- items = await Types [ type ] . getChildren ( element . schema , element . uniqueName ( ) ) ;
510
- }
511
- }
504
+ if ( element instanceof SchemaItem ) {
505
+ items = await this . fetchData ( element . schema , contextValue as SQLType , false ) ;
506
+ } else
507
+ if ( element instanceof SQLObject ) {
508
+ const type = element . type ;
509
+
510
+ if ( Types [ type ] ) {
511
+ items = await Types [ type ] . getChildren ( element . schema , element . uniqueName ( ) ) ;
512
+ }
513
+ }
512
514
513
515
} else {
514
516
const connection = getInstance ( ) . getConnection ( ) ;
0 commit comments