@@ -16,13 +16,28 @@ import {
16
16
MenuContribution
17
17
} from "@theia/core/lib/common" ;
18
18
19
- import { ContainerModule } from ' inversify' ;
20
- import { KeybindingContribution , KeybindingContext } from '@theia/core/lib/browser' ;
19
+ import { ContainerModule , Container , interfaces } from " inversify" ;
20
+ import { KeybindingContribution , KeybindingContext , WidgetFactory , TreeProps , createTreeContainer , defaultTreeProps , TreeWidget , TreeModelImpl , TreeModel } from '@theia/core/lib/browser' ;
21
21
22
- import '../../src/browser/styles/icons.css' ;
22
+ import "../../src/browser/styles/icons.css" ;
23
+ import "../../src/browser/styles/classpath.css" ;
23
24
import { FileStructure } from './navigation/file-structure' ;
24
25
import { FindImplementers } from './navigation/find-implementers' ;
25
26
import { JavaEditorTextFocusContext } from './java-keybinding-contexts' ;
27
+ import { BuildPathTreeWidget , BuildPathTreeWidgetID } from './classpath/build-path-widget' ;
28
+ import { ClassPathDialog , DialogProps } from './classpath/classpath-dialog' ;
29
+ import { ClasspathContainer } from './classpath/classpath-container' ;
30
+ import { SourceModel } from './classpath/pages/source/source-model' ;
31
+ import { LibraryModel } from './classpath/pages/library/library-model' ;
32
+ import { ClasspathDecorator } from './classpath/classpath-tree-decorator' ;
33
+ import { MarkDirAsSourceAction } from './action/mark-dir-as-source' ;
34
+ import { UnmarkDirAsSourceAction } from './action/unmark-dir-as-source' ;
35
+ import { NavigatorTreeDecorator } from '@theia/navigator/lib/browser/navigator-decorator-service' ;
36
+ import { LibraryView , LibraryViewID } from './classpath/pages/library/library-view' ;
37
+ import { SourceView , SourceViewID } from './classpath/pages/source/source-view' ;
38
+ import { IClasspathNode } from './classpath/nodes/classpath-node' ;
39
+ import { LibraryNode } from './classpath/nodes/library-node' ;
40
+ import { SourceNode } from './classpath/nodes/source-node' ;
26
41
27
42
export default new ContainerModule ( ( bind ) => {
28
43
@@ -42,4 +57,127 @@ export default new ContainerModule((bind) => {
42
57
43
58
bind ( KeybindingContext ) . to ( JavaEditorTextFocusContext ) . inSingletonScope ( ) ;
44
59
60
+ /**
61
+ * Classpath configuration
62
+ */
63
+ bind ( MarkDirAsSourceAction ) . toSelf ( ) . inSingletonScope ( ) ;
64
+ bind ( CommandContribution ) . toDynamicValue ( ctx => ctx . container . get ( MarkDirAsSourceAction ) ) ;
65
+ bind ( MenuContribution ) . toDynamicValue ( ctx => ctx . container . get ( MarkDirAsSourceAction ) ) ;
66
+
67
+ bind ( UnmarkDirAsSourceAction ) . toSelf ( ) . inSingletonScope ( ) ;
68
+ bind ( CommandContribution ) . toDynamicValue ( ctx => ctx . container . get ( UnmarkDirAsSourceAction ) ) ;
69
+ bind ( MenuContribution ) . toDynamicValue ( ctx => ctx . container . get ( UnmarkDirAsSourceAction ) ) ;
70
+
71
+ bind ( ClassPathDialog ) . toSelf ( ) . inSingletonScope ( ) ;
72
+ bind ( DialogProps ) . toConstantValue ( { title : 'Configure Classpath' } ) ;
73
+
74
+ bind ( ClasspathContainer ) . toSelf ( ) . inSingletonScope ( ) ;
75
+
76
+ bind ( IClasspathNode ) . to ( LibraryNode ) . inSingletonScope ( ) ;
77
+ bind ( IClasspathNode ) . to ( SourceNode ) . inSingletonScope ( ) ;
78
+
79
+ /**
80
+ * Build path tree widget
81
+ */
82
+ bind ( BuildPathTreeWidget ) . toDynamicValue ( ctx =>
83
+ createBuildPathTreeWidget ( ctx . container )
84
+ ) . inSingletonScope ( ) ;
85
+
86
+ bind ( WidgetFactory ) . toDynamicValue ( context => ( {
87
+ id : BuildPathTreeWidgetID ,
88
+ createWidget : ( ) => context . container . get < BuildPathTreeWidget > ( BuildPathTreeWidget )
89
+ } ) ) ;
90
+
91
+ /**
92
+ * Library View widget
93
+ */
94
+ bind ( LibraryView ) . toDynamicValue ( ctx =>
95
+ createLibraryViewTreeWidget ( ctx . container )
96
+ ) . inSingletonScope ( ) ;
97
+
98
+ bind ( WidgetFactory ) . toDynamicValue ( context => ( {
99
+ id : LibraryViewID ,
100
+ createWidget : ( ) => context . container . get < LibraryView > ( LibraryView )
101
+ } ) ) ;
102
+
103
+ /**
104
+ * Source View widget
105
+ */
106
+ bind ( SourceView ) . toDynamicValue ( ctx =>
107
+ createSourceViewTreeWidget ( ctx . container )
108
+ ) . inSingletonScope ( ) ;
109
+
110
+ bind ( WidgetFactory ) . toDynamicValue ( context => ( {
111
+ id : SourceViewID ,
112
+ createWidget : ( ) => context . container . get < SourceView > ( SourceView )
113
+ } ) ) ;
114
+
115
+ bind ( ClasspathDecorator ) . toSelf ( ) . inSingletonScope ( ) ;
116
+ bind ( NavigatorTreeDecorator ) . toService ( ClasspathDecorator ) ;
117
+
45
118
} ) ;
119
+
120
+ export const PROPS_PROPS = < TreeProps > {
121
+ ...defaultTreeProps ,
122
+ contextMenuPath : [ "NAVIGATOR_CONTEXT_MENU" ] ,
123
+ multiSelect : false
124
+ } ;
125
+
126
+ export function createBuildPathTreeWidgetContainer ( parent : interfaces . Container ) : Container {
127
+ const child = createTreeContainer ( parent ) ;
128
+
129
+ child . rebind ( TreeProps ) . toConstantValue ( PROPS_PROPS ) ;
130
+
131
+ child . unbind ( TreeWidget ) ;
132
+ child . bind ( BuildPathTreeWidget ) . toSelf ( ) ;
133
+
134
+ return child ;
135
+ }
136
+
137
+ export function createBuildPathTreeWidget ( parent : interfaces . Container ) : BuildPathTreeWidget {
138
+ return createBuildPathTreeWidgetContainer ( parent ) . get ( BuildPathTreeWidget ) ;
139
+ }
140
+
141
+ /**
142
+ * Library view
143
+ */
144
+ export function createLibraryViewTreeWidgetContainer ( parent : interfaces . Container ) : Container {
145
+ const child = createTreeContainer ( parent ) ;
146
+
147
+ child . rebind ( TreeProps ) . toConstantValue ( PROPS_PROPS ) ;
148
+
149
+ child . unbind ( TreeModelImpl ) ;
150
+ child . bind ( LibraryModel ) . toSelf ( ) ;
151
+ child . rebind ( TreeModel ) . toDynamicValue ( ctx => ctx . container . get ( LibraryModel ) ) ;
152
+
153
+ child . unbind ( TreeWidget ) ;
154
+ child . bind ( LibraryView ) . toSelf ( ) ;
155
+
156
+ return child ;
157
+ }
158
+
159
+ export function createLibraryViewTreeWidget ( parent : interfaces . Container ) : LibraryView {
160
+ return createLibraryViewTreeWidgetContainer ( parent ) . get ( LibraryView ) ;
161
+ }
162
+
163
+ /**
164
+ * Source view
165
+ */
166
+ export function createSourceViewTreeWidgetContainer ( parent : interfaces . Container ) : Container {
167
+ const child = createTreeContainer ( parent ) ;
168
+
169
+ child . rebind ( TreeProps ) . toConstantValue ( PROPS_PROPS ) ;
170
+
171
+ child . unbind ( TreeModelImpl ) ;
172
+ child . bind ( SourceModel ) . toSelf ( ) ;
173
+ child . rebind ( TreeModel ) . toDynamicValue ( ctx => ctx . container . get ( SourceModel ) ) ;
174
+
175
+ child . unbind ( TreeWidget ) ;
176
+ child . bind ( SourceView ) . toSelf ( ) ;
177
+
178
+ return child ;
179
+ }
180
+
181
+ export function createSourceViewTreeWidget ( parent : interfaces . Container ) : SourceView {
182
+ return createSourceViewTreeWidgetContainer ( parent ) . get ( SourceView ) ;
183
+ }
0 commit comments