Skip to content

Commit

Permalink
Create a new 'Open with Trace Viewer' command, add it to navigator co…
Browse files Browse the repository at this point in the history
…ntext menu

Starting around Theia v1.50.0, the "open-with" service no longer permitted to open
folders from the navigator context menu (only worked for files). It was possible to
make it work again, but there were undesirable side-effects. So instead, we decided
to register our own command, "Open with Trace Viewer", and add it to the navigator's
context menu at the first level. This is very similar to what we have on the `Trace
Viewer for VSCode` extension.

Also updated the README to reflect how a trace can now be be opened from the File
Explorer, and recorded a new .gif showing it.

Signed-off-by: Marc Dumais <[email protected]>
  • Loading branch information
marcdumais-work committed Sep 23, 2024
1 parent 2c07785 commit 1d76e20
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ This is the most intuitive way to open traces and trace groups, but it can only

#### Via the File Explorer

You can open any supported trace format via the file explorer context menu. For a single trace, right-click on the trace file, or folder (for a CTF trace), then select **Open With → Open Trace**. To open several CTF trace files as a group, right-click on the parent folder instead.
You can open any supported trace format via the file explorer context menu. For a single trace, right-click on the trace file, or folder (for a CTF trace), then select **Open with Trace Viewer**. To open several CTF trace files as a group, right-click on the parent folder instead.

![Open With Trace Viewer][image-open-with]
![Open with Trace Viewer][image-open-with-trace-viewer]

### Open a view

Expand Down Expand Up @@ -466,7 +466,7 @@ The code in this repository is licensed under `MIT` (see root `LICENSE`), except
[image-icon]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-icon.png
[image-open-browser]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-open-browser.png
[image-open-view]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-open-view.gif
[image-open-with]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-open-with-trace-viewer.gif
[image-open-with-trace-viewer]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-open-with-trace-viewer.gif
[image-properties]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-item-properties-0.0.2.png
[image-sidebar]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-open-trace-viewer.gif
[image-viewer]: https://raw.githubusercontent.com/eclipse-cdt-cloud/theia-trace-extension/master/doc/images/theia-trace-extension-0.0.3.png
Expand Down
Binary file modified doc/images/theia-trace-extension-open-with-trace-viewer.gif
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 @@ -17,4 +17,9 @@ export namespace TraceExplorerCommands {
id: 'trace-explorer:remove-trace',
label: 'Remove Trace'
};

export const OPEN_WITH_TRACE_VIEWER: Command = {
id: 'trace-explorer:open-with-trace-viewer',
label: 'Open with Trace Viewer'
};
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { injectable } from '@theia/core/shared/inversify';
import { injectable, inject } from '@theia/core/shared/inversify';
import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
import { TraceExplorerWidget } from './trace-explorer-widget';
import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser';
import { MenuModelRegistry, CommandRegistry } from '@theia/core';
import { TraceExplorerCommands, TraceExplorerMenus } from './trace-explorer-commands';
import { NavigatorContextMenu } from '@theia/navigator/lib/browser/navigator-contribution';
import { UriAwareCommandHandler } from '@theia/core/lib/common/uri-command-handler';
import { SelectionService } from '@theia/core/lib/common';
import { TraceViewerContribution } from '../trace-viewer/trace-viewer-contribution';

@injectable()
export class TraceExplorerContribution
extends AbstractViewContribution<TraceExplorerWidget>
implements FrontendApplicationContribution
{
@inject(SelectionService) protected readonly selectionService: SelectionService;
@inject(TraceViewerContribution) protected readonly traceViewer: TraceViewerContribution;

constructor() {
super({
widgetId: TraceExplorerWidget.ID,
Expand Down Expand Up @@ -44,6 +51,11 @@ export class TraceExplorerContribution
label: TraceExplorerCommands.REMOVE_TRACE.label,
order: 'c'
});

menus.registerMenuAction(NavigatorContextMenu.NAVIGATION, {
commandId: TraceExplorerCommands.OPEN_WITH_TRACE_VIEWER.id
// ,order: 'a'
});
}

async registerCommands(registry: CommandRegistry): Promise<void> {
Expand All @@ -67,5 +79,14 @@ export class TraceExplorerContribution
explorerWidget.deleteExperiment(traceUUID);
}
});

registry.registerCommand(
TraceExplorerCommands.OPEN_WITH_TRACE_VIEWER,
UriAwareCommandHandler.MonoSelect(this.selectionService, {
execute: uri => {
this.traceViewer.open(uri);
}
})
);
}
}

0 comments on commit 1d76e20

Please sign in to comment.