Skip to content

Commit

Permalink
Do not open TraceViewerWidget when initializing layout
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Grant <colin.grant@ericsson.com>
  • Loading branch information
colin-grant-work authored and MatthewKhouzam committed Aug 24, 2021
1 parent 820176f commit 4911f94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ export default new ContainerModule(bind => {
bind(TspClientProvider).toSelf().inSingletonScope();
bind(TheiaMessageManager).toSelf().inSingletonScope();

bindViewContribution(bind, TraceViewerToolbarContribution);
bind(TraceViewerToolbarContribution).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(TraceViewerToolbarContribution);
bind(TabBarToolbarContribution).toService(TraceViewerToolbarContribution);
bind(CommandContribution).toService(TraceViewerToolbarContribution);

bind(TraceViewerWidget).toSelf();
bind<WidgetFactory>(WidgetFactory).toDynamicValue(context => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { injectable, inject } from 'inversify';
import { injectable, inject, postConstruct } from 'inversify';
import * as React from 'react';
import { AbstractViewContribution, ApplicationShell, Widget } from '@theia/core/lib/browser';
import { ApplicationShell, Widget } from '@theia/core/lib/browser';
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { CommandRegistry, DisposableCollection, Emitter, MenuModelRegistry } from '@theia/core';
import { CommandContribution, CommandRegistry, DisposableCollection, Emitter, MenuModelRegistry } from '@theia/core';
import { TraceViewerToolbarCommands, TraceViewerToolbarFilterMenus, TRACE_VIEWER_TOOLBAR_COMMAND_FILTER } from './trace-viewer-toolbar-commands';
import { signalManager, Signals } from '@trace-viewer/base/lib/signals/signal-manager';
import { TraceViewerWidget } from './trace-viewer';
import { TspClientProvider } from '../tsp-client-provider-impl';
import { ContextMenuRenderer } from '@theia/core/lib/browser';

@injectable()
export class TraceViewerToolbarContribution extends AbstractViewContribution<Widget> implements TabBarToolbarContribution {
export class TraceViewerToolbarContribution implements TabBarToolbarContribution, CommandContribution {
@inject(ApplicationShell) protected readonly shell: ApplicationShell;
@inject(ContextMenuRenderer) protected readonly contextMenuRenderer!: ContextMenuRenderer;
@inject(TspClientProvider) protected readonly tspClientProvider!: TspClientProvider;
Expand All @@ -19,26 +19,17 @@ export class TraceViewerToolbarContribution extends AbstractViewContribution<Wid

@inject(CommandRegistry)
protected readonly commands: CommandRegistry;

private annotationsMap: Map<string, boolean> = new Map<string, boolean>();
private onAnnotationsFetchedSignal = (annotationsList: string[]) => this.doHandleAnnotationsFetchedSignal(annotationsList);
protected readonly onAnnotationsChangedEmitter = new Emitter<void>();
protected readonly onAnnotationsChangedEvent = this.onAnnotationsChangedEmitter.event;

constructor() {
super({
widgetId: TraceViewerWidget.ID,
widgetName: TraceViewerWidget.LABEL,
defaultWidgetOptions: {
area: 'main',
},
});
@postConstruct()
protected init(): void {
signalManager().on(Signals.ANNOTATIONS_FETCHED, this.onAnnotationsFetchedSignal);
}

initializeLayout(): void {
this.openView({ activate: false });
}

private doHandleAnnotationsFetchedSignal(annotationsList: string[]) {
annotationsList.forEach(annotation => {
if (!this.annotationsMap.has(annotation)) {
Expand All @@ -50,7 +41,6 @@ export class TraceViewerToolbarContribution extends AbstractViewContribution<Wid
}

registerCommands(registry: CommandRegistry): void {
super.registerCommands(registry);
registry.registerCommand(
TraceViewerToolbarCommands.ZOOM_IN, {
isVisible: (w: Widget) => w instanceof TraceViewerWidget,
Expand Down

0 comments on commit 4911f94

Please sign in to comment.