提交 dd6e5ee5 编写于 作者: J Joao Moreno

remove extensions part

上级 c5367062
......@@ -5,7 +5,6 @@
'use strict';
import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { EditorInput } from 'vs/workbench/common/editor';
import { IExtension } from 'vs/workbench/parts/extensions/common/extensions';
......@@ -13,31 +12,6 @@ import { extensionEquals } from 'vs/workbench/parts/extensions/common/extensions
export class ExtensionsInput extends EditorInput {
static get ID() { return 'workbench.extensions.input'; }
constructor() {
super();
}
getId(): string {
return ExtensionsInput.ID;
}
getName(): string {
return localize('extension', 'Extensions');
}
matches(other: any): boolean {
return other instanceof ExtensionsInput;
}
resolve(refresh?: boolean): TPromise<any> {
return TPromise.as(null);
}
}
export class ExtensionsInput2 extends EditorInput {
static get ID() { return 'workbench.extensions.input2'; }
get extension(): IExtension { return this._extension; }
......@@ -54,11 +28,11 @@ export class ExtensionsInput2 extends EditorInput {
}
matches(other: any): boolean {
if (!(other instanceof ExtensionsInput2)) {
if (!(other instanceof ExtensionsInput)) {
return false;
}
const otherExtensionInput = other as ExtensionsInput2;
const otherExtensionInput = other as ExtensionsInput;
return extensionEquals(this.extension, otherExtensionInput.extension);
}
......
......@@ -6,238 +6,27 @@
'use strict';
import 'vs/css!./media/extensions2';
import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { ThrottledDelayer, always } from 'vs/base/common/async';
import { marked } from 'vs/base/common/marked/marked';
import { assign } from 'vs/base/common/objects';
import { IDisposable, toDisposable, empty, dispose } from 'vs/base/common/lifecycle';
import { IDisposable, empty, dispose } from 'vs/base/common/lifecycle';
import { Builder } from 'vs/base/browser/builder';
import { append, emmet as $, addClass, removeClass, getDomNodePosition, addDisposableListener } from 'vs/base/browser/dom';
import { append, emmet as $ } from 'vs/base/browser/dom';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { Position } from 'vs/platform/editor/common/editor';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { IGalleryService } from '../common/extensions';
import { getExtensionId } from '../common/extensionsUtil';
import { ExtensionsInput2 } from '../common/extensionsInput';
import { PagedModel, mapPager } from 'vs/base/common/paging';
import { ExtensionsInput } from '../common/extensionsInput';
import { text as downloadText, IRequestOptions } from 'vs/base/node/request';
import { UserSettings } from 'vs/workbench/node/userSettings';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { getProxyAgent } from 'vs/base/node/proxy';
import { IExtensionEntry, ITemplateData, Delegate, Renderer, ExtensionState } from './extensionsList';
import { ITemplateData } from './extensionsList';
import { EditorOptions } from 'vs/workbench/common/editor';
const EmptyModel = new PagedModel({
firstPage: [],
total: 0,
pageSize: 0,
getPage: null
});
export class ExtensionEditor extends BaseEditor {
export class ExtensionsPart extends BaseEditor {
static ID: string = 'workbench.editor.extensionsPart';
private list: PagedList<IExtensionEntry>;
private searchDelayer: ThrottledDelayer<any>;
private root: HTMLElement;
private searchBox: HTMLInputElement;
private extensionsBox: HTMLElement;
private overlay: HTMLElement;
private _highlight: ITemplateData;
private highlightDisposable: IDisposable;
private toDispose: IDisposable[];
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IGalleryService private galleryService: IGalleryService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IInstantiationService private instantiationService: IInstantiationService
) {
super(ExtensionsPart.ID, telemetryService);
this.searchDelayer = new ThrottledDelayer(500);
this._highlight = null;
this.highlightDisposable = empty;
this.toDispose = [];
}
createEditor(parent: Builder): void {
const container = parent.getHTMLElement();
this.root = append(container, $('.extension-manager'));
this.toDispose.push(addDisposableListener(this.root, 'click', e => {
if (e.target === this.root && this.highlight) {
this.highlight = null;
}
}));
const search = append(this.root, $('.search'));
this.searchBox = append(search, $<HTMLInputElement>('input.search-box'));
this.searchBox.placeholder = localize('searchExtensions', "Search Extensions");
this.extensionsBox = append(this.root, $('.extensions'));
const delegate = new Delegate();
const renderer = this.instantiationService.createInstance(Renderer);
this.list = new PagedList(this.extensionsBox, delegate, [renderer]);
this.overlay = append(this.extensionsBox, $('.overlay'));
this.searchBox.oninput = () => this.triggerSearch(this.searchBox.value);
this.list.onSelectionChange(({ elements }) => {
if (this.highlightDisposable) {
removeClass(this.root, 'animated');
this.highlightDisposable.dispose();
this.highlightDisposable = empty;
}
const [selected] = elements;
if (!selected) {
return;
}
const id = getExtensionId(selected.extension);
const [data] = renderer.templates.filter(t => t.extension && getExtensionId(t.extension) === id);
if (!data) {
return;
}
this.highlight = data;
});
}
setVisible(visible: boolean, position?: Position): TPromise<void> {
return super.setVisible(visible, position).then(() => {
if (visible) {
this.highlight = null;
this.searchBox.value = '';
this.triggerSearch('', 0);
}
});
}
layout({ height }): void {
height -= 72;
this.extensionsBox.style.height = `${ height }px`;
this.list.layout(height);
if (this.highlight) {
this.overlay.style.height = this.extensionsBox.style.height;
}
}
focus(): void {
this.searchBox.focus();
}
private triggerSearch(text: string = '', delay = 500): void {
this.highlight = null;
this.list.model = EmptyModel;
const promise = this.searchDelayer.trigger(() => this.doSearch(text), delay);
addClass(this.extensionsBox, 'loading');
always(promise, () => removeClass(this.extensionsBox, 'loading'));
}
private doSearch(text: string = ''): TPromise<any> {
return this.galleryService.query({ text })
.then(result => new PagedModel(mapPager(result, extension => ({ extension, state: ExtensionState.Installed }))))
.then(model => this.list.model = model);
}
private get highlight(): ITemplateData {
return this._highlight;
}
private set highlight(data: ITemplateData) {
this._highlight = data;
if (!data) {
removeClass(this.root, 'highlighted');
removeClass(this.root, 'animated');
removeClass(this.root, 'highlight-in');
this.highlightDisposable.dispose();
this.highlightDisposable = empty;
return;
}
const position = getDomNodePosition(data.container);
const rootPosition = getDomNodePosition(this.extensionsBox);
this.overlay.style.top = `${ position.top - rootPosition.top - this.list.scrollTop }px`;
this.overlay.style.height = `${ position.height }px`;
let _ = this.overlay.offsetHeight; _++; // trigger reflow
addClass(this.root, 'animated highlight-in');
this.overlay.style.top = '0';
this.overlay.style.height = this.extensionsBox.style.height;
// swap parents
const container = data.container.parentElement;
this.overlay.appendChild(data.container);
// transition end event
const listener = addDisposableListener(this.overlay, 'transitionend', e => {
listener.dispose();
removeClass(this.root, 'animated');
removeClass(this.root, 'highlight-in');
addClass(this.root, 'highlighted');
});
const [version] = data.extension.galleryInformation.versions;
const headers = version.downloadHeaders;
// TODO
this.request(version.readmeUrl)
.then(opts => assign(opts, { headers }))
.then(opts => downloadText(opts))
.then(marked.parse);
// .then(html => data.body.innerHTML = html);
// set up disposable for later
this.highlightDisposable = toDisposable(() => {
listener.dispose();
container.appendChild(data.container);
this.overlay.style.height = '0';
// data.body.innerHTML = '';
});
}
// Helper for proxy business... shameful.
// This should be pushed down and not rely on the context service
private request(url: string): TPromise<IRequestOptions> {
const settings = TPromise.join([
UserSettings.getValue(this.contextService, 'http.proxy'),
UserSettings.getValue(this.contextService, 'http.proxyStrictSSL')
]);
return settings.then(settings => {
const proxyUrl: string = settings[0];
const strictSSL: boolean = settings[1];
const agent = getProxyAgent(url, { proxyUrl, strictSSL });
return { url, agent, strictSSL };
});
}
dispose(): void {
this._highlight = null;
this.toDispose = dispose(this.toDispose);
super.dispose();
}
}
export class ExtensionsPart2 extends BaseEditor {
static ID: string = 'workbench.editor.extensionsPart2';
static ID: string = 'workbench.editor.extension';
private root: HTMLElement;
......@@ -252,7 +41,7 @@ export class ExtensionsPart2 extends BaseEditor {
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IInstantiationService private instantiationService: IInstantiationService
) {
super(ExtensionsPart2.ID, telemetryService);
super(ExtensionEditor.ID, telemetryService);
this._highlight = null;
this.highlightDisposable = empty;
this.toDispose = [];
......@@ -263,7 +52,7 @@ export class ExtensionsPart2 extends BaseEditor {
this.root = append(container, $('.extension'));
}
setInput(input: ExtensionsInput2, options: EditorOptions): TPromise<void> {
setInput(input: ExtensionsInput, options: EditorOptions): TPromise<void> {
this.root.innerHTML = '';
const [version] = input.extension.galleryInformation.versions;
......
......@@ -14,28 +14,25 @@ import { GalleryService } from 'vs/workbench/parts/extensions/common/vsoGalleryS
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ExtensionsWorkbenchExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension';
import { IOutputChannelRegistry, Extensions as OutputExtensions } from 'vs/workbench/parts/output/common/output';
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions, IEditorInputFactory } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ExtensionsInput, ExtensionsInput2 } from 'vs/workbench/parts/extensions/common/extensionsInput';
import { ExtensionsPart } from 'vs/workbench/parts/extensions/electron-browser/extensionsPart';
import { GlobalExtensionsActionContributor } from 'vs/workbench/parts/extensions/electron-browser/extensionsActions';
import { IActionBarRegistry, Scope as ActionBarScope, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actionBarRegistry';
import { EditorInput } from 'vs/workbench/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
// import { EditorInput } from 'vs/workbench/common/editor';
// import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
class ExtensionsInputFactory implements IEditorInputFactory {
// class ExtensionsInputFactory implements IEditorInputFactory {
constructor() {}
// constructor() {}
public serialize(editorInput: EditorInput): string {
return '';
}
// public serialize(editorInput: EditorInput): string {
// return '';
// }
public deserialize(instantiationService: IInstantiationService, resourceRaw: string): EditorInput {
return instantiationService.createInstance(ExtensionsInput);
}
}
// public deserialize(instantiationService: IInstantiationService, resourceRaw: string): EditorInput {
// return instantiationService.createInstance(ExtensionsInput);
// }
// }
registerSingleton(IGalleryService, GalleryService);
......@@ -48,31 +45,18 @@ Registry.as<IStatusbarRegistry>(StatusbarExtensions.Statusbar)
Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
.registerChannel(ExtensionsChannelId, ExtensionsLabel);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditorInputFactory(ExtensionsInput.ID, ExtensionsInputFactory);
// Registry.as<IEditorRegistry>(EditorExtensions.Editors)
// .registerEditorInputFactory(ExtensionsInput.ID, ExtensionsInputFactory);
const editorDescriptor = new EditorDescriptor(
ExtensionsPart.ID,
localize('extensions', "Extensions"),
'vs/workbench/parts/extensions/electron-browser/extensionsPart',
'ExtensionsPart'
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(editorDescriptor, [new SyncDescriptor(ExtensionsInput)]);
const editorDescriptor2 = new EditorDescriptor(
'workbench.editor.extensionsPart2',
'workbench.editor.extension',
localize('extension', "Extension"),
'vs/workbench/parts/extensions/electron-browser/extensionsPart',
'ExtensionsPart2'
'vs/workbench/parts/extensions/electron-browser/extensionEditor',
'ExtensionEditor'
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(editorDescriptor2, [new SyncDescriptor(ExtensionsInput2)]);
Registry.as<IActionBarRegistry>(ActionBarExtensions.Actionbar)
.registerActionBarContributor(ActionBarScope.GLOBAL, GlobalExtensionsActionContributor);
.registerEditor(editorDescriptor, [new SyncDescriptor(ExtensionsInput)]);
const viewletDescriptor = new ViewletDescriptor(
'vs/workbench/parts/extensions/electron-browser/extensionsViewlet',
......
......@@ -5,7 +5,7 @@
import nls = require('vs/nls');
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { IAction, Action } from 'vs/base/common/actions';
import { Action } from 'vs/base/common/actions';
import { assign } from 'vs/base/common/objects';
import Severity from 'vs/base/common/severity';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -15,10 +15,6 @@ import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions';
import { IExtensionsService, IExtension } from 'vs/workbench/parts/extensions/common/extensions';
import { extensionEquals, getTelemetryData } from 'vs/workbench/parts/extensions/common/extensionsUtil';
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
import { ActionBarContributor } from 'vs/workbench/browser/actionBarRegistry';
import { CONTEXT as ToolbarContext } from 'vs/base/browser/ui/toolbar/toolbar';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
const CloseAction = new Action('action.close', nls.localize('close', "Close"));
......@@ -212,31 +208,3 @@ export class UninstallAction extends Action {
this.telemetryService.publicLog('extensionGallery:uninstall', data);
}
}
class ManageExtensionsAction extends Action {
constructor(@IWorkbenchEditorService private editorService: IWorkbenchEditorService) {
super('extensions.manage', nls.localize('openExtensions', "Manage Extensions"), 'manage-extensions-action');
}
run(): TPromise<any> {
return this.editorService.openEditor(new ExtensionsInput());
}
}
export class GlobalExtensionsActionContributor extends ActionBarContributor {
constructor(@IInstantiationService protected instantiationService: IInstantiationService) {
super();
}
public hasActions(context:any):boolean {
return context === ToolbarContext;
}
public getActions(context:any): IAction[] {
return [
this.instantiationService.createInstance(ManageExtensionsAction)
];
}
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionEntry, Delegate, Renderer, ExtensionState } from './extensionsList';
import { IGalleryService } from '../common/extensions';
import { ExtensionsInput2 } from '../common/extensionsInput';
import { ExtensionsInput } from '../common/extensionsInput';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
......@@ -76,7 +76,7 @@ export class ExtensionsViewlet extends Viewlet {
return;
}
return this.editorService.openEditor(new ExtensionsInput2(entry.extension));
return this.editorService.openEditor(new ExtensionsInput(entry.extension));
}, null, this.disposables);
return TPromise.as(null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册