Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 0420ac1

Browse files
author
Nitesh Kumar
committed
Adding missed files
1 parent 5171c85 commit 0420ac1

File tree

3 files changed

+144
-0
lines changed

3 files changed

+144
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*
22+
*/
23+
24+
define(function (require, exports, module) {
25+
"use strict";
26+
27+
28+
var AppInit = brackets.getModule("utils/AppInit"),
29+
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
30+
Strings = brackets.getModule("strings"),
31+
FileViewController = brackets.getModule("project/FileViewController"),
32+
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
33+
NodeDomain = brackets.getModule("utils/NodeDomain"),
34+
FileUtils = brackets.getModule("file/FileUtils");
35+
36+
/**
37+
* @private
38+
* @type {string} fullPath of the OpenWithExternalEditor Domain implementation
39+
*/
40+
var _domainPath = ExtensionUtils.getModulePath(module, "node/OpenWithExternalEditorDomain");
41+
42+
/**
43+
* @private
44+
* @type {NodeDomain}
45+
*/
46+
var _nodeDomain = new NodeDomain("OpenWithExternalEditor", _domainPath);
47+
48+
var extensionToExternalEditorMap = {};
49+
50+
function _openInExternalEdior(event, path) {
51+
_nodeDomain.exec("open", {
52+
path: path,
53+
app: extensionToExternalEditorMap[FileUtils.getFileExtension(path).toLowerCase()]
54+
});
55+
}
56+
57+
PreferencesManager.definePreference("externalEditor", "object", {}, {
58+
description: Strings.DESCRIPTION_EXTERNAL_EDITOR
59+
});
60+
61+
PreferencesManager.on("change", "externalEditor", function () {
62+
extensionToExternalEditorMap = PreferencesManager.get("externalEditor");
63+
});
64+
65+
FileViewController.on("openInExternalEditor", _openInExternalEdior);
66+
67+
AppInit.appReady(function () {
68+
FileUtils.addExtensionToExternalAppList(Object.keys(extensionToExternalEditorMap));
69+
});
70+
});
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*
22+
*/
23+
24+
/*eslint-env node */
25+
/*jslint node: true */
26+
"use strict";
27+
28+
var open = require("open");
29+
30+
var _domainManager;
31+
32+
/**
33+
* @private
34+
*
35+
* @param {Object} params Object to use
36+
*/
37+
function _OpenWithExternalEditor(params) {
38+
var application = "default" === params.app ? "": params.app;
39+
open(params.path, application);
40+
}
41+
42+
43+
/**
44+
* Initializes the OpenWithExternalEditor domain with its commands.
45+
* @param {DomainManager} domainManager The DomainManager for the server
46+
*/
47+
function init(domainManager) {
48+
_domainManager = domainManager;
49+
50+
if (!domainManager.hasDomain("OpenWithExternalEditor")) {
51+
domainManager.registerDomain("OpenWithExternalEditor", {major: 0, minor: 1});
52+
}
53+
_domainManager.registerCommand(
54+
"OpenWithExternalEditor",
55+
"open",
56+
_OpenWithExternalEditor,
57+
true,
58+
"open document with External Editor.",
59+
[{
60+
name: "params",
61+
type: "object",
62+
description: "Params Object having document and App Path."
63+
}],
64+
[]
65+
);
66+
}
67+
68+
exports.init = init;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "brackets-open-external_editor",
3+
"dependencies": {
4+
"open": "0.0.5"
5+
}
6+
}

0 commit comments

Comments
 (0)