move actions to browser

This commit is contained in:
Benjamin Pasero 2017-06-20 12:10:15 +02:00
parent 4f33f59192
commit baa206be63
3 changed files with 51 additions and 48 deletions

View file

@ -10,6 +10,9 @@ 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 { IWorkspaceContextService } from "vs/platform/workspace/common/workspace";
import { IWorkspaceEditingService } from "vs/workbench/services/workspace/common/workspaceEditing";
import URI from "vs/base/common/uri";
export class OpenFolderAction extends Action {
@ -45,4 +48,50 @@ 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.addFolder';
static LABEL = nls.localize('addFolder', "Add Folder...");
constructor(
id: string,
label: string,
@IWindowService private windowService: IWindowService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService
) {
super(id, label);
}
public run(): TPromise<any> {
if (!this.contextService.hasWorkspace()) {
return this.windowService.pickFolderAndOpen(false /* prefer same window */);
}
return this.windowService.pickFolder().then(folders => {
return this.workspaceEditingService.addRoots(folders.map(folder => URI.file(folder)));
});
}
}
export class RemoveFoldersAction extends Action {
static ID = 'workbench.action.removeFolders';
static LABEL = nls.localize('removeFolders', "Remove Folders");
constructor(
id: string,
label: string,
@IWindowService private windowService: IWindowService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService
) {
super(id, label);
}
public run(): TPromise<any> {
return this.workspaceEditingService.clearRoots();
}
}

View file

@ -41,7 +41,6 @@ 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
@ -1423,50 +1422,4 @@ export class DecreaseViewSizeAction extends BaseResizeViewAction {
this.resizePart(-BaseResizeViewAction.RESIZE_INCREMENT);
return TPromise.as(true);
}
}
export class AddFolderAction extends Action {
static ID = 'workbench.action.addFolder';
static LABEL = nls.localize('addFolder', "Add Folder...");
constructor(
id: string,
label: string,
@IWindowService private windowService: IWindowService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService
) {
super(id, label);
}
public run(): TPromise<any> {
if (!this.contextService.hasWorkspace()) {
return this.windowService.pickFolderAndOpen(false /* prefer same window */);
}
return this.windowService.pickFolder().then(folders => {
return this.workspaceEditingService.addRoots(folders.map(folder => URI.file(folder)));
});
}
}
export class RemoveFoldersAction extends Action {
static ID = 'workbench.action.removeFolders';
static LABEL = nls.localize('removeFolders', "Remove Folders");
constructor(
id: string,
label: string,
@IWindowService private windowService: IWindowService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService
) {
super(id, label);
}
public run(): TPromise<any> {
return this.workspaceEditingService.clearRoots();
}
}

View file

@ -14,10 +14,11 @@ 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, AddFolderAction, RemoveFoldersAction } 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 } 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';
import { AddFolderAction, RemoveFoldersAction } from "vs/workbench/browser/actions/fileActions";
// Contribute Commands
registerCommands();