mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Contribute explorer views
- Adopt proposed API to contribute explorer views - Adopt extension host and main to contribute explorer views - Implement contributable views in explorer viewlet
This commit is contained in:
@@ -18,7 +18,7 @@ import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
|
||||
import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/node/extHostDocumentSaveParticipant';
|
||||
import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration';
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import { ExtHostTreeView } from 'vs/workbench/api/node/extHostTreeView';
|
||||
import { ExtHostExplorerView } from 'vs/workbench/api/node/extHostExplorerView';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
import { ExtHostQuickOpen } from 'vs/workbench/api/node/extHostQuickOpen';
|
||||
import { ExtHostProgress } from 'vs/workbench/api/node/extHostProgress';
|
||||
@@ -111,7 +111,7 @@ export function createApiFactory(
|
||||
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, extHostDocumentsAndEditors));
|
||||
const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set<ExtHostCommands>(new ExtHostCommands(threadService, extHostHeapService));
|
||||
const extHostTreeView = col.define(ExtHostContext.ExtHostTreeView).set<ExtHostTreeView>(new ExtHostTreeView(threadService, extHostCommands));
|
||||
const extHostExplorerView = col.define(ExtHostContext.ExtHostExplorerView).set<ExtHostExplorerView>(new ExtHostExplorerView(threadService, extHostCommands));
|
||||
const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set<ExtHostConfiguration>(new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), initData.configuration));
|
||||
const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set<ExtHostDiagnostics>(new ExtHostDiagnostics(threadService));
|
||||
const languageFeatures = col.define(ExtHostContext.ExtHostLanguageFeatures).set<ExtHostLanguageFeatures>(new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostHeapService, extHostDiagnostics));
|
||||
@@ -369,8 +369,8 @@ export function createApiFactory(
|
||||
sampleFunction: proposedApiFunction(extension, () => {
|
||||
return extHostMessageService.showMessage(Severity.Info, 'Hello Proposed Api!', {}, []);
|
||||
}),
|
||||
createTreeView: proposedApiFunction(extension, (providerId: string, provider: vscode.TreeDataProvider<any>): vscode.TreeView<any> => {
|
||||
return extHostTreeView.createTreeView(providerId, provider);
|
||||
createExplorerView: proposedApiFunction(extension, (id: string, name: string, provider: vscode.TreeDataProvider<any>): vscode.View<any> => {
|
||||
return extHostExplorerView.createExplorerView(id, name, provider);
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { MainThreadDiagnostics } from './mainThreadDiagnostics';
|
||||
import { MainThreadDocuments } from './mainThreadDocuments';
|
||||
import { MainThreadEditors } from './mainThreadEditors';
|
||||
import { MainThreadErrors } from './mainThreadErrors';
|
||||
import { MainThreadTreeView } from './mainThreadTreeView';
|
||||
import { MainThreadExplorerView } from './mainThreadExplorerView';
|
||||
import { MainThreadLanguageFeatures } from './mainThreadLanguageFeatures';
|
||||
import { MainThreadLanguages } from './mainThreadLanguages';
|
||||
import { MainThreadMessageService } from './mainThreadMessageService';
|
||||
@@ -74,7 +74,7 @@ export class ExtHostContribution implements IWorkbenchContribution {
|
||||
col.define(MainContext.MainThreadDocuments).set(this.instantiationService.createInstance(MainThreadDocuments, documentsAndEditors));
|
||||
col.define(MainContext.MainThreadEditors).set(this.instantiationService.createInstance(MainThreadEditors, documentsAndEditors));
|
||||
col.define(MainContext.MainThreadErrors).set(create(MainThreadErrors));
|
||||
col.define(MainContext.MainThreadExplorers).set(create(MainThreadTreeView));
|
||||
col.define(MainContext.MainThreadExplorerViews).set(create(MainThreadExplorerView));
|
||||
col.define(MainContext.MainThreadLanguageFeatures).set(create(MainThreadLanguageFeatures));
|
||||
col.define(MainContext.MainThreadLanguages).set(create(MainThreadLanguages));
|
||||
col.define(MainContext.MainThreadMessageService).set(create(MainThreadMessageService));
|
||||
|
||||
@@ -37,7 +37,6 @@ import { IPickOpenEntry, IPickOptions } from 'vs/platform/quickOpen/common/quick
|
||||
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IApplyEditsOptions, IUndoStopOptions, TextEditorRevealType, ITextEditorConfigurationUpdate, IResolvedTextEditorConfiguration, ISelectionChangeEvent } from './mainThreadEditor';
|
||||
|
||||
import { InternalTreeNodeContent } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
|
||||
import { TaskSet } from 'vs/workbench/parts/tasks/common/tasks';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorModel';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
@@ -155,14 +154,17 @@ export abstract class MainThreadEditorsShape {
|
||||
$getDiffInformation(id: string): TPromise<editorCommon.ILineChange[]> { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class MainThreadTreeViewShape {
|
||||
$registerTreeDataProvider(providerId: string): void { throw ni(); }
|
||||
$refresh(providerId: string, node: InternalTreeNodeContent): void { throw ni(); }
|
||||
export interface ITreeNode {
|
||||
id: string;
|
||||
label: string;
|
||||
hasChildren: boolean;
|
||||
clickCommand: string;
|
||||
contextKey: string;
|
||||
}
|
||||
|
||||
export abstract class MainThreadTreeShape {
|
||||
$registerTreeExplorerNodeProvider(providerId: string, node: InternalTreeNodeContent): void { throw ni(); }
|
||||
$refresh(providerId: string, node: InternalTreeNodeContent): void { throw ni(); }
|
||||
export abstract class MainThreadExplorerViewShape {
|
||||
$registerView(id: string, name: string): void { throw ni(); }
|
||||
$refresh(viewId: string, node: ITreeNode): void { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class MainThreadErrorsShape {
|
||||
@@ -366,15 +368,10 @@ export abstract class ExtHostDocumentsAndEditorsShape {
|
||||
}
|
||||
|
||||
|
||||
export abstract class ExtHostTreeViewShape {
|
||||
$provideRootNode(providerId: string): TPromise<InternalTreeNodeContent> { throw ni(); };
|
||||
$resolveChildren(providerId: string, node: InternalTreeNodeContent): TPromise<InternalTreeNodeContent[]> { throw ni(); }
|
||||
$getInternalCommand(providerId: string, node: InternalTreeNodeContent): TPromise<modes.Command> { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class ExtHostTreeShape {
|
||||
$resolveChildren(providerId: string, node: InternalTreeNodeContent): TPromise<InternalTreeNodeContent[]> { throw ni(); }
|
||||
$getInternalCommand(providerId: string, node: InternalTreeNodeContent): TPromise<modes.Command> { throw ni(); }
|
||||
export abstract class ExtHostExplorerViewShape {
|
||||
$provideRootNode(viewId: string): TPromise<ITreeNode> { throw ni(); };
|
||||
$resolveChildren(viewId: string, node: ITreeNode): TPromise<ITreeNode[]> { throw ni(); }
|
||||
$getInternalCommand(viewId: string, node: ITreeNode): TPromise<modes.Command> { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class ExtHostExtensionServiceShape {
|
||||
@@ -465,7 +462,7 @@ export const MainContext = {
|
||||
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments', MainThreadDocumentsShape),
|
||||
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors', MainThreadEditorsShape),
|
||||
MainThreadErrors: createMainId<MainThreadErrorsShape>('MainThreadErrors', MainThreadErrorsShape),
|
||||
MainThreadExplorers: createMainId<MainThreadTreeViewShape>('MainThreadTreeView', MainThreadTreeViewShape),
|
||||
MainThreadExplorerViews: createMainId<MainThreadExplorerViewShape>('MainThreadExplorerView', MainThreadExplorerViewShape),
|
||||
MainThreadLanguageFeatures: createMainId<MainThreadLanguageFeaturesShape>('MainThreadLanguageFeatures', MainThreadLanguageFeaturesShape),
|
||||
MainThreadLanguages: createMainId<MainThreadLanguagesShape>('MainThreadLanguages', MainThreadLanguagesShape),
|
||||
MainThreadMessageService: createMainId<MainThreadMessageServiceShape>('MainThreadMessageService', MainThreadMessageServiceShape),
|
||||
@@ -490,7 +487,7 @@ export const ExtHostContext = {
|
||||
ExtHostDocuments: createExtId<ExtHostDocumentsShape>('ExtHostDocuments', ExtHostDocumentsShape),
|
||||
ExtHostDocumentSaveParticipant: createExtId<ExtHostDocumentSaveParticipantShape>('ExtHostDocumentSaveParticipant', ExtHostDocumentSaveParticipantShape),
|
||||
ExtHostEditors: createExtId<ExtHostEditorsShape>('ExtHostEditors', ExtHostEditorsShape),
|
||||
ExtHostTreeView: createExtId<ExtHostTreeViewShape>('ExtHostTreeView', ExtHostTreeViewShape),
|
||||
ExtHostExplorerView: createExtId<ExtHostExplorerViewShape>('ExtHostExplorerView', ExtHostExplorerViewShape),
|
||||
ExtHostFileSystemEventService: createExtId<ExtHostFileSystemEventServiceShape>('ExtHostFileSystemEventService', ExtHostFileSystemEventServiceShape),
|
||||
ExtHostHeapService: createExtId<ExtHostHeapServiceShape>('ExtHostHeapMonitor', ExtHostHeapServiceShape),
|
||||
ExtHostLanguageFeatures: createExtId<ExtHostLanguageFeaturesShape>('ExtHostLanguageFeatures', ExtHostLanguageFeaturesShape),
|
||||
|
||||
@@ -5,27 +5,28 @@
|
||||
'use strict';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { TreeView, TreeDataProvider } from 'vscode';
|
||||
import { View, TreeDataProvider } from 'vscode';
|
||||
import { defaultGenerator } from 'vs/base/common/idGenerator';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { MainContext, ExtHostTreeViewShape, MainThreadTreeViewShape } from './extHost.protocol';
|
||||
import { InternalTreeNode } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
|
||||
import { MainContext, ExtHostExplorerViewShape, MainThreadExplorerViewShape, ITreeNode } from './extHost.protocol';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
|
||||
class InternalTreeNodeImpl implements InternalTreeNode {
|
||||
class TreeNodeImpl implements ITreeNode {
|
||||
|
||||
readonly id: string;
|
||||
label: string;
|
||||
hasChildren: boolean;
|
||||
clickCommand: string = null;
|
||||
contextKey: string;
|
||||
|
||||
constructor(readonly providerId: string, node: any, provider: TreeDataProvider<any>) {
|
||||
this.id = defaultGenerator.nextId();
|
||||
this.label = provider.getLabel ? provider.getLabel(node) : node.toString();
|
||||
this.hasChildren = provider.getHasChildren ? provider.getHasChildren(node) : true;
|
||||
this.contextKey = provider.getContextKey ? provider.getContextKey(node) : null;
|
||||
if (provider.getClickCommand) {
|
||||
const command = provider.getClickCommand(node);
|
||||
if (command) {
|
||||
@@ -35,13 +36,13 @@ class InternalTreeNodeImpl implements InternalTreeNode {
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
private _proxy: MainThreadTreeViewShape;
|
||||
export class ExtHostExplorerView extends ExtHostExplorerViewShape {
|
||||
private _proxy: MainThreadExplorerViewShape;
|
||||
|
||||
private _extNodeProviders: { [providerId: string]: TreeDataProvider<any> };
|
||||
private _extViews: Map<string, TreeView<any>> = new Map<string, TreeView<any>>();
|
||||
private _extNodeMaps: { [providerId: string]: { [id: string]: InternalTreeNode } };
|
||||
private _mainNodesMap: Map<string, Map<any, InternalTreeNode>>;
|
||||
private _extViews: Map<string, View<any>> = new Map<string, View<any>>();
|
||||
private _extNodeMaps: { [providerId: string]: { [id: string]: ITreeNode } };
|
||||
private _mainNodesMap: Map<string, Map<any, ITreeNode>>;
|
||||
private _childrenNodesMap: Map<string, Map<any, any[]>>;
|
||||
|
||||
constructor(
|
||||
@@ -50,11 +51,11 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
) {
|
||||
super();
|
||||
|
||||
this._proxy = threadService.get(MainContext.MainThreadExplorers);
|
||||
this._proxy = threadService.get(MainContext.MainThreadExplorerViews);
|
||||
|
||||
this._extNodeProviders = Object.create(null);
|
||||
this._extNodeMaps = Object.create(null);
|
||||
this._mainNodesMap = new Map<string, Map<any, InternalTreeNode>>();
|
||||
this._mainNodesMap = new Map<string, Map<any, ITreeNode>>();
|
||||
this._childrenNodesMap = new Map<string, Map<any, any[]>>();
|
||||
|
||||
commands.registerArgumentProcessor({
|
||||
@@ -68,39 +69,39 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
});
|
||||
}
|
||||
|
||||
createTreeView<T>(providerId: string, provider: TreeDataProvider<T>): TreeView<T> {
|
||||
this._proxy.$registerTreeDataProvider(providerId);
|
||||
this._extNodeProviders[providerId] = provider;
|
||||
this._mainNodesMap.set(providerId, new Map<any, InternalTreeNode>());
|
||||
this._childrenNodesMap.set(providerId, new Map<any, any>());
|
||||
createExplorerView<T>(viewId: string, viewName: string, provider: TreeDataProvider<T>): View<T> {
|
||||
this._proxy.$registerView(viewId, viewName);
|
||||
this._extNodeProviders[viewId] = provider;
|
||||
this._mainNodesMap.set(viewId, new Map<any, ITreeNode>());
|
||||
this._childrenNodesMap.set(viewId, new Map<any, any>());
|
||||
|
||||
const treeView: TreeView<T> = {
|
||||
const treeView: View<T> = {
|
||||
refresh: (node: T) => {
|
||||
const mainThreadNode = this._mainNodesMap.get(providerId).get(node);
|
||||
this._proxy.$refresh(providerId, mainThreadNode);
|
||||
const mainThreadNode = this._mainNodesMap.get(viewId).get(node);
|
||||
this._proxy.$refresh(viewId, mainThreadNode);
|
||||
},
|
||||
dispose: () => {
|
||||
delete this._extNodeProviders[providerId];
|
||||
delete this._extNodeProviders[providerId];
|
||||
this._mainNodesMap.delete(providerId);
|
||||
this._childrenNodesMap.delete(providerId);
|
||||
this._extViews.delete(providerId);
|
||||
delete this._extNodeProviders[viewId];
|
||||
delete this._extNodeProviders[viewId];
|
||||
this._mainNodesMap.delete(viewId);
|
||||
this._childrenNodesMap.delete(viewId);
|
||||
this._extViews.delete(viewId);
|
||||
}
|
||||
};
|
||||
this._extViews.set(providerId, treeView);
|
||||
this._extViews.set(viewId, treeView);
|
||||
return treeView;
|
||||
}
|
||||
|
||||
$provideRootNode(providerId: string): TPromise<InternalTreeNode> {
|
||||
$provideRootNode(providerId: string): TPromise<ITreeNode> {
|
||||
const provider = this._extNodeProviders[providerId];
|
||||
if (!provider) {
|
||||
const errMessage = localize('treeExplorer.notRegistered', 'No TreeExplorerNodeProvider with id \'{0}\' registered.', providerId);
|
||||
return TPromise.wrapError<InternalTreeNode>(errMessage);
|
||||
return TPromise.wrapError<ITreeNode>(errMessage);
|
||||
}
|
||||
|
||||
return asWinJsPromise(() => provider.provideRootNode()).then(extRootNode => {
|
||||
const extNodeMap: { [id: string]: InternalTreeNode } = Object.create(null);
|
||||
const internalRootNode = new InternalTreeNodeImpl(providerId, extRootNode, provider);
|
||||
const extNodeMap: { [id: string]: ITreeNode } = Object.create(null);
|
||||
const internalRootNode = new TreeNodeImpl(providerId, extRootNode, provider);
|
||||
|
||||
extNodeMap[internalRootNode.id] = extRootNode;
|
||||
this._extNodeMaps[providerId] = extNodeMap;
|
||||
@@ -110,15 +111,15 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
return internalRootNode;
|
||||
}, err => {
|
||||
const errMessage = localize('treeExplorer.failedToProvideRootNode', 'TreeExplorerNodeProvider \'{0}\' failed to provide root node.', providerId);
|
||||
return TPromise.wrapError<InternalTreeNode>(errMessage);
|
||||
return TPromise.wrapError<ITreeNode>(errMessage);
|
||||
});
|
||||
}
|
||||
|
||||
$resolveChildren(providerId: string, mainThreadNode: InternalTreeNode): TPromise<InternalTreeNode[]> {
|
||||
$resolveChildren(providerId: string, mainThreadNode: ITreeNode): TPromise<ITreeNode[]> {
|
||||
const provider = this._extNodeProviders[providerId];
|
||||
if (!provider) {
|
||||
const errMessage = localize('treeExplorer.notRegistered', 'No TreeExplorerNodeProvider with id \'{0}\' registered.', providerId);
|
||||
return TPromise.wrapError<InternalTreeNode[]>(errMessage);
|
||||
return TPromise.wrapError<ITreeNode[]>(errMessage);
|
||||
}
|
||||
|
||||
const extNodeMap = this._extNodeMaps[providerId];
|
||||
@@ -133,7 +134,7 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
|
||||
return asWinJsPromise(() => provider.resolveChildren(extNode)).then(children => {
|
||||
return children.map(extChild => {
|
||||
const internalChild = new InternalTreeNodeImpl(providerId, extChild, provider);
|
||||
const internalChild = new TreeNodeImpl(providerId, extChild, provider);
|
||||
extNodeMap[internalChild.id] = extChild;
|
||||
this._mainNodesMap.get(providerId).set(extChild, internalChild);
|
||||
return internalChild;
|
||||
@@ -142,7 +143,7 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
}
|
||||
|
||||
// Convert the command on the ExtHost side so we can pass the original externalNode to the registered handler
|
||||
$getInternalCommand(providerId: string, mainThreadNode: InternalTreeNode): TPromise<modes.Command> {
|
||||
$getInternalCommand(providerId: string, mainThreadNode: ITreeNode): TPromise<modes.Command> {
|
||||
const commandConverter = this.commands.converter;
|
||||
|
||||
if (mainThreadNode.clickCommand) {
|
||||
@@ -7,56 +7,73 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { ExtHostContext, MainThreadTreeViewShape, ExtHostTreeViewShape } from './extHost.protocol';
|
||||
import { ITreeExplorerService } from 'vs/workbench/parts/explorers/common/treeExplorerService';
|
||||
import { InternalTreeNodeContent, InternalTreeNodeProvider } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
|
||||
import { ExtHostContext, MainThreadExplorerViewShape, ExtHostExplorerViewShape, ITreeNode } from './extHost.protocol';
|
||||
import { IMessageService, Severity } from 'vs/platform/message/common/message';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IExplorerViewsService, IExplorerViewDataProvider, IExplorerView } from 'vs/workbench/parts/explorers/common/explorer';
|
||||
|
||||
export class MainThreadTreeView extends MainThreadTreeViewShape {
|
||||
private _proxy: ExtHostTreeViewShape;
|
||||
export class MainThreadExplorerView extends MainThreadExplorerViewShape {
|
||||
|
||||
private _proxy: ExtHostExplorerViewShape;
|
||||
private _views: Map<string, IExplorerView<ITreeNode>> = new Map<string, IExplorerView<ITreeNode>>();
|
||||
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService,
|
||||
@ITreeExplorerService private treeExplorerService: ITreeExplorerService,
|
||||
@IExplorerViewsService private explorerViewsService: IExplorerViewsService,
|
||||
@IMessageService private messageService: IMessageService,
|
||||
@ICommandService private commandService: ICommandService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostTreeView);
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostExplorerView);
|
||||
}
|
||||
|
||||
$registerTreeDataProvider(providerId: string): void {
|
||||
$registerView(providerId: string, name: string): void {
|
||||
const provider = new TreeExplorerNodeProvider(providerId, this._proxy, this.messageService, this.commandService);
|
||||
this.treeExplorerService.registerTreeExplorerNodeProvider(providerId, provider);
|
||||
const view = this.explorerViewsService.createView(providerId, name, provider);
|
||||
this._views.set(providerId, view);
|
||||
}
|
||||
|
||||
$refresh(providerId: string, node: InternalTreeNodeContent): void {
|
||||
(<TreeExplorerNodeProvider>this.treeExplorerService.getProvider(providerId))._onRefresh.fire(node);
|
||||
$refresh(providerId: string, node: ITreeNode): void {
|
||||
this._views.get(providerId).refresh(node);
|
||||
}
|
||||
}
|
||||
|
||||
class TreeExplorerNodeProvider implements InternalTreeNodeProvider {
|
||||
class TreeExplorerNodeProvider implements IExplorerViewDataProvider<ITreeNode> {
|
||||
|
||||
readonly _onRefresh: Emitter<InternalTreeNodeContent> = new Emitter<InternalTreeNodeContent>();
|
||||
readonly onRefresh: Event<InternalTreeNodeContent> = this._onRefresh.event;
|
||||
readonly _onRefresh: Emitter<ITreeNode> = new Emitter<ITreeNode>();
|
||||
readonly onRefresh: Event<ITreeNode> = this._onRefresh.event;
|
||||
|
||||
constructor(public readonly id: string, private _proxy: ExtHostTreeViewShape,
|
||||
constructor(public readonly id: string, private _proxy: ExtHostExplorerViewShape,
|
||||
private messageService: IMessageService,
|
||||
private commandService: ICommandService
|
||||
) {
|
||||
}
|
||||
|
||||
provideRootNode(): TPromise<InternalTreeNodeContent> {
|
||||
provideRoot(): TPromise<ITreeNode> {
|
||||
return this._proxy.$provideRootNode(this.id).then(rootNode => rootNode, err => this.messageService.show(Severity.Error, err));
|
||||
}
|
||||
|
||||
resolveChildren(node: InternalTreeNodeContent): TPromise<InternalTreeNodeContent[]> {
|
||||
resolveChildren(node: ITreeNode): TPromise<ITreeNode[]> {
|
||||
return this._proxy.$resolveChildren(this.id, node).then(children => children, err => this.messageService.show(Severity.Error, err));
|
||||
}
|
||||
|
||||
executeCommand(node: InternalTreeNodeContent): TPromise<any> {
|
||||
hasChildren(node: ITreeNode): boolean {
|
||||
return node.hasChildren;
|
||||
}
|
||||
|
||||
getLabel(node: ITreeNode): string {
|
||||
return node.label;
|
||||
}
|
||||
|
||||
getId(node: ITreeNode): string {
|
||||
return node.id;
|
||||
}
|
||||
|
||||
getContextKey(node: ITreeNode): string {
|
||||
return node.contextKey;
|
||||
}
|
||||
|
||||
executeCommand(node: ITreeNode): TPromise<any> {
|
||||
return this._proxy.$getInternalCommand(this.id, node).then(command => {
|
||||
return this.commandService.executeCommand(command.id, ...command.arguments);
|
||||
});
|
||||
Reference in New Issue
Block a user