提交 29c03eaa 编写于 作者: P Pine Wu

Remove children on ExtHost side and refactor

上级 fb032eb0
......@@ -1348,39 +1348,14 @@ declare module 'vscode' {
provideTextDocumentContent(uri: Uri, token: CancellationToken): string | Thenable<string>;
}
/**
* A tree content provider allows extension to contribute a custom tree-like
* explorer as a Viewlet.
*
* Tree content providers are registered through [workspace.registerTreeContentProvider](#workspace.registerTreeContentProvider).
*/
export interface TreeContentProvider {
provideTreeContent(): Thenable<TreeContentNode>;
resolveChildren(node: TreeContentNode): Thenable<TreeContentNode[]>;
export interface TreeExplorerNodeProvider {
provideRootNode(): Thenable<TreeExplorerNode>;
resolveChildren(node: TreeExplorerNode): Thenable<TreeExplorerNode[]>;
}
/**
* Represents a tree node on the tree explorer.
*/
export interface TreeContentNode {
/**
* A human readable string used to render the tree node.
*/
export interface TreeExplorerNode {
label: string;
/**
* Wheather the tree node should be initially be expanded.
* If set to true, [TreeContentProvider.resolveChildren](#TreeContentProvider.resolveChildren) will
* be called on the node after rendering.
*/
shouldInitiallyExpand: boolean;
/**
* Children of the current node. Can be empty initially and later
* resolved through [TreeContentProvider.resolveChildren](#TreeContentProvider.resolveChildren)
*/
children: TreeContentNode[];
}
/**
......@@ -3846,7 +3821,7 @@ declare module 'vscode' {
* @param provider A [TreeContentProvider](#TreeContentProvider)
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export function registerTreeContentProvider(providerId: string, provider: TreeContentProvider): Disposable;
export function registerTreeExplorerNodeProvider(providerId: string, provider: TreeExplorerNodeProvider): Disposable;
/**
* An event that is emitted when a [text document](#TextDocument) is opened.
......
......@@ -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 { ExtHostExplorers } from 'vs/workbench/api/node/extHostExplorers';
import { ExtHostTreeExplorers } from 'vs/workbench/api/node/extHostTreeExplorers';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { ExtHostQuickOpen } from 'vs/workbench/api/node/extHostQuickOpen';
import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
......@@ -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<ExtHostExplorers>(new ExtHostExplorers(threadService));
const extHostExplorers = col.define(ExtHostContext.ExtHostExplorers).set<ExtHostTreeExplorers>(new ExtHostTreeExplorers(threadService));
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));
......@@ -335,7 +335,7 @@ export function createApiFactory(threadService: IThreadService, extensionService
onWillSaveTextDocument: (listener, thisArgs?, disposables?) => {
return extHostDocumentSaveParticipant.onWillSaveTextDocumentEvent(listener, thisArgs, disposables);
},
registerTreeContentProvider(providerId: string, provider: vscode.TreeContentProvider) {
registerTreeExplorerNodeProvider(providerId: string, provider: vscode.TreeExplorerNodeProvider) {
return extHostExplorers.registerTreeContentProvider(providerId, provider);
},
onDidChangeConfiguration: (listener: () => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) => {
......
......@@ -20,7 +20,7 @@ import { MainThreadDiagnostics } from './mainThreadDiagnostics';
import { MainThreadDocuments } from './mainThreadDocuments';
import { MainThreadEditors } from './mainThreadEditors';
import { MainThreadErrors } from './mainThreadErrors';
import { MainThreadExplorers } from './mainThreadExplorers';
import { MainThreadTreeExplorers } from './mainThreadTreeExplorers';
import { MainThreadLanguageFeatures } from './mainThreadLanguageFeatures';
import { MainThreadLanguages } from './mainThreadLanguages';
import { MainThreadMessageService } from './mainThreadMessageService';
......@@ -71,7 +71,7 @@ export class ExtHostContribution implements IWorkbenchContribution {
col.define(MainContext.MainThreadDocuments).set(create(MainThreadDocuments));
col.define(MainContext.MainThreadEditors).set(create(MainThreadEditors));
col.define(MainContext.MainThreadErrors).set(create(MainThreadErrors));
col.define(MainContext.MainThreadExplorers).set(create(MainThreadExplorers));
col.define(MainContext.MainThreadExplorers).set(create(MainThreadTreeExplorers));
col.define(MainContext.MainThreadLanguageFeatures).set(create(MainThreadLanguageFeatures));
col.define(MainContext.MainThreadLanguages).set(create(MainThreadLanguages));
col.define(MainContext.MainThreadMessageService).set(create(MainThreadMessageService));
......
......@@ -34,7 +34,7 @@ import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import { IWorkspaceSymbol } from 'vs/workbench/parts/search/common/search';
import { IApplyEditsOptions, TextEditorRevealType, ITextEditorConfigurationUpdate, IResolvedTextEditorConfiguration, ISelectionChangeEvent } from './mainThreadEditorsTracker';
import { ExtHostTreeNode } from 'vs/workbench/api/node/extHostExplorers';
import { InternalTreeExplorerNode } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
export interface InstanceSetter<T> {
set<R extends T>(instance: T): R;
......@@ -117,7 +117,7 @@ export abstract class MainThreadEditorsShape {
$tryApplyEdits(id: string, modelVersionId: number, edits: editorCommon.ISingleEditOperation[], opts: IApplyEditsOptions): TPromise<boolean> { throw ni(); }
}
export abstract class MainThreadExplorersShape {
export abstract class MainThreadTreeExplorersShape {
$registerTreeContentProvider(treeContentProviderId: string): void { throw ni(); }
$unregisterTreeContentProvider(treeContentProviderId: string): void { throw ni(); }
}
......@@ -264,9 +264,9 @@ export abstract class ExtHostEditorsShape {
$acceptTextEditorRemove(id: string): void { throw ni(); }
}
export abstract class ExtHostExplorersShape {
$provideTreeContent(treeContentProviderId: string): TPromise<ExtHostTreeNode> { throw ni(); };
$resolveChildren(treeContentProviderId: string, node: ExtHostTreeNode): TPromise<ExtHostTreeNode[]> { throw ni(); }
export abstract class ExtHostTreeExplorersShape {
$provideRootNode(providerId: string): TPromise<InternalTreeExplorerNode> { throw ni(); };
$resolveChildren(providerId: string, node: InternalTreeExplorerNode): TPromise<InternalTreeExplorerNode[]> { throw ni(); }
}
export abstract class ExtHostExtensionServiceShape {
......@@ -343,7 +343,7 @@ export const MainContext = {
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments', MainThreadDocumentsShape),
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors', MainThreadEditorsShape),
MainThreadErrors: createMainId<MainThreadErrorsShape>('MainThreadErrors', MainThreadErrorsShape),
MainThreadExplorers: createMainId<MainThreadExplorersShape>('MainThreadExplorers', MainThreadExplorersShape),
MainThreadExplorers: createMainId<MainThreadTreeExplorersShape>('MainThreadExplorers', MainThreadTreeExplorersShape),
MainThreadLanguageFeatures: createMainId<MainThreadLanguageFeaturesShape>('MainThreadLanguageFeatures', MainThreadLanguageFeaturesShape),
MainThreadLanguages: createMainId<MainThreadLanguagesShape>('MainThreadLanguages', MainThreadLanguagesShape),
MainThreadMessageService: createMainId<MainThreadMessageServiceShape>('MainThreadMessageService', MainThreadMessageServiceShape),
......@@ -364,7 +364,7 @@ export const ExtHostContext = {
ExtHostDocuments: createExtId<ExtHostDocumentsShape>('ExtHostDocuments', ExtHostDocumentsShape),
ExtHostDocumentSaveParticipant: createExtId<ExtHostDocumentSaveParticipantShape>('ExtHostDocumentSaveParticipant', ExtHostDocumentSaveParticipantShape),
ExtHostEditors: createExtId<ExtHostEditorsShape>('ExtHostEditors', ExtHostEditorsShape),
ExtHostExplorers: createExtId<ExtHostExplorersShape>('ExtHostExplorers',ExtHostExplorersShape),
ExtHostExplorers: createExtId<ExtHostTreeExplorersShape>('ExtHostExplorers',ExtHostTreeExplorersShape),
ExtHostFileSystemEventService: createExtId<ExtHostFileSystemEventServiceShape>('ExtHostFileSystemEventService', ExtHostFileSystemEventServiceShape),
ExtHostHeapService: createExtId<ExtHostHeapServiceShape>('ExtHostHeapMonitor', ExtHostHeapServiceShape),
ExtHostLanguageFeatures: createExtId<ExtHostLanguageFeaturesShape>('ExtHostLanguageFeatures', ExtHostLanguageFeaturesShape),
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TreeContentNode, TreeContentProvider } from 'vscode';
import {TPromise} from 'vs/base/common/winjs.base';
import {Disposable} from 'vs/workbench/api/node/extHostTypes';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import {MainContext, ExtHostExplorersShape, MainThreadExplorersShape} from './extHost.protocol';
export class ExtHostExplorers extends ExtHostExplorersShape {
private _proxy: MainThreadExplorersShape;
private _treeContentProviders: { [treeContentProviderId: string]: TreeContentProvider };
private _treeContents: { [treeContentProviderId: string]: ExtHostTreeNode };
private _treeNodeMaps: { [treeContentProviderId: string]: { [id: number]: ExtHostTreeNode }};
constructor(
threadService: IThreadService
) {
super();
this._proxy = threadService.get(MainContext.MainThreadExplorers);
this._treeContentProviders = Object.create(null);
this._treeContents = Object.create(null);
this._treeNodeMaps = Object.create(null);
}
registerTreeContentProvider(providerId: string, provider: TreeContentProvider): Disposable {
this._proxy.$registerTreeContentProvider(providerId);
this._treeContentProviders[providerId] = provider;
return new Disposable(() => {
if (delete this._treeContentProviders[providerId]) {
this._proxy.$unregisterTreeContentProvider(providerId);
}
});
}
$provideTreeContent(treeContentProviderId: string): TPromise<ExtHostTreeNode> {
const provider = this._treeContentProviders[treeContentProviderId];
if (!provider) {
throw new Error(`no TreeContentProvider registered with id '${treeContentProviderId}'`);
}
return TPromise.wrap(provider.provideTreeContent().then(treeContent => {
const treeNodeMap = Object.create(null);
this._treeNodeMaps[treeContentProviderId] = treeNodeMap;
this._treeContents[treeContentProviderId] = new ExtHostTreeNode(treeContent, null, treeNodeMap);
return this._treeContents[treeContentProviderId];
}));
}
$resolveChildren(treeContentProviderId: string, mainThreadNode: ExtHostTreeNode): TPromise<ExtHostTreeNode[]> {
const provider = this._treeContentProviders[treeContentProviderId];
if (!provider) {
throw new Error(`no TreeContentProvider registered with id '${treeContentProviderId}'`);
}
const treeNodeMap = this._treeNodeMaps[treeContentProviderId];
const extHostNode = treeNodeMap[mainThreadNode.id];
return TPromise.wrap(provider.resolveChildren(extHostNode).then(children => {
extHostNode.children = children.map(child => {
return new ExtHostTreeNode(child, extHostNode, treeNodeMap);
});
return extHostNode.children;
}));
}
}
export class ExtHostTreeNode implements TreeContentNode {
static idCounter = 1;
id: number;
label: string;
shouldInitiallyExpand: boolean;
children: ExtHostTreeNode[];
constructor(node: TreeContentNode, parent: ExtHostTreeNode, treeNodeMap: { [id: number]: ExtHostTreeNode}) {
this.id = ExtHostTreeNode.idCounter++;
this.label = node.label;
this.shouldInitiallyExpand = node.shouldInitiallyExpand;
this.children = node.children.map(child => {
return new ExtHostTreeNode(child, this, treeNodeMap);
})
treeNodeMap[this.id] = this;
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TreeExplorerNode, TreeExplorerNodeProvider } from 'vscode';
import { TPromise } from 'vs/base/common/winjs.base';
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';
export class ExtHostTreeExplorers extends ExtHostTreeExplorersShape {
private _proxy: MainThreadTreeExplorersShape;
private _treeExplorerNodeProviders: { [providerId: string]: TreeExplorerNodeProvider };
private _trees: { [providerId: string]: InternalTreeExplorerNode };
private _treeNodeMaps: { [providerId: string]: { [id: number]: InternalTreeExplorerNode }};
constructor(
threadService: IThreadService
) {
super();
this._proxy = threadService.get(MainContext.MainThreadExplorers);
this._treeExplorerNodeProviders = Object.create(null);
this._trees = Object.create(null);
this._treeNodeMaps = Object.create(null);
}
registerTreeContentProvider(providerId: string, provider: TreeExplorerNodeProvider): Disposable {
this._proxy.$registerTreeContentProvider(providerId);
this._treeExplorerNodeProviders[providerId] = provider;
return new Disposable(() => {
if (delete this._treeExplorerNodeProviders[providerId]) {
this._proxy.$unregisterTreeContentProvider(providerId);
}
});
}
$provideRootNode(providerId: string): TPromise<InternalTreeExplorerNode> {
const provider = this._treeExplorerNodeProviders[providerId];
if (!provider) {
throw new Error(`no TreeContentProvider registered with id '${providerId}'`);
}
return TPromise.wrap(provider.provideRootNode().then(rootNode => {
const treeNodeMap = Object.create(null);
this._treeNodeMaps[providerId] = treeNodeMap;
const internalRootNode = new InternalTreeExplorerNode(rootNode);
this._trees[providerId] = internalRootNode;
this._treeNodeMaps[providerId][internalRootNode.id] = internalRootNode;
return this._trees[providerId];
}));
}
$resolveChildren(providerId: string, mainThreadNode: InternalTreeExplorerNode): TPromise<InternalTreeExplorerNode[]> {
const provider = this._treeExplorerNodeProviders[providerId];
if (!provider) {
throw new Error(`no TreeContentProvider registered with id '${providerId}'`);
}
const treeNodeMap = this._treeNodeMaps[providerId];
const extHostTreeContentNode = treeNodeMap[mainThreadNode.id];
return TPromise.wrap(provider.resolveChildren(extHostTreeContentNode).then(children => {
return children.map(child => {
const internalChild = new InternalTreeExplorerNode(child);
treeNodeMap[internalChild.id] = internalChild;
return internalChild;
});
}));
}
}
\ No newline at end of file
......@@ -4,19 +4,17 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import {TreeContentNode} from 'vscode';
import {TPromise} from 'vs/base/common/winjs.base';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import {ExtHostContext, MainThreadExplorersShape, ExtHostExplorersShape} from './extHost.protocol';
import {ITreeExplorerViewletService} from 'vs/workbench/parts/explorers/browser/treeExplorerViewletService';
import {TreeViewNode} from 'vs/workbench/parts/explorers/common/treeViewModel';
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 { InternalTreeExplorerNode } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
import { ExtHostTreeNode } from 'vs/workbench/api/node/extHostExplorers';
export class MainThreadTreeExplorers extends MainThreadTreeExplorersShape {
private _proxy: ExtHostTreeExplorersShape;
export class MainThreadExplorers extends MainThreadExplorersShape {
private _proxy: ExtHostExplorersShape;
private _treeContents: { [treeContentProviderId: string]: ExtHostTreeNode };
private _treeContents: { [treeContentProviderId: string]: InternalTreeExplorerNode };
constructor(
@IThreadService threadService: IThreadService,
......@@ -30,13 +28,13 @@ export class MainThreadExplorers extends MainThreadExplorersShape {
$registerTreeContentProvider(providerId: string): void {
this.treeExplorerViewletService.registerTreeContentProvider(providerId, {
provideTreeContent: (): TPromise<ExtHostTreeNode> => {
return this._proxy.$provideTreeContent(providerId).then(treeContent => {
provideRootNode: (): TPromise<InternalTreeExplorerNode> => {
return this._proxy.$provideRootNode(providerId).then(treeContent => {
this._treeContents[providerId] = treeContent;
return treeContent;
})
},
resolveChildren: (node: ExtHostTreeNode): TPromise<ExtHostTreeNode[]> => {
resolveChildren: (node: InternalTreeExplorerNode): TPromise<InternalTreeExplorerNode[]> => {
return this._proxy.$resolveChildren(providerId, node);
}
});
......
'use strict';
import { TreeContentNode, TreeContentProvider } from 'vscode';
import { TreeExplorerNode, TreeExplorerNodeProvider } from 'vscode';
import { TPromise } from 'vs/base/common/winjs.base';
import Event, {Emitter} from 'vs/base/common/event';
import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation';
......@@ -10,15 +10,15 @@ export const ITreeExplorerViewletService = createDecorator<ITreeExplorerViewletS
export interface ITreeExplorerViewletService {
_serviceBrand: any;
registerTreeContentProvider(providerId: string, provider: TreeContentProvider): void;
provideTreeContent(providerId: string): TPromise<TreeContentNode>;
resolveChildren(providerId: string, node: TreeContentNode): TPromise<TreeContentNode[]>;
registerTreeContentProvider(providerId: string, provider: TreeExplorerNodeProvider): void;
provideTreeContent(providerId: string): TPromise<TreeExplorerNode>;
resolveChildren(providerId: string, node: TreeExplorerNode): TPromise<TreeExplorerNode[]>;
}
export class TreeExplorerViewletService implements ITreeExplorerViewletService {
public _serviceBrand: any;
private _treeContentProviders: { [providerId: string]: TreeContentProvider; };
private _treeContentProviders: { [providerId: string]: TreeExplorerNodeProvider; };
constructor(
@IInstantiationService private _instantiationService: IInstantiationService
......@@ -26,15 +26,15 @@ export class TreeExplorerViewletService implements ITreeExplorerViewletService {
this._treeContentProviders = Object.create(null);
}
registerTreeContentProvider(providerId: string, provider: TreeContentProvider): void {
registerTreeContentProvider(providerId: string, provider: TreeExplorerNodeProvider): void {
this._treeContentProviders[providerId] = provider;
}
provideTreeContent(providerId: string): TPromise<TreeContentNode> {
return TPromise.wrap(this._treeContentProviders[providerId].provideTreeContent());
provideTreeContent(providerId: string): TPromise<TreeExplorerNode> {
return TPromise.wrap(this._treeContentProviders[providerId].provideRootNode());
}
resolveChildren(providerId: string, node: TreeContentNode): TPromise<TreeContentNode[]> {
resolveChildren(providerId: string, node: TreeExplorerNode): TPromise<TreeExplorerNode[]> {
return TPromise.wrap(this._treeContentProviders[providerId].resolveChildren(node));
}
}
......@@ -22,10 +22,9 @@ import { ITree, IDataSource, IRenderer } from 'vs/base/parts/tree/browser/tree';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { DefaultController } from 'vs/base/parts/tree/browser/treeDefaults';
import { TreeExplorerViewletState, TreeDataSource, TreeRenderer, TreeController } from 'vs/workbench/parts/explorers/browser/views/treeExplorerViewer';
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import { TreeViewNode } from 'vs/workbench/parts/explorers/common/treeViewModel';
import { TreeViewNode } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
export class TreeExplorerView extends CollapsibleViewletView {
private workspace: IWorkspace;
......@@ -51,7 +50,7 @@ export class TreeExplorerView extends CollapsibleViewletView {
@IEditorGroupService private editorGroupService: IEditorGroupService,
@ITreeExplorerViewletService private treeExplorerViewletService: ITreeExplorerViewletService
) {
super(actionRunner, false, nls.localize('treeExplorerViewletTree', "Tree Explorer Tree Section"), messageService, keybindingService, contextMenuService, headerSize);
super(actionRunner, false, nls.localize('treeExplorerViewletTree', "Tree Explorer Section"), messageService, keybindingService, contextMenuService, headerSize);
this.viewletState = viewletState;
this._treeName = treeName;
......
......@@ -3,7 +3,7 @@ import { $, Builder } from 'vs/base/browser/builder';
import { ITree, IDataSource, IRenderer, IElementCallback } from 'vs/base/parts/tree/browser/tree';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { TreeViewNode } from 'vs/workbench/parts/explorers/common/treeViewModel';
import { TreeViewNode } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
import { ClickBehavior, DefaultController } from 'vs/base/parts/tree/browser/treeDefaults';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
......
import { TreeContentNode } from 'vscode';
import { TreeExplorerNode } from 'vscode';
export class TreeViewNode implements TreeContentNode {
export class TreeViewNode implements TreeExplorerNode {
static idCounter = 1;
id: number;
......@@ -15,8 +15,25 @@ export class TreeViewNode implements TreeContentNode {
this.id = TreeViewNode.idCounter++;
}
public static create(node: TreeContentNode): TreeViewNode {
public static create(node: TreeExplorerNode): TreeViewNode {
const children = node.children.map(TreeViewNode.create);
return new TreeViewNode(node.label, node.shouldInitiallyExpand, children)
}
}
export class InternalTreeExplorerNode implements TreeExplorerNode {
static idCounter = 1;
id: number;
// Property on TreeContentNode
label: string;
shouldInitiallyExpand: boolean;
constructor(node: TreeExplorerNode) {
this.id = InternalTreeExplorerNode.idCounter++;
this.label = node.label;
this.shouldInitiallyExpand = node.shouldInitiallyExpand;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册