@theia/bulk-edit 1.45.0 → 1.46.0-next.72

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 (37) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/bulk-edit-commands.d.ts +6 -6
  3. package/lib/browser/bulk-edit-commands.js +33 -33
  4. package/lib/browser/bulk-edit-contribution.d.ts +19 -19
  5. package/lib/browser/bulk-edit-contribution.js +115 -115
  6. package/lib/browser/bulk-edit-frontend-module.d.ts +4 -4
  7. package/lib/browser/bulk-edit-frontend-module.js +37 -37
  8. package/lib/browser/bulk-edit-tree/bulk-edit-node-selection.d.ts +14 -14
  9. package/lib/browser/bulk-edit-tree/bulk-edit-node-selection.js +35 -35
  10. package/lib/browser/bulk-edit-tree/bulk-edit-tree-container.d.ts +4 -4
  11. package/lib/browser/bulk-edit-tree/bulk-edit-tree-container.js +35 -35
  12. package/lib/browser/bulk-edit-tree/bulk-edit-tree-model.d.ts +10 -10
  13. package/lib/browser/bulk-edit-tree/bulk-edit-tree-model.js +58 -58
  14. package/lib/browser/bulk-edit-tree/bulk-edit-tree-widget.d.ts +33 -33
  15. package/lib/browser/bulk-edit-tree/bulk-edit-tree-widget.js +231 -231
  16. package/lib/browser/bulk-edit-tree/bulk-edit-tree.d.ts +24 -24
  17. package/lib/browser/bulk-edit-tree/bulk-edit-tree.js +112 -112
  18. package/lib/browser/bulk-edit-tree/bulk-edit-tree.spec.d.ts +1 -1
  19. package/lib/browser/bulk-edit-tree/bulk-edit-tree.spec.js +62 -62
  20. package/lib/browser/bulk-edit-tree/bulk-edit-tree.spec.js.map +1 -1
  21. package/lib/browser/bulk-edit-tree/index.d.ts +5 -5
  22. package/lib/browser/bulk-edit-tree/index.js +32 -32
  23. package/lib/browser/bulk-edit-tree-label-provider.d.ts +15 -15
  24. package/lib/browser/bulk-edit-tree-label-provider.js +80 -80
  25. package/package.json +9 -9
  26. package/src/browser/bulk-edit-commands.ts +34 -34
  27. package/src/browser/bulk-edit-contribution.ts +112 -112
  28. package/src/browser/bulk-edit-frontend-module.ts +39 -39
  29. package/src/browser/bulk-edit-tree/bulk-edit-node-selection.ts +44 -44
  30. package/src/browser/bulk-edit-tree/bulk-edit-tree-container.ts +35 -35
  31. package/src/browser/bulk-edit-tree/bulk-edit-tree-model.ts +42 -42
  32. package/src/browser/bulk-edit-tree/bulk-edit-tree-widget.tsx +231 -231
  33. package/src/browser/bulk-edit-tree/bulk-edit-tree.spec.ts +73 -73
  34. package/src/browser/bulk-edit-tree/bulk-edit-tree.ts +114 -114
  35. package/src/browser/bulk-edit-tree/index.ts +21 -21
  36. package/src/browser/bulk-edit-tree-label-provider.ts +71 -71
  37. package/src/browser/style/bulk-edit.css +66 -66
