fix panel issues

This commit is contained in:
Anthony Dresser
2020-04-23 13:39:51 -07:00
parent 6cd2d213ca
commit 89cf3ff515
11 changed files with 122 additions and 162 deletions

View File

@@ -157,5 +157,6 @@ export const VIEW_CONTAINER = Registry.as<IViewContainersRegistry>(ViewContainer
name: localize('dataexplorer.name', "Connections"), name: localize('dataexplorer.name', "Connections"),
ctorDescriptor: new SyncDescriptor(DataExplorerViewPaneContainer), ctorDescriptor: new SyncDescriptor(DataExplorerViewPaneContainer),
icon: 'dataExplorer', icon: 'dataExplorer',
order: 0 order: 0,
storageId: `${VIEWLET_ID}.state`
}, ViewContainerLocation.Sidebar); }, ViewContainerLocation.Sidebar);

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { QUERY_HISTORY_PANEL_ID } from 'sql/workbench/contrib/queryHistory/common/constants'; import { QUERY_HISTORY_VIEW_ID } from 'sql/workbench/contrib/queryHistory/common/constants';
import { RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement'; import { RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
@@ -30,7 +30,7 @@ export class ToggleQueryHistoryAction extends ToggleViewAction {
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService contextKeyService: IContextKeyService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
) { ) {
super(id, label, QUERY_HISTORY_PANEL_ID, viewsService, viewDescriptorService, contextKeyService, layoutService); super(id, label, QUERY_HISTORY_VIEW_ID, viewsService, viewDescriptorService, contextKeyService, layoutService);
} }
} }

View File

@@ -1,48 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/queryHistoryPanel';
import { Dimension } from 'vs/base/browser/dom';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { QueryHistoryView } from 'sql/workbench/contrib/queryHistory/browser/queryHistoryView';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Panel } from 'vs/workbench/browser/panel';
import { QUERY_HISTORY_PANEL_ID } from 'sql/workbench/contrib/queryHistory/common/constants';
import { IAction } from 'vs/base/common/actions';
export class QueryHistoryPanel extends Panel {
private _queryHistoryView: QueryHistoryView;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super(QUERY_HISTORY_PANEL_ID, telemetryService, themeService, storageService);
}
public create(parent: HTMLElement): void {
super.create(parent);
this._queryHistoryView = this.instantiationService.createInstance(QueryHistoryView);
this._queryHistoryView.renderBody(parent);
}
public setVisible(visible: boolean): void {
super.setVisible(visible);
this._queryHistoryView.setVisible(visible);
}
public layout({ height }: Dimension): void {
this._queryHistoryView.layout(height);
}
getActions(): IAction[] {
return this._queryHistoryView.getActions();
}
}

View File

