@theia/workspace 1.34.3 → 1.34.4

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 (105) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/browser/diff-service.d.ts +10 -10
  4. package/lib/browser/diff-service.js +85 -85
  5. package/lib/browser/index.d.ts +6 -6
  6. package/lib/browser/index.js +33 -33
  7. package/lib/browser/quick-open-workspace.d.ts +25 -25
  8. package/lib/browser/quick-open-workspace.js +137 -137
  9. package/lib/browser/untitled-workspace-exit-dialog.d.ts +19 -19
  10. package/lib/browser/untitled-workspace-exit-dialog.js +74 -74
  11. package/lib/browser/workspace-breadcrumbs-contribution.d.ts +10 -10
  12. package/lib/browser/workspace-breadcrumbs-contribution.js +66 -66
  13. package/lib/browser/workspace-commands.d.ts +117 -117
  14. package/lib/browser/workspace-commands.js +593 -593
  15. package/lib/browser/workspace-commands.spec.d.ts +1 -1
  16. package/lib/browser/workspace-commands.spec.js +127 -127
  17. package/lib/browser/workspace-compare-handler.d.ts +26 -26
  18. package/lib/browser/workspace-compare-handler.js +66 -66
  19. package/lib/browser/workspace-delete-handler.d.ts +75 -75
  20. package/lib/browser/workspace-delete-handler.js +214 -214
  21. package/lib/browser/workspace-duplicate-handler.d.ts +30 -30
  22. package/lib/browser/workspace-duplicate-handler.js +86 -86
  23. package/lib/browser/workspace-frontend-contribution.d.ts +135 -135
  24. package/lib/browser/workspace-frontend-contribution.js +568 -568
  25. package/lib/browser/workspace-frontend-contribution.spec.d.ts +1 -1
  26. package/lib/browser/workspace-frontend-contribution.spec.js +53 -53
  27. package/lib/browser/workspace-frontend-module.d.ts +3 -3
  28. package/lib/browser/workspace-frontend-module.js +88 -88
  29. package/lib/browser/workspace-input-dialog.d.ts +19 -19
  30. package/lib/browser/workspace-input-dialog.js +73 -73
  31. package/lib/browser/workspace-preferences.d.ts +11 -11
  32. package/lib/browser/workspace-preferences.js +46 -46
  33. package/lib/browser/workspace-schema-updater.d.ts +32 -32
  34. package/lib/browser/workspace-schema-updater.js +148 -148
  35. package/lib/browser/workspace-service.d.ts +182 -182
  36. package/lib/browser/workspace-service.js +729 -729
  37. package/lib/browser/workspace-storage-service.d.ts +15 -15
  38. package/lib/browser/workspace-storage-service.js +80 -80
  39. package/lib/browser/workspace-trust-preferences.d.ts +21 -21
  40. package/lib/browser/workspace-trust-preferences.js +65 -65
  41. package/lib/browser/workspace-trust-service.d.ts +26 -26
  42. package/lib/browser/workspace-trust-service.js +149 -149
  43. package/lib/browser/workspace-uri-contribution.d.ts +20 -20
  44. package/lib/browser/workspace-uri-contribution.js +113 -113
  45. package/lib/browser/workspace-uri-contribution.spec.d.ts +1 -1
  46. package/lib/browser/workspace-uri-contribution.spec.js +169 -169
  47. package/lib/browser/workspace-user-working-directory-provider.d.ts +12 -12
  48. package/lib/browser/workspace-user-working-directory-provider.js +62 -62
  49. package/lib/browser/workspace-utils.d.ts +15 -15
  50. package/lib/browser/workspace-utils.js +54 -54
  51. package/lib/browser/workspace-variable-contribution.d.ts +23 -23
  52. package/lib/browser/workspace-variable-contribution.js +237 -237
  53. package/lib/browser/workspace-window-title-updater.d.ts +7 -7
  54. package/lib/browser/workspace-window-title-updater.js +57 -57
  55. package/lib/common/index.d.ts +2 -2
  56. package/lib/common/index.js +29 -29
  57. package/lib/common/test/mock-workspace-server.d.ts +7 -7
  58. package/lib/common/test/mock-workspace-server.js +35 -35
  59. package/lib/common/utils.d.ts +21 -21
  60. package/lib/common/utils.js +73 -73
  61. package/lib/common/workspace-protocol.d.ts +26 -26
  62. package/lib/common/workspace-protocol.js +23 -23
  63. package/lib/node/default-workspace-server.d.ts +64 -64
  64. package/lib/node/default-workspace-server.js +248 -248
  65. package/lib/node/default-workspace-server.spec.d.ts +1 -1
  66. package/lib/node/default-workspace-server.spec.js +84 -84
  67. package/lib/node/index.d.ts +2 -2
  68. package/lib/node/index.js +29 -29
  69. package/lib/node/workspace-backend-module.d.ts +3 -3
  70. package/lib/node/workspace-backend-module.js +32 -32
  71. package/package.json +6 -6
  72. package/src/browser/diff-service.ts +62 -62
  73. package/src/browser/index.ts +22 -22
  74. package/src/browser/quick-open-workspace.ts +112 -112
  75. package/src/browser/untitled-workspace-exit-dialog.ts +70 -70
  76. package/src/browser/workspace-breadcrumbs-contribution.ts +56 -56
  77. package/src/browser/workspace-commands.spec.ts +153 -153
  78. package/src/browser/workspace-commands.ts +586 -586
  79. package/src/browser/workspace-compare-handler.ts +56 -56
  80. package/src/browser/workspace-delete-handler.ts +212 -212
  81. package/src/browser/workspace-duplicate-handler.ts +75 -75
  82. package/src/browser/workspace-frontend-contribution.spec.ts +63 -63
  83. package/src/browser/workspace-frontend-contribution.ts +558 -558
  84. package/src/browser/workspace-frontend-module.ts +115 -115
  85. package/src/browser/workspace-input-dialog.ts +60 -60
  86. package/src/browser/workspace-preferences.ts +58 -58
  87. package/src/browser/workspace-schema-updater.ts +148 -148
  88. package/src/browser/workspace-service.ts +772 -772
  89. package/src/browser/workspace-storage-service.ts +67 -67
  90. package/src/browser/workspace-trust-preferences.ts +76 -76
  91. package/src/browser/workspace-trust-service.ts +143 -143
  92. package/src/browser/workspace-uri-contribution.spec.ts +191 -191
  93. package/src/browser/workspace-uri-contribution.ts +97 -97
  94. package/src/browser/workspace-user-working-directory-provider.ts +48 -48
  95. package/src/browser/workspace-utils.ts +45 -45
  96. package/src/browser/workspace-variable-contribution.ts +222 -222
  97. package/src/browser/workspace-window-title-updater.ts +45 -45
  98. package/src/common/index.ts +18 -18
  99. package/src/common/test/mock-workspace-server.ts +29 -29
  100. package/src/common/utils.ts +69 -69
  101. package/src/common/workspace-protocol.ts +47 -47
  102. package/src/node/default-workspace-server.spec.ts +99 -99
  103. package/src/node/default-workspace-server.ts +242 -242
  104. package/src/node/index.ts +18 -18
  105. package/src/node/workspace-backend-module.ts +37 -37
