本文整理匯總了TypeScript中vs/platform/instantiation/common/instantiation.ServicesAccessor類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ServicesAccessor類的具體用法?TypeScript ServicesAccessor怎麽用?TypeScript ServicesAccessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ServicesAccessor類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: services
function services(accessor: ServicesAccessor): { windowService: IWindowService, historyService: IHistoryService, contextService: IWorkspaceContextService, environmentService: IEnvironmentService } {
return {
windowService: accessor.get(IWindowService),
historyService: accessor.get(IHistoryService),
contextService: accessor.get(IWorkspaceContextService),
environmentService: accessor.get(IEnvironmentService)
};
}
示例2: toResource
export const openFileInNewWindowCommand = (accessor: ServicesAccessor) => {
const windowService = accessor.get(IWindowService);
const editorService = accessor.get(IWorkbenchEditorService);
const fileResource = toResource(editorService.getActiveEditorInput(), { supportSideBySide: true, filter: 'file' });
windowService.openFilePicker(true, fileResource ? paths.dirname(fileResource.fsPath) : void 0);
};
示例3:
handler: (accessor: ServicesAccessor) => {
let editorService: IWorkbenchEditorService = accessor.get(IWorkbenchEditorService);
let instantiationService: IInstantiationService = accessor.get(IInstantiationService);
let connectionService: IConnectionManagementService = accessor.get(IConnectionManagementService);
let objectExplorerService: IObjectExplorerService = accessor.get(IObjectExplorerService);
let connectionProfile = TaskUtilities.getCurrentGlobalConnection(objectExplorerService, connectionService, editorService);
let profilerInput = instantiationService.createInstance(ProfilerInput, connectionProfile);
return editorService.openEditor(profilerInput, { pinned: true }, false).then(() => TPromise.as(true));
}
示例4: getOutOfWorkspaceEditorResources
export function getOutOfWorkspaceEditorResources(accessor: ServicesAccessor): URI[] {
const editorService = accessor.get(IEditorService);
const contextService = accessor.get(IWorkspaceContextService);
const fileService = accessor.get(IFileService);
const resources = editorService.editors
.map(editor => toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }))
.filter(resource => !!resource && !contextService.isInsideWorkspace(resource) && fileService.canHandleResource(resource));
return resources as URI[];
}
示例5: getMultiSelectedResources
const revealInOSHandler = (accessor: ServicesAccessor, resource: URI) => {
// Without resource, try to look at the active editor
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IWorkbenchEditorService));
if (resources.length) {
const windowsService = accessor.get(IWindowsService);
sequence(resources.map(r => () => windowsService.showItemInFolder(paths.normalize(r.fsPath, true))));
} else {
const messageService = accessor.get(IMessageService);
messageService.show(severity.Info, nls.localize('openFileToReveal', "Open a file first to reveal"));
}
};
示例6: getResourceForCommand
const revealInOSHandler = (accessor: ServicesAccessor, resource: URI) => {
// Without resource, try to look at the active editor
resource = getResourceForCommand(resource, accessor.get(IListService), accessor.get(IWorkbenchEditorService));
if (resource) {
const windowsService = accessor.get(IWindowsService);
windowsService.showItemInFolder(paths.normalize(resource.fsPath, true));
} else {
const messageService = accessor.get(IMessageService);
messageService.show(severity.Info, nls.localize('openFileToReveal', "Open a file first to reveal"));
}
};
示例7: function
CommandsRegistry.registerCommand('_workbench.previewHtml', function (
accessor: ServicesAccessor,
resource: URI | string,
position?: EditorViewColumn,
label?: string
) {
const uri = resource instanceof URI ? resource : URI.parse(resource);
label = label || uri.fsPath;
let input: HtmlInput;
const editorGroupService = accessor.get(IEditorGroupsService);
let targetGroup: IEditorGroup = editorGroupService.getGroup(viewColumnToEditorGroup(editorGroupService, position));
if (!targetGroup) {
targetGroup = editorGroupService.activeGroup;
}
// Find already opened HTML input if any
if (targetGroup) {
const editors = targetGroup.editors;
for (let i = 0; i < editors.length; i++) {
const editor = editors[i];
const editorResource = editor.getResource();
if (editor instanceof HtmlInput && editorResource && editorResource.toString() === resource.toString()) {
input = editor;
break;
}
}
}
const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
const inputOptions: HtmlInputOptions = {
allowScripts: true,
allowSvgs: true,
svgWhiteList: extensionsWorkbenchService.allowedBadgeProviders
};
// Otherwise, create new input and open it
if (!input) {
input = accessor.get(IInstantiationService).createInstance(HtmlInput, label, '', uri, inputOptions);
} else {
input.setName(label); // make sure to use passed in label
}
return accessor.get(IEditorService)
.openEditor(input, { pinned: true }, viewColumnToEditorGroup(editorGroupService, position))
.then(editor => true);
});
示例8: loadExperiments
export function loadExperiments(accessor?: ServicesAccessor): ITelemetryExperiments {
// shortcut since there are currently no experiments (should introduce separate service to load only once)
if (!accessor) {
return {};
}
const storageService = accessor.get(IStorageService);
const configurationService = accessor.get(IConfigurationService);
let {
} = splitExperimentsRandomness(storageService);
return applyOverrides(defaultExperiments, configurationService);
}
示例9: listFocusLast
function listFocusLast(accessor: ServicesAccessor, options?: { fromFocused: boolean }): void {
const focused = accessor.get(IListService).lastFocusedList;
// Ensure DOM Focus
ensureDOMFocus(focused);
// List
if (focused instanceof List || focused instanceof PagedList) {
const list = focused;
list.setFocus([list.length - 1]);
list.reveal(list.length - 1);
}
// ObjectTree
else if (focused instanceof ObjectTree || focused instanceof DataTree || focused instanceof AsyncDataTree) {
const tree = focused;
const fakeKeyboardEvent = new KeyboardEvent('keydown');
tree.focusLast(fakeKeyboardEvent);
const focus = tree.getFocus();
if (focus.length > 0) {
tree.reveal(focus[0]);
}
}
// Tree
else if (focused) {
const tree = focused;
tree.focusLast({ origin: 'keyboard' }, options && options.fromFocused ? tree.getFocus() : undefined);
tree.reveal(tree.getFocus());
}
}
示例10: function
CommandsRegistry.registerCommand('_workbench.removeFromRecentlyOpened', function (accessor: ServicesAccessor, path: string) {
const windowsService = accessor.get(IWindowsService);
return windowsService.removeFromRecentlyOpened([path]).then(() => {
return void 0;
});
});