提交 63eb7207 编写于 作者: I isidor

get rid of getWorkspaceLabel in workspaces.ts and adopt

上级 9acd3395
...@@ -19,7 +19,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti ...@@ -19,7 +19,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel } from 'vs/base/common/labels'; import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel } from 'vs/base/common/labels';
import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows'; import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows';
import { IHistoryMainService } from 'vs/platform/history/common/history'; import { IHistoryMainService } from 'vs/platform/history/common/history';
import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IMenubarData, IMenubarKeybinding, MenubarMenuItem, isMenubarMenuItemSeparator, isMenubarMenuItemSubmenu, isMenubarMenuItemAction } from 'vs/platform/menubar/common/menubar'; import { IMenubarData, IMenubarKeybinding, MenubarMenuItem, isMenubarMenuItemSeparator, isMenubarMenuItemSubmenu, isMenubarMenuItemAction } from 'vs/platform/menubar/common/menubar';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
...@@ -563,10 +563,10 @@ export class Menubar { ...@@ -563,10 +563,10 @@ export class Menubar {
let label: string; let label: string;
let uri: URI; let uri: URI;
if (isSingleFolderWorkspaceIdentifier(workspaceOrFile) && !isFile) { if (isSingleFolderWorkspaceIdentifier(workspaceOrFile) && !isFile) {
label = unmnemonicLabel(getWorkspaceLabel(workspaceOrFile, this.environmentService, this.uriLabelService, { verbose: true })); label = unmnemonicLabel(this.uriLabelService.getWorkspaceLabel(workspaceOrFile, { verbose: true }));
uri = workspaceOrFile; uri = workspaceOrFile;
} else if (isWorkspaceIdentifier(workspaceOrFile)) { } else if (isWorkspaceIdentifier(workspaceOrFile)) {
label = getWorkspaceLabel(workspaceOrFile, this.environmentService, this.uriLabelService, { verbose: true }); label = this.uriLabelService.getWorkspaceLabel(workspaceOrFile, { verbose: true });
uri = URI.file(workspaceOrFile.configPath); uri = URI.file(workspaceOrFile.configPath);
} else { } else {
label = unmnemonicLabel(this.uriLabelService.getLabel(workspaceOrFile)); label = unmnemonicLabel(this.uriLabelService.getLabel(workspaceOrFile));
......
...@@ -22,7 +22,7 @@ import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel } from 'vs/base ...@@ -22,7 +22,7 @@ import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel } from 'vs/base
import { KeybindingsResolver } from 'vs/code/electron-main/keyboard'; import { KeybindingsResolver } from 'vs/code/electron-main/keyboard';
import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows'; import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows';
import { IHistoryMainService } from 'vs/platform/history/common/history'; import { IHistoryMainService } from 'vs/platform/history/common/history';
import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
...@@ -491,10 +491,10 @@ export class CodeMenu { ...@@ -491,10 +491,10 @@ export class CodeMenu {
let label: string; let label: string;
let uri: URI; let uri: URI;
if (isSingleFolderWorkspaceIdentifier(workspace)) { if (isSingleFolderWorkspaceIdentifier(workspace)) {
label = unmnemonicLabel(getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true })); label = unmnemonicLabel(this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true }));
uri = workspace; uri = workspace;
} else if (isWorkspaceIdentifier(workspace)) { } else if (isWorkspaceIdentifier(workspace)) {
label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true }); label = this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true });
uri = URI.file(workspace.configPath); uri = URI.file(workspace.configPath);
} else { } else {
uri = URI.file(workspace); uri = URI.file(workspace);
......
...@@ -14,9 +14,8 @@ import { getBaseLabel } from 'vs/base/common/labels'; ...@@ -14,9 +14,8 @@ import { getBaseLabel } from 'vs/base/common/labels';
import { IPath } from 'vs/platform/windows/common/windows'; import { IPath } from 'vs/platform/windows/common/windows';
import { Event as CommonEvent, Emitter } from 'vs/base/common/event'; import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
import { isWindows, isMacintosh, isLinux } from 'vs/base/common/platform'; import { isWindows, isMacintosh, isLinux } from 'vs/base/common/platform';
import { IWorkspaceIdentifier, IWorkspacesMainService, getWorkspaceLabel, IWorkspaceSavedEvent, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceIdentifier, IWorkspacesMainService, IWorkspaceSavedEvent, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IHistoryMainService, IRecentlyOpened } from 'vs/platform/history/common/history'; import { IHistoryMainService, IRecentlyOpened } from 'vs/platform/history/common/history';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { isEqual } from 'vs/base/common/paths'; import { isEqual } from 'vs/base/common/paths';
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import { getComparisonKey, isEqual as areResourcesEqual, dirname } from 'vs/base/common/resources'; import { getComparisonKey, isEqual as areResourcesEqual, dirname } from 'vs/base/common/resources';
...@@ -52,7 +51,6 @@ export class HistoryMainService implements IHistoryMainService { ...@@ -52,7 +51,6 @@ export class HistoryMainService implements IHistoryMainService {
@IStateService private stateService: IStateService, @IStateService private stateService: IStateService,
@ILogService private logService: ILogService, @ILogService private logService: ILogService,
@IWorkspacesMainService private workspacesMainService: IWorkspacesMainService, @IWorkspacesMainService private workspacesMainService: IWorkspacesMainService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IUriLabelService private uriLabelService: IUriLabelService @IUriLabelService private uriLabelService: IUriLabelService
) { ) {
this.macOSRecentDocumentsUpdater = new RunOnceScheduler(() => this.updateMacOSRecentDocuments(), 800); this.macOSRecentDocumentsUpdater = new RunOnceScheduler(() => this.updateMacOSRecentDocuments(), 800);
...@@ -368,7 +366,7 @@ export class HistoryMainService implements IHistoryMainService { ...@@ -368,7 +366,7 @@ export class HistoryMainService implements IHistoryMainService {
type: 'custom', type: 'custom',
name: nls.localize('recentFolders', "Recent Workspaces"), name: nls.localize('recentFolders', "Recent Workspaces"),
items: this.getRecentlyOpened().workspaces.slice(0, 7 /* limit number of entries here */).map(workspace => { items: this.getRecentlyOpened().workspaces.slice(0, 7 /* limit number of entries here */).map(workspace => {
const title = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService); const title = this.uriLabelService.getWorkspaceLabel(workspace);
let description; let description;
let args; let args;
if (isSingleFolderWorkspaceIdentifier(workspace)) { if (isSingleFolderWorkspaceIdentifier(workspace)) {
......
...@@ -7,17 +7,10 @@ ...@@ -7,17 +7,10 @@
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { isParent } from 'vs/platform/files/common/files';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { basename, dirname, join } from 'vs/base/common/paths';
import { isLinux } from 'vs/base/common/platform';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { getBaseLabel } from 'vs/base/common/labels';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
export const IWorkspacesMainService = createDecorator<IWorkspacesMainService>('workspacesMainService'); export const IWorkspacesMainService = createDecorator<IWorkspacesMainService>('workspacesMainService');
export const IWorkspacesService = createDecorator<IWorkspacesService>('workspacesService'); export const IWorkspacesService = createDecorator<IWorkspacesService>('workspacesService');
...@@ -113,34 +106,6 @@ export interface IWorkspacesService { ...@@ -113,34 +106,6 @@ export interface IWorkspacesService {
createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise<IWorkspaceIdentifier>; createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise<IWorkspaceIdentifier>;
} }
export function getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), environmentService: IEnvironmentService, uriLabelService: IUriLabelService, options?: { verbose: boolean }): string {
// Workspace: Single Folder
if (isSingleFolderWorkspaceIdentifier(workspace)) {
// Folder on disk
if (workspace.scheme === Schemas.file) {
return options && options.verbose ? uriLabelService.getLabel(workspace) : getBaseLabel(workspace);
}
// Remote folder
return options && options.verbose ? uriLabelService.getLabel(workspace) : `${getBaseLabel(workspace)} (${workspace.scheme})`;
}
// Workspace: Untitled
if (isParent(workspace.configPath, environmentService.workspacesHome, !isLinux /* ignore case */)) {
return localize('untitledWorkspace', "Untitled (Workspace)");
}
// Workspace: Saved
const filename = basename(workspace.configPath);
const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1);
if (options && options.verbose) {
return localize('workspaceNameVerbose', "{0} (Workspace)", uriLabelService.getLabel(URI.file(join(dirname(workspace.configPath), workspaceName))));
}
return localize('workspaceName', "{0} (Workspace)", workspaceName);
}
export function isSingleFolderWorkspaceIdentifier(obj: any): obj is ISingleFolderWorkspaceIdentifier { export function isSingleFolderWorkspaceIdentifier(obj: any): obj is ISingleFolderWorkspaceIdentifier {
return obj instanceof URI; return obj instanceof URI;
} }
......
...@@ -25,8 +25,7 @@ import { Event, Emitter } from 'vs/base/common/event'; ...@@ -25,8 +25,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, Disposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, Disposable, dispose } from 'vs/base/common/lifecycle';
import { domEvent } from 'vs/base/browser/event'; import { domEvent } from 'vs/base/browser/event';
import { IRecentlyOpened } from 'vs/platform/history/common/history'; import { IRecentlyOpened } from 'vs/platform/history/common/history';
import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import { MENUBAR_SELECTION_FOREGROUND, MENUBAR_SELECTION_BACKGROUND, MENUBAR_SELECTION_BORDER, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_FOREGROUND, MENU_BACKGROUND, MENU_FOREGROUND, MENU_SELECTION_BACKGROUND, MENU_SELECTION_FOREGROUND, MENU_SELECTION_BORDER } from 'vs/workbench/common/theme'; import { MENUBAR_SELECTION_FOREGROUND, MENUBAR_SELECTION_BACKGROUND, MENUBAR_SELECTION_BORDER, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_FOREGROUND, MENU_BACKGROUND, MENU_FOREGROUND, MENU_SELECTION_BACKGROUND, MENU_SELECTION_FOREGROUND, MENU_SELECTION_BORDER } from 'vs/workbench/common/theme';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
...@@ -122,7 +121,6 @@ export class MenubarControl extends Disposable { ...@@ -122,7 +121,6 @@ export class MenubarControl extends Disposable {
@IContextKeyService private contextKeyService: IContextKeyService, @IContextKeyService private contextKeyService: IContextKeyService,
@IKeybindingService private keybindingService: IKeybindingService, @IKeybindingService private keybindingService: IKeybindingService,
@IConfigurationService private configurationService: IConfigurationService, @IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IUriLabelService private uriLabelService: IUriLabelService, @IUriLabelService private uriLabelService: IUriLabelService,
@IUpdateService private updateService: IUpdateService @IUpdateService private updateService: IUpdateService
) { ) {
...@@ -533,10 +531,10 @@ export class MenubarControl extends Disposable { ...@@ -533,10 +531,10 @@ export class MenubarControl extends Disposable {
let uri: URI; let uri: URI;
if (isSingleFolderWorkspaceIdentifier(workspace) && !isFile) { if (isSingleFolderWorkspaceIdentifier(workspace) && !isFile) {
label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true }); label = this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true });
uri = workspace; uri = workspace;
} else if (isWorkspaceIdentifier(workspace)) { } else if (isWorkspaceIdentifier(workspace)) {
label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true }); label = this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true });
uri = URI.file(workspace.configPath); uri = URI.file(workspace.configPath);
} else { } else {
uri = workspace; uri = workspace;
......
...@@ -29,7 +29,7 @@ import { webFrame, shell } from 'electron'; ...@@ -29,7 +29,7 @@ import { webFrame, shell } from 'electron';
import { getBaseLabel } from 'vs/base/common/labels'; import { getBaseLabel } from 'vs/base/common/labels';
import { IViewlet } from 'vs/workbench/common/viewlet'; import { IViewlet } from 'vs/workbench/common/viewlet';
import { IPanel } from 'vs/workbench/common/panel'; import { IPanel } from 'vs/workbench/common/panel';
import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { FileKind } from 'vs/platform/files/common/files'; import { FileKind } from 'vs/platform/files/common/files';
import { IssueType } from 'vs/platform/issue/common/issue'; import { IssueType } from 'vs/platform/issue/common/issue';
import { domEvent } from 'vs/base/browser/event'; import { domEvent } from 'vs/base/browser/event';
...@@ -441,11 +441,11 @@ export abstract class BaseOpenRecentAction extends Action { ...@@ -441,11 +441,11 @@ export abstract class BaseOpenRecentAction extends Action {
let description: string; let description: string;
if (isSingleFolderWorkspaceIdentifier(workspace) && fileKind !== FileKind.FILE) { if (isSingleFolderWorkspaceIdentifier(workspace) && fileKind !== FileKind.FILE) {
resource = workspace; resource = workspace;
label = getWorkspaceLabel(workspace, environmentService, uriLabelService); label = uriLabelService.getWorkspaceLabel(workspace);
description = uriLabelService.getLabel(dirname(resource)); description = uriLabelService.getLabel(dirname(resource));
} else if (isWorkspaceIdentifier(workspace)) { } else if (isWorkspaceIdentifier(workspace)) {
resource = URI.file(workspace.configPath); resource = URI.file(workspace.configPath);
label = getWorkspaceLabel(workspace, environmentService, uriLabelService); label = uriLabelService.getWorkspaceLabel(workspace);
description = uriLabelService.getLabel(dirname(resource)); description = uriLabelService.getLabel(dirname(resource));
} else { } else {
resource = workspace; resource = workspace;
......
...@@ -33,8 +33,7 @@ import { registerThemingParticipant } from 'vs/platform/theme/common/themeServic ...@@ -33,8 +33,7 @@ import { registerThemingParticipant } from 'vs/platform/theme/common/themeServic
import { registerColor, focusBorder, textLinkForeground, textLinkActiveForeground, foreground, descriptionForeground, contrastBorder, activeContrastBorder } from 'vs/platform/theme/common/colorRegistry'; import { registerColor, focusBorder, textLinkForeground, textLinkActiveForeground, foreground, descriptionForeground, contrastBorder, activeContrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { getExtraColor } from 'vs/workbench/parts/welcome/walkThrough/node/walkThroughUtils'; import { getExtraColor } from 'vs/workbench/parts/welcome/walkThrough/node/walkThroughUtils';
import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions'; import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IEditorInputFactory, EditorInput } from 'vs/workbench/common/editor'; import { IEditorInputFactory, EditorInput } from 'vs/workbench/common/editor';
import { getIdAndVersionFromLocalExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil'; import { getIdAndVersionFromLocalExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
...@@ -55,9 +54,7 @@ export class WelcomePageContribution implements IWorkbenchContribution { ...@@ -55,9 +54,7 @@ export class WelcomePageContribution implements IWorkbenchContribution {
@IConfigurationService configurationService: IConfigurationService, @IConfigurationService configurationService: IConfigurationService,
@IEditorService editorService: IEditorService, @IEditorService editorService: IEditorService,
@IBackupFileService backupFileService: IBackupFileService, @IBackupFileService backupFileService: IBackupFileService,
@ITelemetryService telemetryService: ITelemetryService,
@ILifecycleService lifecycleService: ILifecycleService, @ILifecycleService lifecycleService: ILifecycleService,
@IStorageService storageService: IStorageService
) { ) {
const enabled = isWelcomePageEnabled(configurationService); const enabled = isWelcomePageEnabled(configurationService);
if (enabled && lifecycleService.startupKind !== StartupKind.ReloadedWindow) { if (enabled && lifecycleService.startupKind !== StartupKind.ReloadedWindow) {
...@@ -283,9 +280,9 @@ class WelcomePage { ...@@ -283,9 +280,9 @@ class WelcomePage {
let resource: URI; let resource: URI;
if (isSingleFolderWorkspaceIdentifier(workspace)) { if (isSingleFolderWorkspaceIdentifier(workspace)) {
resource = workspace; resource = workspace;
label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService); label = this.uriLabelService.getWorkspaceLabel(workspace);
} else if (isWorkspaceIdentifier(workspace)) { } else if (isWorkspaceIdentifier(workspace)) {
label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService); label = this.uriLabelService.getWorkspaceLabel(workspace);
resource = URI.file(workspace.configPath); resource = URI.file(workspace.configPath);
} else { } else {
label = getBaseLabel(workspace); label = getBaseLabel(workspace);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册