44 *--------------------------------------------------------------------------------------------*/
55'use strict' ;
66
7- import { IAction , Action } from 'vs/base/common/actions' ;
8- import { Promise , TPromise } from 'vs/base/common/winjs.base' ;
9- import { SyncDescriptor0 , createSyncDescriptor , AsyncDescriptor0 } from 'vs/platform/instantiation/common/descriptors' ;
10- import { IConstructorSignature2 , IInstantiationService , createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
7+ import { Action } from 'vs/base/common/actions' ;
8+ import { TPromise } from 'vs/base/common/winjs.base' ;
9+ import { SyncDescriptor0 , createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors' ;
10+ import { IConstructorSignature2 , createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
1111import { IKeybindings } from 'vs/platform/keybinding/common/keybinding' ;
1212import { ContextKeyExpr , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
1313import { ICommandService } from 'vs/platform/commands/common/commands' ;
@@ -202,135 +202,4 @@ export class SyncActionDescriptor {
202202 public get keybindingWeight ( ) : number {
203203 return this . _keybindingWeight ;
204204 }
205- }
206-
207- /**
208- * A proxy for an action that needs to load code in order to confunction. Can be used from contributions to defer
209- * module loading up to the point until the run method is being executed.
210- */
211- export class DeferredAction extends Action {
212- private _cachedAction : IAction ;
213- private _emitterUnbind : IDisposable ;
214-
215- constructor ( private _instantiationService : IInstantiationService ,
216- private _descriptor : AsyncDescriptor0 < Action > ,
217- id : string , label = '' , cssClass = '' , enabled = true ) {
218-
219- super ( id , label , cssClass , enabled ) ;
220- }
221-
222- public get cachedAction ( ) : IAction {
223- return this . _cachedAction ;
224- }
225-
226- public set cachedAction ( action : IAction ) {
227- this . _cachedAction = action ;
228- }
229-
230- public get id ( ) : string {
231- if ( this . _cachedAction instanceof Action ) {
232- return this . _cachedAction . id ;
233- }
234-
235- return this . _id ;
236- }
237-
238- public get label ( ) : string {
239- if ( this . _cachedAction instanceof Action ) {
240- return this . _cachedAction . label ;
241- }
242-
243- return this . _label ;
244- }
245-
246- public set label ( value : string ) {
247- if ( this . _cachedAction instanceof Action ) {
248- this . _cachedAction . label = value ;
249- } else {
250- this . _setLabel ( value ) ;
251- }
252- }
253-
254- public get class ( ) : string {
255- if ( this . _cachedAction instanceof Action ) {
256- return this . _cachedAction . class ;
257- }
258-
259- return this . _cssClass ;
260- }
261-
262- public set class ( value : string ) {
263- if ( this . _cachedAction instanceof Action ) {
264- this . _cachedAction . class = value ;
265- } else {
266- this . _setClass ( value ) ;
267- }
268- }
269-
270- public get enabled ( ) : boolean {
271- if ( this . _cachedAction instanceof Action ) {
272- return this . _cachedAction . enabled ;
273- }
274- return this . _enabled ;
275- }
276-
277- public set enabled ( value : boolean ) {
278- if ( this . _cachedAction instanceof Action ) {
279- this . _cachedAction . enabled = value ;
280- } else {
281- this . _setEnabled ( value ) ;
282- }
283- }
284-
285- public get order ( ) : number {
286- if ( this . _cachedAction instanceof Action ) {
287- return ( < Action > this . _cachedAction ) . order ;
288- }
289- return this . _order ;
290- }
291-
292- public set order ( order : number ) {
293- if ( this . _cachedAction instanceof Action ) {
294- ( < Action > this . _cachedAction ) . order = order ;
295- } else {
296- this . _order = order ;
297- }
298- }
299-
300- public run ( event ?: any ) : Promise {
301- if ( this . _cachedAction ) {
302- return this . _cachedAction . run ( event ) ;
303- }
304- return this . _createAction ( ) . then ( ( action : IAction ) => {
305- return action . run ( event ) ;
306- } ) ;
307- }
308-
309- private _createAction ( ) : TPromise < IAction > {
310- let promise = TPromise . as ( undefined ) ;
311- return promise . then ( ( ) => {
312- return this . _instantiationService . createInstance ( this . _descriptor ) ;
313- } ) . then ( action => {
314- if ( action instanceof Action ) {
315- this . _cachedAction = action ;
316- // Pipe events from the instantated action through this deferred action
317- this . _emitterUnbind = action . onDidChange ( e => this . _onDidChange . fire ( e ) ) ;
318-
319- } else {
320- throw new Error ( 'Action must be an instanceof Base Action' ) ;
321- }
322-
323- return action ;
324- } ) ;
325- }
326-
327- public dispose ( ) : void {
328- if ( this . _emitterUnbind ) {
329- this . _emitterUnbind . dispose ( ) ;
330- }
331- if ( this . _cachedAction ) {
332- this . _cachedAction . dispose ( ) ;
333- }
334- super . dispose ( ) ;
335- }
336- }
205+ }
0 commit comments