Skip to content

Commit

Permalink
Progress bar (#45589)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Mar 26, 2018
1 parent cad4523 commit f5a2f27
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/vs/workbench/browser/parts/quickinput/quickInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

.quick-input-header {
display: flex;
padding: 6px;
padding: 6px 6px 4px 6px;
}

.quick-input-select-all {
Expand Down Expand Up @@ -53,6 +53,11 @@
outline:0;
}

.quick-input-progress.monaco-progress-container,
.quick-input-progress.monaco-progress-container .progress-bit {
height: 2px;
}

.quick-input-checkbox-list {
line-height: 22px;
}
Expand Down
38 changes: 33 additions & 5 deletions src/vs/workbench/browser/parts/quickinput/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { CLOSE_ON_FOCUS_LOST_CONFIG } from 'vs/workbench/browser/quickopen';
import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
import { attachBadgeStyler } from 'vs/platform/theme/common/styler';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';

const $ = dom.$;

Expand All @@ -43,6 +44,8 @@ export class QuickInputService extends Component implements IQuickInputService {
private selectAll: HTMLInputElement;
private inputBox: QuickInputBox;
private count: CountBadge;
private ready = false;
private progressBar: ProgressBar;
private checkboxList: QuickInputCheckboxList;
private ignoreFocusLost = false;

Expand Down Expand Up @@ -99,7 +102,14 @@ export class QuickInputService extends Component implements IQuickInputService {

const ok = dom.append(headerContainer, $('button.quick-input-action'));
ok.textContent = localize('ok', "OK");
this.toUnbind.push(dom.addDisposableListener(ok, dom.EventType.CLICK, e => this.close(this.checkboxList.getSelectedElements())));
this.toUnbind.push(dom.addDisposableListener(ok, dom.EventType.CLICK, e => {
if (this.ready) {
this.close(this.checkboxList.getSelectedElements());
}
}));

this.progressBar = new ProgressBar(this.container); // TODO theme
this.progressBar.getContainer().addClass('quick-input-progress');

this.checkboxList = this.instantiationService.createInstance(QuickInputCheckboxList, this.container);
this.toUnbind.push(this.checkboxList);
Expand Down Expand Up @@ -130,8 +140,10 @@ export class QuickInputService extends Component implements IQuickInputService {
const event = new StandardKeyboardEvent(e);
switch (event.keyCode) {
case KeyCode.Enter:
dom.EventHelper.stop(e, true);
this.close(this.checkboxList.getSelectedElements());
if (this.ready) {
dom.EventHelper.stop(e, true);
this.close(this.checkboxList.getSelectedElements());
}
break;
case KeyCode.Escape:
dom.EventHelper.stop(e, true);
Expand All @@ -157,12 +169,15 @@ export class QuickInputService extends Component implements IQuickInputService {
this.resolve();
}

this.inputBox.setValue('');
this.inputBox.value = '';
this.inputBox.setPlaceholder(options.placeHolder || '');
this.checkboxList.matchOnDescription = options.matchOnDescription;
this.checkboxList.matchOnDetail = options.matchOnDetail;
this.ignoreFocusLost = options.ignoreFocusLost;

this.progressBar.stop();
this.ready = false;

this.checkboxList.setElements([]);
this.selectAll.checked = this.checkboxList.getAllVisibleSelected();
this.count.setCount(this.checkboxList.getSelectedCount());
Expand All @@ -175,11 +190,24 @@ export class QuickInputService extends Component implements IQuickInputService {
const d = token.onCancellationRequested(() => this.close());
result.then(() => d.dispose(), () => d.dispose());

// TODO: Progress indication.
const delay = TPromise.timeout(800);
delay.then(() => this.progressBar.infinite(), () => { /* ignore */ });

const wasResolve = this.resolve;
picks.then(elements => {
delay.cancel();
if (this.resolve !== wasResolve) {
return;
}

this.progressBar.stop();
this.ready = true;

this.checkboxList.setElements(elements);
this.checkboxList.filter(this.inputBox.value);
this.selectAll.checked = this.checkboxList.getAllVisibleSelected();
this.count.setCount(this.checkboxList.getSelectedCount());

this.updateLayout();
}).then(null, reason => this.close(TPromise.wrapError(reason)));

Expand Down
6 changes: 5 additions & 1 deletion src/vs/workbench/browser/parts/quickinput/quickInputBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export class QuickInputBox {
return this.inputBox.onDidChange(handler);
}

setValue(value: string) {
get value() {
return this.inputBox.value;
}

set value(value: string) {
this.inputBox.value = value;
}

Expand Down

0 comments on commit f5a2f27

Please sign in to comment.