@theia/outline-view 1.53.0-next.5 → 1.53.0-next.55

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.
@@ -1,36 +1,36 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 Redhat, Ericsson 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 { inject, injectable, named } from '@theia/core/shared/inversify';
18
- import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
19
- import { TreeDecorator, AbstractTreeDecoratorService } from '@theia/core/lib/browser/tree/tree-decorator';
20
-
21
- /**
22
- * Symbol for all decorators that would like to contribute into the outline.
23
- */
24
- export const OutlineTreeDecorator = Symbol('OutlineTreeDecorator');
25
-
26
- /**
27
- * Decorator service for the outline.
28
- */
29
- @injectable()
30
- export class OutlineDecoratorService extends AbstractTreeDecoratorService {
31
-
32
- constructor(@inject(ContributionProvider) @named(OutlineTreeDecorator) protected readonly contributions: ContributionProvider<TreeDecorator>) {
33
- super(contributions.getContributions());
34
- }
35
-
36
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 Redhat, Ericsson 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 { inject, injectable, named } from '@theia/core/shared/inversify';
18
+ import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
19
+ import { TreeDecorator, AbstractTreeDecoratorService } from '@theia/core/lib/browser/tree/tree-decorator';
20
+
21
+ /**
22
+ * Symbol for all decorators that would like to contribute into the outline.
23
+ */
24
+ export const OutlineTreeDecorator = Symbol('OutlineTreeDecorator');
25
+
26
+ /**
27
+ * Decorator service for the outline.
28
+ */
29
+ @injectable()
30
+ export class OutlineDecoratorService extends AbstractTreeDecoratorService {
31
+
32
+ constructor(@inject(ContributionProvider) @named(OutlineTreeDecorator) protected readonly contributions: ContributionProvider<TreeDecorator>) {
33
+ super(contributions.getContributions());
34
+ }
35
+
36
+ }
@@ -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
+ }