提交 6483a2df 编写于 作者: I isidor

panel: share close panel action

上级 3611a725
......@@ -38,7 +38,7 @@ import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingServic
export abstract class CompositePart<T extends Composite> extends Part {
private instantiationService: IInstantiationService;
protected instantiationService: IInstantiationService;
private activeCompositeListeners: { (): void; }[];
private instantiatedCompositeListeners: { (): void; }[];
private mapCompositeToCompositeContainer: { [compositeId: string]: Builder; };
......@@ -365,6 +365,10 @@ export abstract class CompositePart<T extends Composite> extends Part {
let primaryActions: IAction[] = composite.getActions();
let secondaryActions: IAction[] = composite.getSecondaryActions();
// From Part
primaryActions.push(...this.getActions());
secondaryActions.push(...this.getSecondaryActions());
// From Contributions
let actionBarRegistry = <IActionBarRegistry>Registry.as(Extensions.Actionbar);
primaryActions.push(...actionBarRegistry.getActionBarActionsForContext(this.actionContributionScope, composite));
......@@ -474,6 +478,14 @@ export abstract class CompositePart<T extends Composite> extends Part {
this.messageService.show(Severity.Error, types.isString(error) ? new Error(error) : error);
}
protected getActions(): IAction[] {
return [];
}
protected getSecondaryActions(): IAction[] {
return [];
}
public layout(dimension: Dimension): Dimension[] {
// Pass to super
......
......@@ -8,7 +8,7 @@ import nls = require('vs/nls');
import {TPromise, Promise} from 'vs/base/common/winjs.base';
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
import strings = require('vs/base/common/strings');
import {Action} from 'vs/base/common/actions';
import {Action, IAction} from 'vs/base/common/actions';
import {Builder} from 'vs/base/browser/builder';
import {Registry} from 'vs/platform/platform';
import {Scope} from 'vs/workbench/browser/actionBarRegistry';
......@@ -92,6 +92,10 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
return this.showComposite(panel);
}
protected getActions(): IAction[] {
return [this.instantiationService.createInstance(ClosePanelAction, ClosePanelAction.ID, ClosePanelAction.LABEL)]
}
public getActivePanel(): IPanel {
return this.getActiveComposite();
}
......@@ -106,7 +110,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
export class ClosePanelAction extends Action {
class ClosePanelAction extends Action {
static ID = 'workbench.action.closePanel';
static LABEL = nls.localize('closePanel', "Close");
......@@ -124,7 +128,7 @@ export class ClosePanelAction extends Action {
}
}
export class TogglePanelAction extends Action {
class TogglePanelAction extends Action {
static ID = 'workbench.action.togglePanel';
static LABEL = nls.localize('togglePanel', "Toggle Panel Visibility");
......
......@@ -18,7 +18,6 @@ import debug = require('vs/workbench/parts/debug/common/debug');
import debugactions = require('vs/workbench/parts/debug/electron-browser/debugActions');
import replhistory = require('vs/workbench/parts/debug/common/replHistory');
import { Panel } from 'vs/workbench/browser/panel';
import { ClosePanelAction } from 'vs/workbench/browser/parts/panel/panelPart';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
......@@ -162,8 +161,7 @@ export class Repl extends Panel {
public getActions(): actions.IAction[] {
if (!this.actions) {
this.actions = [
this.instantiationService.createInstance(debugactions.ClearReplAction, debugactions.ClearReplAction.ID, debugactions.ClearReplAction.LABEL),
this.instantiationService.createInstance(ClosePanelAction, ClosePanelAction.ID, ClosePanelAction.LABEL)
this.instantiationService.createInstance(debugactions.ClearReplAction, debugactions.ClearReplAction.ID, debugactions.ClearReplAction.LABEL)
];
this.actions.forEach(a => {
......
......@@ -22,7 +22,6 @@ import {OUTPUT_PANEL_ID, IOutputService} from 'vs/workbench/parts/output/common/
import {OutputEditorInput} from 'vs/workbench/parts/output/common/outputEditorInput';
import {SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction} from 'vs/workbench/parts/output/browser/outputActions';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {ClosePanelAction} from 'vs/workbench/browser/parts/panel/panelPart';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
export class OutputPanel extends StringEditor {
......@@ -55,8 +54,7 @@ export class OutputPanel extends StringEditor {
if (!this.actions) {
this.actions = [
this.instantiationService.createInstance(SwitchOutputAction),
this.instantiationService.createInstance(ClearOutputAction),
this.instantiationService.createInstance(ClosePanelAction, ClosePanelAction.ID, ClosePanelAction.LABEL)
this.instantiationService.createInstance(ClearOutputAction)
];
this.actions.forEach(a => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册