@@ -9,7 +9,6 @@ import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachListStyler } from 'vs/platform/theme/common/styler'; import { attachListStyler } from 'vs/platform/theme/common/styler';
import { ITree } from 'vs/base/parts/tree/browser/tree'; import { ITree } from 'vs/base/parts/tree/browser/tree';
import { Disposable } from 'vs/base/common/lifecycle';
import { DefaultFilter, DefaultDragAndDrop, DefaultAccessibilityProvider } from 'vs/base/parts/tree/browser/treeDefaults'; import { DefaultFilter, DefaultDragAndDrop, DefaultAccessibilityProvider } from 'vs/base/parts/tree/browser/treeDefaults';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { hide, $, append, show } from 'vs/base/browser/dom'; import { hide, $, append, show } from 'vs/base/browser/dom';
@@ -22,21 +21,38 @@ import { IQueryHistoryService } from 'sql/workbench/services/queryHistory/common
import { QueryHistoryNode } from 'sql/workbench/contrib/queryHistory/browser/queryHistoryNode'; import { QueryHistoryNode } from 'sql/workbench/contrib/queryHistory/browser/queryHistoryNode';
import { QueryHistoryInfo } from 'sql/workbench/services/queryHistory/common/queryHistoryInfo'; import { QueryHistoryInfo } from 'sql/workbench/services/queryHistory/common/queryHistoryInfo';
import { IAction } from 'vs/base/common/actions'; import { IAction } from 'vs/base/common/actions';
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { IViewDescriptorService } from 'vs/workbench/common/views';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IOpenerService } from 'vs/platform/opener/common/opener';
/** /**
* QueryHistoryView implements the dynamic tree view for displaying Query History * QueryHistoryView implements the dynamic tree view for displaying Query History
*/ */
export class QueryHistoryView extends Disposable { export class QueryHistoryView extends ViewPane {
private _messages: HTMLElement; private _messages: HTMLElement;
private _tree: ITree; private _tree: ITree;
private _actionProvider: QueryHistoryActionProvider; private _actionProvider: QueryHistoryActionProvider;
constructor( constructor(
@IInstantiationService private _instantiationService: IInstantiationService, options: IViewPaneOptions,
@IThemeService private _themeService: IThemeService, @IInstantiationService instantiationService: IInstantiationService,
@IQueryHistoryService private readonly _queryHistoryService: IQueryHistoryService @IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IConfigurationService configurationService: IConfigurationService,
@ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService,
@IContextMenuService contextMenuService: IContextMenuService,
@IKeybindingService keybindingService: IKeybindingService,
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@IQueryHistoryService private readonly queryHistoryService: IQueryHistoryService
) { ) {
super(); super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
this._actionProvider = this._instantiationService.createInstance(QueryHistoryActionProvider); this._actionProvider = this.instantiationService.createInstance(QueryHistoryActionProvider);
} }
/** /**
@@ -49,12 +65,12 @@ export class QueryHistoryView extends Disposable {
const noQueriesMessage = localize('noQueriesMessage', "No queries to display."); const noQueriesMessage = localize('noQueriesMessage', "No queries to display.");
append(this._messages, $('span')).innerText = noQueriesMessage; append(this._messages, $('span')).innerText = noQueriesMessage;
this._tree = this._register(this.createQueryHistoryTree(container, this._instantiationService)); this._tree = this._register(this.createQueryHistoryTree(container, this.instantiationService));
// Theme styler // Theme styler
this._register(attachListStyler(this._tree, this._themeService)); this._register(attachListStyler(this._tree, this.themeService));
this._queryHistoryService.onInfosUpdated((nodes: QueryHistoryInfo[]) => { this.queryHistoryService.onInfosUpdated((nodes: QueryHistoryInfo[]) => {
this.refreshTree(); this.refreshTree();
}); });
@@ -97,7 +113,7 @@ export class QueryHistoryView extends Disposable {
targetsToExpand = expandableTree.getExpandedElements(); targetsToExpand = expandableTree.getExpandedElements();
} }
const nodes: QueryHistoryNode[] = this._queryHistoryService.getQueryHistoryInfos().map(i => new QueryHistoryNode(i)); const nodes: QueryHistoryNode[] = this.queryHistoryService.getQueryHistoryInfos().map(i => new QueryHistoryNode(i));
if (nodes.length > 0) { if (nodes.length > 0) {
hide(this._messages); hide(this._messages);

View File

@@ -6,4 +6,5 @@
/** /**
* Query History panel id * Query History panel id
*/ */
export const QUERY_HISTORY_PANEL_ID = 'workbench.panel.queryHistory'; export const QUERY_HISTORY_CONTAINER_ID = 'workbench.panel.queryHistory';
export const QUERY_HISTORY_VIEW_ID = 'workbench.panel.queryHistory.view';

View File

@@ -10,12 +10,14 @@ import { localize } from 'vs/nls';
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { QueryHistoryPanel } from 'sql/workbench/contrib/queryHistory/browser/queryHistoryPanel';
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { QUERY_HISTORY_PANEL_ID } from 'sql/workbench/contrib/queryHistory/common/constants';
import { ToggleQueryHistoryAction } from 'sql/workbench/contrib/queryHistory/browser/queryHistoryActions'; import { ToggleQueryHistoryAction } from 'sql/workbench/contrib/queryHistory/browser/queryHistoryActions';
import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IConfigurationRegistry, ConfigurationScope, Extensions } from 'vs/platform/configuration/common/configurationRegistry'; import { IConfigurationRegistry, ConfigurationScope, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
import { ViewContainer, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewsRegistry, ViewContainerLocation } from 'vs/workbench/common/views';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { QUERY_HISTORY_CONTAINER_ID, QUERY_HISTORY_VIEW_ID } from 'sql/workbench/contrib/queryHistory/common/constants';
import { QueryHistoryView } from 'sql/workbench/contrib/queryHistory/browser/queryHistoryView';
export class QueryHistoryWorkbenchContribution implements IWorkbenchContribution { export class QueryHistoryWorkbenchContribution implements IWorkbenchContribution {
@@ -82,16 +84,6 @@ export class QueryHistoryWorkbenchContribution implements IWorkbenchContribution
localize('viewCategory', "View") localize('viewCategory', "View")
); );
// Register Output Panel
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create(
QueryHistoryPanel,
QUERY_HISTORY_PANEL_ID,
localize('queryHistory', "Query History"),
'output',
20,
ToggleQueryHistoryAction.ID
));
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
group: '4_panels', group: '4_panels',
command: { command: {
@@ -100,6 +92,27 @@ export class QueryHistoryWorkbenchContribution implements IWorkbenchContribution
}, },
order: 2 order: 2
}); });
// markers view container
const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({
id: QUERY_HISTORY_CONTAINER_ID,
name: localize('queryHistory', "Query History"),
hideIfEmpty: true,
order: 20,
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [QUERY_HISTORY_CONTAINER_ID, { mergeViewWithContainerWhenSingleView: true, donotShowContainerTitleWhenMergedWithContainer: true }]),
storageId: `${QUERY_HISTORY_CONTAINER_ID}.storage`,
focusCommand: {
id: ToggleQueryHistoryAction.ID
}
}, ViewContainerLocation.Panel);
Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).registerViews([{
id: QUERY_HISTORY_VIEW_ID,
name: localize('queryHistory', "Query History"),
canToggleVisibility: false,
canMoveView: false,
ctorDescriptor: new SyncDescriptor(QueryHistoryView),
}], VIEW_CONTAINER);
} }
} }
}); });

