提交 5c9d1c4c 编写于 作者: J Johannes Rieken

debt - less builder is better

上级 523f7893
......@@ -5,22 +5,22 @@
'use strict';
import 'vs/css!./media/peekViewWidget';
import * as nls from 'vs/nls';
import { Action } from 'vs/base/common/actions';
import * as strings from 'vs/base/common/strings';
import * as objects from 'vs/base/common/objects';
import { $ } from 'vs/base/browser/builder';
import { Event, Emitter } from 'vs/base/common/event';
import * as dom from 'vs/base/browser/dom';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import { ActionBar, IActionBarOptions } from 'vs/base/browser/ui/actionbar/actionbar';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { Action } from 'vs/base/common/actions';
import { Color } from 'vs/base/common/color';
import { Emitter, Event } from 'vs/base/common/event';
import * as objects from 'vs/base/common/objects';
import * as strings from 'vs/base/common/strings';
import 'vs/css!./media/peekViewWidget';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IOptions, ZoneWidget, IStyles } from 'vs/editor/contrib/zoneWidget/zoneWidget';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { IOptions, IStyles, ZoneWidget } from 'vs/editor/contrib/zoneWidget/zoneWidget';
import * as nls from 'vs/nls';
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Color } from 'vs/base/common/color';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
export namespace PeekContext {
export const inPeekEditor = new RawContextKey<boolean>('inReferenceSearchEditor', true);
......@@ -111,8 +111,8 @@ export abstract class PeekViewWidget extends ZoneWidget {
protected _fillContainer(container: HTMLElement): void {
this.setCssClass('peekview-widget');
this._headElement = <HTMLDivElement>$('.head').getHTMLElement();
this._bodyElement = <HTMLDivElement>$('.body').getHTMLElement();
this._headElement = dom.$('.head');
this._bodyElement = dom.$('.body');
this._fillHead(this._headElement);
this._fillBody(this._bodyElement);
......@@ -122,18 +122,20 @@ export abstract class PeekViewWidget extends ZoneWidget {
}
protected _fillHead(container: HTMLElement): void {
const titleElement = $('.peekview-title').
on(dom.EventType.CLICK, e => this._onTitleClick(<MouseEvent>e)).
appendTo(this._headElement).
getHTMLElement();
const titleElement = dom.$('.peekview-title');
dom.append(this._headElement, titleElement);
dom.addStandardDisposableListener(titleElement, 'click', event => this._onTitleClick(event));
this._primaryHeading = dom.$('span.filename');
this._secondaryHeading = dom.$('span.dirname');
this._metaHeading = dom.$('span.meta');
dom.append(titleElement, this._primaryHeading, this._secondaryHeading, this._metaHeading);
this._primaryHeading = $('span.filename').appendTo(titleElement).getHTMLElement();
this._secondaryHeading = $('span.dirname').appendTo(titleElement).getHTMLElement();
this._metaHeading = $('span.meta').appendTo(titleElement).getHTMLElement();
const actionsContainer = dom.$('.peekview-actions');
dom.append(this._headElement, actionsContainer);
const actionsContainer = $('.peekview-actions').appendTo(this._headElement);
const actionBarOptions = this._getActionBarOptions();
this._actionbarWidget = new ActionBar(actionsContainer.getHTMLElement(), actionBarOptions);
this._actionbarWidget = new ActionBar(actionsContainer, actionBarOptions);
this._disposables.push(this._actionbarWidget);
this._actionbarWidget.push(new Action('peekview.close', nls.localize('label.close', "Close"), 'close-peekview-action', true, () => {
......@@ -146,15 +148,15 @@ export abstract class PeekViewWidget extends ZoneWidget {
return {};
}
protected _onTitleClick(event: MouseEvent): void {
protected _onTitleClick(event: IMouseEvent): void {
// implement me
}
public setTitle(primaryHeading: string, secondaryHeading?: string): void {
$(this._primaryHeading).safeInnerHtml(primaryHeading);
this._primaryHeading.innerHTML = strings.escape(primaryHeading);
this._primaryHeading.setAttribute('aria-label', primaryHeading);
if (secondaryHeading) {
$(this._secondaryHeading).safeInnerHtml(secondaryHeading);
this._secondaryHeading.innerHTML = strings.escape(secondaryHeading);
} else {
dom.clearNode(this._secondaryHeading);
}
......@@ -162,7 +164,7 @@ export abstract class PeekViewWidget extends ZoneWidget {
public setMetaTitle(value: string): void {
if (value) {
$(this._metaHeading).safeInnerHtml(value);
this._metaHeading.innerHTML = strings.escape(value);
} else {
dom.clearNode(this._metaHeading);
}
......
......@@ -4,45 +4,45 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./media/referencesWidget';
import * as nls from 'vs/nls';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import * as strings from 'vs/base/common/strings';
import { TPromise } from 'vs/base/common/winjs.base';
import { Color } from 'vs/base/common/color';
import { $, Builder } from 'vs/base/browser/builder';
import * as dom from 'vs/base/browser/dom';
import { Sash, ISashEvent, IVerticalSashLayoutProvider } from 'vs/base/browser/ui/sash/sash';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import { GestureEvent } from 'vs/base/browser/touch';
import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
import { IconLabel } from 'vs/base/browser/ui/iconLabel/iconLabel';
import { ISashEvent, IVerticalSashLayoutProvider, Sash } from 'vs/base/browser/ui/sash/sash';
import { Color } from 'vs/base/common/color';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
import { getBaseLabel } from 'vs/base/common/labels';
import { dispose, IDisposable, IReference } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { basenameOrAuthority, dirname } from 'vs/base/common/resources';
import * as strings from 'vs/base/common/strings';
import { TPromise } from 'vs/base/common/winjs.base';
import * as tree from 'vs/base/parts/tree/browser/tree';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Range, IRange } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { TextModel, ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
import 'vs/css!./media/referencesWidget';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { PeekViewWidget } from './peekViewWidget';
import { FileReferences, OneReference, ReferencesModel } from './referencesModel';
import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
import { registerColor, activeContrastBorder, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant, ITheme, IThemeService } from 'vs/platform/theme/common/themeService';
import { attachBadgeStyler } from 'vs/platform/theme/common/styler';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { TrackedRangeStickiness, IModelDeltaDecoration } from 'vs/editor/common/model';
import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IRange, Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { IModelDeltaDecoration, TrackedRangeStickiness } from 'vs/editor/common/model';
import { ModelDecorationOptions, TextModel } from 'vs/editor/common/model/textModel';
import { Location } from 'vs/editor/common/modes';
import { ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
import { ITextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
import * as nls from 'vs/nls';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILabelService } from 'vs/platform/label/common/label';
import { dirname, basenameOrAuthority } from 'vs/base/common/resources';
import { getBaseLabel } from 'vs/base/common/labels';
import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService';
import { activeContrastBorder, contrastBorder, registerColor } from 'vs/platform/theme/common/colorRegistry';
import { attachBadgeStyler } from 'vs/platform/theme/common/styler';
import { ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { PeekViewWidget } from './peekViewWidget';
import { FileReferences, OneReference, ReferencesModel } from './referencesModel';
class DecorationsManager implements IDisposable {
......@@ -572,7 +572,7 @@ export class ReferenceWidget extends PeekViewWidget {
this._tree.domFocus();
}
protected _onTitleClick(e: MouseEvent): void {
protected _onTitleClick(e: IMouseEvent): void {
if (this._preview && this._preview.getModel()) {
this._onDidSelectReference.fire({
element: this._getFocusedReference(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册