@@ -1,81 +1,81 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.BulkEditTreeLabelProvider = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const label_provider_1 = require("@theia/core/lib/browser/label-provider");
30
- const bulk_edit_tree_1 = require("./bulk-edit-tree");
31
- const tree_label_provider_1 = require("@theia/core/lib/browser/tree/tree-label-provider");
32
- const browser_1 = require("@theia/workspace/lib/browser");
33
- let BulkEditTreeLabelProvider = class BulkEditTreeLabelProvider {
34
- canHandle(element) {
35
- return bulk_edit_tree_1.BulkEditInfoNode.is(element) ?
36
- this.treeLabelProvider.canHandle(element) + 1 :
37
- 0;
38
- }
39
- getIcon(node) {
40
- return this.labelProvider.getIcon(node.uri);
41
- }
42
- getName(node) {
43
- return this.labelProvider.getName(node.uri);
44
- }
45
- getLongName(node) {
46
- const description = [];
47
- const rootUri = this.workspaceService.getWorkspaceRootUri(node.uri);
48
- // In a multiple-root workspace include the root name to the label before the parent directory.
49
- if (this.workspaceService.isMultiRootWorkspaceOpened && rootUri) {
50
- description.push(this.labelProvider.getName(rootUri));
51
- }
52
- // If the given resource is not at the workspace root, include the parent directory to the label.
53
- if ((rootUri === null || rootUri === void 0 ? void 0 : rootUri.toString()) !== node.uri.parent.toString()) {
54
- description.push(this.labelProvider.getLongName(node.uri.parent));
55
- }
56
- return description.join(' ● ');
57
- }
58
- getDescription(node) {
59
- return this.labelProvider.getLongName(node.uri.parent);
60
- }
61
- affects(node, event) {
62
- return event.affects(node.uri) || event.affects(node.uri.parent);
63
- }
64
- };
65
- __decorate([
66
- (0, inversify_1.inject)(label_provider_1.LabelProvider),
67
- __metadata("design:type", label_provider_1.LabelProvider)
68
- ], BulkEditTreeLabelProvider.prototype, "labelProvider", void 0);
69
- __decorate([
70
- (0, inversify_1.inject)(tree_label_provider_1.TreeLabelProvider),
71
- __metadata("design:type", tree_label_provider_1.TreeLabelProvider)
72
- ], BulkEditTreeLabelProvider.prototype, "treeLabelProvider", void 0);
73
- __decorate([
74
- (0, inversify_1.inject)(browser_1.WorkspaceService),
75
- __metadata("design:type", browser_1.WorkspaceService)
76
- ], BulkEditTreeLabelProvider.prototype, "workspaceService", void 0);
77
- BulkEditTreeLabelProvider = __decorate([
78
- (0, inversify_1.injectable)()
79
- ], BulkEditTreeLabelProvider);
80
- exports.BulkEditTreeLabelProvider = BulkEditTreeLabelProvider;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.BulkEditTreeLabelProvider = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const label_provider_1 = require("@theia/core/lib/browser/label-provider");
30
+ const bulk_edit_tree_1 = require("./bulk-edit-tree");
31
+ const tree_label_provider_1 = require("@theia/core/lib/browser/tree/tree-label-provider");
32
+ const browser_1 = require("@theia/workspace/lib/browser");
33
+ let BulkEditTreeLabelProvider = class BulkEditTreeLabelProvider {
34
+ canHandle(element) {
35
+ return bulk_edit_tree_1.BulkEditInfoNode.is(element) ?
36
+ this.treeLabelProvider.canHandle(element) + 1 :
37
+ 0;
38
+ }
39
+ getIcon(node) {
40
+ return this.labelProvider.getIcon(node.uri);
41
+ }
42
+ getName(node) {
43
+ return this.labelProvider.getName(node.uri);
44
+ }
45
+ getLongName(node) {
46
+ const description = [];
47
+ const rootUri = this.workspaceService.getWorkspaceRootUri(node.uri);
48
+ // In a multiple-root workspace include the root name to the label before the parent directory.
49
+ if (this.workspaceService.isMultiRootWorkspaceOpened && rootUri) {
50
+ description.push(this.labelProvider.getName(rootUri));
51
+ }
52
+ // If the given resource is not at the workspace root, include the parent directory to the label.
53
+ if ((rootUri === null || rootUri === void 0 ? void 0 : rootUri.toString()) !== node.uri.parent.toString()) {
54
+ description.push(this.labelProvider.getLongName(node.uri.parent));
55
+ }
56
+ return description.join(' ● ');
57
+ }
58
+ getDescription(node) {
59
+ return this.labelProvider.getLongName(node.uri.parent);
60
+ }
61
+ affects(node, event) {
62
+ return event.affects(node.uri) || event.affects(node.uri.parent);
63
+ }
64
+ };
65
+ __decorate([
66
+ (0, inversify_1.inject)(label_provider_1.LabelProvider),
67
+ __metadata("design:type", label_provider_1.LabelProvider)
68
+ ], BulkEditTreeLabelProvider.prototype, "labelProvider", void 0);
69
+ __decorate([
70
+ (0, inversify_1.inject)(tree_label_provider_1.TreeLabelProvider),
71
+ __metadata("design:type", tree_label_provider_1.TreeLabelProvider)
72
+ ], BulkEditTreeLabelProvider.prototype, "treeLabelProvider", void 0);
73
+ __decorate([
74
+ (0, inversify_1.inject)(browser_1.WorkspaceService),
75
+ __metadata("design:type", browser_1.WorkspaceService)
76
+ ], BulkEditTreeLabelProvider.prototype, "workspaceService", void 0);
77
+ BulkEditTreeLabelProvider = __decorate([
78
+ (0, inversify_1.injectable)()
79
+ ], BulkEditTreeLabelProvider);
80
+ exports.BulkEditTreeLabelProvider = BulkEditTreeLabelProvider;
81
81
  //# sourceMappingURL=bulk-edit-tree-label-provider.js.map
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@theia/bulk-edit",
3
- "version": "1.45.0",
3
+ "version": "1.46.0-next.72+4a275b29d",
4
4
  "description": "Theia - Bulk Edit Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.45.0",
