|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import 'vs/css!./media/activityaction'; |
| 7 | +import * as nls from 'vs/nls'; |
7 | 8 | import * as DOM from 'vs/base/browser/dom'; |
| 9 | +import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; |
| 10 | +import { StandardMouseEvent } from 'vs/base/browser/mouseEvent'; |
8 | 11 | import { EventType as TouchEventType, GestureEvent } from 'vs/base/browser/touch'; |
9 | 12 | import { Action } from 'vs/base/common/actions'; |
| 13 | +import { KeyCode } from 'vs/base/common/keyCodes'; |
| 14 | +import { dispose } from 'vs/base/common/lifecycle'; |
| 15 | +import { URI } from 'vs/base/common/uri'; |
| 16 | +import { TPromise } from 'vs/base/common/winjs.base'; |
| 17 | +import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; |
10 | 18 | import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; |
| 19 | +import { Registry } from 'vs/platform/registry/common/platform'; |
| 20 | +import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; |
| 21 | +import { activeContrastBorder, focusBorder } from 'vs/platform/theme/common/colorRegistry'; |
| 22 | +import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; |
| 23 | +import { ActivityAction, ActivityActionItem, ICompositeBar, ICompositeBarColors, ToggleCompositePinnedAction } from 'vs/workbench/browser/parts/compositeBarActions'; |
11 | 24 | import { ViewletDescriptor } from 'vs/workbench/browser/viewlet'; |
| 25 | +import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions'; |
12 | 26 | import { IActivity, IGlobalActivity } from 'vs/workbench/common/activity'; |
13 | | -import { dispose } from 'vs/base/common/lifecycle'; |
14 | | -import { IViewletService, } from 'vs/workbench/services/viewlet/browser/viewlet'; |
15 | | -import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; |
16 | | -import { IThemeService, ITheme, registerThemingParticipant, ICssStyleCollector } from 'vs/platform/theme/common/themeService'; |
17 | | -import { activeContrastBorder, focusBorder } from 'vs/platform/theme/common/colorRegistry'; |
18 | | -import { StandardMouseEvent } from 'vs/base/browser/mouseEvent'; |
19 | | -import { KeyCode } from 'vs/base/common/keyCodes'; |
20 | | -import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; |
21 | | -import { ActivityAction, ActivityActionItem, ICompositeBarColors, ToggleCompositePinnedAction, ICompositeBar } from 'vs/workbench/browser/parts/compositeBarActions'; |
22 | | -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; |
23 | | -import { URI } from 'vs/base/common/uri'; |
24 | 27 | import { ACTIVITY_BAR_FOREGROUND } from 'vs/workbench/common/theme'; |
| 28 | +import { IActivityService } from 'vs/workbench/services/activity/common/activity'; |
| 29 | +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; |
| 30 | +import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; |
25 | 31 |
|
26 | 32 | export class ViewletActivityAction extends ActivityAction { |
27 | 33 |
|
@@ -188,6 +194,77 @@ export class PlaceHolderToggleCompositePinnedAction extends ToggleCompositePinne |
188 | 194 | } |
189 | 195 | } |
190 | 196 |
|
| 197 | +class SwitchSidebarViewAction extends Action { |
| 198 | + |
| 199 | + constructor( |
| 200 | + id: string, |
| 201 | + name: string, |
| 202 | + @IViewletService private viewletService: IViewletService, |
| 203 | + @IActivityService private activityService: IActivityService |
| 204 | + ) { |
| 205 | + super(id, name); |
| 206 | + } |
| 207 | + |
| 208 | + run(offset: number): TPromise<any> { |
| 209 | + const pinnedViewletIds = this.activityService.getPinnedViewletIds(); |
| 210 | + |
| 211 | + const activeViewlet = this.viewletService.getActiveViewlet(); |
| 212 | + if (!activeViewlet) { |
| 213 | + return TPromise.as(null); |
| 214 | + } |
| 215 | + let targetViewletId: string; |
| 216 | + for (let i = 0; i < pinnedViewletIds.length; i++) { |
| 217 | + if (pinnedViewletIds[i] === activeViewlet.getId()) { |
| 218 | + targetViewletId = pinnedViewletIds[(i + pinnedViewletIds.length + offset) % pinnedViewletIds.length]; |
| 219 | + break; |
| 220 | + } |
| 221 | + } |
| 222 | + return this.viewletService.openViewlet(targetViewletId, true); |
| 223 | + } |
| 224 | +} |
| 225 | + |
| 226 | +export class PreviousSidebarViewAction extends SwitchSidebarViewAction { |
| 227 | + |
| 228 | + static readonly ID = 'workbench.action.previousSidebarView'; |
| 229 | + static LABEL = nls.localize('previousSidebarView', 'Previous Sidebar View'); |
| 230 | + |
| 231 | + constructor( |
| 232 | + id: string, |
| 233 | + name: string, |
| 234 | + @IViewletService viewletService: IViewletService, |
| 235 | + @IActivityService activityService: IActivityService |
| 236 | + ) { |
| 237 | + super(id, name, viewletService, activityService); |
| 238 | + } |
| 239 | + |
| 240 | + run(): TPromise<any> { |
| 241 | + return super.run(-1); |
| 242 | + } |
| 243 | +} |
| 244 | + |
| 245 | +export class NextSidebarViewAction extends SwitchSidebarViewAction { |
| 246 | + |
| 247 | + static readonly ID = 'workbench.action.nextSidebarView'; |
| 248 | + static LABEL = nls.localize('nextSidebarView', 'Next Sidebar View'); |
| 249 | + |
| 250 | + constructor( |
| 251 | + id: string, |
| 252 | + name: string, |
| 253 | + @IViewletService viewletService: IViewletService, |
| 254 | + @IActivityService activityService: IActivityService |
| 255 | + ) { |
| 256 | + super(id, name, viewletService, activityService); |
| 257 | + } |
| 258 | + |
| 259 | + run(): TPromise<any> { |
| 260 | + return super.run(1); |
| 261 | + } |
| 262 | +} |
| 263 | + |
| 264 | +const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions); |
| 265 | +registry.registerWorkbenchAction(new SyncActionDescriptor(PreviousSidebarViewAction, PreviousSidebarViewAction.ID, PreviousSidebarViewAction.LABEL), 'View: Open Previous Sidebar View', nls.localize('view', "View")); |
| 266 | +registry.registerWorkbenchAction(new SyncActionDescriptor(NextSidebarViewAction, NextSidebarViewAction.ID, NextSidebarViewAction.LABEL), 'View: Open Next Sidebar View', nls.localize('view', "View")); |
| 267 | + |
191 | 268 | registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { |
192 | 269 |
|
193 | 270 | const activeForegroundColor = theme.getColor(ACTIVITY_BAR_FOREGROUND); |
|
0 commit comments