@theia/outline-view 1.48.0 → 1.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/index.d.ts +2 -2
  3. package/lib/browser/index.js +20 -20
  4. package/lib/browser/outline-breadcrumbs-contribution.d.ts +57 -57
  5. package/lib/browser/outline-breadcrumbs-contribution.js +214 -214
  6. package/lib/browser/outline-decorator-service.d.ts +13 -13
  7. package/lib/browser/outline-decorator-service.js +42 -42
  8. package/lib/browser/outline-view-contribution.d.ts +36 -36
  9. package/lib/browser/outline-view-contribution.js +125 -125
  10. package/lib/browser/outline-view-frontend-module.d.ts +4 -4
  11. package/lib/browser/outline-view-frontend-module.js +68 -68
  12. package/lib/browser/outline-view-service.d.ts +26 -26
  13. package/lib/browser/outline-view-service.js +78 -78
  14. package/lib/browser/outline-view-tree-model.d.ts +19 -19
  15. package/lib/browser/outline-view-tree-model.js +76 -76
  16. package/lib/browser/outline-view-widget.d.ts +76 -76
  17. package/lib/browser/outline-view-widget.js +184 -184
  18. package/lib/package.spec.js +25 -25
  19. package/package.json +4 -4
  20. package/src/browser/index.ts +18 -18
  21. package/src/browser/outline-breadcrumbs-contribution.tsx +229 -229
  22. package/src/browser/outline-decorator-service.ts +36 -36
  23. package/src/browser/outline-view-contribution.ts +132 -132
  24. package/src/browser/outline-view-frontend-module.ts +84 -84
  25. package/src/browser/outline-view-service.ts +82 -82
  26. package/src/browser/outline-view-tree-model.ts +77 -77
  27. package/src/browser/outline-view-widget.tsx +212 -212
  28. package/src/browser/styles/index.css +24 -24
  29. package/src/package.spec.ts +28 -28
