This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdebugpanel.js
144 lines (126 loc) · 5.08 KB
/
debugpanel.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
define(function(require, module, exports) {
main.consumes = ["Plugin", "ui", "debugger"];
main.provides = ["DebugPanel"];
return main;
function main(options, imports, register) {
var Plugin = imports.Plugin;
var ui = imports.ui;
var debug = imports.debugger;
function DebugPanel(developer, deps, options) {
// Editor extends ext.Plugin
var plugin = new Plugin(developer, deps);
var emit = plugin.getEmitter();
emit.setMaxListeners(1000);
var caption = options.caption;
var index = options.index || 100;
var amlFrame;
plugin.on("load", function() {
// Draw panel when debugger is drawn
debug.once("drawPanels", draw, plugin);
});
function draw(e) {
amlFrame = ui.frame({
htmlNode: e.html,
buttons: "min",
activetitle: "min",
caption: caption
});
ui.insertByIndex(e.html, amlFrame.$ext, index, false);
plugin.addElement(amlFrame);
emit.sticky("draw", { aml: amlFrame, html: amlFrame.$int });
}
/***** Methods *****/
function show() {
draw();
amlFrame.show();
}
function hide() {
amlFrame.hide();
}
/***** Register and define API *****/
plugin.freezePublicAPI.baseclass();
/**
* Debug panel base class for the {@link debugger Cloud9 debugger}.
*
* A debug panel is a section of the debugger that allows users to
* interact with the debugger. Debuggers in Cloud9 are pluggable
* and there are many different debuggers available as a
* {@link debugger.implementation debugger implementation}.
*
* The debugger UI is re-used for all these debugger
* implementations. Panels can decide for which debugger they should
* be shown:
*
* var debug = imports.debugger;
*
* debug.on("attach", function(e) {
* if (e.implementation.type == "html5")
* plugin.show();
* else
* plugin.hide();
* });
*
* Implementing your own debug panel takes a new DebugPanel() object
* rather than a new Plugin() object. Here's a short example:
*
* var plugin = new DebugPanel("(Company) Name", main.consumes, {
* caption : "Cool Caption"
* });
* var emit = plugin.getEmitter();
*
* plugin.on("draw", function(e) {
* e.html.innerHTML = "Hello World!";
* });
*
* plugin.freezePublicAPI({
* });
*
* @class DebugPanel
* @extends Plugin
*/
/**
* @constructor
* Creates a new DebugPanel instance.
* @param {String} developer The name of the developer of the plugin
* @param {String[]} deps A list of dependencies for this
* plugin. In most cases it's a reference to `main.consumes`.
* @param {Object} options The options for the debug panel
* @param {String} options.caption The caption of the frame.
*/
plugin.freezePublicAPI({
/**
* The APF UI element that is presenting the pane in the UI.
* This property is here for internal reasons only. *Do not
* depend on this property in your plugin.*
* @property {AMLElement} aml
* @private
* @readonly
*/
get aml() { return amlFrame; },
_events: [
/**
* Fired when the panel container is drawn.
* @event draw
* @param {Object} e
* @param {HTMLElement} e.html The html container.
* @param {AMLElement} e.aml The aml container.
*/
"draw"
],
/**
* Shows the panel.
*/
show: show,
/**
* Hides the panel.
*/
hide: hide
});
return plugin;
}
/***** Register and define API *****/
register(null, {
DebugPanel: DebugPanel
});
}
});