提交 0df9f972 编写于 作者: I isidor

open editors: replace working files

上级 5c26ecb5
......@@ -17,7 +17,7 @@ import {SplitView} from 'vs/base/browser/ui/splitview/splitview';
import {ActionRunner, FileViewletState} from 'vs/workbench/parts/files/browser/views/explorerViewer';
import {ExplorerView} from 'vs/workbench/parts/files/browser/views/explorerView';
import {EmptyView} from 'vs/workbench/parts/files/browser/views/emptyView';
import {WorkingFilesView} from 'vs/workbench/parts/files/browser/views/workingFilesView';
import {OpenEditorsView} from 'vs/workbench/parts/files/browser/views/openEditorsView';
import {IStorageService} from 'vs/platform/storage/common/storage';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
......@@ -29,8 +29,8 @@ export class ExplorerViewlet extends Viewlet {
private views: IViewletView[];
private explorerView: ExplorerView;
private workingFilesView: WorkingFilesView;
private lastFocusedView: ExplorerView | WorkingFilesView | EmptyView;
private openEditorsView: OpenEditorsView;
private lastFocusedView: ExplorerView | OpenEditorsView | EmptyView;
private focusListener: IDisposable;
private viewletSettings: any;
......@@ -58,24 +58,24 @@ export class ExplorerViewlet extends Viewlet {
this.splitView = new SplitView(this.viewletContainer.getHTMLElement());
// Working files view
this.addWorkingFilesView();
this.addOpenEditorsView();
// Explorer view
this.addExplorerView();
// Track focus
this.focusListener = this.splitView.onFocus((view: ExplorerView | WorkingFilesView | EmptyView) => {
this.focusListener = this.splitView.onFocus((view: ExplorerView | OpenEditorsView | EmptyView) => {
this.lastFocusedView = view;
});
return TPromise.join(this.views.map((view) => view.create())).then(() => void 0);
}
private addWorkingFilesView(): void {
this.workingFilesView = this.instantiationService.createInstance(WorkingFilesView, this.getActionRunner(), this.viewletSettings);
this.splitView.addView(this.workingFilesView);
private addOpenEditorsView(): void {
this.openEditorsView = this.instantiationService.createInstance(OpenEditorsView, this.getActionRunner(), this.viewletSettings);
this.splitView.addView(this.openEditorsView);
this.views.push(this.workingFilesView);
this.views.push(this.openEditorsView);
}
private addExplorerView(): void {
......@@ -99,8 +99,8 @@ export class ExplorerViewlet extends Viewlet {
return this.explorerView;
}
public getWorkingFilesView(): WorkingFilesView {
return this.workingFilesView;
public getOpenEditorsView(): OpenEditorsView {
return this.openEditorsView;
}
public setVisible(visible: boolean): TPromise<void> {
......@@ -117,26 +117,26 @@ export class ExplorerViewlet extends Viewlet {
return;
}
if (this.hasSelectionOrFocus(this.workingFilesView)) {
return this.workingFilesView.focusBody();
if (this.hasSelectionOrFocus(this.openEditorsView)) {
return this.openEditorsView.focusBody();
}
if (this.hasSelectionOrFocus(this.explorerView)) {
return this.explorerView.focusBody();
}
if (this.workingFilesView && this.workingFilesView.isExpanded()) {
return this.workingFilesView.focusBody();
if (this.openEditorsView && this.openEditorsView.isExpanded()) {
return this.openEditorsView.focusBody();
}
if (this.explorerView && this.explorerView.isExpanded()) {
return this.explorerView.focusBody();
}
return this.workingFilesView.focus();
return this.openEditorsView.focus();
}
private hasSelectionOrFocus(view: ExplorerView | WorkingFilesView | EmptyView): boolean {
private hasSelectionOrFocus(view: ExplorerView | OpenEditorsView | EmptyView): boolean {
if (!view) {
return false;
}
......@@ -145,7 +145,7 @@ export class ExplorerViewlet extends Viewlet {
return false;
}
if (view instanceof ExplorerView || view instanceof WorkingFilesView) {
if (view instanceof ExplorerView || view instanceof OpenEditorsView) {
const viewer = view.getViewer();
if (!viewer) {
return false;
......@@ -172,7 +172,7 @@ export class ExplorerViewlet extends Viewlet {
public getOptimalWidth(): number {
let additionalMargin = 16;
let workingFilesViewWidth = this.getWorkingFilesView().getOptimalWidth();
let workingFilesViewWidth = this.openEditorsView.getOptimalWidth();
let explorerView = this.getExplorerView();
let explorerViewWidth = explorerView ? explorerView.getOptimalWidth() : 0;
let optimalWidth = Math.max(workingFilesViewWidth, explorerViewWidth);
......
......@@ -10,7 +10,7 @@ import {Action, IAction} from 'vs/base/common/actions';
import {ActionItem, BaseActionItem, Separator} from 'vs/base/browser/ui/actionbar/actionbar';
import {Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor} from 'vs/workbench/browser/actionBarRegistry';
import {IEditorInputActionContext, IEditorInputAction, EditorInputActionContributor} from 'vs/workbench/browser/parts/editor/baseEditor';
import {AddToWorkingFiles, FocusWorkingFiles, FocusFilesExplorer, OpenPreviousWorkingFile, OpenNextWorkingFile, CloseAllFilesAction, CloseFileAction, CloseOtherFilesAction, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, keybindingForAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, ReopenClosedFileAction, OpenToSideAction, ShowActiveFileInExplorer} from 'vs/workbench/parts/files/browser/fileActions';
import {AddToWorkingFiles, FocusOpenEditors, FocusFilesExplorer, OpenPreviousWorkingFile, OpenNextWorkingFile, CloseAllFilesAction, CloseFileAction, CloseOtherFilesAction, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, keybindingForAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, ReopenClosedFileAction, OpenToSideAction, ShowActiveFileInExplorer} from 'vs/workbench/parts/files/browser/fileActions';
import {RevertLocalChangesAction, AcceptLocalChangesAction, ConflictResolutionDiffEditorInput} from 'vs/workbench/parts/files/browser/saveErrorHandler';
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
import {IWorkbenchActionRegistry, Extensions as ActionExtensions} from 'vs/workbench/common/actionRegistry';
......@@ -176,6 +176,6 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(ReopenClosedFileAction
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextWorkingFile, OpenNextWorkingFile.ID, OpenNextWorkingFile.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.DownArrow) }), 'Files: Open Next Working File', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousWorkingFile, OpenPreviousWorkingFile.ID, OpenPreviousWorkingFile.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.UpArrow) }), 'Files: Open Previous Working File', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(AddToWorkingFiles, AddToWorkingFiles.ID, AddToWorkingFiles.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.Enter) }), 'Files: Add Active File to Working Files', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusWorkingFiles, FocusWorkingFiles.ID, FocusWorkingFiles.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_E) }), 'Files: Focus on Working Files', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusOpenEditors, FocusOpenEditors.ID, FocusOpenEditors.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_E) }), 'Files: Focus on Working Files', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusFilesExplorer, FocusFilesExplorer.ID, FocusFilesExplorer.LABEL), 'Files: Focus on Files Explorer', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowActiveFileInExplorer, ShowActiveFileInExplorer.ID, ShowActiveFileInExplorer.LABEL), 'Files: Show Active File in Explorer', category);
......@@ -2281,10 +2281,10 @@ export class AddToWorkingFiles extends Action {
}
}
export class FocusWorkingFiles extends Action {
export class FocusOpenEditors extends Action {
public static ID = 'workbench.files.action.focusWorkingFiles';
public static LABEL = nls.localize('focusWorkingFiles', "Focus on Working Files");
public static ID = 'workbench.files.action.focusOpenEditors';
public static LABEL = nls.localize('focusOpenEditors', "Focus on Open Editors");
constructor(
id: string,
......@@ -2296,8 +2296,8 @@ export class FocusWorkingFiles extends Action {
public run(): TPromise<any> {
return this.viewletService.openViewlet(Files.VIEWLET_ID, true).then((viewlet: ExplorerViewlet) => {
viewlet.getWorkingFilesView().expand();
viewlet.getWorkingFilesView().getViewer().DOMFocus();
viewlet.getOpenEditorsView().expand();
viewlet.getOpenEditorsView().getViewer().DOMFocus();
});
}
}
......@@ -2354,8 +2354,8 @@ export class ShowActiveFileInExplorer extends Action {
explorerView.select(fileInput.getResource(), true);
}
} else {
const workingFilesView = viewlet.getWorkingFilesView();
workingFilesView.expand();
const openEditorsView = viewlet.getOpenEditorsView();
openEditorsView.expand();
}
});
} else {
......
......@@ -7,6 +7,7 @@ import nls = require('vs/nls');
import errors = require('vs/base/common/errors');
import {IActionRunner} from 'vs/base/common/actions';
import dom = require('vs/base/browser/dom');
import {CollapsibleState} from 'vs/base/browser/ui/splitview/splitview';
import {Tree} from 'vs/base/parts/tree/browser/treeImpl';
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
import {IMessageService} from 'vs/platform/message/common/message';
......@@ -114,4 +115,16 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
return itemsToShow * Renderer.ITEM_HEIGHT;
}
public getOptimalWidth():number {
let parentNode = this.tree.getHTMLElement();
let childNodes = [].slice.call(parentNode.querySelectorAll('.monaco-file-label > .file-name'));
return dom.getLargestChildWidth(parentNode, childNodes);
}
public shutdown(): void {
this.settings[OpenEditorsView.MEMENTO_COLLAPSED] = (this.state === CollapsibleState.COLLAPSED);
super.shutdown();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册