@@ -1,132 +1,132 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable } from '@theia/core/shared/inversify';
18
- import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
19
- import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
20
- import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
21
- import { Command, CommandRegistry } from '@theia/core/lib/common/command';
22
- import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
23
- import { codicon, Widget } from '@theia/core/lib/browser/widgets';
24
- import { OutlineViewWidget } from './outline-view-widget';
25
- import { CompositeTreeNode } from '@theia/core/lib/browser/tree';
26
- import { OS } from '@theia/core/lib/common/os';
27
- import { nls } from '@theia/core/lib/common/nls';
28
-
29
- export const OUTLINE_WIDGET_FACTORY_ID = 'outline-view';
30
-
31
- /**
32
- * Collection of `outline-view` commands.
33
- */
34
- export namespace OutlineViewCommands {
35
- /**
36
- * Command which collapses all nodes from the `outline-view` tree.
37
- */
38
- export const COLLAPSE_ALL: Command = {
39
- id: 'outlineView.collapse.all',
40
- iconClass: codicon('collapse-all')
41
- };
42
-
43
- /**
44
- * Command which expands all nodes from the `outline-view` tree.
45
- */
46
- export const EXPAND_ALL: Command = {
47
- id: 'outlineView.expand.all',
48
- iconClass: codicon('expand-all')
49
- };
50
- }
51
-
52
- @injectable()
53
- export class OutlineViewContribution extends AbstractViewContribution<OutlineViewWidget> implements FrontendApplicationContribution, TabBarToolbarContribution {
54
-
55
- constructor() {
56
- super({
57
- widgetId: OUTLINE_WIDGET_FACTORY_ID,
58
- widgetName: OutlineViewWidget.LABEL,
59
- defaultWidgetOptions: {
60
- area: 'right',
61
- rank: 500
62
- },
63
- toggleCommandId: 'outlineView:toggle',
64
- toggleKeybinding: OS.type() !== OS.Type.Linux
65
- ? 'ctrlcmd+shift+i'
66
- : undefined
67
- });
68
- }
69
-
70
- async initializeLayout(app: FrontendApplication): Promise<void> {
71
- await this.openView();
72
- }
73
-
74
- override registerCommands(commands: CommandRegistry): void {
75
- super.registerCommands(commands);
76
- commands.registerCommand(OutlineViewCommands.COLLAPSE_ALL, {
77
- isEnabled: w => this.withWidget(w, () => true),
78
- isVisible: w => this.withWidget(w, widget => !widget.model.areNodesCollapsed()),
79
- execute: () => this.collapseAllItems()
80
- });
81
- commands.registerCommand(OutlineViewCommands.EXPAND_ALL, {
82
- isEnabled: w => this.withWidget(w, () => true),
83
- isVisible: w => this.withWidget(w, widget => widget.model.areNodesCollapsed()),
84
- execute: () => this.expandAllItems()
85
- });
86
- }
87
-
88
- async registerToolbarItems(toolbar: TabBarToolbarRegistry): Promise<void> {
89
- const widget = await this.widget;
90
- const onDidChange = widget.onDidUpdate;
91
- toolbar.registerItem({
92
- id: OutlineViewCommands.COLLAPSE_ALL.id,
93
- command: OutlineViewCommands.COLLAPSE_ALL.id,
94
- tooltip: nls.localizeByDefault('Collapse All'),
95
- priority: 0,
96
- onDidChange
97
- });
98
- toolbar.registerItem({
99
- id: OutlineViewCommands.EXPAND_ALL.id,
100
- command: OutlineViewCommands.EXPAND_ALL.id,
101
- tooltip: nls.localizeByDefault('Expand All'),
102
- priority: 0,
103
- onDidChange
104
- });
105
- }
106
-
107
- /**
108
- * Collapse all nodes in the outline view tree.
109
- */
110
- protected async collapseAllItems(): Promise<void> {
111
- const { model } = await this.widget;
112
- const root = model.root;
113
- if (CompositeTreeNode.is(root)) {
114
- model.collapseAll(root);
115
- }
116
- }
117
-
118
- protected async expandAllItems(): Promise<void> {
119
- const { model } = await this.widget;
120
- model.expandAll(model.root);
121
- }
122
-
123
- /**
124
- * Determine if the current widget is the `outline-view`.
125
- */
126
- protected withWidget<T>(widget: Widget | undefined = this.tryGetWidget(), cb: (widget: OutlineViewWidget) => T): T | false {
127
- if (widget instanceof OutlineViewWidget && widget.id === OUTLINE_WIDGET_FACTORY_ID) {
128
- return cb(widget);
129
- }
130
- return false;
131
- }
132
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
19
+ import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
20
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
21
+ import { Command, CommandRegistry } from '@theia/core/lib/common/command';
22
+ import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
23
+ import { codicon, Widget } from '@theia/core/lib/browser/widgets';
24
+ import { OutlineViewWidget } from './outline-view-widget';
25
+ import { CompositeTreeNode } from '@theia/core/lib/browser/tree';
26
+ import { OS } from '@theia/core/lib/common/os';
27
+ import { nls } from '@theia/core/lib/common/nls';
28
+
29
+ export const OUTLINE_WIDGET_FACTORY_ID = 'outline-view';
30
+
31
+ /**
32
+ * Collection of `outline-view` commands.
33
+ */
34
+ export namespace OutlineViewCommands {
35
+ /**
36
+ * Command which collapses all nodes from the `outline-view` tree.
37
+ */
38
+ export const COLLAPSE_ALL: Command = {
39
+ id: 'outlineView.collapse.all',
40
+ iconClass: codicon('collapse-all')
41
+ };
42
+
43
+ /**
44
+ * Command which expands all nodes from the `outline-view` tree.
45
+ */
46
+ export const EXPAND_ALL: Command = {
47
+ id: 'outlineView.expand.all',
48
+ iconClass: codicon('expand-all')
49
+ };
50
+ }
51
+
52
+ @injectable()
53
+ export class OutlineViewContribution extends AbstractViewContribution<OutlineViewWidget> implements FrontendApplicationContribution, TabBarToolbarContribution {
54
+
55
+ constructor() {
56
+ super({
57
+ widgetId: OUTLINE_WIDGET_FACTORY_ID,
58
+ widgetName: OutlineViewWidget.LABEL,
59
+ defaultWidgetOptions: {
60
+ area: 'right',
61
+ rank: 500
62
+ },
63
+ toggleCommandId: 'outlineView:toggle',
64
+ toggleKeybinding: OS.type() !== OS.Type.Linux
65
+ ? 'ctrlcmd+shift+i'
66
+ : undefined
67
+ });
68
+ }
69
+
70
+ async initializeLayout(app: FrontendApplication): Promise<void> {
71
+ await this.openView();
72
+ }
73
+
74
+ override registerCommands(commands: CommandRegistry): void {
75
+ super.registerCommands(commands);
76
+ commands.registerCommand(OutlineViewCommands.COLLAPSE_ALL, {
77
+ isEnabled: w => this.withWidget(w, () => true),
78
+ isVisible: w => this.withWidget(w, widget => !widget.model.areNodesCollapsed()),
79
+ execute: () => this.collapseAllItems()
80
+ });
81
+ commands.registerCommand(OutlineViewCommands.EXPAND_ALL, {
82
+ isEnabled: w => this.withWidget(w, () => true),
83
+ isVisible: w => this.withWidget(w, widget => widget.model.areNodesCollapsed()),
84
+ execute: () => this.expandAllItems()
85
+ });
86
+ }
87
+
88
+ async registerToolbarItems(toolbar: TabBarToolbarRegistry): Promise<void> {
89
+ const widget = await this.widget;
90
+ const onDidChange = widget.onDidUpdate;
91
+ toolbar.registerItem({
92
+ id: OutlineViewCommands.COLLAPSE_ALL.id,
93
+ command: OutlineViewCommands.COLLAPSE_ALL.id,
94
+ tooltip: nls.localizeByDefault('Collapse All'),
95
+ priority: 0,
96
+ onDidChange
97
+ });
98
+ toolbar.registerItem({
99
+ id: OutlineViewCommands.EXPAND_ALL.id,
100
+ command: OutlineViewCommands.EXPAND_ALL.id,
101
+ tooltip: nls.localizeByDefault('Expand All'),
102
+ priority: 0,
103
+ onDidChange
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Collapse all nodes in the outline view tree.
109
+ */
110
+ protected async collapseAllItems(): Promise<void> {
111
+ const { model } = await this.widget;
112
+ const root = model.root;
113
+ if (CompositeTreeNode.is(root)) {
114
+ model.collapseAll(root);
115
+ }
116
+ }
117
+
118
+ protected async expandAllItems(): Promise<void> {
119
+ const { model } = await this.widget;
120
+ model.expandAll(model.root);
121
+ }
122
+
123
+ /**
124
+ * Determine if the current widget is the `outline-view`.
125
+ */
126
+ protected withWidget<T>(widget: Widget | undefined = this.tryGetWidget(), cb: (widget: OutlineViewWidget) => T): T | false {
127
+ if (widget instanceof OutlineViewWidget && widget.id === OUTLINE_WIDGET_FACTORY_ID) {
128
+ return cb(widget);
129
+ }
130
+ return false;
131
+ }
132
+ }
@@ -1,84 +1,84 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
18
- import { OutlineViewService } from './outline-view-service';
19
- import { OutlineViewContribution } from './outline-view-contribution';
20
- import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
21
- import {
22
- FrontendApplicationContribution,
23
- createTreeContainer,
24
- bindViewContribution,
25
- TreeProps,
26
- defaultTreeProps,
27
- BreadcrumbsContribution
28
- } from '@theia/core/lib/browser';
29
- import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
30
- import { OutlineViewWidgetFactory, OutlineViewWidget } from './outline-view-widget';
31
- import '../../src/browser/styles/index.css';
32
- import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
33
- import { OutlineDecoratorService, OutlineTreeDecorator } from './outline-decorator-service';
34
- import { OutlineViewTreeModel } from './outline-view-tree-model';
35
- import { BreadcrumbPopupOutlineView, BreadcrumbPopupOutlineViewFactory, OutlineBreadcrumbsContribution } from './outline-breadcrumbs-contribution';
36
-
37
- export default new ContainerModule(bind => {
38
- bind(OutlineViewWidgetFactory).toFactory(ctx =>
39
- () => createOutlineViewWidget(ctx.container)
40
- );
41
-
42
- bind(BreadcrumbPopupOutlineViewFactory).toFactory(({ container }) => () => {
43
- const child = createOutlineViewWidgetContainer(container);
44
- child.rebind(OutlineViewWidget).to(BreadcrumbPopupOutlineView);
45
- child.rebind(TreeProps).toConstantValue({ ...defaultTreeProps, expandOnlyOnExpansionToggleClick: true, search: false, virtualized: false });
46
- return child.get(OutlineViewWidget);
47
- });
48
-
49
- bind(OutlineViewService).toSelf().inSingletonScope();
50
- bind(WidgetFactory).toService(OutlineViewService);
51
-
52
- bindViewContribution(bind, OutlineViewContribution);
53
- bind(FrontendApplicationContribution).toService(OutlineViewContribution);
54
- bind(TabBarToolbarContribution).toService(OutlineViewContribution);
55
-
56
- bind(OutlineBreadcrumbsContribution).toSelf().inSingletonScope();
57
- bind(BreadcrumbsContribution).toService(OutlineBreadcrumbsContribution);
58
- });
59
-
60
- function createOutlineViewWidgetContainer(parent: interfaces.Container): interfaces.Container {
61
- const child = createTreeContainer(parent, {
62
- props: { expandOnlyOnExpansionToggleClick: true, search: true },
63
- widget: OutlineViewWidget,
64
- model: OutlineViewTreeModel,
65
- decoratorService: OutlineDecoratorService,
66
- });
67
- bindContributionProvider(child, OutlineTreeDecorator);
68
- return child;
69
- }
70
-
71
- /**
72
- * Create an `OutlineViewWidget`.
73
- * - The creation of the `OutlineViewWidget` includes:
74
- * - The creation of the tree widget itself with it's own customized props.
75
- * - The binding of necessary components into the container.
76
- * @param parent the Inversify container.
77
- *
78
- * @returns the `OutlineViewWidget`.
79
- */
80
- function createOutlineViewWidget(parent: interfaces.Container): OutlineViewWidget {
81
- const child = createOutlineViewWidgetContainer(parent);
82
-
83
- return child.get(OutlineViewWidget);
84
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
18
+ import { OutlineViewService } from './outline-view-service';
19
+ import { OutlineViewContribution } from './outline-view-contribution';
20
+ import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
21
+ import {
22
+ FrontendApplicationContribution,
23
+ createTreeContainer,
24
+ bindViewContribution,
25
+ TreeProps,
26
+ defaultTreeProps,
27
+ BreadcrumbsContribution
28
+ } from '@theia/core/lib/browser';
29
+ import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
30
+ import { OutlineViewWidgetFactory, OutlineViewWidget } from './outline-view-widget';
31
+ import '../../src/browser/styles/index.css';
32
+ import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
33
+ import { OutlineDecoratorService, OutlineTreeDecorator } from './outline-decorator-service';
34
+ import { OutlineViewTreeModel } from './outline-view-tree-model';
35
+ import { BreadcrumbPopupOutlineView, BreadcrumbPopupOutlineViewFactory, OutlineBreadcrumbsContribution } from './outline-breadcrumbs-contribution';
36
+
37
+ export default new ContainerModule(bind => {
38
+ bind(OutlineViewWidgetFactory).toFactory(ctx =>
39
+ () => createOutlineViewWidget(ctx.container)
40
+ );
41
+
42
+ bind(BreadcrumbPopupOutlineViewFactory).toFactory(({ container }) => () => {
43
+ const child = createOutlineViewWidgetContainer(container);
44
+ child.rebind(OutlineViewWidget).to(BreadcrumbPopupOutlineView);
45
+ child.rebind(TreeProps).toConstantValue({ ...defaultTreeProps, expandOnlyOnExpansionToggleClick: true, search: false, virtualized: false });
46
+ return child.get(OutlineViewWidget);
47
+ });
48
+
49
+ bind(OutlineViewService).toSelf().inSingletonScope();
50
+ bind(WidgetFactory).toService(OutlineViewService);
51
+
52
+ bindViewContribution(bind, OutlineViewContribution);
53
+ bind(FrontendApplicationContribution).toService(OutlineViewContribution);
54
+ bind(TabBarToolbarContribution).toService(OutlineViewContribution);
55
+
56
+ bind(OutlineBreadcrumbsContribution).toSelf().inSingletonScope();
57
+ bind(BreadcrumbsContribution).toService(OutlineBreadcrumbsContribution);
58
+ });
59
+
60
+ function createOutlineViewWidgetContainer(parent: interfaces.Container): interfaces.Container {
61
+ const child = createTreeContainer(parent, {
62
+ props: { expandOnlyOnExpansionToggleClick: true, search: true },
63
+ widget: OutlineViewWidget,
64
+ model: OutlineViewTreeModel,
65
+ decoratorService: OutlineDecoratorService,
66
+ });
67
+ bindContributionProvider(child, OutlineTreeDecorator);
68
+ return child;
69
+ }
70
+
71
+ /**
72
+ * Create an `OutlineViewWidget`.
73
+ * - The creation of the `OutlineViewWidget` includes:
74
+ * - The creation of the tree widget itself with it's own customized props.
75
+ * - The binding of necessary components into the container.
76
+ * @param parent the Inversify container.
77
+ *
78
+ * @returns the `OutlineViewWidget`.
79
+ */
80
+ function createOutlineViewWidget(parent: interfaces.Container): OutlineViewWidget {
81
+ const child = createOutlineViewWidgetContainer(parent);
82
+
83
+ return child.get(OutlineViewWidget);
84
+ }
@@ -1,82 +1,82 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject } from '@theia/core/shared/inversify';
18
- import { Event, Emitter, DisposableCollection } from '@theia/core';
19
- import { WidgetFactory } from '@theia/core/lib/browser';
20
- import { OutlineViewWidget, OutlineViewWidgetFactory, OutlineSymbolInformationNode } from './outline-view-widget';
21
- import { Widget } from '@theia/core/shared/@phosphor/widgets';
22
-
23
- @injectable()
24
- export class OutlineViewService implements WidgetFactory {
25
-
26
- id = 'outline-view';
27
-
28
- protected widget?: OutlineViewWidget;
29
- protected readonly onDidChangeOutlineEmitter = new Emitter<OutlineSymbolInformationNode[]>();
30
- protected readonly onDidChangeOpenStateEmitter = new Emitter<boolean>();
31
- protected readonly onDidSelectEmitter = new Emitter<OutlineSymbolInformationNode>();
32
- protected readonly onDidOpenEmitter = new Emitter<OutlineSymbolInformationNode>();
33
-
34
- constructor(@inject(OutlineViewWidgetFactory) protected factory: OutlineViewWidgetFactory) { }
35
-
36
- get onDidSelect(): Event<OutlineSymbolInformationNode> {
37
- return this.onDidSelectEmitter.event;
38
- }
39
-
40
- get onDidOpen(): Event<OutlineSymbolInformationNode> {
41
- return this.onDidOpenEmitter.event;
42
- }
43
-
44
- get onDidChangeOutline(): Event<OutlineSymbolInformationNode[]> {
45
- return this.onDidChangeOutlineEmitter.event;
46
- }
47
-
48
- get onDidChangeOpenState(): Event<boolean> {
49
- return this.onDidChangeOpenStateEmitter.event;
50
- }
51
-
52
- get open(): boolean {
53
- return this.widget !== undefined && this.widget.isVisible;
54
- }
55
-
56
- /**
57
- * Publish the collection of outline view symbols.
58
- * - Publishing includes setting the `OutlineViewWidget` tree with symbol information.
59
- * @param roots the list of outline symbol information nodes.
60
- */
61
- publish(roots: OutlineSymbolInformationNode[]): void {
62
- if (this.widget) {
63
- this.widget.setOutlineTree(roots);
64
- }
65
- // onDidChangeOutline needs to be fired even when the outline view widget is closed
66
- // in order to update breadcrumbs.
67
- this.onDidChangeOutlineEmitter.fire(roots);
68
- }
69
-
70
- createWidget(): Promise<Widget> {
71
- this.widget = this.factory();
72
- const disposables = new DisposableCollection();
73
- disposables.push(this.widget.onDidChangeOpenStateEmitter.event(open => this.onDidChangeOpenStateEmitter.fire(open)));
74
- disposables.push(this.widget.model.onOpenNode(node => this.onDidOpenEmitter.fire(node as OutlineSymbolInformationNode)));
75
- disposables.push(this.widget.model.onSelectionChanged(selection => this.onDidSelectEmitter.fire(selection[0] as OutlineSymbolInformationNode)));
76
- this.widget.disposed.connect(() => {
77
- this.widget = undefined;
78
- disposables.dispose();
79
- });
80
- return Promise.resolve(this.widget);
81
- }
82
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject } from '@theia/core/shared/inversify';
18
+ import { Event, Emitter, DisposableCollection } from '@theia/core';
19
+ import { WidgetFactory } from '@theia/core/lib/browser';
20
+ import { OutlineViewWidget, OutlineViewWidgetFactory, OutlineSymbolInformationNode } from './outline-view-widget';
21
+ import { Widget } from '@theia/core/shared/@phosphor/widgets';
22
+
23
+ @injectable()
24
+ export class OutlineViewService implements WidgetFactory {
25
+
26
+ id = 'outline-view';
27
+
28
+ protected widget?: OutlineViewWidget;
29
+ protected readonly onDidChangeOutlineEmitter = new Emitter<OutlineSymbolInformationNode[]>();
30
+ protected readonly onDidChangeOpenStateEmitter = new Emitter<boolean>();
31
+ protected readonly onDidSelectEmitter = new Emitter<OutlineSymbolInformationNode>();
32
+ protected readonly onDidOpenEmitter = new Emitter<OutlineSymbolInformationNode>();
33
+
34
+ constructor(@inject(OutlineViewWidgetFactory) protected factory: OutlineViewWidgetFactory) { }
35
+
36
+ get onDidSelect(): Event<OutlineSymbolInformationNode> {
37
+ return this.onDidSelectEmitter.event;
38
+ }
39
+
40
+ get onDidOpen(): Event<OutlineSymbolInformationNode> {
41
+ return this.onDidOpenEmitter.event;
42
+ }
43
+
44
+ get onDidChangeOutline(): Event<OutlineSymbolInformationNode[]> {
45
+ return this.onDidChangeOutlineEmitter.event;
46
+ }
47
+
48
+ get onDidChangeOpenState(): Event<boolean> {
49
+ return this.onDidChangeOpenStateEmitter.event;
50
+ }
51
+
52
+ get open(): boolean {
53
+ return this.widget !== undefined && this.widget.isVisible;
54
+ }
55
+
56
+ /**
57
+ * Publish the collection of outline view symbols.
58
+ * - Publishing includes setting the `OutlineViewWidget` tree with symbol information.
59
+ * @param roots the list of outline symbol information nodes.
60
+ */
61
+ publish(roots: OutlineSymbolInformationNode[]): void {
62
+ if (this.widget) {
63
+ this.widget.setOutlineTree(roots);
64
+ }
65
+ // onDidChangeOutline needs to be fired even when the outline view widget is closed
66
+ // in order to update breadcrumbs.
67
+ this.onDidChangeOutlineEmitter.fire(roots);
68
+ }
69
+
70
+ createWidget(): Promise<Widget> {
71
+ this.widget = this.factory();
72
+ const disposables = new DisposableCollection();
73
+ disposables.push(this.widget.onDidChangeOpenStateEmitter.event(open => this.onDidChangeOpenStateEmitter.fire(open)));
74
+ disposables.push(this.widget.model.onOpenNode(node => this.onDidOpenEmitter.fire(node as OutlineSymbolInformationNode)));
75
+ disposables.push(this.widget.model.onSelectionChanged(selection => this.onDidSelectEmitter.fire(selection[0] as OutlineSymbolInformationNode)));
76
+ this.widget.disposed.connect(() => {
77
+ this.widget = undefined;
78
+ disposables.dispose();
79
+ });
80
+ return Promise.resolve(this.widget);
81
+ }
82
+ }