提交 ff5c1edc 编写于 作者: I isidor

compositeBar: addComposite, removeComposite

上级 08e2d758
...@@ -96,15 +96,7 @@ export class ActivitybarPart extends Part { ...@@ -96,15 +96,7 @@ export class ActivitybarPart extends Part {
if (location === 'sidebar') { if (location === 'sidebar') {
this.compositeBar.addComposite(this.viewletService.getViewlet(SEARCH_VIEW_ID)); this.compositeBar.addComposite(this.viewletService.getViewlet(SEARCH_VIEW_ID));
} else { } else {
let promise: TPromise<any> = TPromise.as(null); this.compositeBar.removeComposite(SEARCH_VIEW_ID);
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);
});
} }
} }
})); }));
......
...@@ -82,11 +82,21 @@ export class CompositeBar implements ICompositeBar { ...@@ -82,11 +82,21 @@ export class CompositeBar implements ICompositeBar {
} }
public addComposite(compositeData: { id: string; name: string }): void { public addComposite(compositeData: { id: string; name: string }): void {
// todo@isidor if (this.options.composites.filter(c => c.id === compositeData.id).length) {
return;
}
this.options.composites.push(compositeData);
this.pin(compositeData.id);
} }
public removeComposite(id: string): void { public removeComposite(id: string): void {
// todo@isidor if (this.options.composites.filter(c => c.id === id).length === 0) {
return;
}
this.options.composites = this.options.composites.filter(c => c.id !== id);
this.unpin(id);
} }
public activateComposite(id: string): void { public activateComposite(id: string): void {
......
...@@ -119,15 +119,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService { ...@@ -119,15 +119,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
if (location === 'panel') { if (location === 'panel') {
this.compositeBar.addComposite(this.getPanel(SEARCH_VIEW_ID)); this.compositeBar.addComposite(this.getPanel(SEARCH_VIEW_ID));
} else { } else {
let promise: TPromise<any> = TPromise.as(null); this.compositeBar.removeComposite(SEARCH_VIEW_ID);
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);
});
} }
} }
})); }));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册