提交 3157d842 编写于 作者: B Benjamin Pasero

grid - open some editors right on startup for testing

上级 6ebd8dd3
......@@ -9,9 +9,14 @@ import { localize } from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { OpenNextEditorAction } from 'vs/workbench/browser/parts/editor2/nextEditorActions';
import { OpenNextEditorAction, NextEditorContribution } from 'vs/workbench/browser/parts/editor2/nextEditorActions';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
// Register Next Editor Actions
const category = localize('nextEditor', "Next Editor");
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextEditorAction, OpenNextEditorAction.ID, OpenNextEditorAction.LABEL), 'View: Open Next Editor in Group', category);
// Register Workbench Contribution
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(NextEditorContribution, LifecyclePhase.Running);
\ No newline at end of file
......@@ -12,6 +12,17 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { INextEditorPartService } from 'vs/workbench/services/editor/common/nextEditorPartService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class NextEditorContribution implements IWorkbenchContribution {
constructor(
@IInstantiationService instantiationService: IInstantiationService
) {
instantiationService.createInstance(OpenNextEditorAction, OpenNextEditorAction.ID, OpenNextEditorAction.LABEL).run();
}
}
export class OpenNextEditorAction extends Action {
......
......@@ -19,8 +19,8 @@ import { TabsTitleControl } from 'vs/workbench/browser/parts/editor/tabsTitleCon
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
import { attachProgressBarStyler } from 'vs/platform/theme/common/styler';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Themable, EDITOR_GROUP_HEADER_TABS_BORDER, EDITOR_GROUP_HEADER_TABS_BACKGROUND } from '../../../common/theme';
import { editorBackground, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { Themable, EDITOR_GROUP_HEADER_TABS_BORDER, EDITOR_GROUP_HEADER_TABS_BACKGROUND } from 'vs/workbench/common/theme';
export class NextEditorGroupView extends Themable implements IView {
......@@ -53,6 +53,12 @@ export class NextEditorGroupView extends Themable implements IView {
this.create();
}
openEditor(input: EditorInput, options?: EditorOptions): void {
this._group.openEditor(input, options);
this.render(this.container, Orientation.HORIZONTAL);
}
get element(): HTMLElement {
return this._element;
}
......@@ -65,11 +71,11 @@ export class NextEditorGroupView extends Themable implements IView {
// TODO@grid simplify containers by flattening the hierarchy more?
// Overall Container
// Overall container
this._element = document.createElement('div');
addClass(this._element, 'one-editor-silo');
// Title / Progress / Editor Container
// Title / Progress / Editor container
this.container = document.createElement('div');
addClass(this.container, 'container');
this._element.appendChild(this.container);
......@@ -79,28 +85,29 @@ export class NextEditorGroupView extends Themable implements IView {
[IContextKeyService, this._register(this.contextKeyService.createScoped(this.container))]
));
// Title Container
// Title container
const titleContainer = document.createElement('div');
addClasses(titleContainer, 'title', 'tabs', 'show-file-icons'); // TODO@grid title options (tabs, icons)
addClasses(titleContainer, 'title', 'tabs', 'show-file-icons', 'active'); // TODO@grid title options (tabs, icons, etc...)
this.container.appendChild(titleContainer);
// Title Widget
// Title widget
this.titleAreaControl = this._register(instantiationService.createInstance<ITitleAreaControl>(TabsTitleControl)); // TODO@grid title control choice (tabs vs no tabs)
this.titleAreaControl.create(titleContainer);
this.titleAreaControl.setContext(this._group);
this.titleAreaControl.refresh(true /* instant */);
// Progress Bar
// Progress bar
this.progressBar = new ProgressBar(this.container);
this._register(attachProgressBarStyler(this.progressBar, this.themeService));
this.progressBar.hide();
// Editor Container
// Editor container
this.editorContainer = document.createElement('div');
addClass(this.editorContainer, 'editor-container');
this.editorContainer.setAttribute('role', 'tabpanel');
this.container.appendChild(this.editorContainer);
// Update Styles
// Update styles
this.updateStyles();
}
......@@ -122,17 +129,13 @@ export class NextEditorGroupView extends Themable implements IView {
// TODO@grid Editor container border
}
openEditor(input: EditorInput, options?: EditorOptions): void {
this._group.openEditor(input, options);
this.render(this.container, Orientation.HORIZONTAL);
}
render(container: HTMLElement, orientation: Orientation): void {
this.titleAreaControl.refresh(true /* instant */);
}
layout(size: number, orientation: Orientation): void {
// Layout title
this.titleAreaControl.layout(new Dimension(size, NextEditorGroupView.EDITOR_TITLE_HEIGHT));
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册