Skip to content

Commit

Permalink
add an extensions action in the activity bar
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Dec 7, 2015
1 parent 9a68266 commit 9958eab
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import actions = require('vs/base/common/actions');
import toolbar = require('vs/base/browser/ui/toolbar/toolbar');
import actionbar = require('vs/base/browser/ui/actionbar/actionbar');
import platform = require('vs/platform/platform');
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import statusbar = require('vs/workbench/browser/parts/statusbar/statusbar');
import actionbarregistry = require('vs/workbench/browser/actionBarRegistry');
import { ExtensionsStatusbarItem } from 'vs/workbench/parts/extensions/electron-browser/extensionsWidgets';
import { IGalleryService } from 'vs/workbench/parts/extensions/common/extensions';
import { GlobalExtensionsAction } from './extensionsActions';
import { GalleryService } from 'vs/workbench/parts/extensions/node/vsoGalleryService';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ExtensionsWorkbenchExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

// Register Gallery Service
registerSingleton(IGalleryService, GalleryService);
Expand All @@ -20,9 +25,33 @@ registerSingleton(IGalleryService, GalleryService);
ExtensionsWorkbenchExtension
);

// Register Statusbar item
(<statusbar.IStatusbarRegistry>platform.Registry.as(statusbar.Extensions.Statusbar)).registerStatusbarItem(new statusbar.StatusbarItemDescriptor(
ExtensionsStatusbarItem,
statusbar.StatusbarAlignment.LEFT,
150 /* Very High Priority */
));
class GlobalExtensionsActionContributor extends actionbarregistry.ActionBarContributor {

constructor(
@IInstantiationService private instantiationService:IInstantiationService
) {
super();
}

public hasActions(context:any):boolean {
return context === toolbar.CONTEXT;
}

public getActions(context:any): actions.IAction[] {
return [
this.instantiationService.createInstance(GlobalExtensionsAction, GlobalExtensionsAction.ID, GlobalExtensionsAction.LABEL)
];
}

// public getActionItem(context: any, action: actions.Action): actionbar.BaseActionItem {
// if (action.id === GlobalExtensionsAction.ID) {
// return this.instantiationService.createInstance(GlobalExtensionsActionItem, action);
// }

// return null;
// }
}

// Register Global Extensions Action
let actionBarRegistry = <actionbarregistry.IActionBarRegistry> platform.Registry.as(actionbarregistry.Extensions.Actionbar);
actionBarRegistry.registerActionBarContributor(actionbarregistry.Scope.GLOBAL, GlobalExtensionsActionContributor);
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import nls = require('vs/nls');
import { Promise } from 'vs/base/common/winjs.base';
import { Action } from 'vs/base/common/actions';
import { ActivityActionItem } from 'vs/workbench/browser/parts/activityBar/activityAction';
import { IExtensionsService } from 'vs/workbench/parts/extensions/common/extensions';
import { IQuickOpenService } from 'vs/workbench/services/quickopen/browser/quickOpenService';

Expand Down Expand Up @@ -77,3 +78,25 @@ export class ListOutdatedExtensionsAction extends Action {
return true;
}
}

export class GlobalExtensionsAction extends Action {
static ID = 'workbench.extensions.action.globalExtensions';
static LABEL = nls.localize('extensions', "Extensions");

constructor(
id: string,
label: string,
@IExtensionsService private extensionsService: IExtensionsService,
@IQuickOpenService private quickOpenService: IQuickOpenService
) {
super(id, label, 'extensions', true);
}

public run(): Promise {
return this.quickOpenService.show('ext install ');
}

protected isEnabled(): boolean {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import 'vs/css!./extensions';
import 'vs/css!./media/extensions';

import nls = require('vs/nls');
import { IDisposable, disposeAll } from 'vs/base/common/lifecycle';
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

/* Activity Bar */
.monaco-workbench > .activitybar .monaco-action-bar .action-label.extensions {
/*TODO@Isidor inline icon needed */
background-image: url('extensions-global-action.svg')
}

.quick-open-widget .extension {
padding: 0 14px 0 0;
height: 48px;
Expand Down Expand Up @@ -120,8 +126,3 @@
-o-transform: none;
transform: none;
}

/* Status bar */
.monaco-shell .extensions-statusbar {
cursor: pointer;
}

0 comments on commit 9958eab

Please sign in to comment.