@@ -17,12 +17,27 @@ import {
1717 ResourceResolver
1818} from "@theia/core/lib/common" ;
1919
20- import { ContainerModule } from ' inversify' ;
21- import { KeybindingContribution , KeybindingContext , WidgetFactory } from '@theia/core/lib/browser' ;
20+ import { ContainerModule , Container , interfaces } from " inversify" ;
21+ import { KeybindingContribution , KeybindingContext , WidgetFactory , TreeProps , createTreeContainer , defaultTreeProps , TreeWidget , TreeModelImpl , TreeModel } from '@theia/core/lib/browser' ;
2222
23- import '../../src/browser/styles/icons.css' ;
23+ import "../../src/browser/styles/icons.css" ;
24+ import "../../src/browser/styles/classpath.css" ;
2425import { FileStructure } from './navigation/file-structure' ;
2526import { 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' ;
2641
2742import { ExternalLibrariesWidget , EXTERNAL_LIBRARIES_ID } from './libraries/external-libraries-widget' ;
2843import { createExternalLibrariesWidget } from './libraries/external-libraries-container' ;
@@ -64,4 +79,128 @@ export default new ContainerModule((bind, unbind, isBound) => {
6479 id : EXTERNAL_LIBRARIES_ID ,
6580 createWidget : ( ) => context . container . get < ExternalLibrariesWidget > ( ExternalLibrariesWidget )
6681 } ) ) ;
82+
83+ /**
84+ * Classpath configuration
85+ */
86+ bind ( MarkDirAsSourceAction ) . toSelf ( ) . inSingletonScope ( ) ;
87+ bind ( CommandContribution ) . toDynamicValue ( ctx => ctx . container . get ( MarkDirAsSourceAction ) ) ;
88+ bind ( MenuContribution ) . toDynamicValue ( ctx => ctx . container . get ( MarkDirAsSourceAction ) ) ;
89+
90+ bind ( UnmarkDirAsSourceAction ) . toSelf ( ) . inSingletonScope ( ) ;
91+ bind ( CommandContribution ) . toDynamicValue ( ctx => ctx . container . get ( UnmarkDirAsSourceAction ) ) ;
92+ bind ( MenuContribution ) . toDynamicValue ( ctx => ctx . container . get ( UnmarkDirAsSourceAction ) ) ;
93+
94+ bind ( ClassPathDialog ) . toSelf ( ) . inSingletonScope ( ) ;
95+ bind ( DialogProps ) . toConstantValue ( { title : 'Configure Classpath' } ) ;
96+
97+ bind ( ClasspathContainer ) . toSelf ( ) . inSingletonScope ( ) ;
98+
99+ bind ( IClasspathNode ) . to ( LibraryNode ) . inSingletonScope ( ) ;
100+ bind ( IClasspathNode ) . to ( SourceNode ) . inSingletonScope ( ) ;
101+
102+ /**
103+ * Build path tree widget
104+ */
105+ bind ( BuildPathTreeWidget ) . toDynamicValue ( ctx =>
106+ createBuildPathTreeWidget ( ctx . container )
107+ ) . inSingletonScope ( ) ;
108+
109+ bind ( WidgetFactory ) . toDynamicValue ( context => ( {
110+ id : BuildPathTreeWidgetID ,
111+ createWidget : ( ) => context . container . get < BuildPathTreeWidget > ( BuildPathTreeWidget )
112+ } ) ) ;
113+
114+ /**
115+ * Library View widget
116+ */
117+ bind ( LibraryView ) . toDynamicValue ( ctx =>
118+ createLibraryViewTreeWidget ( ctx . container )
119+ ) . inSingletonScope ( ) ;
120+
121+ bind ( WidgetFactory ) . toDynamicValue ( context => ( {
122+ id : LibraryViewID ,
123+ createWidget : ( ) => context . container . get < LibraryView > ( LibraryView )
124+ } ) ) ;
125+
126+ /**
127+ * Source View widget
128+ */
129+ bind ( SourceView ) . toDynamicValue ( ctx =>
130+ createSourceViewTreeWidget ( ctx . container )
131+ ) . inSingletonScope ( ) ;
132+
133+ bind ( WidgetFactory ) . toDynamicValue ( context => ( {
134+ id : SourceViewID ,
135+ createWidget : ( ) => context . container . get < SourceView > ( SourceView )
136+ } ) ) ;
137+
138+ bind ( ClasspathDecorator ) . toSelf ( ) . inSingletonScope ( ) ;
139+ bind ( NavigatorTreeDecorator ) . toService ( ClasspathDecorator ) ;
140+
67141} ) ;
142+
143+ export const PROPS_PROPS = < TreeProps > {
144+ ...defaultTreeProps ,
145+ contextMenuPath : [ "NAVIGATOR_CONTEXT_MENU" ] ,
146+ multiSelect : false
147+ } ;
148+
149+ export function createBuildPathTreeWidgetContainer ( parent : interfaces . Container ) : Container {
150+ const child = createTreeContainer ( parent ) ;
151+
152+ child . rebind ( TreeProps ) . toConstantValue ( PROPS_PROPS ) ;
153+
154+ child . unbind ( TreeWidget ) ;
155+ child . bind ( BuildPathTreeWidget ) . toSelf ( ) ;
156+
157+ return child ;
158+ }
159+
160+ export function createBuildPathTreeWidget ( parent : interfaces . Container ) : BuildPathTreeWidget {
161+ return createBuildPathTreeWidgetContainer ( parent ) . get ( BuildPathTreeWidget ) ;
162+ }
163+
164+ /**
165+ * Library view
166+ */
167+ export function createLibraryViewTreeWidgetContainer ( parent : interfaces . Container ) : Container {
168+ const child = createTreeContainer ( parent ) ;
169+
170+ child . rebind ( TreeProps ) . toConstantValue ( PROPS_PROPS ) ;
171+
172+ child . unbind ( TreeModelImpl ) ;
173+ child . bind ( LibraryModel ) . toSelf ( ) ;
174+ child . rebind ( TreeModel ) . toDynamicValue ( ctx => ctx . container . get ( LibraryModel ) ) ;
175+
176+ child . unbind ( TreeWidget ) ;
177+ child . bind ( LibraryView ) . toSelf ( ) ;
178+
179+ return child ;
180+ }
181+
182+ export function createLibraryViewTreeWidget ( parent : interfaces . Container ) : LibraryView {
183+ return createLibraryViewTreeWidgetContainer ( parent ) . get ( LibraryView ) ;
184+ }
185+
186+ /**
187+ * Source view
188+ */
189+ export function createSourceViewTreeWidgetContainer ( parent : interfaces . Container ) : Container {
190+ const child = createTreeContainer ( parent ) ;
191+
192+ child . rebind ( TreeProps ) . toConstantValue ( PROPS_PROPS ) ;
193+
194+ child . unbind ( TreeModelImpl ) ;
195+ child . bind ( SourceModel ) . toSelf ( ) ;
196+ child . rebind ( TreeModel ) . toDynamicValue ( ctx => ctx . container . get ( SourceModel ) ) ;
197+
198+ child . unbind ( TreeWidget ) ;
199+ child . bind ( SourceView ) . toSelf ( ) ;
200+
201+ return child ;
202+ }
203+
204+ export function createSourceViewTreeWidget ( parent : interfaces . Container ) : SourceView {
205+ return createSourceViewTreeWidgetContainer ( parent ) . get ( SourceView ) ;
206+ }
0 commit comments