7
- "@theia/editor": "1.45.0",
8
- "@theia/filesystem": "1.45.0",
9
- "@theia/monaco": "1.45.0",
10
- "@theia/monaco-editor-core": "1.72.3",
11
- "@theia/workspace": "1.45.0"
6
+ "@theia/core": "1.46.0-next.72+4a275b29d",
7
+ "@theia/editor": "1.46.0-next.72+4a275b29d",
8
+ "@theia/filesystem": "1.46.0-next.72+4a275b29d",
9
+ "@theia/monaco": "1.46.0-next.72+4a275b29d",
10
+ "@theia/monaco-editor-core": "1.83.101",
11
+ "@theia/workspace": "1.46.0-next.72+4a275b29d"
12
12
  },
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -43,10 +43,10 @@
43
43
  "watch": "theiaext watch"
44
44
  },
45
45
  "devDependencies": {
46
- "@theia/ext-scripts": "1.45.0"
46
+ "@theia/ext-scripts": "1.46.0"
47
47
  },
48
48
  "nyc": {
49
49
  "extends": "../../configs/nyc.json"
50
50
  },
51
- "gitHead": "2b20a60a0f9b54b19838a0f71760989a19622495"
51
+ "gitHead": "4a275b29d0db6c81190488c7f76cb667da05ef19"
52
52
  }
