-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tree decorators infrastructure created
- Loading branch information
1 parent
4e72dcc
commit b47ebd3
Showing
12 changed files
with
308 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 {Registry, BaseRegistry} from 'vs/platform/platform'; | ||
import {IConstructorSignature0} from 'vs/platform/instantiation/common/instantiation'; | ||
import tree = require('vs/base/parts/tree/browser/tree'); | ||
|
||
export namespace Extensions { | ||
export const Decorators = 'decorator.contributions.kind'; | ||
} | ||
|
||
export type IDecoratorSignature = IConstructorSignature0<tree.IDecorator>; | ||
|
||
export interface IDecoratorRegistry { | ||
|
||
/** | ||
* Registers a decorator to the platform that will be loaded when the workbench starts and disposed when | ||
* the workbench shuts down. | ||
*/ | ||
registerDecorator(decorator: IDecoratorSignature): void; | ||
|
||
/** | ||
* Returns all decorators that are known to the platform. | ||
*/ | ||
getDecorators(): tree.IDecorator[]; | ||
} | ||
|
||
class DecorationsRegistry extends BaseRegistry<tree.IDecorator> implements IDecoratorRegistry { | ||
|
||
public registerDecorator(ctor: IDecoratorSignature): void { | ||
super._register(ctor); | ||
} | ||
|
||
public getDecorators(): tree.IDecorator[] { | ||
return super._getInstances(); | ||
} | ||
|
||
public setDecorators(contributions: tree.IDecorator[]): void { | ||
super._setInstances(contributions); | ||
} | ||
} | ||
|
||
Registry.add(Extensions.Decorators, new DecorationsRegistry()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 tree = require('vs/base/parts/tree/browser/tree'); | ||
import lifecycle = require('vs/base/common/lifecycle'); | ||
import {Registry} from 'vs/platform/platform'; | ||
import {IDecoratorRegistry, Extensions as DecoratorExtensions} from 'vs/workbench/parts/decorators/decoratorRegistry'; | ||
|
||
export class TreeDecorator implements tree.IDecorator { | ||
|
||
protected decorators: tree.IDecorator[] = []; | ||
protected toDispose: lifecycle.IDisposable[] = []; | ||
constructor() { | ||
} | ||
|
||
public onActivate(tree: tree.ITree): void { | ||
this.decorators = Registry.as<IDecoratorRegistry>(DecoratorExtensions.Decorators).getDecorators(); | ||
this.decorators.forEach(decorator=>decorator.onActivate(tree)); | ||
} | ||
|
||
public decorate(tree: tree.ITree, element: any, templateId: string, row: tree.IRow): void { | ||
this.decorators.forEach(decorator=>decorator.decorate(tree,element,templateId, row)); | ||
} | ||
|
||
public dispose(): void { | ||
this.decorators.forEach(decorator => decorator.dispose()); | ||
this.toDispose.forEach(item => item.dispose()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.