提交 08e2d758 编写于 作者: I isidor

activitybar and panelPart react on changes of search.location

上级 ce1f35c8
......@@ -29,6 +29,8 @@ import { ACTIVITY_BAR_BACKGROUND, ACTIVITY_BAR_BORDER, ACTIVITY_BAR_FOREGROUND,
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { CompositeBar } from 'vs/workbench/browser/parts/compositebar/compositeBar';
import { ToggleCompositePinnedAction } from 'vs/workbench/browser/parts/compositebar/compositeBarActions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ISearchConfiguration, VIEW_ID as SEARCH_VIEW_ID } from 'vs/platform/search/common/search';
export class ActivitybarPart extends Part {
......@@ -56,7 +58,8 @@ export class ActivitybarPart extends Part {
@IContextMenuService private contextMenuService: IContextMenuService,
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IThemeService themeService: IThemeService
@IThemeService themeService: IThemeService,
@IConfigurationService private configurationService: IConfigurationService
) {
super(id, { hasTitle: false }, themeService);
......@@ -86,6 +89,25 @@ export class ActivitybarPart extends Part {
// Deactivate viewlet action on close
this.toUnbind.push(this.viewletService.onDidViewletClose(viewlet => this.compositeBar.deactivateComposite(viewlet.getId())));
this.toUnbind.push(this.compositeBar.onDidContextMenu(e => this.showContextMenu(e)));
this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('search.location')) {
const location = this.configurationService.getValue<ISearchConfiguration>().search.location;
if (location === 'sidebar') {
this.compositeBar.addComposite(this.viewletService.getViewlet(SEARCH_VIEW_ID));
} else {
let promise: TPromise<any> = TPromise.as(null);
const activeViewlet = this.viewletService.getActiveViewlet();
if (activeViewlet && activeViewlet.getId() === SEARCH_VIEW_ID) {
promise = this.viewletService.openViewlet(this.viewletService.getDefaultViewletId());
}
promise.then(() => {
this.compositeBar.removeComposite(SEARCH_VIEW_ID);
});
}
}
}));
}
public showActivity(viewletOrActionId: string, badge: IBadge, clazz?: string, priority?: number): IDisposable {
......
......@@ -81,6 +81,14 @@ export class CompositeBar implements ICompositeBar {
return this._onDidContextMenu.event;
}
public addComposite(compositeData: { id: string; name: string }): void {
// todo@isidor
}
public removeComposite(id: string): void {
// todo@isidor
}
public activateComposite(id: string): void {
if (this.compositeIdToActions[id]) {
if (this.compositeIdToActions[this.activeCompositeId]) {
......
......@@ -109,10 +109,28 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
// Need to relayout composite bar since different panels have different action bar width
this.layoutCompositeBar();
}));
this.toUnbind.push(this.compositeBar.onDidContextMenu(e => this.showContextMenu(e)));
// Deactivate panel action on close
this.toUnbind.push(this.onDidPanelClose(panel => this.compositeBar.deactivateComposite(panel.getId())));
this.toUnbind.push(this.compositeBar.onDidContextMenu(e => this.showContextMenu(e)));
this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('search.location')) {
const location = this.configurationService.getValue<ISearchConfiguration>().search.location;
if (location === 'panel') {
this.compositeBar.addComposite(this.getPanel(SEARCH_VIEW_ID));
} else {
let promise: TPromise<any> = TPromise.as(null);
const activePanel = this.getActivePanel();
if (activePanel && activePanel.getId() === SEARCH_VIEW_ID) {
promise = this.openPanel(Registry.as<PanelRegistry>(PanelExtensions.Panels).getDefaultPanelId());
}
promise.then(() => {
this.compositeBar.removeComposite(SEARCH_VIEW_ID);
});
}
}
}));
}
public get onDidPanelOpen(): Event<IPanel> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册