提交 5915e1cb 编写于 作者: I isidor

explorer service: reorder methods

上级 b82a5152
...@@ -84,6 +84,8 @@ export class ExplorerService implements IExplorerService { ...@@ -84,6 +84,8 @@ export class ExplorerService implements IExplorerService {
return model; return model;
} }
// IExplorerService methods
findClosest(resource: URI): ExplorerItem { findClosest(resource: URI): ExplorerItem {
return this.model.findClosest(resource); return this.model.findClosest(resource);
} }
...@@ -121,14 +123,6 @@ export class ExplorerService implements IExplorerService { ...@@ -121,14 +123,6 @@ export class ExplorerService implements IExplorerService {
}, e => { this.notificationService.error(e); }); }, e => { this.notificationService.error(e); });
} }
private onConfigurationUpdated(configuration: IFilesConfiguration, event?: IConfigurationChangeEvent): void {
const configSortOrder = configuration && configuration.explorer && configuration.explorer.sortOrder || 'default';
if (this.sortOrder !== configSortOrder) {
this.sortOrder = configSortOrder;
this.roots.forEach(r => this._onDidChangeItem.fire(r));
}
}
// File events // File events
private onFileOperation(e: FileOperationEvent): void { private onFileOperation(e: FileOperationEvent): void {
...@@ -297,6 +291,14 @@ export class ExplorerService implements IExplorerService { ...@@ -297,6 +291,14 @@ export class ExplorerService implements IExplorerService {
})); }));
} }
private onConfigurationUpdated(configuration: IFilesConfiguration, event?: IConfigurationChangeEvent): void {
const configSortOrder = configuration && configuration.explorer && configuration.explorer.sortOrder || 'default';
if (this.sortOrder !== configSortOrder) {
this.sortOrder = configSortOrder;
this.roots.forEach(r => this._onDidChangeItem.fire(r));
}
}
dispose(): void { dispose(): void {
dispose(this.disposables); dispose(this.disposables);
} }
......
...@@ -198,18 +198,6 @@ export class ExplorerView extends ViewletPanel { ...@@ -198,18 +198,6 @@ export class ExplorerView extends ViewletPanel {
} }
} }
private getActiveFile(): URI {
const input = this.editorService.activeEditor;
// ignore diff editor inputs (helps to get out of diffing when returning to explorer)
if (input instanceof DiffEditorInput) {
return undefined;
}
// check for files
return toResource(input, { supportSideBySide: true });
}
private createTree(container: HTMLElement): void { private createTree(container: HTMLElement): void {
this.filter = this.instantiationService.createInstance(FilesFilter); this.filter = this.instantiationService.createInstance(FilesFilter);
this.disposables.push(this.filter); this.disposables.push(this.filter);
...@@ -276,13 +264,6 @@ export class ExplorerView extends ViewletPanel { ...@@ -276,13 +264,6 @@ export class ExplorerView extends ViewletPanel {
this.disposables.push(this.tree.onContextMenu(e => this.onContextMenu(e))); this.disposables.push(this.tree.onContextMenu(e => this.onContextMenu(e)));
} }
getOptimalWidth(): number {
const parentNode = this.tree.getHTMLElement();
const childNodes = ([] as HTMLElement[]).slice.call(parentNode.querySelectorAll('.explorer-item .label-name')); // select all file labels
return DOM.getLargestChildWidth(parentNode, childNodes);
}
// React on events // React on events
private onConfigurationUpdated(configuration: IFilesConfiguration, event?: IConfigurationChangeEvent): void { private onConfigurationUpdated(configuration: IFilesConfiguration, event?: IConfigurationChangeEvent): void {
...@@ -357,6 +338,13 @@ export class ExplorerView extends ViewletPanel { ...@@ -357,6 +338,13 @@ export class ExplorerView extends ViewletPanel {
return this.tree.refresh(toRefresh, true); return this.tree.refresh(toRefresh, true);
} }
getOptimalWidth(): number {
const parentNode = this.tree.getHTMLElement();
const childNodes = ([] as HTMLElement[]).slice.call(parentNode.querySelectorAll('.explorer-item .label-name')); // select all file labels
return DOM.getLargestChildWidth(parentNode, childNodes);
}
private setTreeInput(newRoots?: IWorkspaceFolder[]): Promise<void> { private setTreeInput(newRoots?: IWorkspaceFolder[]): Promise<void> {
if (!this.isVisible()) { if (!this.isVisible()) {
this.shouldRefresh = true; this.shouldRefresh = true;
...@@ -392,6 +380,18 @@ export class ExplorerView extends ViewletPanel { ...@@ -392,6 +380,18 @@ export class ExplorerView extends ViewletPanel {
return promise; return promise;
} }
private getActiveFile(): URI {
const input = this.editorService.activeEditor;
// ignore diff editor inputs (helps to get out of diffing when returning to explorer)
if (input instanceof DiffEditorInput) {
return undefined;
}
// check for files
return toResource(input, { supportSideBySide: true });
}
private onSelectItem(fileStat: ExplorerItem, reveal = this.autoReveal): Promise<void> { private onSelectItem(fileStat: ExplorerItem, reveal = this.autoReveal): Promise<void> {
if (!fileStat || !this.isVisible()) { if (!fileStat || !this.isVisible()) {
return Promise.resolve(void 0); return Promise.resolve(void 0);
......
...@@ -20,7 +20,6 @@ function toResource(path) { ...@@ -20,7 +20,6 @@ function toResource(path) {
} else { } else {
return URI.file(join('/home/john', path)); return URI.file(join('/home/john', path));
} }
} }
suite('Files - View Model', () => { suite('Files - View Model', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册