@theia/workspace 1.67.0-next.56 → 1.67.0-next.86
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.
- package/lib/browser/canonical-uri-service.d.ts +12 -0
- package/lib/browser/canonical-uri-service.d.ts.map +1 -0
- package/lib/browser/canonical-uri-service.js +55 -0
- package/lib/browser/canonical-uri-service.js.map +1 -0
- package/lib/browser/diff-service.d.ts +11 -0
- package/lib/browser/diff-service.d.ts.map +1 -0
- package/lib/browser/diff-service.js +69 -0
- package/lib/browser/diff-service.js.map +1 -0
- package/lib/browser/index.d.ts +7 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +25 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/quick-open-workspace.d.ts +18 -0
- package/lib/browser/quick-open-workspace.d.ts.map +1 -0
- package/lib/browser/quick-open-workspace.js +112 -0
- package/lib/browser/quick-open-workspace.js.map +1 -0
- package/lib/browser/untitled-workspace-exit-dialog.d.ts +20 -0
- package/lib/browser/untitled-workspace-exit-dialog.d.ts.map +1 -0
- package/lib/browser/untitled-workspace-exit-dialog.js +64 -0
- package/lib/browser/untitled-workspace-exit-dialog.js.map +1 -0
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts +11 -0
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts.map +1 -0
- package/lib/browser/workspace-breadcrumbs-contribution.js +59 -0
- package/lib/browser/workspace-breadcrumbs-contribution.js.map +1 -0
- package/lib/browser/workspace-commands.d.ts +116 -0
- package/lib/browser/workspace-commands.d.ts.map +1 -0
- package/lib/browser/workspace-commands.js +568 -0
- package/lib/browser/workspace-commands.js.map +1 -0
- package/lib/browser/workspace-commands.spec.d.ts +2 -0
- package/lib/browser/workspace-commands.spec.d.ts.map +1 -0
- package/lib/browser/workspace-commands.spec.js +128 -0
- package/lib/browser/workspace-commands.spec.js.map +1 -0
- package/lib/browser/workspace-compare-handler.d.ts +27 -0
- package/lib/browser/workspace-compare-handler.d.ts.map +1 -0
- package/lib/browser/workspace-compare-handler.js +59 -0
- package/lib/browser/workspace-compare-handler.js.map +1 -0
- package/lib/browser/workspace-delete-handler.d.ts +76 -0
- package/lib/browser/workspace-delete-handler.d.ts.map +1 -0
- package/lib/browser/workspace-delete-handler.js +207 -0
- package/lib/browser/workspace-delete-handler.js.map +1 -0
- package/lib/browser/workspace-duplicate-handler.d.ts +31 -0
- package/lib/browser/workspace-duplicate-handler.d.ts.map +1 -0
- package/lib/browser/workspace-duplicate-handler.js +79 -0
- package/lib/browser/workspace-duplicate-handler.js.map +1 -0
- package/lib/browser/workspace-frontend-contribution.d.ts +111 -0
- package/lib/browser/workspace-frontend-contribution.d.ts.map +1 -0
- package/lib/browser/workspace-frontend-contribution.js +538 -0
- package/lib/browser/workspace-frontend-contribution.js.map +1 -0
- package/lib/browser/workspace-frontend-module.d.ts +4 -0
- package/lib/browser/workspace-frontend-module.d.ts.map +1 -0
- package/lib/browser/workspace-frontend-module.js +93 -0
- package/lib/browser/workspace-frontend-module.js.map +1 -0
- package/lib/browser/workspace-input-dialog.d.ts +20 -0
- package/lib/browser/workspace-input-dialog.d.ts.map +1 -0
- package/lib/browser/workspace-input-dialog.js +64 -0
- package/lib/browser/workspace-input-dialog.js.map +1 -0
- package/lib/browser/workspace-schema-updater.d.ts +34 -0
- package/lib/browser/workspace-schema-updater.d.ts.map +1 -0
- package/lib/browser/workspace-schema-updater.js +147 -0
- package/lib/browser/workspace-schema-updater.js.map +1 -0
- package/lib/browser/workspace-service.d.ts +201 -0
- package/lib/browser/workspace-service.d.ts.map +1 -0
- package/lib/browser/workspace-service.js +758 -0
- package/lib/browser/workspace-service.js.map +1 -0
- package/lib/browser/workspace-storage-service.d.ts +16 -0
- package/lib/browser/workspace-storage-service.d.ts.map +1 -0
- package/lib/browser/workspace-storage-service.js +73 -0
- package/lib/browser/workspace-storage-service.js.map +1 -0
- package/lib/browser/workspace-trust-service.d.ts +30 -0
- package/lib/browser/workspace-trust-service.d.ts.map +1 -0
- package/lib/browser/workspace-trust-service.js +153 -0
- package/lib/browser/workspace-trust-service.js.map +1 -0
- package/lib/browser/workspace-uri-contribution.d.ts +21 -0
- package/lib/browser/workspace-uri-contribution.d.ts.map +1 -0
- package/lib/browser/workspace-uri-contribution.js +106 -0
- package/lib/browser/workspace-uri-contribution.js.map +1 -0
- package/lib/browser/workspace-uri-contribution.spec.d.ts +2 -0
- package/lib/browser/workspace-uri-contribution.spec.d.ts.map +1 -0
- package/lib/browser/workspace-uri-contribution.spec.js +170 -0
- package/lib/browser/workspace-uri-contribution.spec.js.map +1 -0
- package/lib/browser/workspace-user-working-directory-provider.d.ts +13 -0
- package/lib/browser/workspace-user-working-directory-provider.d.ts.map +1 -0
- package/lib/browser/workspace-user-working-directory-provider.js +55 -0
- package/lib/browser/workspace-user-working-directory-provider.js.map +1 -0
- package/lib/browser/workspace-utils.d.ts +16 -0
- package/lib/browser/workspace-utils.d.ts.map +1 -0
- package/lib/browser/workspace-utils.js +47 -0
- package/lib/browser/workspace-utils.js.map +1 -0
- package/lib/browser/workspace-variable-contribution.d.ts +24 -0
- package/lib/browser/workspace-variable-contribution.d.ts.map +1 -0
- package/lib/browser/workspace-variable-contribution.js +231 -0
- package/lib/browser/workspace-variable-contribution.js.map +1 -0
- package/lib/browser/workspace-window-title-updater.d.ts +8 -0
- package/lib/browser/workspace-window-title-updater.d.ts.map +1 -0
- package/lib/browser/workspace-window-title-updater.js +50 -0
- package/lib/browser/workspace-window-title-updater.js.map +1 -0
- package/lib/browser-only/browser-only-workspace-server.d.ts +13 -0
- package/lib/browser-only/browser-only-workspace-server.d.ts.map +1 -0
- package/lib/browser-only/browser-only-workspace-server.js +73 -0
- package/lib/browser-only/browser-only-workspace-server.js.map +1 -0
- package/lib/browser-only/workspace-frontend-only-module.d.ts +4 -0
- package/lib/browser-only/workspace-frontend-only-module.d.ts.map +1 -0
- package/lib/browser-only/workspace-frontend-only-module.js +30 -0
- package/lib/browser-only/workspace-frontend-only-module.js.map +1 -0
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +23 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/test/mock-workspace-server.d.ts +8 -0
- package/lib/common/test/mock-workspace-server.d.ts.map +1 -0
- package/lib/common/test/mock-workspace-server.js +31 -0
- package/lib/common/test/mock-workspace-server.js.map +1 -0
- package/lib/common/untitled-workspace-service.d.ts +9 -0
- package/lib/common/untitled-workspace-service.d.ts.map +1 -0
- package/lib/common/untitled-workspace-service.js +53 -0
- package/lib/common/untitled-workspace-service.js.map +1 -0
- package/lib/common/workspace-file-service.d.ts +27 -0
- package/lib/common/workspace-file-service.d.ts.map +1 -0
- package/lib/common/workspace-file-service.js +67 -0
- package/lib/common/workspace-file-service.js.map +1 -0
- package/lib/common/workspace-preferences.d.ts +12 -0
- package/lib/common/workspace-preferences.d.ts.map +1 -0
- package/lib/common/workspace-preferences.js +46 -0
- package/lib/common/workspace-preferences.js.map +1 -0
- package/lib/common/workspace-protocol.d.ts +27 -0
- package/lib/common/workspace-protocol.d.ts.map +1 -0
- package/lib/common/workspace-protocol.js +24 -0
- package/lib/common/workspace-protocol.js.map +1 -0
- package/lib/common/workspace-trust-preferences.d.ts +22 -0
- package/lib/common/workspace-trust-preferences.d.ts.map +1 -0
- package/lib/common/workspace-trust-preferences.js +66 -0
- package/lib/common/workspace-trust-preferences.js.map +1 -0
- package/lib/node/default-workspace-server.d.ts +78 -0
- package/lib/node/default-workspace-server.d.ts.map +1 -0
- package/lib/node/default-workspace-server.js +265 -0
- package/lib/node/default-workspace-server.js.map +1 -0
- package/lib/node/default-workspace-server.spec.d.ts +2 -0
- package/lib/node/default-workspace-server.spec.d.ts.map +1 -0
- package/lib/node/default-workspace-server.spec.js +96 -0
- package/lib/node/default-workspace-server.spec.js.map +1 -0
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +21 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/workspace-backend-module.d.ts +4 -0
- package/lib/node/workspace-backend-module.d.ts.map +1 -0
- package/lib/node/workspace-backend-module.js +40 -0
- package/lib/node/workspace-backend-module.js.map +1 -0
- package/package.json +5 -5
- package/src/browser/workspace-service.ts +5 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2021 Ericsson 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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
|
|
19
|
+
let disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
|
20
|
+
const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
|
|
21
|
+
frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
|
|
22
|
+
const chai_1 = require("chai");
|
|
23
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
24
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
25
|
+
const browser_1 = require("@theia/filesystem/lib/browser");
|
|
26
|
+
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
27
|
+
const browser_2 = require("@theia/core/lib/browser");
|
|
28
|
+
const common_1 = require("@theia/core/lib/common");
|
|
29
|
+
const selection_service_1 = require("@theia/core/lib/common/selection-service");
|
|
30
|
+
const workspace_commands_1 = require("./workspace-commands");
|
|
31
|
+
const workspace_compare_handler_1 = require("./workspace-compare-handler");
|
|
32
|
+
const workspace_delete_handler_1 = require("./workspace-delete-handler");
|
|
33
|
+
const workspace_duplicate_handler_1 = require("./workspace-duplicate-handler");
|
|
34
|
+
const workspace_preferences_1 = require("../common/workspace-preferences");
|
|
35
|
+
const workspace_service_1 = require("./workspace-service");
|
|
36
|
+
const application_protocol_1 = require("@theia/core/lib/common/application-protocol");
|
|
37
|
+
const clipboard_service_1 = require("@theia/core/lib/browser/clipboard-service");
|
|
38
|
+
disableJSDOM();
|
|
39
|
+
describe('workspace-commands', () => {
|
|
40
|
+
let commands;
|
|
41
|
+
const childStat = {
|
|
42
|
+
isFile: true,
|
|
43
|
+
isDirectory: false,
|
|
44
|
+
isSymbolicLink: false,
|
|
45
|
+
isReadonly: false,
|
|
46
|
+
resource: new uri_1.default('foo/bar'),
|
|
47
|
+
name: 'bar',
|
|
48
|
+
};
|
|
49
|
+
const parent = {
|
|
50
|
+
isFile: false,
|
|
51
|
+
isDirectory: true,
|
|
52
|
+
isSymbolicLink: false,
|
|
53
|
+
isReadonly: false,
|
|
54
|
+
resource: new uri_1.default('foo'),
|
|
55
|
+
name: 'foo',
|
|
56
|
+
children: [
|
|
57
|
+
childStat
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
before(() => disableJSDOM = (0, jsdom_1.enableJSDOM)());
|
|
61
|
+
after(() => disableJSDOM());
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
const container = new inversify_1.Container();
|
|
64
|
+
container.bind(browser_1.FileDialogService).toConstantValue({});
|
|
65
|
+
container.bind(file_service_1.FileService).toConstantValue({
|
|
66
|
+
async exists(resource) {
|
|
67
|
+
return resource.path.base.includes('bar'); // 'bar' exists for test purposes.
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
container.bind(browser_2.FrontendApplication).toConstantValue({});
|
|
71
|
+
container.bind(browser_2.LabelProvider).toConstantValue({});
|
|
72
|
+
container.bind(common_1.MessageService).toConstantValue({});
|
|
73
|
+
container.bind(browser_2.OpenerService).toConstantValue({});
|
|
74
|
+
container.bind(selection_service_1.SelectionService).toConstantValue({});
|
|
75
|
+
container.bind(workspace_commands_1.WorkspaceCommandContribution).toSelf().inSingletonScope();
|
|
76
|
+
container.bind(workspace_compare_handler_1.WorkspaceCompareHandler).toConstantValue({});
|
|
77
|
+
container.bind(workspace_delete_handler_1.WorkspaceDeleteHandler).toConstantValue({});
|
|
78
|
+
container.bind(workspace_duplicate_handler_1.WorkspaceDuplicateHandler).toConstantValue({});
|
|
79
|
+
container.bind(workspace_preferences_1.WorkspacePreferences).toConstantValue({});
|
|
80
|
+
container.bind(workspace_service_1.WorkspaceService).toConstantValue({});
|
|
81
|
+
container.bind(clipboard_service_1.ClipboardService).toConstantValue({});
|
|
82
|
+
container.bind(application_protocol_1.ApplicationServer).toConstantValue({
|
|
83
|
+
getBackendOS() {
|
|
84
|
+
return Promise.resolve(common_1.OS.type());
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
commands = container.get(workspace_commands_1.WorkspaceCommandContribution);
|
|
88
|
+
});
|
|
89
|
+
describe('#validateFileName', () => {
|
|
90
|
+
it('should not validate an empty file name', async () => {
|
|
91
|
+
const message = await commands['validateFileName']('', parent);
|
|
92
|
+
(0, chai_1.expect)(message).to.equal('');
|
|
93
|
+
});
|
|
94
|
+
it('should accept the resource does not exist', async () => {
|
|
95
|
+
const message = await commands['validateFileName']('a.ts', parent);
|
|
96
|
+
(0, chai_1.expect)(message).to.equal('');
|
|
97
|
+
});
|
|
98
|
+
it('should not accept if the resource exists', async () => {
|
|
99
|
+
const message = await commands['validateFileName']('bar', parent);
|
|
100
|
+
(0, chai_1.expect)(message).to.not.equal(''); // a non empty message indicates an error.
|
|
101
|
+
});
|
|
102
|
+
it('should not accept invalid filenames', async () => {
|
|
103
|
+
let message = await commands['validateFileName']('.', parent, true); // invalid filename.
|
|
104
|
+
(0, chai_1.expect)(message).to.not.equal('');
|
|
105
|
+
message = await commands['validateFileName']('/a', parent, true); // invalid starts-with `\`.
|
|
106
|
+
(0, chai_1.expect)(message).to.not.equal('');
|
|
107
|
+
message = await commands['validateFileName'](' a', parent, true); // invalid leading whitespace.
|
|
108
|
+
(0, chai_1.expect)(message).to.not.equal('');
|
|
109
|
+
message = await commands['validateFileName']('a ', parent, true); // invalid trailing whitespace.
|
|
110
|
+
(0, chai_1.expect)(message).to.not.equal('');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('#validateFileRename', () => {
|
|
114
|
+
it('should accept if the resource exists case-insensitively', async () => {
|
|
115
|
+
const oldName = 'bar';
|
|
116
|
+
const newName = 'Bar';
|
|
117
|
+
const message = await commands['validateFileRename'](oldName, newName, parent);
|
|
118
|
+
(0, chai_1.expect)(message).to.equal('');
|
|
119
|
+
});
|
|
120
|
+
it('should accept if the resource does not exist case-insensitively', async () => {
|
|
121
|
+
const oldName = 'bar';
|
|
122
|
+
const newName = 'foo';
|
|
123
|
+
const message = await commands['validateFileRename'](oldName, newName, parent);
|
|
124
|
+
(0, chai_1.expect)(message).to.equal('');
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=workspace-commands.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-commands.spec.js","sourceRoot":"","sources":["../../src/browser/workspace-commands.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,8DAAiE;AACjE,IAAI,YA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9B,MAAM,OAAO,GAAG,KAAK,CAAC;YACtB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAC/E,IAAA,aAAM,EAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import URI from '@theia/core/lib/common/uri';
|
|
2
|
+
import { UriCommandHandler } from '@theia/core/lib/common/uri-command-handler';
|
|
3
|
+
import { DiffService } from './diff-service';
|
|
4
|
+
export declare class WorkspaceCompareHandler implements UriCommandHandler<URI[]> {
|
|
5
|
+
protected readonly diffService: DiffService;
|
|
6
|
+
/**
|
|
7
|
+
* Determine if the command is visible.
|
|
8
|
+
*
|
|
9
|
+
* @param uris URIs of selected resources.
|
|
10
|
+
* @returns `true` if the command is visible.
|
|
11
|
+
*/
|
|
12
|
+
isVisible(uris: URI[]): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Determine if the command is enabled.
|
|
15
|
+
*
|
|
16
|
+
* @param uris URIs of selected resources.
|
|
17
|
+
* @returns `true` if the command is enabled.
|
|
18
|
+
*/
|
|
19
|
+
isEnabled(uris: URI[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Execute the command.
|
|
22
|
+
*
|
|
23
|
+
* @param uris URIs of selected resources.
|
|
24
|
+
*/
|
|
25
|
+
execute(uris: URI[]): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=workspace-compare-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-compare-handler.d.ts","sourceRoot":"","sources":["../../src/browser/workspace-compare-handler.ts"],"names":[],"mappings":"AAiBA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBACa,uBAAwB,YAAW,iBAAiB,CAAC,GAAG,EAAE,CAAC;IAE/C,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAEjE;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAI/B;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAI/B;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAI5C"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2019 Red Hat, Inc. 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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WorkspaceCompareHandler = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const diff_service_1 = require("./diff-service");
|
|
22
|
+
let WorkspaceCompareHandler = class WorkspaceCompareHandler {
|
|
23
|
+
/**
|
|
24
|
+
* Determine if the command is visible.
|
|
25
|
+
*
|
|
26
|
+
* @param uris URIs of selected resources.
|
|
27
|
+
* @returns `true` if the command is visible.
|
|
28
|
+
*/
|
|
29
|
+
isVisible(uris) {
|
|
30
|
+
return uris.length === 2;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Determine if the command is enabled.
|
|
34
|
+
*
|
|
35
|
+
* @param uris URIs of selected resources.
|
|
36
|
+
* @returns `true` if the command is enabled.
|
|
37
|
+
*/
|
|
38
|
+
isEnabled(uris) {
|
|
39
|
+
return uris.length === 2;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Execute the command.
|
|
43
|
+
*
|
|
44
|
+
* @param uris URIs of selected resources.
|
|
45
|
+
*/
|
|
46
|
+
async execute(uris) {
|
|
47
|
+
const [left, right] = uris;
|
|
48
|
+
await this.diffService.openDiffEditor(left, right);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.WorkspaceCompareHandler = WorkspaceCompareHandler;
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, inversify_1.inject)(diff_service_1.DiffService),
|
|
54
|
+
tslib_1.__metadata("design:type", diff_service_1.DiffService)
|
|
55
|
+
], WorkspaceCompareHandler.prototype, "diffService", void 0);
|
|
56
|
+
exports.WorkspaceCompareHandler = WorkspaceCompareHandler = tslib_1.__decorate([
|
|
57
|
+
(0, inversify_1.injectable)()
|
|
58
|
+
], WorkspaceCompareHandler);
|
|
59
|
+
//# sourceMappingURL=workspace-compare-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-compare-handler.js","sourceRoot":"","sources":["../../src/browser/workspace-compare-handler.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAGlE,iDAA6C;AAGtC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAIhC;;;;;OAKG;IACH,SAAS,CAAC,IAAW;QACjB,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAW;QACjB,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,IAAW;QACrB,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC3B,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;CACJ,CAAA;AAjCY,0DAAuB;AAEQ;IAAvC,IAAA,kBAAM,EAAC,0BAAW,CAAC;sCAAiC,0BAAW;4DAAC;kCAFxD,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAiCnC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import URI from '@theia/core/lib/common/uri';
|
|
2
|
+
import { ApplicationShell } from '@theia/core/lib/browser';
|
|
3
|
+
import { UriCommandHandler } from '@theia/core/lib/common/uri-command-handler';
|
|
4
|
+
import { WorkspaceService } from './workspace-service';
|
|
5
|
+
import { WorkspaceUtils } from './workspace-utils';
|
|
6
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
7
|
+
import { FileSystemPreferences } from '@theia/filesystem/lib/common/filesystem-preferences';
|
|
8
|
+
import { FileDeleteOptions } from '@theia/filesystem/lib/common/files';
|
|
9
|
+
export declare class WorkspaceDeleteHandler implements UriCommandHandler<URI[]> {
|
|
10
|
+
protected readonly fileService: FileService;
|
|
11
|
+
protected readonly shell: ApplicationShell;
|
|
12
|
+
protected readonly workspaceUtils: WorkspaceUtils;
|
|
13
|
+
protected readonly workspaceService: WorkspaceService;
|
|
14
|
+
protected readonly fsPreferences: FileSystemPreferences;
|
|
15
|
+
/**
|
|
16
|
+
* Determine if the command is visible.
|
|
17
|
+
*
|
|
18
|
+
* @param uris URIs of selected resources.
|
|
19
|
+
* @returns `true` if the command is visible.
|
|
20
|
+
*/
|
|
21
|
+
isVisible(uris: URI[]): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Determine if the command is enabled.
|
|
24
|
+
*
|
|
25
|
+
* @param uris URIs of selected resources.
|
|
26
|
+
* @returns `true` if the command is enabled.
|
|
27
|
+
*/
|
|
28
|
+
isEnabled(uris: URI[]): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Execute the command.
|
|
31
|
+
*
|
|
32
|
+
* @param uris URIs of selected resources.
|
|
33
|
+
*/
|
|
34
|
+
execute(uris: URI[]): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Display dialog to confirm deletion.
|
|
37
|
+
*
|
|
38
|
+
* @param uris URIs of selected resources.
|
|
39
|
+
*/
|
|
40
|
+
protected confirm(uris: URI[], options: FileDeleteOptions): Promise<boolean | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the dialog confirmation message for deletion.
|
|
43
|
+
*
|
|
44
|
+
* @param uris URIs of selected resources.
|
|
45
|
+
*/
|
|
46
|
+
protected getConfirmMessage(uris: URI[]): string | HTMLElement;
|
|
47
|
+
/**
|
|
48
|
+
* Get which URI are presently dirty.
|
|
49
|
+
*
|
|
50
|
+
* @param uris URIs of selected resources.
|
|
51
|
+
* @returns An array of dirty URI.
|
|
52
|
+
*/
|
|
53
|
+
protected getDirty(uris: URI[]): URI[];
|
|
54
|
+
/**
|
|
55
|
+
* Perform deletion of a given URI.
|
|
56
|
+
*
|
|
57
|
+
* @param uri URI of selected resource.
|
|
58
|
+
* @param options deletion options.
|
|
59
|
+
*/
|
|
60
|
+
protected delete(uri: URI, options: FileDeleteOptions): Promise<void>;
|
|
61
|
+
protected deleteFilePermanently(uri: URI, options: FileDeleteOptions): Promise<void>;
|
|
62
|
+
protected moveFileToTrash(uri: URI, options: FileDeleteOptions): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Display dialog to confirm the permanent deletion of a file.
|
|
65
|
+
*
|
|
66
|
+
* @param uri URI of selected resource.
|
|
67
|
+
*/
|
|
68
|
+
protected confirmDeletePermanently(uri: URI): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Close widget without saving changes.
|
|
71
|
+
*
|
|
72
|
+
* @param uri URI of a selected resource.
|
|
73
|
+
*/
|
|
74
|
+
protected closeWithoutSaving(uri: URI): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=workspace-delete-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-delete-handler.d.ts","sourceRoot":"","sources":["../../src/browser/workspace-delete-handler.ts"],"names":[],"mappings":"AAiBA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAC7C,OAAO,EAAiB,gBAAgB,EAAqC,MAAM,yBAAyB,CAAC;AAC7G,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAkC,MAAM,oCAAoC,CAAC;AAGvG,qBACa,sBAAuB,YAAW,iBAAiB,CAAC,GAAG,EAAE,CAAC;IAGnE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAG5C,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IAG3C,SAAS,CAAC,QAAQ,CAAC,cA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// *****************************************************************************
|
|
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-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WorkspaceDeleteHandler = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
22
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
23
|
+
const workspace_service_1 = require("./workspace-service");
|
|
24
|
+
const workspace_utils_1 = require("./workspace-utils");
|
|
25
|
+
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
26
|
+
const filesystem_preferences_1 = require("@theia/filesystem/lib/common/filesystem-preferences");
|
|
27
|
+
const nls_1 = require("@theia/core/lib/common/nls");
|
|
28
|
+
let WorkspaceDeleteHandler = class WorkspaceDeleteHandler {
|
|
29
|
+
/**
|
|
30
|
+
* Determine if the command is visible.
|
|
31
|
+
*
|
|
32
|
+
* @param uris URIs of selected resources.
|
|
33
|
+
* @returns `true` if the command is visible.
|
|
34
|
+
*/
|
|
35
|
+
isVisible(uris) {
|
|
36
|
+
return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Determine if the command is enabled.
|
|
40
|
+
*
|
|
41
|
+
* @param uris URIs of selected resources.
|
|
42
|
+
* @returns `true` if the command is enabled.
|
|
43
|
+
*/
|
|
44
|
+
isEnabled(uris) {
|
|
45
|
+
return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Execute the command.
|
|
49
|
+
*
|
|
50
|
+
* @param uris URIs of selected resources.
|
|
51
|
+
*/
|
|
52
|
+
async execute(uris) {
|
|
53
|
+
const distinctUris = uri_1.default.getDistinctParents(uris);
|
|
54
|
+
const resolved = {
|
|
55
|
+
recursive: true,
|
|
56
|
+
useTrash: this.fsPreferences['files.enableTrash'] && distinctUris[0] && this.fileService.hasCapability(distinctUris[0], 4096 /* FileSystemProviderCapabilities.Trash */)
|
|
57
|
+
};
|
|
58
|
+
if (await this.confirm(distinctUris, resolved)) {
|
|
59
|
+
await Promise.all(distinctUris.map(uri => this.delete(uri, resolved)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Display dialog to confirm deletion.
|
|
64
|
+
*
|
|
65
|
+
* @param uris URIs of selected resources.
|
|
66
|
+
*/
|
|
67
|
+
confirm(uris, options) {
|
|
68
|
+
let title = uris.length === 1 ? nls_1.nls.localizeByDefault('File') : nls_1.nls.localizeByDefault('Files');
|
|
69
|
+
if (options.useTrash) {
|
|
70
|
+
title = nls_1.nls.localize('theia/workspace/trashTitle', 'Move {0} to Trash', title);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
title = nls_1.nls.localizeByDefault('Delete {0}', title);
|
|
74
|
+
}
|
|
75
|
+
return new browser_1.ConfirmDialog({
|
|
76
|
+
title,
|
|
77
|
+
msg: this.getConfirmMessage(uris)
|
|
78
|
+
}).open();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the dialog confirmation message for deletion.
|
|
82
|
+
*
|
|
83
|
+
* @param uris URIs of selected resources.
|
|
84
|
+
*/
|
|
85
|
+
getConfirmMessage(uris) {
|
|
86
|
+
const dirty = this.getDirty(uris);
|
|
87
|
+
if (dirty.length) {
|
|
88
|
+
if (dirty.length === 1) {
|
|
89
|
+
return nls_1.nls.localize('theia/workspace/confirmMessage.dirtySingle', 'Do you really want to delete {0} with unsaved changes?', dirty[0].path.base);
|
|
90
|
+
}
|
|
91
|
+
return nls_1.nls.localize('theia/workspace/confirmMessage.dirtyMultiple', 'Do you really want to delete {0} files with unsaved changes?', dirty.length);
|
|
92
|
+
}
|
|
93
|
+
if (uris.length === 1) {
|
|
94
|
+
return nls_1.nls.localize('theia/workspace/confirmMessage.uriSingle', 'Do you really want to delete {0}?', uris[0].path.base);
|
|
95
|
+
}
|
|
96
|
+
if (uris.length > 10) {
|
|
97
|
+
return nls_1.nls.localize('theia/workspace/confirmMessage.uriMultiple', 'Do you really want to delete all the {0} selected files?', uris.length);
|
|
98
|
+
}
|
|
99
|
+
const messageContainer = document.createElement('div');
|
|
100
|
+
messageContainer.textContent = nls_1.nls.localize('theia/workspace/confirmMessage.delete', 'Do you really want to delete the following files?');
|
|
101
|
+
const list = document.createElement('ul');
|
|
102
|
+
list.style.listStyleType = 'none';
|
|
103
|
+
for (const uri of uris) {
|
|
104
|
+
const listItem = document.createElement('li');
|
|
105
|
+
listItem.textContent = uri.path.base;
|
|
106
|
+
list.appendChild(listItem);
|
|
107
|
+
}
|
|
108
|
+
messageContainer.appendChild(list);
|
|
109
|
+
return messageContainer;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get which URI are presently dirty.
|
|
113
|
+
*
|
|
114
|
+
* @param uris URIs of selected resources.
|
|
115
|
+
* @returns An array of dirty URI.
|
|
116
|
+
*/
|
|
117
|
+
getDirty(uris) {
|
|
118
|
+
const dirty = new Map();
|
|
119
|
+
const widgets = browser_1.NavigatableWidget.getAffected(browser_1.SaveableWidget.getDirty(this.shell.widgets), uris);
|
|
120
|
+
for (const [resourceUri] of widgets) {
|
|
121
|
+
dirty.set(resourceUri.toString(), resourceUri);
|
|
122
|
+
}
|
|
123
|
+
return [...dirty.values()];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Perform deletion of a given URI.
|
|
127
|
+
*
|
|
128
|
+
* @param uri URI of selected resource.
|
|
129
|
+
* @param options deletion options.
|
|
130
|
+
*/
|
|
131
|
+
async delete(uri, options) {
|
|
132
|
+
try {
|
|
133
|
+
await Promise.all([
|
|
134
|
+
this.closeWithoutSaving(uri),
|
|
135
|
+
options.useTrash ? this.moveFileToTrash(uri, options) : this.deleteFilePermanently(uri, options)
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
console.error(e);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async deleteFilePermanently(uri, options) {
|
|
143
|
+
this.fileService.delete(uri, { ...options, useTrash: false });
|
|
144
|
+
}
|
|
145
|
+
async moveFileToTrash(uri, options) {
|
|
146
|
+
try {
|
|
147
|
+
await this.fileService.delete(uri, { ...options, useTrash: true });
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.error('Error deleting with trash:', error);
|
|
151
|
+
if (await this.confirmDeletePermanently(uri)) {
|
|
152
|
+
return this.deleteFilePermanently(uri, options);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Display dialog to confirm the permanent deletion of a file.
|
|
158
|
+
*
|
|
159
|
+
* @param uri URI of selected resource.
|
|
160
|
+
*/
|
|
161
|
+
async confirmDeletePermanently(uri) {
|
|
162
|
+
const title = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.title', 'Error deleting file');
|
|
163
|
+
const msg = document.createElement('div');
|
|
164
|
+
const question = document.createElement('p');
|
|
165
|
+
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);
|
|
166
|
+
msg.append(question);
|
|
167
|
+
const info = document.createElement('p');
|
|
168
|
+
info.textContent = nls_1.nls.localize('theia/workspace/confirmDeletePermanently.solution', 'You can disable the use of Trash in the preferences.');
|
|
169
|
+
msg.append(info);
|
|
170
|
+
const response = await new browser_1.ConfirmDialog({ title, msg }).open();
|
|
171
|
+
return response || false;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Close widget without saving changes.
|
|
175
|
+
*
|
|
176
|
+
* @param uri URI of a selected resource.
|
|
177
|
+
*/
|
|
178
|
+
async closeWithoutSaving(uri) {
|
|
179
|
+
const toClose = [...browser_1.NavigatableWidget.getAffected(this.shell.widgets, uri)].map(([, widget]) => widget);
|
|
180
|
+
await this.shell.closeMany(toClose, { save: false });
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
exports.WorkspaceDeleteHandler = WorkspaceDeleteHandler;
|
|
184
|
+
tslib_1.__decorate([
|
|
185
|
+
(0, inversify_1.inject)(file_service_1.FileService),
|
|
186
|
+
tslib_1.__metadata("design:type", file_service_1.FileService)
|
|
187
|
+
], WorkspaceDeleteHandler.prototype, "fileService", void 0);
|
|
188
|
+
tslib_1.__decorate([
|
|
189
|
+
(0, inversify_1.inject)(browser_1.ApplicationShell),
|
|
190
|
+
tslib_1.__metadata("design:type", browser_1.ApplicationShell)
|
|
191
|
+
], WorkspaceDeleteHandler.prototype, "shell", void 0);
|
|
192
|
+
tslib_1.__decorate([
|
|
193
|
+
(0, inversify_1.inject)(workspace_utils_1.WorkspaceUtils),
|
|
194
|
+
tslib_1.__metadata("design:type", workspace_utils_1.WorkspaceUtils)
|
|
195
|
+
], WorkspaceDeleteHandler.prototype, "workspaceUtils", void 0);
|
|
196
|
+
tslib_1.__decorate([
|
|
197
|
+
(0, inversify_1.inject)(workspace_service_1.WorkspaceService),
|
|
198
|
+
tslib_1.__metadata("design:type", workspace_service_1.WorkspaceService)
|
|
199
|
+
], WorkspaceDeleteHandler.prototype, "workspaceService", void 0);
|
|
200
|
+
tslib_1.__decorate([
|
|
201
|
+
(0, inversify_1.inject)(filesystem_preferences_1.FileSystemPreferences),
|
|
202
|
+
tslib_1.__metadata("design:type", Object)
|
|
203
|
+
], WorkspaceDeleteHandler.prototype, "fsPreferences", void 0);
|
|
204
|
+
exports.WorkspaceDeleteHandler = WorkspaceDeleteHandler = tslib_1.__decorate([
|
|
205
|
+
(0, inversify_1.injectable)()
|
|
206
|
+
], WorkspaceDeleteHandler);
|
|
207
|
+
//# sourceMappingURL=workspace-delete-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-delete-handler.js","sourceRoot":"","sources":["../../src/browser/workspace-delete-handler.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAClE,oDAA6C;AAC7C,qDAA6G;AAE7G,2DAAuD;AACvD,uDAAmD;AACnD,6EAAyE;AACzE,gGAA4F;AAE5F,oDAAiD;AAG1C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAiB/B;;;;;OAKG;IACH,SAAS,CAAC,IAAW;QACjB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAW;QACjB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,IAAW;QACrB,MAAM,YAAY,GAAG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7B,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,kBAAkB,CAAC,GAAQ;QACvC,MAAM,OAAO,GAAG,CAAC,GAAG,2BAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;QACxG,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AAvLY,wDAAsB;AAGZ;IADlB,IAAA,kBAAM,EAAC,0BAAW,CAAC;sCACY,0BAAW;2DAAC;AAGzB;IADlB,IAAA,kBAAM,EAAC,0BAAgB,CAAC;sCACC,0BAAgB;qDAAC;AAGxB;IADlB,IAAA,kBAAM,EAAC,gCAAc,CAAC;sCACY,gCAAc;8DAAC;AAG/B;IADlB,IAAA,kBAAM,EAAC,oCAAgB,CAAC;sCACY,oCAAgB;gEAAC;AAGnC;IADlB,IAAA,kBAAM,EAAC,8CAAqB,CAAC;;6DAC0B;iCAf/C,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CAuLlC"}
|
|
@@ -0,0 +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
|
+
}
|
|
31
|
+
//# sourceMappingURL=workspace-duplicate-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-duplicate-handler.d.ts","sourceRoot":"","sources":["../../src/browser/workspace-duplicate-handler.ts"],"names":[],"mappings":"AAgBA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,qBACa,yBAA0B,YAAW,iBAAiB,CAAC,GAAG,EAAE,CAAC;IAGtE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAG5C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAEtD;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAI/B;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAI/B;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAa5C"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 Ericsson 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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WorkspaceDuplicateHandler = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const workspace_utils_1 = require("./workspace-utils");
|
|
22
|
+
const workspace_service_1 = require("./workspace-service");
|
|
23
|
+
const filesystem_utils_1 = require("@theia/filesystem/lib/common/filesystem-utils");
|
|
24
|
+
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
25
|
+
let WorkspaceDuplicateHandler = class WorkspaceDuplicateHandler {
|
|
26
|
+
/**
|
|
27
|
+
* Determine if the command is visible.
|
|
28
|
+
*
|
|
29
|
+
* @param uris URIs of selected resources.
|
|
30
|
+
* @returns `true` if the command is visible.
|
|
31
|
+
*/
|
|
32
|
+
isVisible(uris) {
|
|
33
|
+
return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Determine if the command is enabled.
|
|
37
|
+
*
|
|
38
|
+
* @param uris URIs of selected resources.
|
|
39
|
+
* @returns `true` if the command is enabled.
|
|
40
|
+
*/
|
|
41
|
+
isEnabled(uris) {
|
|
42
|
+
return !!uris.length && !this.workspaceUtils.containsRootDirectory(uris);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Execute the command.
|
|
46
|
+
*
|
|
47
|
+
* @param uris URIs of selected resources.
|
|
48
|
+
*/
|
|
49
|
+
async execute(uris) {
|
|
50
|
+
await Promise.all(uris.map(async (uri) => {
|
|
51
|
+
try {
|
|
52
|
+
const parent = await this.fileService.resolve(uri.parent);
|
|
53
|
+
const targetFileStat = await this.fileService.resolve(uri);
|
|
54
|
+
const target = filesystem_utils_1.FileSystemUtils.generateUniqueResourceURI(parent, uri, targetFileStat.isDirectory, 'copy');
|
|
55
|
+
await this.fileService.copy(uri, target);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
console.error(e);
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
exports.WorkspaceDuplicateHandler = WorkspaceDuplicateHandler;
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, inversify_1.inject)(file_service_1.FileService),
|
|
66
|
+
tslib_1.__metadata("design:type", file_service_1.FileService)
|
|
67
|
+
], WorkspaceDuplicateHandler.prototype, "fileService", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, inversify_1.inject)(workspace_utils_1.WorkspaceUtils),
|
|
70
|
+
tslib_1.__metadata("design:type", workspace_utils_1.WorkspaceUtils)
|
|
71
|
+
], WorkspaceDuplicateHandler.prototype, "workspaceUtils", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, inversify_1.inject)(workspace_service_1.WorkspaceService),
|
|
74
|
+
tslib_1.__metadata("design:type", workspace_service_1.WorkspaceService)
|
|
75
|
+
], WorkspaceDuplicateHandler.prototype, "workspaceService", void 0);
|
|
76
|
+
exports.WorkspaceDuplicateHandler = WorkspaceDuplicateHandler = tslib_1.__decorate([
|
|
77
|
+
(0, inversify_1.injectable)()
|
|
78
|
+
], WorkspaceDuplicateHandler);
|
|
79
|
+
//# sourceMappingURL=workspace-duplicate-handler.js.map
|