Skip to content

Commit

Permalink
panel: add focus panel action
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn authored and jrieken committed Jul 12, 2016
1 parent 2d2b0fa commit 9e907a1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/vs/workbench/browser/parts/panel/panelPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,39 @@ class TogglePanelAction extends Action {
}
}

class FocusPanelAction extends Action {

public static ID = 'workbench.action.focusPanel';
public static LABEL = nls.localize('focusPanel', "Focus into Panel");

constructor(
id: string,
label: string,
@IPanelService private panelService: IPanelService,
@IPartService private partService: IPartService
) {
super(id, label);
}

public run(): TPromise<boolean> {

// Show panel
if (this.partService.isPanelHidden()) {
this.partService.setPanelHidden(false);
}

// Focus into active panel
else {
let panel = this.panelService.getActivePanel();
if (panel) {
panel.focus();
}
}

return TPromise.as(true);
}
}

let actionRegistry = <IWorkbenchActionRegistry>Registry.as(WorkbenchExtensions.WorkbenchActions);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(TogglePanelAction, TogglePanelAction.ID, TogglePanelAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_J }), 'View: Toggle Panel Visibility', nls.localize('view', "View"));
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusPanelAction, FocusPanelAction.ID, FocusPanelAction.LABEL), 'View: Focus into Panel', nls.localize('view', "View"));
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/sidebar/sidebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
}
}

export class FocusSideBarAction extends Action {
class FocusSideBarAction extends Action {

public static ID = 'workbench.action.focusSideBar';
public static LABEL = nls.localize('focusSideBar', "Focus into Side Bar");
Expand Down

0 comments on commit 9e907a1

Please sign in to comment.