提交 754bf961 编写于 作者: B Benjamin Pasero

adopt new event style for onFocusChange

上级 5520b5e3
......@@ -27,7 +27,7 @@ import {EventType as WorkbenchEventType, EditorEvent} from 'vs/workbench/common/
import {IEditorRegistry, Extensions as EditorExtensions, BaseEditor, IEditorInputActionContext, EditorDescriptor} from 'vs/workbench/browser/parts/editor/baseEditor';
import {EditorInput, EditorOptions, TextEditorOptions} from 'vs/workbench/common/editor';
import {BaseTextEditor} from 'vs/workbench/browser/parts/editor/textEditor';
import {EventType as SideBySideEventType, SideBySideEditorControl, Rochade} from 'vs/workbench/browser/parts/editor/sideBySideEditorControl';
import {SideBySideEditorControl, Rochade} from 'vs/workbench/browser/parts/editor/sideBySideEditorControl';
import {WorkbenchProgressService} from 'vs/workbench/services/progress/browser/progressService';
import {EditorArrangement} from 'vs/workbench/services/editor/common/editorService';
import {IEditorPart} from 'vs/workbench/services/editor/browser/editorService';
......@@ -897,7 +897,8 @@ export class EditorPart extends Part implements IEditorPart {
// Side by Side Control
this.sideBySideControl = this.instantiationService.createInstance(SideBySideEditorControl, contentArea);
this.toUnbind.push(this.sideBySideControl.addListener(SideBySideEventType.EDITOR_FOCUS_CHANGED, () => { this.onEditorFocusChanged(); }));
const unbind = this.sideBySideControl.onEditorFocusChange(() => this.onEditorFocusChanged());
this.toUnbind.push(() => unbind.dispose());
// get settings
this.memento = this.getMemento(this.storageService, MementoScope.WORKSPACE);
......
......@@ -11,7 +11,7 @@ import {Registry} from 'vs/platform/platform';
import {Scope, IActionBarRegistry, Extensions} from 'vs/workbench/browser/actionBarRegistry';
import {IAction, Action} from 'vs/base/common/actions';
import arrays = require('vs/base/common/arrays');
import {EventEmitter} from 'vs/base/common/eventEmitter';
import Event, {Emitter} from 'vs/base/common/event';
import {StandardMouseEvent} from 'vs/base/browser/mouseEvent';
import errors = require('vs/base/common/errors');
import {isWindows} from 'vs/base/common/platform';
......@@ -45,14 +45,10 @@ export enum Rochade {
CENTER_AND_RIGHT_TO_LEFT
}
export const EventType = {
EDITOR_FOCUS_CHANGED: 'editorFocusChanged'
};
/**
* Helper class to manage multiple side by side editors for the editor part.
*/
export class SideBySideEditorControl extends EventEmitter implements IVerticalSashLayoutProvider {
export class SideBySideEditorControl implements IVerticalSashLayoutProvider {
private static MIN_EDITOR_WIDTH = 170;
private static EDITOR_TITLE_HEIGHT = 35;
......@@ -91,6 +87,8 @@ export class SideBySideEditorControl extends EventEmitter implements IVerticalSa
private visibleEditorFocusTrackers: DOM.IFocusTracker[];
private editorInputStateChangeListener: () => void;
private _onEditorFocusChange: Emitter<void>;
constructor(
parent: Builder,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
......@@ -103,8 +101,6 @@ export class SideBySideEditorControl extends EventEmitter implements IVerticalSa
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IInstantiationService private instantiationService: IInstantiationService
) {
super();
this.parent = parent;
this.dimension = new Dimension(0, 0);
......@@ -122,6 +118,8 @@ export class SideBySideEditorControl extends EventEmitter implements IVerticalSa
this.visibleEditorContainers = [];
this.visibleEditorFocusTrackers = [];
this._onEditorFocusChange = new Emitter<void>();
this.closeEditorAction = POSITIONS.map((position) => this.instantiationService.createInstance(CloseEditorAction, CLOSE_EDITOR_ACTION_ID, CLOSE_EDITOR_ACTION_LABEL));
POSITIONS.map((position) => this.closeEditorAction[position].setPosition(position) || (this.closeEditorAction[position].class = 'close-editor-action'));
this.splitEditorAction = this.instantiationService.createInstance(SplitEditorAction, SPLIT_EDITOR_ACTION_ID, SPLIT_EDITOR_ACTION_LABEL);
......@@ -161,6 +159,10 @@ export class SideBySideEditorControl extends EventEmitter implements IVerticalSa
);
}
public get onEditorFocusChange(): Event<void> {
return this._onEditorFocusChange.event;
}
public show(editor: BaseEditor, container: Builder, position: Position, preserveActive: boolean, widthRatios?: number[]): void {
let visibleEditorCount = this.getVisibleEditorCount();
......@@ -330,7 +332,7 @@ export class SideBySideEditorControl extends EventEmitter implements IVerticalSa
}
// Re-emit to outside
this.emit(EventType.EDITOR_FOCUS_CHANGED);
this._onEditorFocusChange.fire();
}
}
......@@ -1540,6 +1542,6 @@ export class SideBySideEditorControl extends EventEmitter implements IVerticalSa
this.visibleEditors = null;
this.visibleEditorContainers = null;
super.dispose();
this._onEditorFocusChange.dispose();
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册