-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
60 lines (51 loc) · 2.4 KB
/
main.js
File metadata and controls
60 lines (51 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*global define, $, brackets, window, console */
define(function (require, exports, module) {
"use strict";
var CommandManager = brackets.getModule("command/CommandManager"),
KeyBindingManager = brackets.getModule("command/KeyBindingManager"),
Menus = brackets.getModule("command/Menus"),
fileMenu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU),
UIController = require('./src/UIController'),
fileLoader = require('./src/fileLoader'),
installer = require('./src/extensionsInstaller'),
exporter = require('./src/extensionsExporter'),
reporter = require('./src/reporter'),
MY_COMMAND_ID;
UIController.initUI();
UIController.setInstallBtnHandler(function () {
reporter.reset();
fileLoader.selectAndParseFile()
.then(function (extensionsObject) {
UIController.addStatusMessage('File loaded and parsed...', 'info');
UIController.resetInstallTable().showLoadedExtensions();
return installer.install(extensionsObject);
})
.done(function () {
UIController.addStatusMessage('Extensions installation finished', 'info');
reporter.generateReport();
})
.fail(function (error) {
UIController.addStatusMessage(error.message, 'error');
});
});
UIController.setExportBtnHandler(function () {
exporter.exportInstalled()
.done(function (fileName) {
UIController.addStatusMessage('Installed extensions saved to file at location ' + fileName);
})
.fail(function (error) {
UIController.addStatusMessage('Failed to save extensions to file');
UIController.addStatusMessage('Error message: ' + error.message);
console.dir(error.data);
});
});
// Function to run when the menu item is clicked
function handleBulkInstallerCall() {
UIController.togglePanel();
}
MY_COMMAND_ID = "milosh86.bulk.installer";
CommandManager.register("Extensions Bulk Installer", MY_COMMAND_ID, handleBulkInstallerCall);
// Ctrl-Alt-M clashed with refactoring.extractToFunction
fileMenu.addMenuItem(MY_COMMAND_ID, "Ctrl-I", Menus.LAST_IN_SECTION, Menus.MenuSection.FILE_EXTENSION_MANAGER);
// (Note: "Ctrl" is automatically mapped to "Cmd" on Mac)
});