@@ -1,34 +1,34 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company 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 { codicon } from '@theia/core/lib/browser';
18
- import { Command } from '@theia/core/lib/common';
19
-
20
- export namespace BulkEditCommands {
21
- export const TOGGLE_VIEW: Command = {
22
- id: 'bulk-edit:toggleView'
23
- };
24
-
25
- export const APPLY: Command = {
26
- id: 'bulk-edit:apply',
27
- iconClass: codicon('check')
28
- };
29
-
30
- export const DISCARD: Command = {
31
- id: 'bulk-edit:discard',
32
- iconClass: codicon('clear-all')
33
- };
34
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company 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 { codicon } from '@theia/core/lib/browser';
18
+ import { Command } from '@theia/core/lib/common';
19
+
20
+ export namespace BulkEditCommands {
21
+ export const TOGGLE_VIEW: Command = {
22
+ id: 'bulk-edit:toggleView'
23
+ };
24
+
25
+ export const APPLY: Command = {
26
+ id: 'bulk-edit:apply',
27
+ iconClass: codicon('check')
28
+ };
29
+
30
+ export const DISCARD: Command = {
31
+ id: 'bulk-edit:discard',
32
+ iconClass: codicon('clear-all')
33
+ };
34
+ }
@@ -1,112 +1,112 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company 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, optional } from '@theia/core/shared/inversify';
18
- import { Widget } from '@theia/core/lib/browser/widgets/widget';
19
- import { CommandRegistry } from '@theia/core/lib/common';
20
- import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
21
- import { BulkEditCommands } from './bulk-edit-commands';
22
- import { MonacoBulkEditService } from '@theia/monaco/lib/browser/monaco-bulk-edit-service';
23
- import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
24
- import { BulkEditTreeWidget, BULK_EDIT_TREE_WIDGET_ID, BULK_EDIT_WIDGET_NAME } from './bulk-edit-tree';
25
- import { QuickViewService } from '@theia/core/lib/browser';
26
- import { nls } from '@theia/core/lib/common/nls';
27
- import { ResourceEdit } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
28
-
29
- @injectable()
30
- export class BulkEditContribution extends AbstractViewContribution<BulkEditTreeWidget> implements TabBarToolbarContribution {
31
- private edits: ResourceEdit[];
32
-
33
- @inject(QuickViewService) @optional()
34
- protected override readonly quickView: QuickViewService;
35
-
36
- constructor(private readonly bulkEditService: MonacoBulkEditService) {
37
- super({
38
- widgetId: BULK_EDIT_TREE_WIDGET_ID,
39
- widgetName: BULK_EDIT_WIDGET_NAME,
40
- defaultWidgetOptions: {
41
- area: 'bottom'
42
- }
43
- });
44
- this.bulkEditService.setPreviewHandler((edits: ResourceEdit[]) => this.previewEdit(edits));
45
- }
46
-
47
- override registerCommands(registry: CommandRegistry): void {
48
- super.registerCommands(registry);
49
- this.quickView?.hideItem(BULK_EDIT_WIDGET_NAME);
50
-
51
- registry.registerCommand(BulkEditCommands.APPLY, {
52
- isEnabled: widget => this.withWidget(widget, () => true),
53
- isVisible: widget => this.withWidget(widget, () => true),
54
- execute: widget => this.withWidget(widget, () => this.apply())
55
- });
56
- registry.registerCommand(BulkEditCommands.DISCARD, {
57
- isEnabled: widget => this.withWidget(widget, () => true),
58
- isVisible: widget => this.withWidget(widget, () => true),
59
- execute: widget => this.withWidget(widget, () => this.discard())
60
- });
61
- }
62
-
63
- async registerToolbarItems(toolbarRegistry: TabBarToolbarRegistry): Promise<void> {
64
- toolbarRegistry.registerItem({
65
- id: BulkEditCommands.APPLY.id,
66
- command: BulkEditCommands.APPLY.id,
67
- tooltip: nls.localizeByDefault('Apply Refactoring'),
68
- priority: 0,
69
- });
70
- toolbarRegistry.registerItem({
71
- id: BulkEditCommands.DISCARD.id,
72
- command: BulkEditCommands.DISCARD.id,
73
- tooltip: nls.localizeByDefault('Discard Refactoring'),
74
- priority: 1,
75
- });
76
- }
77
-
78
- protected withWidget<T>(widget: Widget | undefined = this.tryGetWidget(), cb: (bulkEdit: BulkEditTreeWidget) => T): T | false {
79
- if (widget instanceof BulkEditTreeWidget) {
80
- return cb(widget);
81
- }
82
- return false;
83
- }
84
-
85
- private async previewEdit(edits: ResourceEdit[]): Promise<ResourceEdit[]> {
86
- const widget = await this.openView({ activate: true });
87
-
88
- if (widget) {
89
- this.edits = edits;
90
- await widget.initModel(edits);
91
- }
92
-
93
- return edits;
94
- }
95
-
96
- private apply(): void {
97
- if (this.edits) {
98
- this.edits.forEach(edit => {
99
- if (edit.metadata) {
100
- edit.metadata.needsConfirmation = false;
101
- }
102
- });
103
- this.bulkEditService.apply(this.edits);
104
- }
105
- this.closeView();
106
- }
107
-
108
- private discard(): void {
109
- this.edits = [];
110
- this.closeView();
111
- }
112
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company 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, optional } from '@theia/core/shared/inversify';
18
+ import { Widget } from '@theia/core/lib/browser/widgets/widget';
19
+ import { CommandRegistry } from '@theia/core/lib/common';
20
+ import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
21
+ import { BulkEditCommands } from './bulk-edit-commands';
22
+ import { MonacoBulkEditService } from '@theia/monaco/lib/browser/monaco-bulk-edit-service';
23
+ import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
24
+ import { BulkEditTreeWidget, BULK_EDIT_TREE_WIDGET_ID, BULK_EDIT_WIDGET_NAME } from './bulk-edit-tree';
25
+ import { QuickViewService } from '@theia/core/lib/browser';
26
+ import { nls } from '@theia/core/lib/common/nls';
27
+ import { ResourceEdit } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
28
+
29
+ @injectable()
30
+ export class BulkEditContribution extends AbstractViewContribution<BulkEditTreeWidget> implements TabBarToolbarContribution {
31
+ private edits: ResourceEdit[];
32
+
33
+ @inject(QuickViewService) @optional()
34
+ protected override readonly quickView: QuickViewService;
35
+
36
+ constructor(private readonly bulkEditService: MonacoBulkEditService) {
37
+ super({
38
+ widgetId: BULK_EDIT_TREE_WIDGET_ID,
39
+ widgetName: BULK_EDIT_WIDGET_NAME,
40
+ defaultWidgetOptions: {
41
+ area: 'bottom'
42
+ }
43
+ });
44
+ this.bulkEditService.setPreviewHandler((edits: ResourceEdit[]) => this.previewEdit(edits));
45
+ }
46
+
47
+ override registerCommands(registry: CommandRegistry): void {
48
+ super.registerCommands(registry);
49
+ this.quickView?.hideItem(BULK_EDIT_WIDGET_NAME);
50
+
51
+ registry.registerCommand(BulkEditCommands.APPLY, {
52
+ isEnabled: widget => this.withWidget(widget, () => true),
53
+ isVisible: widget => this.withWidget(widget, () => true),
54
+ execute: widget => this.withWidget(widget, () => this.apply())
55
+ });
56
+ registry.registerCommand(BulkEditCommands.DISCARD, {
57
+ isEnabled: widget => this.withWidget(widget, () => true),
58
+ isVisible: widget => this.withWidget(widget, () => true),
59
+ execute: widget => this.withWidget(widget, () => this.discard())
60
+ });
61
+ }
62
+
63
+ async registerToolbarItems(toolbarRegistry: TabBarToolbarRegistry): Promise<void> {
64
+ toolbarRegistry.registerItem({
65
+ id: BulkEditCommands.APPLY.id,
66
+ command: BulkEditCommands.APPLY.id,
67
+ tooltip: nls.localizeByDefault('Apply Refactoring'),
68
+ priority: 0,
69
+ });
70
+ toolbarRegistry.registerItem({
71
+ id: BulkEditCommands.DISCARD.id,
72
+ command: BulkEditCommands.DISCARD.id,
73
+ tooltip: nls.localizeByDefault('Discard Refactoring'),
74
+ priority: 1,
75
+ });
76
+ }
77
+
78
+ protected withWidget<T>(widget: Widget | undefined = this.tryGetWidget(), cb: (bulkEdit: BulkEditTreeWidget) => T): T | false {
79
+ if (widget instanceof BulkEditTreeWidget) {
80
+ return cb(widget);
81
+ }
82
+ return false;
83
+ }
84
+
85
+ private async previewEdit(edits: ResourceEdit[]): Promise<ResourceEdit[]> {
86
+ const widget = await this.openView({ activate: true });
87
+
88
+ if (widget) {
89
+ this.edits = edits;
90
+ await widget.initModel(edits);
91
+ }
92
+
93
+ return edits;
94
+ }
95
+
96
+ private apply(): void {
97
+ if (this.edits) {
98
+ this.edits.forEach(edit => {
99
+ if (edit.metadata) {
100
+ edit.metadata.needsConfirmation = false;
101
+ }
102
+ });
103
+ this.bulkEditService.apply(this.edits);
104
+ }
105
+ this.closeView();
106
+ }
107
+
108
+ private discard(): void {
109
+ this.edits = [];
110
+ this.closeView();
111
+ }
112
+ }
@@ -1,39 +1,39 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company 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
- import { ContainerModule } from '@theia/core/shared/inversify';
17
- import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
18
- import { BulkEditTreeWidget, BULK_EDIT_TREE_WIDGET_ID, createBulkEditTreeWidget } from './bulk-edit-tree';
19
- import { FrontendApplicationContribution, LabelProviderContribution, bindViewContribution } from '@theia/core/lib/browser';
20
- import { BulkEditContribution } from './bulk-edit-contribution';
21
- import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
22
- import { BulkEditTreeLabelProvider } from './bulk-edit-tree-label-provider';
23
- import '../../src/browser/style/bulk-edit.css';
24
-
25
- export default new ContainerModule(bind => {
26
- bind(BulkEditTreeWidget).toDynamicValue(ctx =>
27
- createBulkEditTreeWidget(ctx.container)
28
- );
29
- bind(WidgetFactory).toDynamicValue(context => ({
30
- id: BULK_EDIT_TREE_WIDGET_ID,
31
- createWidget: () => context.container.get(BulkEditTreeWidget)
32
- }));
33
- bindViewContribution(bind, BulkEditContribution);
34
- bind(FrontendApplicationContribution).toService(BulkEditContribution);
35
- bind(TabBarToolbarContribution).toService(BulkEditContribution);
36
-
37
- bind(BulkEditTreeLabelProvider).toSelf().inSingletonScope();
38
- bind(LabelProviderContribution).toService(BulkEditTreeLabelProvider);
39
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company 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
+ import { ContainerModule } from '@theia/core/shared/inversify';
17
+ import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
18
+ import { BulkEditTreeWidget, BULK_EDIT_TREE_WIDGET_ID, createBulkEditTreeWidget } from './bulk-edit-tree';
19
+ import { FrontendApplicationContribution, LabelProviderContribution, bindViewContribution } from '@theia/core/lib/browser';
20
+ import { BulkEditContribution } from './bulk-edit-contribution';
21
+ import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
22
+ import { BulkEditTreeLabelProvider } from './bulk-edit-tree-label-provider';
23
+ import '../../src/browser/style/bulk-edit.css';
24
+
25
+ export default new ContainerModule(bind => {
26
+ bind(BulkEditTreeWidget).toDynamicValue(ctx =>
27
+ createBulkEditTreeWidget(ctx.container)
28
+ );
29
+ bind(WidgetFactory).toDynamicValue(context => ({
30
+ id: BULK_EDIT_TREE_WIDGET_ID,
31
+ createWidget: () => context.container.get(BulkEditTreeWidget)
32
+ }));
33
+ bindViewContribution(bind, BulkEditContribution);
34
+ bind(FrontendApplicationContribution).toService(BulkEditContribution);
35
+ bind(TabBarToolbarContribution).toService(BulkEditContribution);
36
+
37
+ bind(BulkEditTreeLabelProvider).toSelf().inSingletonScope();
38
+ bind(LabelProviderContribution).toService(BulkEditTreeLabelProvider);
39
+ });