View File

@@ -8,16 +8,18 @@ import { localize } from 'vs/nls';
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { TasksPanel } from 'sql/workbench/contrib/tasks/browser/tasksPanel';
import * as lifecycle from 'vs/base/common/lifecycle'; import * as lifecycle from 'vs/base/common/lifecycle';
import * as ext from 'vs/workbench/common/contributions'; import * as ext from 'vs/workbench/common/contributions';
import { ITaskService } from 'sql/workbench/services/tasks/common/tasksService'; import { ITaskService } from 'sql/workbench/services/tasks/common/tasksService';
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity'; import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { TASKS_PANEL_ID } from 'sql/workbench/contrib/tasks/common/tasks';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ToggleTasksAction } from 'sql/workbench/contrib/tasks/browser/tasksActions'; import { ToggleTasksAction } from 'sql/workbench/contrib/tasks/browser/tasksActions';
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { IViewContainersRegistry, Extensions as ViewContainerExtensions, ViewContainer, ViewContainerLocation, IViewsRegistry } from 'vs/workbench/common/views';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { TASKS_CONTAINER_ID, TASKS_VIEW_ID } from 'sql/workbench/contrib/tasks/common/tasks';
import { TaskHistoryView } from 'sql/workbench/contrib/tasks/browser/tasksView';
export class StatusUpdater extends lifecycle.Disposable implements ext.IWorkbenchContribution { export class StatusUpdater extends lifecycle.Disposable implements ext.IWorkbenchContribution {
static ID = 'data.taskhistory.statusUpdater'; static ID = 'data.taskhistory.statusUpdater';
@@ -32,7 +34,7 @@ export class StatusUpdater extends lifecycle.Disposable implements ext.IWorkbenc
super(); super();
this._register(this.taskService.onAddNewTask(args => { this._register(this.taskService.onAddNewTask(args => {
this.panelService.openPanel(TASKS_PANEL_ID, true); this.panelService.openPanel(TASKS_CONTAINER_ID, true);
this.onServiceChange(); this.onServiceChange();
})); }));
@@ -46,7 +48,7 @@ export class StatusUpdater extends lifecycle.Disposable implements ext.IWorkbenc
lifecycle.dispose(this.badgeHandle); lifecycle.dispose(this.badgeHandle);
let numOfInProgressTask: number = this.taskService.getNumberOfInProgressTasks(); let numOfInProgressTask: number = this.taskService.getNumberOfInProgressTasks();
let badge: NumberBadge = new NumberBadge(numOfInProgressTask, n => localize('inProgressTasksChangesBadge', "{0} in progress tasks", n)); let badge: NumberBadge = new NumberBadge(numOfInProgressTask, n => localize('inProgressTasksChangesBadge', "{0} in progress tasks", n));
this.badgeHandle = this.activityBarService.showActivity(TASKS_PANEL_ID, badge, 'taskhistory-viewlet-label'); this.badgeHandle = this.activityBarService.showActivity(TASKS_CONTAINER_ID, badge, 'taskhistory-viewlet-label');
} }
public getId(): string { public getId(): string {
@@ -70,15 +72,26 @@ registry.registerWorkbenchAction(
localize('viewCategory', "View") localize('viewCategory', "View")
); );
// Register Output Panel // markers view container
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create( const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({
TasksPanel, id: TASKS_CONTAINER_ID,
TASKS_PANEL_ID, name: localize('tasks', "Tasks"),
localize('tasks', "Tasks"), hideIfEmpty: true,
'output', order: 20,
20, ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [TASKS_CONTAINER_ID, { mergeViewWithContainerWhenSingleView: true, donotShowContainerTitleWhenMergedWithContainer: true }]),
ToggleTasksAction.ID storageId: `${TASKS_CONTAINER_ID}.storage`,
)); focusCommand: {
id: ToggleTasksAction.ID
}
}, ViewContainerLocation.Panel);
Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).registerViews([{
id: TASKS_VIEW_ID,
name: localize('tasks', "Tasks"),
canToggleVisibility: false,
canMoveView: false,
ctorDescriptor: new SyncDescriptor(TaskHistoryView),
}], VIEW_CONTAINER);
// Register StatusUpdater // Register StatusUpdater
(<ext.IWorkbenchContributionsRegistry>Registry.as(ext.Extensions.Workbench)).registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Restored); (<ext.IWorkbenchContributionsRegistry>Registry.as(ext.Extensions.Workbench)).registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Restored);

