-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurable default view for the trace overview
Currently, the trace overview default view is hard-coded in the trace viewer. This commit allows users/developers to set an XY view as the default view for the trace overview (using its name). Users can set the default view for the trace overview using the Preference UI (File > Preferences > Open Settings or Ctrl + ,). Developers can also set the default view for a specific Theia build by adding the "trace Viewer.trace Overview.defaultView" property to the "preferences" object in the package.json file of the build and indicate the name of the default view. Fixes #840. Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca>
- Loading branch information
1 parent
d85e56b
commit 5d8c66e
Showing
4 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
theia-extensions/viewer-prototype/src/browser/trace-overview-binding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { interfaces } from 'inversify'; | ||
import { PreferenceService, createPreferenceProxy, PreferenceContribution } from '@theia/core/lib/browser'; | ||
import { OverviewPreferences, OverviewSchema } from './trace-overview-preference'; | ||
|
||
export function bindTraceOverviewPreferences(bind: interfaces.Bind): void { | ||
bind(OverviewPreferences).toDynamicValue(ctx => { | ||
const preferences = ctx.container.get<PreferenceService>(PreferenceService); | ||
return createPreferenceProxy(preferences, OverviewSchema); | ||
}).inSingletonScope(); | ||
bind(PreferenceContribution).toConstantValue({ | ||
schema: OverviewSchema, | ||
}); | ||
} |
35 changes: 35 additions & 0 deletions
35
theia-extensions/viewer-prototype/src/browser/trace-overview-preference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { PreferenceProxy, PreferenceSchema, PreferenceScope } from '@theia/core/lib/browser'; | ||
|
||
export const TRACE_OVERVIEW_DEFAULT_VIEW_KEY = 'trace Viewer.trace Overview.defaultView'; | ||
export const DEFAULT_OVERVIEW_OUTPUT_NAME = 'Histogram'; | ||
|
||
export function getSwitchToDefaultViewErrorMessage(preferredName: string, defaultName: string): string { | ||
return `The ${preferredName} view cannot be opened as the trace overview. ` + | ||
`Opening ${defaultName} instead. ` + | ||
'Please set the Default View preference (Ctrl + ,) of the Trace Overview to an XY view, ' + | ||
'or make sure the name is spelled correctly.'; | ||
} | ||
|
||
export function getOpenTraceOverviewFailErrorMessage(): string { | ||
return 'An error has occurred while opening the trace overview.'; | ||
} | ||
|
||
export const OverviewSchema: PreferenceSchema = { | ||
scope: PreferenceScope.Folder, | ||
type: 'object', | ||
properties: { | ||
[TRACE_OVERVIEW_DEFAULT_VIEW_KEY]: { | ||
type: 'string', | ||
default: DEFAULT_OVERVIEW_OUTPUT_NAME, | ||
description: 'Specify the name of the view that will be used as the default view for the Trace Overview. ' + | ||
'Use the same name displayed in the Available Views list. E.g: For the Histogram view, enter Histogram.' | ||
} | ||
}, | ||
}; | ||
|
||
interface OverviewContribution { | ||
[TRACE_OVERVIEW_DEFAULT_VIEW_KEY]: string | ||
} | ||
|
||
export const OverviewPreferences = Symbol('OverviewPreferences'); | ||
export type OverviewPreferences = PreferenceProxy<OverviewContribution>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters