提交 5aa43e52 编写于 作者: B Benjamin Pasero

grid - adopt some services in workbench core

上级 2001f6b2
......@@ -42,7 +42,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { isMacintosh } from 'vs/base/common/platform';
import { GroupOnePicker, GroupTwoPicker, GroupThreePicker, AllEditorsPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
import { Schemas } from 'vs/base/common/network';
import { GridOpenEditorsAction, GridCloseActiveEditorAction, GridOpenOneEditorAction, GridOpenOneEditorSideBySideAction, ResetGridEditorAction } from 'vs/workbench/browser/parts/editor2/nextEditorActions';
import { GridOpenEditorsAction, ResetGridEditorAction } from 'vs/workbench/browser/parts/editor2/nextEditorActions';
// Register String Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
......@@ -441,10 +441,7 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: editorComman
const gridCategory = nls.localize('grid', "Grid");
registry.registerWorkbenchAction(new SyncActionDescriptor(ResetGridEditorAction, ResetGridEditorAction.ID, ResetGridEditorAction.LABEL), 'Grid: Reset Grid', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(GridOpenEditorsAction, GridOpenEditorsAction.ID, GridOpenEditorsAction.LABEL), 'Grid: Open Some Editors', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(GridCloseActiveEditorAction, GridCloseActiveEditorAction.ID, GridCloseActiveEditorAction.LABEL), 'Grid: Close Active Editor', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(RemoveActiveEditorGroupAction, RemoveActiveEditorGroupAction.ID, RemoveActiveEditorGroupAction.LABEL), 'Grid: Remove Active Editor Group', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(GridOpenOneEditorAction, GridOpenOneEditorAction.ID, GridOpenOneEditorAction.LABEL), 'Grid: Open One Editor', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(GridOpenOneEditorSideBySideAction, GridOpenOneEditorSideBySideAction.ID, GridOpenOneEditorSideBySideAction.LABEL), 'Grid: Open One Editor Side by Side', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(SplitEditorGroupHorizontalAction, SplitEditorGroupHorizontalAction.ID, SplitEditorGroupHorizontalAction.LABEL), 'Grid: Split Horizontal', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(SplitEditorGroupVerticalAction, SplitEditorGroupVerticalAction.ID, SplitEditorGroupVerticalAction.LABEL), 'Grid: Split Vertical', gridCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(SplitEditorGroupVerticalAction, SplitEditorGroupVerticalAction.ID, SplitEditorGroupVerticalAction.LABEL), 'Grid: Split Vertical', gridCategory);
\ No newline at end of file
......@@ -6,7 +6,7 @@
import { IDisposable } from 'vs/base/common/lifecycle';
import URI from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { IRange } from 'vs/editor/common/core/range';
import { CursorChangeReason, ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
......@@ -28,7 +28,7 @@ export class RangeHighlightDecorations implements IDisposable {
private readonly _onHighlightRemoved: Emitter<void> = new Emitter<void>();
public readonly onHighlghtRemoved: Event<void> = this._onHighlightRemoved.event;
constructor(@IWorkbenchEditorService private editorService: IWorkbenchEditorService) {
constructor(@INextEditorService private editorService: INextEditorService) {
}
public removeHighlightRange() {
......@@ -55,11 +55,11 @@ export class RangeHighlightDecorations implements IDisposable {
}
private getEditor(resourceRange: IRangeHighlightDecoration): ICodeEditor {
const activeInput = this.editorService.getActiveEditorInput();
const resource = activeInput && activeInput.getResource();
const activeEditor = this.editorService.activeEditor;
const resource = activeEditor && activeEditor.getResource();
if (resource) {
if (resource.toString() === resourceRange.resource.toString()) {
return <ICodeEditor>this.editorService.getActiveEditor().getControl();
return this.editorService.activeTextEditorControl as ICodeEditor;
}
}
return null;
......
......@@ -21,7 +21,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Registry } from 'vs/platform/registry/common/platform';
import { TPromise } from 'vs/base/common/winjs.base';
import { Action } from 'vs/base/common/actions';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { memoize } from 'vs/base/common/decorators';
import * as platform from 'vs/base/common/platform';
import { IFileService } from 'vs/platform/files/common/files';
......@@ -245,15 +245,15 @@ class ZoomStatusbarItem extends Themable implements IStatusbarItem {
constructor(
@IContextMenuService private contextMenuService: IContextMenuService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@INextEditorService editorService: INextEditorService,
@IThemeService themeService: IThemeService
) {
super(themeService);
ZoomStatusbarItem.instance = this;
this.toUnbind.push(editorGroupService.onEditorsChanged(() => this.onEditorsChanged()));
this.toUnbind.push(editorService.onDidActiveEditorChange(() => this.onActiveEditorChanged()));
}
private onEditorsChanged(): void {
private onActiveEditorChanged(): void {
this.hide();
this.onSelectScale = void 0;
}
......
......@@ -10,11 +10,10 @@ import { Action } from 'vs/base/common/actions';
import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { INextEditorGroupsService, GroupDirection } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { EditorInput } from 'vs/workbench/common/editor';
import { join, dirname } from 'vs/base/common/paths';
import { isWindows } from 'vs/base/common/platform';
import { INextEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
function getVSCodeBaseFolder(): string {
let workingDir = process.cwd();
......@@ -32,7 +31,7 @@ export class GridOpenEditorsAction extends Action {
constructor(
id: string,
label: string,
@IWorkbenchEditorService private legacyEditorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INextEditorGroupsService private nextEditorGroupsService: INextEditorGroupsService
) {
super(id, label);
......@@ -50,7 +49,7 @@ export class GridOpenEditorsAction extends Action {
join(workingDir, 'src/vs/workbench/browser/parts/editor2/nextTabsTitleControl.ts'),
join(workingDir, 'src/vs/workbench/browser/parts/editor2/nextTitleControl.ts')
].map(input => {
return this.legacyEditorService.createInput({ resource: URI.file(input) }) as EditorInput;
return this.editorService.createInput({ resource: URI.file(input) }) as EditorInput;
});
const firstGroup = this.nextEditorGroupsService.activeGroup;
......@@ -72,28 +71,6 @@ export class GridOpenEditorsAction extends Action {
}
}
export class GridOpenOneEditorAction extends Action {
static readonly ID = 'workbench.action.gridOpenOneEditor';
static readonly LABEL = localize('gridOpenOneEditor', "Open One Editor");
constructor(
id: string,
label: string,
@IWorkbenchEditorService private legacyEditorService: IWorkbenchEditorService,
@INextEditorGroupsService private nextEditorGroupsService: INextEditorGroupsService
) {
super(id, label);
}
run(): TPromise<any> {
const path = join(getVSCodeBaseFolder(), 'src/vs/workbench/browser/parts/editor/editor.contribution.ts');
this.nextEditorGroupsService.activeGroup.openEditor(this.legacyEditorService.createInput({ resource: URI.file(path) }) as EditorInput);
return TPromise.as(void 0);
}
}
export class ResetGridEditorAction extends Action {
static readonly ID = 'workbench.action.resetGrid';
......@@ -120,48 +97,6 @@ export class ResetGridEditorAction extends Action {
}
}
return TPromise.as(void 0);
}
}
export class GridOpenOneEditorSideBySideAction extends Action {
static readonly ID = 'workbench.action.gridOpenOneEditorSideBySide';
static readonly LABEL = localize('gridOpenOneEditorSideBySide', "Open One Editor Side by Side");
constructor(
id: string,
label: string,
@IWorkbenchEditorService private legacyEditorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService
) {
super(id, label);
}
run(): TPromise<any> {
const path = join(getVSCodeBaseFolder(), 'src/vs/workbench/browser/parts/editor/editor.contribution.ts');
this.editorService.openEditor(this.legacyEditorService.createInput({ resource: URI.file(path) }) as EditorInput, null, SIDE_GROUP);
return TPromise.as(void 0);
}
}
export class GridCloseActiveEditorAction extends Action {
static readonly ID = 'workbench.action.gridCloseActiveEditor';
static readonly LABEL = localize('gridCloseActiveEditor', "Close Active Editor");
constructor(
id: string,
label: string,
@INextEditorGroupsService private nextEditorGroupsService: INextEditorGroupsService
) {
super(id, label);
}
run(): TPromise<any> {
this.nextEditorGroupsService.activeGroup.closeEditor();
return TPromise.as(void 0);
}
}
\ No newline at end of file
......@@ -18,7 +18,7 @@ import { NotificationsList } from 'vs/workbench/browser/parts/notifications/noti
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { addClass, removeClass, isAncestor, Dimension } from 'vs/base/browser/dom';
import { widgetShadow } from 'vs/platform/theme/common/colorRegistry';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { localize } from 'vs/nls';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { ClearAllNotificationsAction, HideNotificationsCenterAction, NotificationActionRunner } from 'vs/workbench/browser/parts/notifications/notificationsActions';
......@@ -45,7 +45,7 @@ export class NotificationsCenter extends Themable {
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IContextKeyService contextKeyService: IContextKeyService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IKeybindingService private keybindingService: IKeybindingService
) {
super(themeService);
......@@ -205,9 +205,9 @@ export class NotificationsCenter extends Themable {
}
private focusEditor(): void {
const editor = this.editorService.getActiveEditor();
if (editor) {
editor.focus();
const activeControl = this.editorService.activeControl;
if (activeControl) {
activeControl.focus();
}
}
......
......@@ -16,7 +16,7 @@ import { IPartService, Parts } from 'vs/workbench/services/part/common/partServi
import { Themable, NOTIFICATIONS_TOAST_BORDER } from 'vs/workbench/common/theme';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { widgetShadow } from 'vs/platform/theme/common/colorRegistry';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { NotificationsToastsVisibleContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { localize } from 'vs/nls';
......@@ -64,7 +64,7 @@ export class NotificationsToasts extends Themable {
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IThemeService themeService: IThemeService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IContextKeyService contextKeyService: IContextKeyService,
@ILifecycleService private lifecycleService: ILifecycleService
) {
......@@ -250,9 +250,9 @@ export class NotificationsToasts extends Themable {
}
private focusEditor(): void {
const editor = this.editorService.getActiveEditor();
if (editor) {
editor.focus();
const activeControl = this.editorService.activeControl;
if (activeControl) {
activeControl.focus();
}
}
......
......@@ -33,7 +33,7 @@ import { Button } from 'vs/base/browser/ui/button/button';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { onUnexpectedError, canceled } from 'vs/base/common/errors';
import Severity from 'vs/base/common/severity';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Action } from 'vs/base/common/actions';
......@@ -369,7 +369,7 @@ export class QuickInputService extends Component implements IQuickInputService {
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IContextKeyService contextKeyService: IContextKeyService,
@IThemeService themeService: IThemeService
) {
......@@ -550,9 +550,9 @@ export class QuickInputService extends Component implements IQuickInputService {
}
private restoreFocus(): void {
const editor = this.editorService.getActiveEditor();
if (editor) {
editor.focus();
const activeControl = this.editorService.activeControl;
if (activeControl) {
activeControl.focus();
}
}
......
......@@ -14,13 +14,12 @@ import { $ } from 'vs/base/browser/builder';
import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
import { Registry } from 'vs/platform/registry/common/platform';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { Part } from 'vs/workbench/browser/part';
import { StatusbarAlignment, IStatusbarRegistry, Extensions, IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStatusbarService, IStatusbarEntry } from 'vs/platform/statusbar/common/statusbar';
import { getCodeEditor } from 'vs/editor/browser/services/codeEditorService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Action } from 'vs/base/common/actions';
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
......@@ -229,7 +228,7 @@ class StatusBarEntryItem implements IStatusbarItem {
@INotificationService private notificationService: INotificationService,
@ITelemetryService private telemetryService: ITelemetryService,
@IContextMenuService private contextMenuService: IContextMenuService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IThemeService private themeService: IThemeService
) {
this.entry = entry;
......@@ -301,10 +300,9 @@ class StatusBarEntryItem implements IStatusbarItem {
args = args || [];
// Maintain old behaviour of always focusing the editor here
const activeEditor = this.editorService.getActiveEditor();
const codeEditor = getCodeEditor(activeEditor);
if (codeEditor) {
codeEditor.focus();
const activeTextEditorControl = this.editorService.activeTextEditorControl;
if (activeTextEditorControl) {
activeTextEditorControl.focus();
}
/* __GDPR__
......
......@@ -18,8 +18,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IAction, Action } from 'vs/base/common/actions';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as nls from 'vs/nls';
import * as labels from 'vs/base/common/labels';
......@@ -61,8 +60,7 @@ export class TitlebarPart extends Part implements ITitleService {
@IWindowService private windowService: IWindowService,
@IConfigurationService private configurationService: IConfigurationService,
@IWindowsService private windowsService: IWindowsService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@INextEditorService private editorService: INextEditorService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IThemeService themeService: IThemeService,
......@@ -88,7 +86,7 @@ export class TitlebarPart extends Part implements ITitleService {
this.toUnbind.push(addDisposableListener(window, EventType.BLUR, () => this.onBlur()));
this.toUnbind.push(addDisposableListener(window, EventType.FOCUS, () => this.onFocus()));
this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationChanged(e)));
this.toUnbind.push(this.editorGroupService.onEditorsChanged(() => this.onEditorsChanged()));
this.toUnbind.push(this.editorService.onDidActiveEditorChange(() => this.onActiveEditorChange()));
this.toUnbind.push(this.contextService.onDidChangeWorkspaceFolders(() => this.setTitle(this.getWindowTitle())));
this.toUnbind.push(this.contextService.onDidChangeWorkbenchState(() => this.setTitle(this.getWindowTitle())));
this.toUnbind.push(this.contextService.onDidChangeWorkspaceName(() => this.setTitle(this.getWindowTitle())));
......@@ -110,25 +108,23 @@ export class TitlebarPart extends Part implements ITitleService {
}
}
private onEditorsChanged(): void {
private onActiveEditorChange(): void {
// Dispose old listeners
dispose(this.activeEditorListeners);
this.activeEditorListeners = [];
const activeEditor = this.editorService.getActiveEditor();
const activeInput = activeEditor ? activeEditor.input : void 0;
// Calculate New Window Title
this.setTitle(this.getWindowTitle());
// Apply listener for dirty and label changes
if (activeInput instanceof EditorInput) {
this.activeEditorListeners.push(activeInput.onDidChangeDirty(() => {
const activeEditor = this.editorService.activeEditor;
if (activeEditor instanceof EditorInput) {
this.activeEditorListeners.push(activeEditor.onDidChangeDirty(() => {
this.setTitle(this.getWindowTitle());
}));
this.activeEditorListeners.push(activeInput.onDidChangeLabel(() => {
this.activeEditorListeners.push(activeEditor.onDidChangeLabel(() => {
this.setTitle(this.getWindowTitle());
}));
}
......@@ -183,7 +179,7 @@ export class TitlebarPart extends Part implements ITitleService {
* {separator}: conditional separator
*/
private doGetWindowTitle(): string {
const input = this.editorService.getActiveEditorInput();
const editor = this.editorService.activeEditor;
const workspace = this.contextService.getWorkspace();
let root: URI;
......@@ -196,17 +192,17 @@ export class TitlebarPart extends Part implements ITitleService {
// Compute folder resource
// Single Root Workspace: always the root single workspace in this case
// Otherwise: root folder of the currently active file if any
let folder = this.contextService.getWorkbenchState() === WorkbenchState.FOLDER ? workspace.folders[0] : this.contextService.getWorkspaceFolder(toResource(input, { supportSideBySide: true }));
let folder = this.contextService.getWorkbenchState() === WorkbenchState.FOLDER ? workspace.folders[0] : this.contextService.getWorkspaceFolder(toResource(editor, { supportSideBySide: true }));
// Variables
const activeEditorShort = input ? input.getTitle(Verbosity.SHORT) : '';
const activeEditorMedium = input ? input.getTitle(Verbosity.MEDIUM) : activeEditorShort;
const activeEditorLong = input ? input.getTitle(Verbosity.LONG) : activeEditorMedium;
const activeEditorShort = editor ? editor.getTitle(Verbosity.SHORT) : '';
const activeEditorMedium = editor ? editor.getTitle(Verbosity.MEDIUM) : activeEditorShort;
const activeEditorLong = editor ? editor.getTitle(Verbosity.LONG) : activeEditorMedium;
const rootName = workspace.name;
const rootPath = root ? labels.getPathLabel(root, void 0, this.environmentService) : '';
const folderName = folder ? folder.name : '';
const folderPath = folder ? labels.getPathLabel(folder.uri, void 0, this.environmentService) : '';
const dirty = input && input.isDirty() ? TitlebarPart.TITLE_DIRTY : '';
const dirty = editor && editor.isDirty() ? TitlebarPart.TITLE_DIRTY : '';
const appName = this.environmentService.appNameLong;
const separator = TitlebarPart.TITLE_SEPARATOR;
const titleTemplate = this.configurationService.getValue<string>('window.title');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册