@@ -41,7 +41,7 @@ object ([see the documentation](https://jupyterlab.github.io/jupyterlab/apputils
41
41
Here it is stored in the private ` _sessionContext ` variable:
42
42
43
43
``` ts
44
- // src/panel.ts#L86-L86
44
+ // src/panel.ts#L94-L94
45
45
46
46
private _sessionContext : SessionContext ;
47
47
```
@@ -50,7 +50,7 @@ A `SessionContext` handles a single kernel session. The session itself (not yet
50
50
the kernel) is started with these lines:
51
51
52
52
``` ts
53
- // src/panel.ts#L36-L40
53
+ // src/panel.ts#L44-L48
54
54
55
55
this ._sessionContext = new SessionContext ({
56
56
sessionManager: manager .sessions ,
@@ -63,7 +63,7 @@ The private session variable is exposed as read-only for other users
63
63
through a getter method:
64
64
65
65
``` ts
66
- // src/panel.ts#L64-L66
66
+ // src/panel.ts#L72-L74
67
67
68
68
get session (): ISessionContext {
69
69
return this ._sessionContext ;
@@ -75,7 +75,7 @@ with this line:
75
75
76
76
<!-- prettier-ignore-start -->
77
77
``` ts
78
- // src/panel.ts#L50-L61
78
+ // src/panel.ts#L58-L69
79
79
80
80
void this ._sessionContext
81
81
.initialize ()
@@ -99,7 +99,7 @@ The following two methods ensure the clean disposal of the session
99
99
when you close the panel.
100
100
101
101
``` ts
102
- // src/panel.ts#L68-L71
102
+ // src/panel.ts#L76-L79
103
103
104
104
dispose (): void {
105
105
this ._sessionContext .dispose ();
@@ -108,7 +108,7 @@ dispose(): void {
108
108
```
109
109
110
110
``` ts
111
- // src/panel.ts#L81-L84
111
+ // src/panel.ts#L89-L92
112
112
113
113
protected onCloseRequest (msg : Message ): void {
114
114
super .onCloseRequest (msg );
@@ -124,7 +124,7 @@ You can instantiate it with a new `OutputAreaModel`; this is class containing
124
124
the data to show:
125
125
126
126
``` ts
127
- // src/panel.ts#L42-L46
127
+ // src/panel.ts#L50-L54
128
128
129
129
this ._outputareamodel = new OutputAreaModel ();
130
130
this ._outputarea = new SimplifiedOutputArea ({
@@ -138,7 +138,7 @@ some code to a kernel through a `ISessionContext` ([see documentation](https://j
138
138
in the specific ` SimplifiedOutputArea ` object you created:
139
139
140
140
``` ts
141
- // src/panel.ts#L73-L79
141
+ // src/panel.ts#L81-L87
142
142
143
143
execute (code : string ): void {
144
144
SimplifiedOutputArea .execute (code , this ._outputarea , this ._sessionContext )
@@ -158,7 +158,7 @@ To display the `SimplifiedOutputArea` Widget you need to add it to your
158
158
panel with:
159
159
160
160
``` ts
161
- // src/panel.ts#L48-L48
161
+ // src/panel.ts#L56-L56
162
162
163
163
this .addWidget (this ._outputarea );
164
164
```
@@ -172,7 +172,7 @@ The last step is to add the panel to the JupyterLab main area.
172
172
First, it is a good practice to unify the extension commands into one namespace at the top of the file:
173
173
174
174
``` ts
175
- // src/index.ts#L21-L25
175
+ // src/index.ts#L23-L27
176
176
177
177
namespace CommandIDs {
178
178
export const create = ' kernel-output:create' ;
@@ -185,7 +185,7 @@ You can then add the commands to the palette and the menu by iterating
185
185
on a list:
186
186
187
187
``` ts
188
- // src/index.ts#L105-L109
188
+ // src/index.ts#L110-L114
189
189
190
190
// add items in command palette and menu
191
191
[CommandIDs .create , CommandIDs .execute ].forEach (command => {
@@ -198,7 +198,7 @@ To create a new client session, the service manager must be obtained from
198
198
the JupyterLab application:
199
199
200
200
``` ts
201
- // src/index.ts#L54-L54
201
+ // src/index.ts#L58-L58
202
202
203
203
const manager = app .serviceManager ;
204
204
```
@@ -208,7 +208,7 @@ ready. Then once the panel is created and its session is ready, it
208
208
can be added to the JupyterLab main area:
209
209
210
210
``` ts
211
- // src/index.ts#L58-L69
211
+ // src/index.ts#L63-L74
212
212
213
213
let panel: ExamplePanel ;
214
214
@@ -218,7 +218,7 @@ let panel: ExamplePanel;
218
218
* @returns The panel
219
219
*/
220
220
async function createPanel(): Promise <ExamplePanel > {
221
- panel = new ExamplePanel (manager , rendermime );
221
+ panel = new ExamplePanel (manager , rendermime , translator );
222
222
shell .add (panel , ' main' );
223
223
return panel ;
224
224
}
@@ -231,21 +231,21 @@ to be executed by the kernel. Then you will send it to your panel for execution
231
231
and display:
232
232
233
233
``` ts
234
- // src/index.ts#L83-L103
234
+ // src/index.ts#L88-L108
235
235
236
236
commands .addCommand (CommandIDs .execute , {
237
- label: ' Contact Kernel and Execute Code' ,
238
- caption: ' Contact Kernel and Execute Code' ,
237
+ label: trans . __ ( ' Contact Kernel and Execute Code' ) ,
238
+ caption: trans . __ ( ' Contact Kernel and Execute Code' ) ,
239
239
execute : async () => {
240
240
// Create the panel if it does not exist
241
241
if (! panel ) {
242
242
await createPanel ();
243
243
}
244
244
// Prompt the user about the statement to be executed
245
245
const input = await InputDialog .getText ({
246
- title: ' Code to execute' ,
247
- okLabel: ' Execute' ,
248
- placeholder: ' Statement to execute'
246
+ title: trans . __ ( ' Code to execute' ) ,
247
+ okLabel: trans . __ ( ' Execute' ) ,
248
+ placeholder: trans . __ ( ' Statement to execute' )
249
249
});
250
250
// Execute the statement
251
251
if (input .button .accept ) {
0 commit comments