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

bring back more extensions quick open & global commands

上级 2c2958b6
......@@ -18,14 +18,13 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IRequestService } from 'vs/platform/request/common/request';
import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionsInput } from './extensionsInput';
import { IExtensionsWorkbenchService } from './extensions';
import { IExtensionsWorkbenchService, IExtensionsViewlet, VIEWLET_ID } from './extensions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITemplateData } from './extensionsList';
import { RatingsWidget, InstallWidget } from './extensionsWidgets';
import { EditorOptions } from 'vs/workbench/common/editor';
import { shell } from 'electron';
import product from 'vs/platform/product';
import { IExtensionsViewlet } from './extensions';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { CombinedInstallAction, UpdateAction } from './extensionsActions';
......@@ -115,7 +114,7 @@ export class ExtensionEditor extends BaseEditor {
this.name.onclick = finalHandler(() => shell.openExternal(extensionUrl));
this.rating.onclick = finalHandler(() => shell.openExternal(`${ extensionUrl }#review-details`));
this.publisher.onclick = finalHandler(() => {
this.viewletService.openViewlet('workbench.viewlet.extensions', true)
this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.done(viewlet => viewlet.search(`publisher:"${ extension.publisherDisplayName }"`, true));
});
......
......@@ -11,7 +11,6 @@ import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IExtensionGalleryService, IExtensionTipsService, ExtensionsLabel, ExtensionsChannelId } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingService';
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actionRegistry';
import { ExtensionTipsService } from 'vs/workbench/parts/extensions/electron-browser/extensionTipsService';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
......@@ -21,33 +20,18 @@ import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } fro
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { VIEWLET_ID, IExtensionsWorkbenchService } from './extensions';
import { ExtensionsWorkbenchService } from './extensionsWorkbenchService';
import { OpenExtensionsViewletAction, ListOutdatedExtensionsAction } from './extensionsActions';
import { ExtensionsInput } from './extensionsInput';
// import { EditorInput } from 'vs/workbench/common/editor';
// import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ToggleViewletAction } from 'vs/workbench/browser/viewlet';
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { ExtensionEditor } from './extensionEditor';
import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenRegistry, Extensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
// class ExtensionsInputFactory implements IEditorInputFactory {
// constructor() {}
// public serialize(editorInput: EditorInput): string {
// return '';
// }
// public deserialize(instantiationService: IInstantiationService, resourceRaw: string): EditorInput {
// return instantiationService.createInstance(ExtensionsInput);
// }
// }
// Singletons
registerSingleton(IExtensionGalleryService, ExtensionGalleryService);
registerSingleton(IExtensionTipsService, ExtensionTipsService);
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
// Workbench contributions
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(ExtensionsWorkbenchExtension);
......@@ -57,6 +41,16 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
.registerChannel(ExtensionsChannelId, ExtensionsLabel);
// Quickopen
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/parts/extensions/electron-browser/extensionsQuickOpen',
'ExtensionsHandler',
'ext ',
localize('extensionsCommands', "Manage Extensions"),
true
)
);
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
......@@ -68,10 +62,7 @@ Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
)
);
// Registry.as<IEditorRegistry>(EditorExtensions.Editors)
// .registerEditorInputFactory(ExtensionsInput.ID, ExtensionsInputFactory);
// Editor
const editorDescriptor = new EditorDescriptor(
ExtensionEditor.ID,
localize('extension', "Extension"),
......@@ -82,6 +73,7 @@ const editorDescriptor = new EditorDescriptor(
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(editorDescriptor, [new SyncDescriptor(ExtensionsInput)]);
// Viewlet
const viewletDescriptor = new ViewletDescriptor(
'vs/workbench/parts/extensions/electron-browser/extensionsViewlet',
'ExtensionsViewlet',
......@@ -94,22 +86,11 @@ const viewletDescriptor = new ViewletDescriptor(
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets)
.registerViewlet(viewletDescriptor);
class OpenExtensionsViewletAction extends ToggleViewletAction {
public static ID = 'workbench.extensions.showViewlet';
public static LABEL = localize('toggleExtensionsViewlet', "Show Extensions");
// Global actions
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions);
constructor(
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
}
}
const openViewletKb: IKeybindings = {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_X
};
const openViewletActionDescriptor = new SyncActionDescriptor(OpenExtensionsViewletAction, OpenExtensionsViewletAction.ID, OpenExtensionsViewletAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_X });
actionRegistry.registerWorkbenchAction(openViewletActionDescriptor, 'View: Show Extensions', localize('view', "View"));
const registry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenExtensionsViewletAction, OpenExtensionsViewletAction.ID, OpenExtensionsViewletAction.LABEL, openViewletKb), 'View: Show Extensions', localize('view', "View"));
\ No newline at end of file
const listOutdatedActionDescriptor = new SyncActionDescriptor(ListOutdatedExtensionsAction, ListOutdatedExtensionsAction.ID, ListOutdatedExtensionsAction.LABEL);
actionRegistry.registerWorkbenchAction(listOutdatedActionDescriptor, 'Extensions: Show Outdated Extensions', ExtensionsLabel);
......@@ -13,10 +13,13 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
// import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
// import { IMessageService } from 'vs/platform/message/common/message';
import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions';
import { IExtension, ExtensionState, IExtensionsWorkbenchService } from './extensions';
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewlet } from './extensions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
// import { extensionEquals, getTelemetryData } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
// import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
import { ToggleViewletAction } from 'vs/workbench/browser/viewlet';
import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
// const CloseAction = new Action('action.close', localize('close', "Close"));
......@@ -415,4 +418,47 @@ export class EnableAction extends Action {
super.dispose();
this.disposables = dispose(this.disposables);
}
}
\ No newline at end of file
}
export class OpenExtensionsViewletAction extends ToggleViewletAction {
static ID = 'workbench.extensions.showViewlet';
static LABEL = localize('toggleExtensionsViewlet', "Show Extensions");
constructor(
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
}
}
export class ListOutdatedExtensionsAction extends Action {
static ID = 'workbench.extensions.action.listOutdatedExtensions';
static LABEL = localize('showOutdatedExtensions', "Show Outdated Extensions");
constructor(
id: string,
label: string,
@IViewletService private viewletService: IViewletService
) {
super(id, label, null, true);
}
run(): TPromise<void> {
return this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => {
viewlet.search('@outdated', true);
viewlet.focus();
});
}
protected isEnabled(): boolean {
return true;
}
}
......@@ -5,29 +5,24 @@
import nls = require('vs/nls');
import { TPromise } from 'vs/base/common/winjs.base';
import { ThrottledDelayer } from 'vs/base/common/async';
import { IAutoFocus, Mode, IModel } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenEntry, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { QuickOpenHandler } from 'vs/workbench/browser/quickopen';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionsViewlet } from './extensions';
import { IExtensionsViewlet, VIEWLET_ID } from './extensions';
import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletService';
class SearchExtensionEntry extends QuickOpenEntry {
class SimpleEntry extends QuickOpenEntry {
constructor(
private text: string,
@IViewletService private viewletService: IViewletService
) {
constructor(private label: string, private action: Function) {
super();
}
getLabel(): string {
return nls.localize('searchFor', "Press Enter to search for '{0}' in the Marketplace.", this.text);
return this.label;
}
getAriaLabel(): string {
return this.getLabel();
return this.label;
}
run(mode:Mode):boolean {
......@@ -35,33 +30,62 @@ class SearchExtensionEntry extends QuickOpenEntry {
return false;
}
this.viewletService.openViewlet('workbench.viewlet.extensions', true)
.then(viewlet => viewlet as IExtensionsViewlet)
.done(viewlet => {
viewlet.search(this.text, true);
viewlet.focus();
});
this.action();
return true;
}
}
export class GalleryExtensionsHandler extends QuickOpenHandler {
export class ExtensionsHandler extends QuickOpenHandler {
constructor(@IViewletService private viewletService: IViewletService) {
super();
}
getResults(text: string): TPromise<IModel<any>> {
const label = nls.localize('manage', "Press Enter to manage your extensions.");
const action = () => {
this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.done(viewlet => {
viewlet.search('', true);
viewlet.focus();
});
};
return TPromise.as(new QuickOpenModel([new SimpleEntry(label, action)]));
}
getEmptyLabel(input: string): string {
return '';
}
getAutoFocus(searchValue: string): IAutoFocus {
return { autoFocusFirstEntry: true };
}
}
private delayer: ThrottledDelayer<any>;
export class GalleryExtensionsHandler extends QuickOpenHandler {
constructor(
@IInstantiationService private instantiationService: IInstantiationService
) {
constructor(@IViewletService private viewletService: IViewletService) {
super();
this.delayer = new ThrottledDelayer(500);
}
getResults(text: string): TPromise<IModel<any>> {
const entries = [];
if (text) {
entries.push(this.instantiationService.createInstance(SearchExtensionEntry, text));
const label = nls.localize('searchFor', "Press Enter to search for '{0}' in the Marketplace.", text);
const action = () => {
this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.done(viewlet => {
viewlet.search(text, true);
viewlet.focus();
});
};
entries.push(new SimpleEntry(label, action));
}
return TPromise.as(new QuickOpenModel(entries));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册