提交 d8966860 编写于 作者: B Benjamin Pasero

multi root - not yet in stable

上级 c2d9659f
......@@ -10,8 +10,6 @@ import { Action } from 'vs/base/common/actions';
import nls = require('vs/nls');
import { IWindowService } from 'vs/platform/windows/common/windows';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceEditingService } from "vs/workbench/services/workspace/common/workspaceEditing";
import URI from "vs/base/common/uri";
export class OpenFolderAction extends Action {
......@@ -47,25 +45,4 @@ export class OpenFileFolderAction extends Action {
run(event?: any, data?: ITelemetryData): TPromise<any> {
return this.windowService.pickFileFolderAndOpen(undefined, data);
}
}
export class AddFolderAction extends Action {
static ID = 'workbench.action.files.addFolder';
static LABEL = nls.localize('addFolder', "Add Folder...");
constructor(
id: string,
label: string,
@IWindowService private windowService: IWindowService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService
) {
super(id, label);
}
public run(event?: any, data?: ITelemetryData): TPromise<any> {
return this.windowService.pickFolder().then(folders => {
this.workspaceEditingService.addRoots(folders.map(folder => URI.file(folder)));
});
}
}
\ No newline at end of file
......@@ -42,6 +42,7 @@ import { webFrame } from 'electron';
import { getPathLabel } from "vs/base/common/labels";
import { IViewlet } from "vs/workbench/common/viewlet";
import { IPanel } from "vs/workbench/common/panel";
import { IWorkspaceEditingService } from "vs/workbench/services/workspace/common/workspaceEditing";
// --- actions
......@@ -1424,3 +1425,24 @@ export class DecreaseViewSizeAction extends BaseResizeViewAction {
return TPromise.as(true);
}
}
export class AddFolderAction extends Action {
static ID = 'workbench.action.files.addFolder';
static LABEL = nls.localize('addFolder', "Add Folder...");
constructor(
id: string,
label: string,
@IWindowService private windowService: IWindowService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService
) {
super(id, label);
}
public run(): TPromise<any> {
return this.windowService.pickFolder().then(folders => {
this.workspaceEditingService.addRoots(folders.map(folder => URI.file(folder)));
});
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
import { CloseEditorAction, KeybindingsReferenceAction, OpenDocumentationUrlAction, OpenIntroductoryVideosUrlAction, ReportIssueAction, ReportPerformanceIssueAction, ZoomResetAction, ZoomOutAction, ZoomInAction, ToggleFullScreenAction, ToggleMenuBarAction, CloseFolderAction, CloseWindowAction, SwitchWindow, NewWindowAction, CloseMessagesAction, NavigateUpAction, NavigateDownAction, NavigateLeftAction, NavigateRightAction, IncreaseViewSizeAction, DecreaseViewSizeAction, ShowStartupPerformance, ToggleSharedProcessAction, QuickSwitchWindow, QuickOpenRecentAction } from 'vs/workbench/electron-browser/actions';
import { CloseEditorAction, KeybindingsReferenceAction, OpenDocumentationUrlAction, OpenIntroductoryVideosUrlAction, ReportIssueAction, ReportPerformanceIssueAction, ZoomResetAction, ZoomOutAction, ZoomInAction, ToggleFullScreenAction, ToggleMenuBarAction, CloseFolderAction, CloseWindowAction, SwitchWindow, NewWindowAction, CloseMessagesAction, NavigateUpAction, NavigateDownAction, NavigateLeftAction, NavigateRightAction, IncreaseViewSizeAction, DecreaseViewSizeAction, ShowStartupPerformance, ToggleSharedProcessAction, QuickSwitchWindow, QuickOpenRecentAction, AddFolderAction } from 'vs/workbench/electron-browser/actions';
import { MessagesVisibleContext } from 'vs/workbench/electron-browser/workbench';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { registerCommands } from 'vs/workbench/electron-browser/commands';
......@@ -77,6 +77,11 @@ workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(Naviga
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(IncreaseViewSizeAction, IncreaseViewSizeAction.ID, IncreaseViewSizeAction.LABEL, null), 'View: Increase Current View Size', viewCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(DecreaseViewSizeAction, DecreaseViewSizeAction.ID, DecreaseViewSizeAction.LABEL, null), 'View: Decrease Current View Size', viewCategory);
// TODO@Ben multi root
if (product.quality !== 'stable') {
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(AddFolderAction, AddFolderAction.ID, AddFolderAction.LABEL), 'Files: Add Folder...', 'Files');
}
// Developer related actions
const developerCategory = nls.localize('developer', "Developer");
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowStartupPerformance, ShowStartupPerformance.ID, ShowStartupPerformance.LABEL), 'Developer: Startup Performance', developerCategory);
......@@ -361,30 +366,33 @@ configurationRegistry.registerConfiguration({
});
// Configuration: Workspace
configurationRegistry.registerConfiguration({
'id': 'workspace',
'order': 10000,
'title': nls.localize('workspaceConfigurationTitle', "Workspace"),
'type': 'object',
'properties': {
'workspace': {
'type': 'object',
'description': nls.localize('workspaces.title', "Folder configuration of the workspace"),
'additionalProperties': {
'anyOf': [{
'type': 'object',
'description': nls.localize('files.exclude.boolean', "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."),
'properties': {
'folders': {
'description': nls.localize('workspaces.additionalFolders', "Folders of this workspace"),
'type': 'array',
'items': {
'type': 'string'
// TODO@Ben multi root
if (product.quality !== 'stable') {
configurationRegistry.registerConfiguration({
'id': 'workspace',
'order': 10000,
'title': nls.localize('workspaceConfigurationTitle', "Workspace"),
'type': 'object',
'properties': {
'workspace': {
'type': 'object',
'description': nls.localize('workspaces.title', "Folder configuration of the workspace"),
'additionalProperties': {
'anyOf': [{
'type': 'object',
'description': nls.localize('files.exclude.boolean', "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."),
'properties': {
'folders': {
'description': nls.localize('workspaces.additionalFolders', "Folders of this workspace"),
'type': 'array',
'items': {
'type': 'string'
}
}
}
}
}]
}]
}
}
}
}
});
\ No newline at end of file
});
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { FileStat } from 'vs/workbench/parts/files/common/explorerViewModel';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { OpenFolderAction, OpenFileFolderAction, AddFolderAction } from 'vs/workbench/browser/actions/fileActions';
import { OpenFolderAction, OpenFileFolderAction } from 'vs/workbench/browser/actions/fileActions';
import { copyFocusedFilesExplorerViewItem, revealInOSFocusedFilesExplorerItem, openFocusedExplorerItemSideBySideCommand, copyPathOfFocusedExplorerItem, copyPathCommand, revealInExplorerCommand, revealInOSCommand, openFolderPickerCommand, openWindowCommand, openFileInNewWindowCommand, deleteFocusedFilesExplorerViewItemCommand, moveFocusedFilesExplorerViewItemToTrashCommand, renameFocusedFilesExplorerViewItemCommand } from 'vs/workbench/parts/files/browser/fileCommands';
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
......@@ -196,7 +196,6 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFileAsAction, Save
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewUntitledFileAction, GlobalNewUntitledFileAction.ID, GlobalNewUntitledFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_N }), 'Files: New Untitled File', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalRevealInOSAction, GlobalRevealInOSAction.ID, GlobalRevealInOSAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_R) }), 'Files: Reveal Active File', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowOpenedFileInNewWindow, ShowOpenedFileInNewWindow.ID, ShowOpenedFileInNewWindow.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_O) }), 'Files: Open Active File in New Window', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(AddFolderAction, AddFolderAction.ID, AddFolderAction.LABEL), 'Files: Add Folder...', category);
if (isMacintosh) {
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenFileFolderAction, OpenFileFolderAction.ID, OpenFileFolderAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_O }), 'Files: Open...', category);
......
......@@ -192,8 +192,9 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
}
private resolveAdditionalFolders(): void {
if (!this.workspace) {
return; // no additional folders for empty workspaces
// TODO@Ben multi root
if (!this.workspace || this.environmentService.appQuality === 'stable') {
return; // no additional folders for empty workspaces or in stable
}
// Resovled configured folders for workspace
......
......@@ -12,6 +12,7 @@ import { TPromise } from "vs/base/common/winjs.base";
import { IWorkspaceContextService } from "vs/platform/workspace/common/workspace";
import { IConfigurationEditingService, ConfigurationTarget } from "vs/workbench/services/configuration/common/configurationEditing";
import { IConfigurationService } from "vs/platform/configuration/common/configuration";
import { IEnvironmentService } from "vs/platform/environment/common/environment";
interface IWorkspaceConfiguration {
[master: string]: {
......@@ -28,12 +29,22 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
constructor(
@IConfigurationEditingService private configurationEditingService: IConfigurationEditingService,
@IConfigurationService private configurationService: IConfigurationService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IEnvironmentService private environmentService: IEnvironmentService
) {
}
public addRoots(rootsToAdd: URI[]): TPromise<void> {
private supported(): boolean {
if (!this.contextService.hasWorkspace()) {
return false; // we need a workspace to begin with
}
// TODO@Ben multi root
return this.environmentService.appQuality !== 'stable'; // not yet enabled in stable
}
public addRoots(rootsToAdd: URI[]): TPromise<void> {
if (!this.supported) {
return TPromise.as(void 0); // we need a workspace to begin with
}
......@@ -43,7 +54,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
}
public removeRoots(rootsToRemove: URI[]): TPromise<void> {
if (!this.contextService.hasWorkspace()) {
if (!this.supported) {
return TPromise.as(void 0); // we need a workspace to begin with
}
......@@ -54,7 +65,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
}
public clearRoots(): TPromise<void> {
if (!this.contextService.hasWorkspace()) {
if (!this.supported) {
return TPromise.as(void 0); // we need a workspace to begin with
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册