View File

@@ -8,7 +8,7 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la
import { ToggleViewAction } from 'vs/workbench/browser/actions/layoutActions'; import { ToggleViewAction } from 'vs/workbench/browser/actions/layoutActions';
import { IViewsService, IViewDescriptorService } from 'vs/workbench/common/views'; import { IViewsService, IViewDescriptorService } from 'vs/workbench/common/views';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { TASKS_PANEL_ID } from 'sql/workbench/contrib/tasks/common/tasks'; import { TASKS_VIEW_ID } from 'sql/workbench/contrib/tasks/common/tasks';
export class ToggleTasksAction extends ToggleViewAction { export class ToggleTasksAction extends ToggleViewAction {
@@ -22,6 +22,6 @@ export class ToggleTasksAction extends ToggleViewAction {
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService contextKeyService: IContextKeyService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
) { ) {
super(id, label, TASKS_PANEL_ID, viewsService, viewDescriptorService, contextKeyService, layoutService); super(id, label, TASKS_VIEW_ID, viewsService, viewDescriptorService, contextKeyService, layoutService);
} }
} }

View File

@@ -1,43 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/tasksPanel';
import { Dimension } from 'vs/base/browser/dom';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { TaskHistoryView } from 'sql/workbench/contrib/tasks/browser/tasksView';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Panel } from 'vs/workbench/browser/panel';
import { TASKS_PANEL_ID } from 'sql/workbench/contrib/tasks/common/tasks';
export class TasksPanel extends Panel {
private _taskHistoryView: TaskHistoryView;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super(TASKS_PANEL_ID, telemetryService, themeService, storageService);
}
public create(parent: HTMLElement): void {
super.create(parent);
this._taskHistoryView = this.instantiationService.createInstance(TaskHistoryView);
this._taskHistoryView.renderBody(parent);
}
public setVisible(visible: boolean): void {
super.setVisible(visible);
this._taskHistoryView.setVisible(visible);
}
public layout({ height }: Dimension): void {
this._taskHistoryView.layout(height);
}
}

View File

