提交 8ecb3ad5 编写于 作者: R Rob Lourens

#57196 - remove Builder from searchview 'messages'

上级 c54e49d5
...@@ -61,6 +61,7 @@ import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/ ...@@ -61,6 +61,7 @@ import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences'; import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
export class SearchView extends Viewlet implements IViewlet, IPanel { export class SearchView extends Viewlet implements IViewlet, IPanel {
...@@ -93,7 +94,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -93,7 +94,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
private actions: (RefreshAction | CollapseDeepestExpandedLevelAction | ClearSearchResultsAction | CancelSearchAction)[] = []; private actions: (RefreshAction | CollapseDeepestExpandedLevelAction | ClearSearchResultsAction | CancelSearchAction)[] = [];
private tree: WorkbenchTree; private tree: WorkbenchTree;
private viewletSettings: any; private viewletSettings: any;
private messages: Builder; private messagesElement: HTMLElement;
private messageDisposables: IDisposable[] = [];
private searchWidgetsContainer: Builder; private searchWidgetsContainer: Builder;
private searchWidget: SearchWidget; private searchWidget: SearchWidget;
private size: dom.Dimension; private size: dom.Dimension;
...@@ -110,7 +112,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -110,7 +112,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
private changedWhileHidden: boolean; private changedWhileHidden: boolean;
private isWide: boolean; private isWide: boolean;
private searchWithoutFolderMessageBuilder: Builder; private searchWithoutFolderMessageElement: HTMLElement;
constructor( constructor(
@IPartService partService: IPartService, @IPartService partService: IPartService,
...@@ -163,8 +165,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -163,8 +165,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
} }
private onDidChangeWorkbenchState(): void { private onDidChangeWorkbenchState(): void {
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.searchWithoutFolderMessageBuilder) { if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.searchWithoutFolderMessageElement) {
this.searchWithoutFolderMessageBuilder.hide(); dom.hide(this.searchWithoutFolderMessageElement);
} }
} }
...@@ -295,9 +297,9 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -295,9 +297,9 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}); });
}).getHTMLElement(); }).getHTMLElement();
this.messages = builder.div({ 'class': 'messages' }).hide().clone(); this.messagesElement = dom.append(builder.getContainer(), dom.$('.messages'));
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) { if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
this.searchWithoutFolderMessage(this.clearMessage()); this.showSearchWithoutFolderMessage();
} }
this.createSearchResultsView(builder); this.createSearchResultsView(builder);
...@@ -461,8 +463,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -461,8 +463,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.searchWidget.setReplaceAllActionState(false); this.searchWidget.setReplaceAllActionState(false);
this.viewModel.searchResult.replaceAll(progressRunner).then(() => { this.viewModel.searchResult.replaceAll(progressRunner).then(() => {
progressRunner.done(); progressRunner.done();
this.clearMessage() const messageEl = this.clearMessage();
.p({ text: afterReplaceAllMessage }); dom.append(messageEl, dom.$('p', undefined, afterReplaceAllMessage));
}, (error) => { }, (error) => {
progressRunner.done(); progressRunner.done();
errors.isPromiseCanceledError(error); errors.isPromiseCanceledError(error);
...@@ -536,12 +538,15 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -536,12 +538,15 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
return nls.localize('replaceAll.occurrences.files.confirmation.message', "Replace {0} occurrences across {1} files?", occurrences, fileCount); return nls.localize('replaceAll.occurrences.files.confirmation.message', "Replace {0} occurrences across {1} files?", occurrences, fileCount);
} }
private clearMessage(): Builder { private clearMessage(): HTMLElement {
this.searchWithoutFolderMessageBuilder = void 0; this.searchWithoutFolderMessageElement = void 0;
return this.messages.empty().show() dom.clearNode(this.messagesElement);
.asContainer().div({ 'class': 'message' }) dom.show(this.messagesElement);
.asContainer(); dispose(this.messageDisposables);
this.messageDisposables = [];
return dom.append(this.messagesElement, dom.$('.message'));
} }
private createSearchResultsView(builder: Builder): void { private createSearchResultsView(builder: Builder): void {
...@@ -839,7 +844,10 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -839,7 +844,10 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.inputPatternExcludes.setWidth(this.size.width - 28 /* container margin */); this.inputPatternExcludes.setWidth(this.size.width - 28 /* container margin */);
this.inputPatternIncludes.setWidth(this.size.width - 28 /* container margin */); this.inputPatternIncludes.setWidth(this.size.width - 28 /* container margin */);
const messagesSize = this.messages.isHidden() ? 0 : dom.getTotalHeight(this.messages.getHTMLElement()); const messagesSize = this.messagesElement.style.display === 'none' ?
0 :
dom.getTotalHeight(this.messagesElement);
const searchResultContainerSize = this.size.height - const searchResultContainerSize = this.size.height -
messagesSize - messagesSize -
dom.getTotalHeight(this.searchWidgetsContainer.getContainer()); dom.getTotalHeight(this.searchWidgetsContainer.getContainer());
...@@ -874,7 +882,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -874,7 +882,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.viewModel.searchResult.clear(); this.viewModel.searchResult.clear();
this.showEmptyStage(); this.showEmptyStage();
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) { if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
this.searchWithoutFolderMessage(this.clearMessage()); this.showSearchWithoutFolderMessage();
} }
this.searchWidget.clear(); this.searchWidget.clear();
this.viewModel.cancelSearch(); this.viewModel.cancelSearch();
...@@ -1220,37 +1228,29 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -1220,37 +1228,29 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.tree.onHidden(); this.tree.onHidden();
this.results.hide(); this.results.hide();
const div = this.clearMessage();
const p = $(div).p({ text: message }); const messageEl = this.clearMessage();
const p = dom.append(messageEl, dom.$('p', undefined, message));
if (!completed) { if (!completed) {
$(p).a({ const searchAgainLink = dom.append(p, dom.$('a.pointer.prominent', undefined, nls.localize('rerunSearch.message', "Search again")));
'class': ['pointer', 'prominent'], this.messageDisposables.push(dom.addDisposableListener(searchAgainLink, dom.EventType.CLICK, (e: MouseEvent) => {
text: nls.localize('rerunSearch.message', "Search again")
}).on(dom.EventType.CLICK, (e: MouseEvent) => {
dom.EventHelper.stop(e, false); dom.EventHelper.stop(e, false);
this.onQueryChanged(true); this.onQueryChanged(true);
}); }));
} else if (hasIncludes || hasExcludes) { } else if (hasIncludes || hasExcludes) {
$(p).a({ const searchAgainLink = dom.append(p, dom.$('a.pointer.prominent', { tabindex: 0 }, nls.localize('rerunSearchInAll.message', "Search again in all files")));
'class': ['pointer', 'prominent'], this.messageDisposables.push(dom.addDisposableListener(searchAgainLink, dom.EventType.CLICK, (e: MouseEvent) => {
'tabindex': '0',
text: nls.localize('rerunSearchInAll.message', "Search again in all files")
}).on(dom.EventType.CLICK, (e: MouseEvent) => {
dom.EventHelper.stop(e, false); dom.EventHelper.stop(e, false);
this.inputPatternExcludes.setValue(''); this.inputPatternExcludes.setValue('');
this.inputPatternIncludes.setValue(''); this.inputPatternIncludes.setValue('');
this.onQueryChanged(true); this.onQueryChanged(true);
}); }));
} else { } else {
$(p).a({ const openSettingsLink = dom.append(p, dom.$('a.pointer.prominent', { tabindex: 0 }, nls.localize('openSettings.message', "Open Settings")));
'class': ['pointer', 'prominent'], this.messageDisposables.push(dom.addDisposableListener(openSettingsLink, dom.EventType.CLICK, (e: MouseEvent) => {
'tabindex': '0',
text: nls.localize('openSettings.message', "Open Settings")
}).on(dom.EventType.CLICK, (e: MouseEvent) => {
dom.EventHelper.stop(e, false); dom.EventHelper.stop(e, false);
let editorPromise = this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? this.preferencesService.openWorkspaceSettings() : this.preferencesService.openGlobalSettings(); let editorPromise = this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? this.preferencesService.openWorkspaceSettings() : this.preferencesService.openGlobalSettings();
...@@ -1259,27 +1259,22 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -1259,27 +1259,22 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
editor.focusSearch('.exclude'); editor.focusSearch('.exclude');
} }
}, errors.onUnexpectedError); }, errors.onUnexpectedError);
}); }));
} }
if (completed) { if (completed) {
$(p).span({ dom.append(p, dom.$('span', undefined, ' - '));
text: ' - '
});
$(p).a({ const learnMoreLink = dom.append(p, dom.$('a.pointer.prominent', { tabindex: 0 }, nls.localize('openSettings.learnMore', "Learn More")));
'class': ['pointer', 'prominent'], this.messageDisposables.push(dom.addDisposableListener(learnMoreLink, dom.EventType.CLICK, (e: MouseEvent) => {
'tabindex': '0',
text: nls.localize('openSettings.learnMore', "Learn More")
}).on(dom.EventType.CLICK, (e: MouseEvent) => {
dom.EventHelper.stop(e, false); dom.EventHelper.stop(e, false);
window.open('https://go.microsoft.com/fwlink/?linkid=853977'); window.open('https://go.microsoft.com/fwlink/?linkid=853977');
}); }));
} }
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) { if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
this.searchWithoutFolderMessage(div); this.showSearchWithoutFolderMessage();
} }
} else { } else {
this.viewModel.searchResult.toggleHighlights(true); // show highlights this.viewModel.searchResult.toggleHighlights(true); // show highlights
...@@ -1367,15 +1362,15 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -1367,15 +1362,15 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
const fileCount = this.viewModel.searchResult.fileCount(); const fileCount = this.viewModel.searchResult.fileCount();
this.hasSearchResultsKey.set(fileCount > 0); this.hasSearchResultsKey.set(fileCount > 0);
const msgWasHidden = this.messages.isHidden(); const msgWasHidden = this.messagesElement.style.display === 'none';
if (fileCount > 0) { if (fileCount > 0) {
const div = this.clearMessage(); const messageEl = this.clearMessage();
$(div).p({ text: this.buildResultCountMessage(this.viewModel.searchResult.count(), fileCount) }); dom.append(messageEl, dom.$('p', undefined, this.buildResultCountMessage(this.viewModel.searchResult.count(), fileCount)));
if (msgWasHidden) { if (msgWasHidden) {
this.reLayout(); this.reLayout();
} }
} else if (!msgWasHidden) { } else if (!msgWasHidden) {
this.messages.hide(); dom.hide(this.messagesElement);
} }
} }
...@@ -1391,26 +1386,27 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -1391,26 +1386,27 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
} }
} }
private searchWithoutFolderMessage(div: Builder): void { private showSearchWithoutFolderMessage(): void {
this.searchWithoutFolderMessageBuilder = $(div); this.searchWithoutFolderMessageElement = this.clearMessage();
this.searchWithoutFolderMessageBuilder.p({ text: nls.localize('searchWithoutFolder', "You have not yet opened a folder. Only open files are currently searched - ") }) const textEl = dom.append(this.searchWithoutFolderMessageElement,
.asContainer().a({ dom.$('p', undefined, nls.localize('searchWithoutFolder', "You have not yet opened a folder. Only open files are currently searched - ")));
'class': ['pointer', 'prominent'],
'tabindex': '0',
text: nls.localize('openFolder', "Open Folder")
}).on(dom.EventType.CLICK, (e: MouseEvent) => {
dom.EventHelper.stop(e, false);
const actionClass = env.isMacintosh ? OpenFileFolderAction : OpenFolderAction; const openFolderLink = dom.append(textEl,
const action = this.instantiationService.createInstance<string, string, IAction>(actionClass, actionClass.ID, actionClass.LABEL); dom.$('a.pointer.prominent', { tabindex: 0 }, nls.localize('openFolder', "Open Folder")));
this.actionRunner.run(action).done(() => {
action.dispose(); this.messageDisposables.push(dom.addDisposableListener(openFolderLink, dom.EventType.CLICK, (e: MouseEvent) => {
}, err => { dom.EventHelper.stop(e, false);
action.dispose();
errors.onUnexpectedError(err); const actionClass = env.isMacintosh ? OpenFileFolderAction : OpenFolderAction;
}); const action = this.instantiationService.createInstance<string, string, IAction>(actionClass, actionClass.ID, actionClass.LABEL);
this.actionRunner.run(action).done(() => {
action.dispose();
}, err => {
action.dispose();
errors.onUnexpectedError(err);
}); });
}));
} }
private showEmptyStage(): void { private showEmptyStage(): void {
...@@ -1421,7 +1417,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -1421,7 +1417,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
// clean up ui // clean up ui
// this.replaceService.disposeAllReplacePreviews(); // this.replaceService.disposeAllReplacePreviews();
this.messages.hide(); dom.hide(this.messagesElement);
this.results.show(); this.results.show();
this.tree.onVisible(); this.tree.onVisible();
this.currentSelectedFileMatch = null; this.currentSelectedFileMatch = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册