@@ -10,28 +10,35 @@ import {
10
10
import {
11
11
ApplicationShell as TheiaApplicationShell ,
12
12
DockPanel ,
13
+ DockPanelRenderer as TheiaDockPanelRenderer ,
13
14
Panel ,
15
+ TabBar ,
14
16
Widget ,
17
+ SHELL_TABBAR_CONTEXT_MENU ,
15
18
} from '@theia/core/lib/browser' ;
16
19
import { Sketch } from '../../../common/protocol' ;
17
20
import { SaveAsSketch } from '../../contributions/save-as-sketch' ;
18
- import { CurrentSketch , SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl' ;
21
+ import {
22
+ CurrentSketch ,
23
+ SketchesServiceClientImpl ,
24
+ } from '../../../common/protocol/sketches-service-client-impl' ;
19
25
import { nls } from '@theia/core/lib/common' ;
20
26
import URI from '@theia/core/lib/common/uri' ;
27
+ import { ToolbarAwareTabBar } from './tab-bars' ;
21
28
22
29
@injectable ( )
23
30
export class ApplicationShell extends TheiaApplicationShell {
24
31
@inject ( CommandService )
25
- protected readonly commandService : CommandService ;
32
+ private readonly commandService : CommandService ;
26
33
27
34
@inject ( MessageService )
28
- protected readonly messageService : MessageService ;
35
+ private readonly messageService : MessageService ;
29
36
30
37
@inject ( SketchesServiceClientImpl )
31
- protected readonly sketchesServiceClient : SketchesServiceClientImpl ;
38
+ private readonly sketchesServiceClient : SketchesServiceClientImpl ;
32
39
33
40
@inject ( ConnectionStatusService )
34
- protected readonly connectionStatusService : ConnectionStatusService ;
41
+ private readonly connectionStatusService : ConnectionStatusService ;
35
42
36
43
protected override track ( widget : Widget ) : void {
37
44
super . track ( widget ) ;
@@ -43,7 +50,7 @@ export class ApplicationShell extends TheiaApplicationShell {
43
50
this . sketchesServiceClient . currentSketch ( ) . then ( ( sketch ) => {
44
51
if ( CurrentSketch . isValid ( sketch ) ) {
45
52
if ( ! this . isSketchFile ( widget . editor . uri , sketch . uri ) ) {
46
- return ;
53
+ return ;
47
54
}
48
55
if ( Sketch . isInSketch ( widget . editor . uri , sketch ) ) {
49
56
widget . title . closable = false ;
@@ -54,11 +61,11 @@ export class ApplicationShell extends TheiaApplicationShell {
54
61
}
55
62
56
63
private isSketchFile ( uri : URI , sketchUriString : string ) : boolean {
57
- const sketchUri = new URI ( sketchUriString ) ;
58
- if ( uri . parent . isEqual ( sketchUri ) ) {
59
- return true ;
60
- }
61
- return false ;
64
+ const sketchUri = new URI ( sketchUriString ) ;
65
+ if ( uri . parent . isEqual ( sketchUri ) ) {
66
+ return true ;
67
+ }
68
+ return false ;
62
69
}
63
70
64
71
override async addWidget (
@@ -120,15 +127,41 @@ export class ApplicationShell extends TheiaApplicationShell {
120
127
}
121
128
}
122
129
130
+ export class DockPanelRenderer extends TheiaDockPanelRenderer {
131
+ override createTabBar ( ) : TabBar < Widget > {
132
+ const renderer = this . tabBarRendererFactory ( ) ;
133
+ // `ToolbarAwareTabBar` is from IDE2 and not from Theia. Check the imports.
134
+ const tabBar = new ToolbarAwareTabBar (
135
+ this . tabBarToolbarRegistry ,
136
+ this . tabBarToolbarFactory ,
137
+ this . breadcrumbsRendererFactory ,
138
+ {
139
+ renderer,
140
+ // Scroll bar options
141
+ handlers : [ 'drag-thumb' , 'keyboard' , 'wheel' , 'touch' ] ,
142
+ useBothWheelAxes : true ,
143
+ scrollXMarginOffset : 4 ,
144
+ suppressScrollY : true ,
145
+ }
146
+ ) ;
147
+ this . tabBarClasses . forEach ( ( c ) => tabBar . addClass ( c ) ) ;
148
+ renderer . tabBar = tabBar ;
149
+ tabBar . disposed . connect ( ( ) => renderer . dispose ( ) ) ;
150
+ renderer . contextMenuPath = SHELL_TABBAR_CONTEXT_MENU ;
151
+ tabBar . currentChanged . connect ( this . onCurrentTabChanged , this ) ;
152
+ return tabBar ;
153
+ }
154
+ }
155
+
123
156
const originalHandleEvent = DockPanel . prototype . handleEvent ;
124
157
125
158
DockPanel . prototype . handleEvent = function ( event ) {
126
159
switch ( event . type ) {
127
- case 'p-dragenter' :
128
- case 'p-dragleave' :
129
- case 'p-dragover' :
130
- case 'p-drop' :
131
- return ;
160
+ case 'p-dragenter' :
161
+ case 'p-dragleave' :
162
+ case 'p-dragover' :
163
+ case 'p-drop' :
164
+ return ;
132
165
}
133
166
originalHandleEvent . bind ( this ) ( event ) ;
134
167
} ;
0 commit comments