panel: extract action contribution scope
This commit is contained in:
parent
bbb50c8640
commit
b03e3e6f58
4 changed files with 58 additions and 8 deletions
|
@ -59,9 +59,30 @@ export class ActionBarContributor {
|
|||
* Some predefined scopes to contribute actions to
|
||||
*/
|
||||
export const Scope = {
|
||||
|
||||
/**
|
||||
* Actions inside the global activity bar (DEPRECATED)
|
||||
*/
|
||||
GLOBAL: 'global',
|
||||
VIEW: 'view',
|
||||
|
||||
/**
|
||||
* Actions inside viewlets.
|
||||
*/
|
||||
VIEWLET: 'viewlet',
|
||||
|
||||
/**
|
||||
* Actions inside panels.
|
||||
*/
|
||||
PANEL: 'panel',
|
||||
|
||||
/**
|
||||
* Actions inside editors.
|
||||
*/
|
||||
EDITOR: 'editor',
|
||||
|
||||
/**
|
||||
* Actions inside tree widgets.
|
||||
*/
|
||||
VIEWER: 'viewer'
|
||||
};
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
|||
private activeCompositeSettingsKey: string,
|
||||
private nameForTelemetry: string,
|
||||
private compositeCssClass: string,
|
||||
private actionContributionScope: string,
|
||||
id: string
|
||||
) {
|
||||
super(id);
|
||||
|
@ -366,8 +367,8 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
|||
|
||||
// From Contributions
|
||||
let actionBarRegistry = <IActionBarRegistry>Registry.as(Extensions.Actionbar);
|
||||
primaryActions.push(...actionBarRegistry.getActionBarActionsForContext(Scope.VIEW, composite));
|
||||
secondaryActions.push(...actionBarRegistry.getSecondaryActionBarActionsForContext(Scope.VIEW, composite));
|
||||
primaryActions.push(...actionBarRegistry.getActionBarActionsForContext(this.actionContributionScope, composite));
|
||||
secondaryActions.push(...actionBarRegistry.getSecondaryActionBarActionsForContext(this.actionContributionScope, composite));
|
||||
|
||||
// Return fn to set into toolbar
|
||||
return this.toolBar.setActions(prepareActions(primaryActions), prepareActions(secondaryActions));
|
||||
|
@ -454,7 +455,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
|||
// Check Registry
|
||||
if (!actionItem) {
|
||||
let actionBarRegistry = <IActionBarRegistry>Registry.as(Extensions.Actionbar);
|
||||
actionItem = actionBarRegistry.getActionItemForContext(Scope.VIEW, ToolBarContext, action);
|
||||
actionItem = actionBarRegistry.getActionItemForContext(this.actionContributionScope, ToolBarContext, action);
|
||||
}
|
||||
|
||||
return actionItem;
|
||||
|
|
|
@ -11,6 +11,7 @@ import strings = require('vs/base/common/strings');
|
|||
import {Action} 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';
|
||||
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
|
||||
import {IWorkbenchActionRegistry, Extensions as WorkbenchExtensions} from 'vs/workbench/common/actionRegistry';
|
||||
import {IPanel} from 'vs/workbench/common/panel';
|
||||
|
@ -44,8 +45,21 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
|
|||
keybindingService: IKeybindingService,
|
||||
id: string
|
||||
) {
|
||||
super(messageService, storageService, eventService, telemetryService, contextMenuService, partService, keybindingService,
|
||||
(<PanelRegistry>Registry.as(PanelExtensions.Panels)), PanelPart.activePanelSettingsKey, 'panel', 'panel', id);
|
||||
super(
|
||||
messageService,
|
||||
storageService,
|
||||
eventService,
|
||||
telemetryService,
|
||||
contextMenuService,
|
||||
partService,
|
||||
keybindingService,
|
||||
(<PanelRegistry>Registry.as(PanelExtensions.Panels)),
|
||||
PanelPart.activePanelSettingsKey,
|
||||
'panel',
|
||||
'panel',
|
||||
Scope.PANEL,
|
||||
id
|
||||
);
|
||||
}
|
||||
|
||||
public openPanel(id: string, focus?: boolean): TPromise<Panel> {
|
||||
|
|
|
@ -17,6 +17,7 @@ import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
|
|||
import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService';
|
||||
import {IPartService} from 'vs/workbench/services/part/common/partService';
|
||||
import {IViewlet} from 'vs/workbench/common/viewlet';
|
||||
import {Scope} from 'vs/workbench/browser/actionBarRegistry';
|
||||
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
|
||||
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
|
@ -44,8 +45,21 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
|
|||
keybindingService: IKeybindingService,
|
||||
id: string
|
||||
) {
|
||||
super(messageService, storageService, eventService, telemetryService, contextMenuService, partService, keybindingService,
|
||||
(<ViewletRegistry>Registry.as(ViewletExtensions.Viewlets)), SidebarPart.activeViewletSettingsKey, 'sideBar', 'viewlet', id);
|
||||
super(
|
||||
messageService,
|
||||
storageService,
|
||||
eventService,
|
||||
telemetryService,
|
||||
contextMenuService,
|
||||
partService,
|
||||
keybindingService,
|
||||
(<ViewletRegistry>Registry.as(ViewletExtensions.Viewlets)),
|
||||
SidebarPart.activeViewletSettingsKey,
|
||||
'sideBar',
|
||||
'viewlet',
|
||||
Scope.VIEWLET,
|
||||
id
|
||||
);
|
||||
}
|
||||
|
||||
public openViewlet(id: string, focus?: boolean): TPromise<Viewlet> {
|
||||
|
|
Loading…
Reference in a new issue