Resolving onClickCommand and clean up

Drop the viewlet part in treeExplorerViewletService
This commit is contained in:
Pine Wu
2016-10-11 15:24:34 -07:00
parent 09703d267e
commit c7f2d3d1f1
10 changed files with 53 additions and 22 deletions

View File

@@ -66,7 +66,7 @@ export function createApiFactory(threadService: IThreadService, extensionService
const extHostDocuments = col.define(ExtHostContext.ExtHostDocuments).set<ExtHostDocuments>(new ExtHostDocuments(threadService));
const extHostDocumentSaveParticipant = col.define(ExtHostContext.ExtHostDocumentSaveParticipant).set<ExtHostDocumentSaveParticipant>(new ExtHostDocumentSaveParticipant(extHostDocuments, threadService.get(MainContext.MainThreadWorkspace)));
const extHostEditors = col.define(ExtHostContext.ExtHostEditors).set<ExtHostEditors>(new ExtHostEditors(threadService, extHostDocuments));
const extHostExplorers = col.define(ExtHostContext.ExtHostExplorers).set<ExtHostTreeExplorers>(new ExtHostTreeExplorers(threadService));
const extHostExplorers = col.define(ExtHostContext.ExtHostExplorers).set<ExtHostTreeExplorers>(new ExtHostTreeExplorers(threadService, extHostCommands));
const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set<ExtHostCommands>(new ExtHostCommands(threadService, extHostEditors, extHostHeapService));
const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set<ExtHostConfiguration>(new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration)));
const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set<ExtHostDiagnostics>(new ExtHostDiagnostics(threadService));

View File

@@ -267,6 +267,7 @@ export abstract class ExtHostEditorsShape {
export abstract class ExtHostTreeExplorersShape {
$provideRootNode(providerId: string): TPromise<InternalTreeExplorerNode> { throw ni(); };
$resolveChildren(providerId: string, node: InternalTreeExplorerNode): TPromise<InternalTreeExplorerNode[]> { throw ni(); }
$resolveCommand(providerId: string, node: InternalTreeExplorerNode): TPromise<void> { throw ni(); }
}
export abstract class ExtHostExtensionServiceShape {

View File

@@ -10,6 +10,7 @@ import { Disposable } from 'vs/workbench/api/node/extHostTypes';
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
import { MainContext, ExtHostTreeExplorersShape, MainThreadTreeExplorersShape } from './extHost.protocol';
import { InternalTreeExplorerNode } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
export class ExtHostTreeExplorers extends ExtHostTreeExplorersShape {
private _proxy: MainThreadTreeExplorersShape;
@@ -19,7 +20,8 @@ export class ExtHostTreeExplorers extends ExtHostTreeExplorersShape {
private _externalNodeMaps: { [providerId: string]: { [id: number]: TreeExplorerNode }};
constructor(
threadService: IThreadService
threadService: IThreadService,
private commands: ExtHostCommands
) {
super();
@@ -73,4 +75,20 @@ export class ExtHostTreeExplorers extends ExtHostTreeExplorersShape {
});
}));
}
$resolveCommand(providerId: string, mainThreadNode: InternalTreeExplorerNode): TPromise<void> {
const provider = this._treeExplorerNodeProviders[providerId];
if (!provider) {
throw new Error(`no TreeContentProvider registered with id '${providerId}'`);
}
if (mainThreadNode.onClickCommand) {
return TPromise.wrap(this.commands.executeCommand(mainThreadNode.onClickCommand, this._externalNodeMaps[providerId][mainThreadNode.id]).then(() => {
// Todo: error handling
return null;
}));
}
return TPromise.as(null);
}
}

View File

@@ -8,7 +8,7 @@ import { TreeExplorerNode } from 'vscode';
import { TPromise } from 'vs/base/common/winjs.base';
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
import { ExtHostContext, MainThreadTreeExplorersShape, ExtHostTreeExplorersShape } from './extHost.protocol';
import { ITreeExplorerViewletService } from 'vs/workbench/parts/explorers/browser/treeExplorerViewletService';
import { ITreeExplorerService } from 'vs/workbench/parts/explorers/browser/treeExplorerService';
import { InternalTreeExplorerNode } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
export class MainThreadTreeExplorers extends MainThreadTreeExplorersShape {
@@ -18,7 +18,7 @@ export class MainThreadTreeExplorers extends MainThreadTreeExplorersShape {
constructor(
@IThreadService threadService: IThreadService,
@ITreeExplorerViewletService private treeExplorerViewletService: ITreeExplorerViewletService
@ITreeExplorerService private treeExplorerViewletService: ITreeExplorerService
) {
super();
@@ -36,6 +36,9 @@ export class MainThreadTreeExplorers extends MainThreadTreeExplorersShape {
},
resolveChildren: (node: InternalTreeExplorerNode): TPromise<InternalTreeExplorerNode[]> => {
return this._proxy.$resolveChildren(providerId, node);
},
resolveCommand: (node: InternalTreeExplorerNode): TPromise<void> => {
return this._proxy.$resolveCommand(providerId, node);
}
});
}