@@ -10,10 +10,17 @@ import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachListStyler } from 'vs/platform/theme/common/styler'; import { attachListStyler } from 'vs/platform/theme/common/styler';
import { ITree } from 'vs/base/parts/tree/browser/tree'; import { ITree } from 'vs/base/parts/tree/browser/tree';
import { Disposable } from 'vs/base/common/lifecycle';
import { DefaultFilter, DefaultDragAndDrop, DefaultAccessibilityProvider } from 'vs/base/parts/tree/browser/treeDefaults'; import { DefaultFilter, DefaultDragAndDrop, DefaultAccessibilityProvider } from 'vs/base/parts/tree/browser/treeDefaults';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { hide, $, append } from 'vs/base/browser/dom'; import { hide, $, append } from 'vs/base/browser/dom';
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { IViewDescriptorService } from 'vs/workbench/common/views';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { TaskHistoryRenderer } from 'sql/workbench/contrib/tasks/browser/tasksRenderer'; import { TaskHistoryRenderer } from 'sql/workbench/contrib/tasks/browser/tasksRenderer';
import { TaskHistoryDataSource } from 'sql/workbench/contrib/tasks/browser/tasksDataSource'; import { TaskHistoryDataSource } from 'sql/workbench/contrib/tasks/browser/tasksDataSource';
@@ -27,25 +34,34 @@ import { IExpandableTree } from 'sql/workbench/services/objectExplorer/browser/t
/** /**
* TaskHistoryView implements the dynamic tree view. * TaskHistoryView implements the dynamic tree view.
*/ */
export class TaskHistoryView extends Disposable { export class TaskHistoryView extends ViewPane {
private _messages: HTMLElement; private _messages: HTMLElement;
private _tree: ITree; private _tree: ITree;
constructor( constructor(
@IInstantiationService private _instantiationService: IInstantiationService, options: IViewPaneOptions,
@ITaskService private _taskService: ITaskService, @IInstantiationService instantiationService: IInstantiationService,
@IErrorMessageService private _errorMessageService: IErrorMessageService, @IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IThemeService private _themeService: IThemeService @IConfigurationService configurationService: IConfigurationService,
@ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService,
@IContextMenuService contextMenuService: IContextMenuService,
@IKeybindingService keybindingService: IKeybindingService,
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITaskService private readonly taskService: ITaskService,
@IErrorMessageService private readonly errorMessageService: IErrorMessageService
) { ) {
super(); super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
} }
/** /**
* Render the view body * Render the view body
*/ */
public renderBody(container: HTMLElement): void { public renderBody(container: HTMLElement): void {
super.renderBody(container);
let taskNode = this._taskService.getAllTasks(); let taskNode = this.taskService.getAllTasks();
// Add div to display no task executed message // Add div to display no task executed message
this._messages = append(container, $('div.empty-task-message')); this._messages = append(container, $('div.empty-task-message'));
@@ -56,17 +72,17 @@ export class TaskHistoryView extends Disposable {
let noTaskMessage = localize('noTaskMessage', "No task history to display."); let noTaskMessage = localize('noTaskMessage', "No task history to display.");
append(this._messages, $('span')).innerText = noTaskMessage; append(this._messages, $('span')).innerText = noTaskMessage;
this._tree = this._register(this.createTaskHistoryTree(container, this._instantiationService)); this._tree = this._register(this.createTaskHistoryTree(container, this.instantiationService));
this._register(this._tree.onDidChangeSelection((event) => this.onSelected(event))); this._register(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
// Theme styler // Theme styler
this._register(attachListStyler(this._tree, this._themeService)); this._register(attachListStyler(this._tree, this.themeService));
this._register(this._taskService.onAddNewTask(args => { this._register(this.taskService.onAddNewTask(args => {
hide(this._messages); hide(this._messages);
this.refreshTree(); this.refreshTree();
})); }));
this._register(this._taskService.onTaskComplete(task => { this._register(this.taskService.onTaskComplete(task => {
this.updateTask(task); this.updateTask(task);
})); }));
@@ -118,7 +134,7 @@ export class TaskHistoryView extends Disposable {
} }
//Get the tree Input //Get the tree Input
let treeInput = this._taskService.getAllTasks(); let treeInput = this.taskService.getAllTasks();
if (treeInput) { if (treeInput) {
this._tree.setInput(treeInput).then(async () => { this._tree.setInput(treeInput).then(async () => {
// Make sure to expand all folders that where expanded in the previous session // Make sure to expand all folders that where expanded in the previous session
@@ -143,7 +159,7 @@ export class TaskHistoryView extends Disposable {
if (isDoubleClick) { if (isDoubleClick) {
if (task.status === TaskStatus.Failed) { if (task.status === TaskStatus.Failed) {
let err = task.taskName + ': ' + task.message; let err = task.taskName + ': ' + task.message;
this._errorMessageService.showDialog(Severity.Error, localize('taskError', "Task error"), err); this.errorMessageService.showDialog(Severity.Error, localize('taskError', "Task error"), err);
} }
} }
} }
@@ -152,18 +168,8 @@ export class TaskHistoryView extends Disposable {
/** /**
* set the layout of the view * set the layout of the view
*/ */
public layout(height: number): void { public layoutBody(height: number, width: number): void {
super.layoutBody(height, width);
this._tree.layout(height); this._tree.layout(height);
} }
/**
* set the visibility of the view
*/
public setVisible(visible: boolean): void {
if (visible) {
this._tree.onVisible();
} else {
this._tree.onHidden();
}
}
} }

View File

@@ -6,4 +6,5 @@
/** /**
* Tasks panel id * Tasks panel id
*/ */
export const TASKS_PANEL_ID = 'workbench.panel.tasks'; export const TASKS_CONTAINER_ID = 'workbench.panel.tasks';
export const TASKS_VIEW_ID = 'workbench.panel.tasks.view';