@@ -1,215 +1,215 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 TypeFox 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 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.WorkspaceDeleteHandler = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const uri_1 = require("@theia/core/lib/common/uri");
30
- const browser_1 = require("@theia/core/lib/browser");
31
- const workspace_service_1 = require("./workspace-service");
32
- const workspace_utils_1 = require("./workspace-utils");
33
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
34
- const filesystem_preferences_1 = require("@theia/filesystem/lib/browser/filesystem-preferences");
35
- const nls_1 = require("@theia/core/lib/common/nls");
36
- let WorkspaceDeleteHandler = class WorkspaceDeleteHandler {
37
- /**
38
- * Determine if the command is visible.
39
- *
40
- * @param uris URIs of selected resources.
41
- * @returns `true` if the command is visible.
42
- */
43
- isVisible(uris) {
44
- return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
45
- }
46
- /**
47
- * Determine if the command is enabled.
48
- *
49
- * @param uris URIs of selected resources.
50
- * @returns `true` if the command is enabled.
51
- */
52
- isEnabled(uris) {
53
- return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
54
- }
55
- /**
56
- * Execute the command.
57
- *
58
- * @param uris URIs of selected resources.
59
- */
60
- async execute(uris) {
61
- const distinctUris = uri_1.default.getDistinctParents(uris);
62
- const resolved = {
63
- recursive: true,
64
- useTrash: this.fsPreferences['files.enableTrash'] && distinctUris[0] && this.fileService.hasCapability(distinctUris[0], 4096 /* Trash */)
65
- };
66
- if (await this.confirm(distinctUris, resolved)) {
67
- await Promise.all(distinctUris.map(uri => this.delete(uri, resolved)));
68
- }
69
- }
70
- /**
71
- * Display dialog to confirm deletion.
72
- *
73
- * @param uris URIs of selected resources.
74
- */
75
- confirm(uris, options) {
76
- let title = uris.length === 1 ? nls_1.nls.localizeByDefault('File') : nls_1.nls.localizeByDefault('Files');
77
- if (options.useTrash) {
78
- title = nls_1.nls.localize('theia/workspace/trashTitle', 'Move {0} to Trash', title);
79
- }
80
- else {
81
- title = nls_1.nls.localizeByDefault('Delete {0}', title);
82
- }
83
- return new browser_1.ConfirmDialog({
84
- title,
85
- msg: this.getConfirmMessage(uris)
86
- }).open();
87
- }
88
- /**
89
- * Get the dialog confirmation message for deletion.
90
- *
91
- * @param uris URIs of selected resources.
92
- */
93
- getConfirmMessage(uris) {
94
- const dirty = this.getDirty(uris);
95
- if (dirty.length) {
96
- if (dirty.length === 1) {
97
- return nls_1.nls.localize('theia/workspace/confirmMessage.dirtySingle', 'Do you really want to delete {0} with unsaved changes?', dirty[0].path.base);
98
- }
99
- return nls_1.nls.localize('theia/workspace/confirmMessage.dirtyMultiple', 'Do you really want to delete {0} files with unsaved changes?', dirty.length);
100
- }
101
- if (uris.length === 1) {
102
- return nls_1.nls.localize('theia/workspace/confirmMessage.uriSingle', 'Do you really want to delete {0}?', uris[0].path.base);
103
- }
104
- if (uris.length > 10) {
105
- return nls_1.nls.localize('theia/workspace/confirmMessage.uriMultiple', 'Do you really want to delete all the {0} selected files?', uris.length);
106
- }
107
- const messageContainer = document.createElement('div');
108
- messageContainer.textContent = nls_1.nls.localize('theia/workspace/confirmMessage.delete', 'Do you really want to delete the following files?');
109
- const list = document.createElement('ul');
110
- list.style.listStyleType = 'none';
111
- for (const uri of uris) {
112
- const listItem = document.createElement('li');
113
- listItem.textContent = uri.path.base;
114
- list.appendChild(listItem);
115
- }
116
- messageContainer.appendChild(list);
117
- return messageContainer;
118
- }
119
- /**
120
- * Get which URI are presently dirty.
121
- *
122
- * @param uris URIs of selected resources.
123
- * @returns An array of dirty URI.
124
- */
125
- getDirty(uris) {
126
- const dirty = new Map();
127
- const widgets = browser_1.NavigatableWidget.getAffected(browser_1.SaveableWidget.getDirty(this.shell.widgets), uris);
128
- for (const [resourceUri] of widgets) {
129
- dirty.set(resourceUri.toString(), resourceUri);
130
- }
131
- return [...dirty.values()];
132
- }
133
- /**
134
- * Perform deletion of a given URI.
135
- *
136
- * @param uri URI of selected resource.
137
- * @param options deletion options.
138
- */
139
- async delete(uri, options) {
140
- try {
141
- await Promise.all([
142
- this.closeWithoutSaving(uri),
143
- options.useTrash ? this.moveFileToTrash(uri, options) : this.deleteFilePermanently(uri, options)
144
- ]);
145
- }
146
- catch (e) {
147
- console.error(e);
148
- }
149
- }
150
- async deleteFilePermanently(uri, options) {
151
- this.fileService.delete(uri, Object.assign(Object.assign({}, options), { useTrash: false }));
152
- }
153
- async moveFileToTrash(uri, options) {
154
- try {
155
- this.fileService.delete(uri, Object.assign(Object.assign({}, options), { useTrash: true }));
156
- }
157
- catch (error) {
158
- console.error('Error deleting with trash:', error);
159
- if (await this.confirmDeletePermanently(uri)) {
160
- return this.deleteFilePermanently(uri, options);
161
- }
162
- }
163
- }
164
- /**
165
- * Display dialog to confirm the permanent deletion of a file.
166
- *
167
- * @param uri URI of selected resource.
168
- */
169
- async confirmDeletePermanently(uri) {
170
- const title = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.title', 'Error deleting file');
171
- const msg = document.createElement('div');
172
- const question = document.createElement('p');
173
- question.textContent = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.description', 'Failed to delete "{0}" using the Trash. Do you want to permanently delete instead?', uri.path.base);
174
- msg.append(question);
175
- const info = document.createElement('p');
176
- info.textContent = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.solution', 'You can disable the use of Trash in the preferences.');
177
- msg.append(info);
178
- const response = await new browser_1.ConfirmDialog({ title, msg }).open();
179
- return response || false;
180
- }
181
- /**
182
- * Close widget without saving changes.
183
- *
184
- * @param uri URI of a selected resource.
185
- */
186
- async closeWithoutSaving(uri) {
187
- const toClose = [...browser_1.NavigatableWidget.getAffected(this.shell.widgets, uri)].map(([, widget]) => widget);
188
- await this.shell.closeMany(toClose, { save: false });
189
- }
190
- };
191
- __decorate([
192
- (0, inversify_1.inject)(file_service_1.FileService),
193
- __metadata("design:type", file_service_1.FileService)
194
- ], WorkspaceDeleteHandler.prototype, "fileService", void 0);
195
- __decorate([
196
- (0, inversify_1.inject)(browser_1.ApplicationShell),
197
- __metadata("design:type", browser_1.ApplicationShell)
198
- ], WorkspaceDeleteHandler.prototype, "shell", void 0);
199
- __decorate([
200
- (0, inversify_1.inject)(workspace_utils_1.WorkspaceUtils),
201
- __metadata("design:type", workspace_utils_1.WorkspaceUtils)
202
- ], WorkspaceDeleteHandler.prototype, "workspaceUtils", void 0);
203
- __decorate([
204
- (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
205
- __metadata("design:type", workspace_service_1.WorkspaceService)
206
- ], WorkspaceDeleteHandler.prototype, "workspaceService", void 0);
207
- __decorate([
208
- (0, inversify_1.inject)(filesystem_preferences_1.FileSystemPreferences),
209
- __metadata("design:type", Object)
210
- ], WorkspaceDeleteHandler.prototype, "fsPreferences", void 0);
211
- WorkspaceDeleteHandler = __decorate([
212
- (0, inversify_1.injectable)()
213
- ], WorkspaceDeleteHandler);
214
- exports.WorkspaceDeleteHandler = WorkspaceDeleteHandler;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 TypeFox 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 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.WorkspaceDeleteHandler = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const uri_1 = require("@theia/core/lib/common/uri");
30
+ const browser_1 = require("@theia/core/lib/browser");
31
+ const workspace_service_1 = require("./workspace-service");
32
+ const workspace_utils_1 = require("./workspace-utils");
33
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
34
+ const filesystem_preferences_1 = require("@theia/filesystem/lib/browser/filesystem-preferences");
35
+ const nls_1 = require("@theia/core/lib/common/nls");
36
+ let WorkspaceDeleteHandler = class WorkspaceDeleteHandler {
37
+ /**
38
+ * Determine if the command is visible.
39
+ *
40
+ * @param uris URIs of selected resources.
41
+ * @returns `true` if the command is visible.
42
+ */
43
+ isVisible(uris) {
44
+ return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
45
+ }
46
+ /**
47
+ * Determine if the command is enabled.
48
+ *
49
+ * @param uris URIs of selected resources.
50
+ * @returns `true` if the command is enabled.
51
+ */
52
+ isEnabled(uris) {
53
+ return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
54
+ }
55
+ /**
56
+ * Execute the command.
57
+ *
58
+ * @param uris URIs of selected resources.
59
+ */
60
+ async execute(uris) {
61
+ const distinctUris = uri_1.default.getDistinctParents(uris);
62
+ const resolved = {
63
+ recursive: true,
64
+ useTrash: this.fsPreferences['files.enableTrash'] && distinctUris[0] && this.fileService.hasCapability(distinctUris[0], 4096 /* Trash */)
65
+ };
66
+ if (await this.confirm(distinctUris, resolved)) {
67
+ await Promise.all(distinctUris.map(uri => this.delete(uri, resolved)));
68
+ }
69
+ }
70
+ /**
71
+ * Display dialog to confirm deletion.
72
+ *
73
+ * @param uris URIs of selected resources.
74
+ */
75
+ confirm(uris, options) {
76
+ let title = uris.length === 1 ? nls_1.nls.localizeByDefault('File') : nls_1.nls.localizeByDefault('Files');
77
+ if (options.useTrash) {
78
+ title = nls_1.nls.localize('theia/workspace/trashTitle', 'Move {0} to Trash', title);
79
+ }
80
+ else {
81
+ title = nls_1.nls.localizeByDefault('Delete {0}', title);
82
+ }
83
+ return new browser_1.ConfirmDialog({
84
+ title,
85
+ msg: this.getConfirmMessage(uris)
86
+ }).open();
87
+ }
88
+ /**
89
+ * Get the dialog confirmation message for deletion.
90
+ *
91
+ * @param uris URIs of selected resources.
92
+ */
93
+ getConfirmMessage(uris) {
94
+ const dirty = this.getDirty(uris);
95
+ if (dirty.length) {
96
+ if (dirty.length === 1) {
97
+ return nls_1.nls.localize('theia/workspace/confirmMessage.dirtySingle', 'Do you really want to delete {0} with unsaved changes?', dirty[0].path.base);
98
+ }
99
+ return nls_1.nls.localize('theia/workspace/confirmMessage.dirtyMultiple', 'Do you really want to delete {0} files with unsaved changes?', dirty.length);
100
+ }
101
+ if (uris.length === 1) {
102
+ return nls_1.nls.localize('theia/workspace/confirmMessage.uriSingle', 'Do you really want to delete {0}?', uris[0].path.base);
103
+ }
104
+ if (uris.length > 10) {
105
+ return nls_1.nls.localize('theia/workspace/confirmMessage.uriMultiple', 'Do you really want to delete all the {0} selected files?', uris.length);
106
+ }
107
+ const messageContainer = document.createElement('div');
108
+ messageContainer.textContent = nls_1.nls.localize('theia/workspace/confirmMessage.delete', 'Do you really want to delete the following files?');
109
+ const list = document.createElement('ul');
110
+ list.style.listStyleType = 'none';
111
+ for (const uri of uris) {
112
+ const listItem = document.createElement('li');
113
+ listItem.textContent = uri.path.base;
114
+ list.appendChild(listItem);
115
+ }
116
+ messageContainer.appendChild(list);
117
+ return messageContainer;
118
+ }
119
+ /**
120
+ * Get which URI are presently dirty.
121
+ *
122
+ * @param uris URIs of selected resources.
123
+ * @returns An array of dirty URI.
124
+ */
125
+ getDirty(uris) {
126
+ const dirty = new Map();
127
+ const widgets = browser_1.NavigatableWidget.getAffected(browser_1.SaveableWidget.getDirty(this.shell.widgets), uris);
128
+ for (const [resourceUri] of widgets) {
129
+ dirty.set(resourceUri.toString(), resourceUri);
130
+ }
131
+ return [...dirty.values()];
132
+ }
133
+ /**
134
+ * Perform deletion of a given URI.
135
+ *
136
+ * @param uri URI of selected resource.
137
+ * @param options deletion options.
138
+ */
139
+ async delete(uri, options) {
140
+ try {
141
+ await Promise.all([
142
+ this.closeWithoutSaving(uri),
143
+ options.useTrash ? this.moveFileToTrash(uri, options) : this.deleteFilePermanently(uri, options)
144
+ ]);
145
+ }
146
+ catch (e) {
147
+ console.error(e);
148
+ }
149
+ }
150
+ async deleteFilePermanently(uri, options) {
151
+ this.fileService.delete(uri, Object.assign(Object.assign({}, options), { useTrash: false }));
152
+ }
153
+ async moveFileToTrash(uri, options) {
154
+ try {
155
+ this.fileService.delete(uri, Object.assign(Object.assign({}, options), { useTrash: true }));
156
+ }
157
+ catch (error) {
158
+ console.error('Error deleting with trash:', error);
159
+ if (await this.confirmDeletePermanently(uri)) {
160
+ return this.deleteFilePermanently(uri, options);
161
+ }
162
+ }
163
+ }
164
+ /**
165
+ * Display dialog to confirm the permanent deletion of a file.
166
+ *
167
+ * @param uri URI of selected resource.
168
+ */
169
+ async confirmDeletePermanently(uri) {
170
+ const title = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.title', 'Error deleting file');
171
+ const msg = document.createElement('div');
172
+ const question = document.createElement('p');
173
+ question.textContent = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.description', 'Failed to delete "{0}" using the Trash. Do you want to permanently delete instead?', uri.path.base);
174
+ msg.append(question);
175
+ const info = document.createElement('p');
176
+ info.textContent = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.solution', 'You can disable the use of Trash in the preferences.');
177
+ msg.append(info);
178
+ const response = await new browser_1.ConfirmDialog({ title, msg }).open();
179
+ return response || false;
180
+ }
181
+ /**
182
+ * Close widget without saving changes.
183
+ *
184
+ * @param uri URI of a selected resource.
185
+ */
186
+ async closeWithoutSaving(uri) {
187
+ const toClose = [...browser_1.NavigatableWidget.getAffected(this.shell.widgets, uri)].map(([, widget]) => widget);
188
+ await this.shell.closeMany(toClose, { save: false });
189
+ }
190
+ };
191
+ __decorate([
192
+ (0, inversify_1.inject)(file_service_1.FileService),
193
+ __metadata("design:type", file_service_1.FileService)
194
+ ], WorkspaceDeleteHandler.prototype, "fileService", void 0);
195
+ __decorate([
196
+ (0, inversify_1.inject)(browser_1.ApplicationShell),
197
+ __metadata("design:type", browser_1.ApplicationShell)
198
+ ], WorkspaceDeleteHandler.prototype, "shell", void 0);
199
+ __decorate([
200
+ (0, inversify_1.inject)(workspace_utils_1.WorkspaceUtils),
201
+ __metadata("design:type", workspace_utils_1.WorkspaceUtils)
202
+ ], WorkspaceDeleteHandler.prototype, "workspaceUtils", void 0);
203
+ __decorate([
204
+ (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
205
+ __metadata("design:type", workspace_service_1.WorkspaceService)
206
+ ], WorkspaceDeleteHandler.prototype, "workspaceService", void 0);
207
+ __decorate([
208
+ (0, inversify_1.inject)(filesystem_preferences_1.FileSystemPreferences),
209
+ __metadata("design:type", Object)
210
+ ], WorkspaceDeleteHandler.prototype, "fsPreferences", void 0);
211
+ WorkspaceDeleteHandler = __decorate([
212
+ (0, inversify_1.injectable)()
213
+ ], WorkspaceDeleteHandler);
214
+ exports.WorkspaceDeleteHandler = WorkspaceDeleteHandler;
215
215
  //# sourceMappingURL=workspace-delete-handler.js.map
@@ -1,31 +1,31 @@
1
- import URI from '@theia/core/lib/common/uri';
2
- import { WorkspaceUtils } from './workspace-utils';
3
- import { WorkspaceService } from './workspace-service';
4
- import { UriCommandHandler } from '@theia/core/lib/common/uri-command-handler';
5
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
6
- export declare class WorkspaceDuplicateHandler implements UriCommandHandler<URI[]> {
7
- protected readonly fileService: FileService;
8
- protected readonly workspaceUtils: WorkspaceUtils;
9
- protected readonly workspaceService: WorkspaceService;
10
- /**
11
- * Determine if the command is visible.
12
- *
13
- * @param uris URIs of selected resources.
14
- * @returns `true` if the command is visible.
15
- */
16
- isVisible(uris: URI[]): boolean;
17
- /**
18
- * Determine if the command is enabled.
19
- *
20
- * @param uris URIs of selected resources.
21
- * @returns `true` if the command is enabled.
22
- */
23
- isEnabled(uris: URI[]): boolean;
24
- /**
25
- * Execute the command.
26
- *
27
- * @param uris URIs of selected resources.
28
- */
29
- execute(uris: URI[]): Promise<void>;
30
- }
1
+ import URI from '@theia/core/lib/common/uri';
2
+ import { WorkspaceUtils } from './workspace-utils';
3
+ import { WorkspaceService } from './workspace-service';
4
+ import { UriCommandHandler } from '@theia/core/lib/common/uri-command-handler';
5
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
6
+ export declare class WorkspaceDuplicateHandler implements UriCommandHandler<URI[]> {
7
+ protected readonly fileService: FileService;
8
+ protected readonly workspaceUtils: WorkspaceUtils;
9
+ protected readonly workspaceService: WorkspaceService;
10
+ /**
11
+ * Determine if the command is visible.
12
+ *
13
+ * @param uris URIs of selected resources.
14
+ * @returns `true` if the command is visible.
15
+ */
16
+ isVisible(uris: URI[]): boolean;
17
+ /**
18
+ * Determine if the command is enabled.
19
+ *
20
+ * @param uris URIs of selected resources.
21
+ * @returns `true` if the command is enabled.
22
+ */
23
+ isEnabled(uris: URI[]): boolean;
24
+ /**
25
+ * Execute the command.
26
+ *
27
+ * @param uris URIs of selected resources.
28
+ */
29
+ execute(uris: URI[]): Promise<void>;
30
+ }
31
31
  //# sourceMappingURL=workspace-duplicate-handler.d.ts.map