@@ -7,90 +7,59 @@ import { Dispatch } from "@reduxjs/toolkit";
7
7
import Output from "./components/Output" ;
8
8
import Sources from "./components/Sources" ;
9
9
import Libraries from "./components/Libraries" ;
10
- import Exception from "./components/Exception" ;
11
- import { ClasspathViewException , ProjectInfo } from "../../../types" ;
12
- import { catchException , listVmInstalls , loadClasspath , updateActiveTab } from "./classpathConfigurationViewSlice" ;
10
+ import { listVmInstalls , updateActiveTab } from "./classpathConfigurationViewSlice" ;
13
11
import JdkRuntime from "./components/JdkRuntime" ;
14
- import { ClasspathRequest } from "../../vscode/utils" ;
15
- import { VSCodePanelTab , VSCodePanelView , VSCodePanels , VSCodeProgressRing } from "@vscode/webview-ui-toolkit/react" ;
12
+ import { VSCodePanelTab , VSCodePanelView , VSCodePanels } from "@vscode/webview-ui-toolkit/react" ;
16
13
import { ProjectType } from "../../../../utils/webview" ;
17
14
import UnmanagedFolderSources from "./components/UnmanagedFolderSources" ;
18
15
import Hint from "./components/Hint" ;
19
16
import "../style.scss" ;
20
- import { setProjectType } from "../../mainpage/features/commonSlice" ;
21
17
22
18
const ClasspathConfigurationView = ( ) : JSX . Element => {
23
19
const activeTab : string = useSelector ( ( state : any ) => state . classpathConfig . ui . activeTab ) ;
24
20
const activeProjectIndex : number = useSelector ( ( state : any ) => state . commonConfig . ui . activeProjectIndex ) ;
25
- const projects : ProjectInfo [ ] = useSelector ( ( state : any ) => state . commonConfig . data . projects ) ;
26
21
const projectType : ProjectType = useSelector ( ( state : any ) => state . commonConfig . data . projectType [ activeProjectIndex ] ) ;
27
- const exception : ClasspathViewException | undefined = useSelector ( ( state : any ) => state . classpathConfig . exception ) ;
28
22
const dispatch : Dispatch < any > = useDispatch ( ) ;
29
23
30
24
const onClickTab = ( tabId : string ) => {
31
25
dispatch ( updateActiveTab ( tabId ) ) ;
32
26
} ;
33
27
34
- let content : JSX . Element ;
35
- if ( exception ) {
36
- content = < Exception /> ;
37
- } else if ( projects . length === 0 ) {
38
- content = < VSCodeProgressRing > </ VSCodeProgressRing > ;
39
- } else {
40
- content = (
41
- < div className = "root" >
42
- < VSCodePanels activeid = { activeTab } className = "setting-panels" >
43
- < VSCodePanelTab id = "source" onClick = { ( ) => onClickTab ( "source" ) } > Sources</ VSCodePanelTab >
44
- < VSCodePanelTab id = "jdk" onClick = { ( ) => onClickTab ( "jdk" ) } > JDK Runtime</ VSCodePanelTab >
45
- < VSCodePanelTab id = "libraries" onClick = { ( ) => onClickTab ( "libraries" ) } > Libraries</ VSCodePanelTab >
46
- < VSCodePanelView className = "setting-panels-view" >
47
- { [ ProjectType . Gradle , ProjectType . Maven ] . includes ( projectType ) && ( < Sources /> ) }
48
- { projectType !== ProjectType . Gradle && projectType !== ProjectType . Maven && ( < UnmanagedFolderSources /> ) }
49
- { projectType === ProjectType . UnmanagedFolder && ( < Output /> ) }
50
- </ VSCodePanelView >
51
- < VSCodePanelView className = "setting-panels-view" >
52
- < JdkRuntime />
53
- </ VSCodePanelView >
54
- < VSCodePanelView className = "setting-panels-view" >
55
- < Libraries />
56
- </ VSCodePanelView >
57
- </ VSCodePanels >
58
- < Hint />
59
- </ div >
60
- ) ;
61
- }
62
-
63
28
const onMessage = ( event : any ) => {
64
29
const { data } = event ;
65
30
if ( data . command === "classpath.onDidListVmInstalls" ) {
66
31
dispatch ( listVmInstalls ( data . vmInstalls ) )
67
- } else if ( data . command === "classpath.onDidLoadProjectClasspath" ) {
68
- dispatch ( setProjectType ( {
69
- projectType : data . projectType
70
- } ) ) ;
71
- dispatch ( loadClasspath ( {
72
- activeProjectIndex,
73
- ...data
74
- } ) ) ;
75
- } else if ( data . command === "classpath.onException" ) {
76
- dispatch ( catchException ( data . exception ) ) ;
77
32
}
78
33
} ;
79
34
80
35
useEffect ( ( ) => {
81
36
window . addEventListener ( "message" , onMessage ) ;
82
- if ( projects . length == 0 ) {
83
- // this makes sure the initialization only happens when the
84
- // redux store is empty. When switching between tabs, the
85
- // state will be preserved.
86
- ClasspathRequest . onWillListProjects ( ) ;
87
- }
88
37
return ( ) => {
89
38
window . removeEventListener ( "message" , onMessage ) ;
90
39
}
91
40
} , [ ] ) ;
92
41
93
- return content ;
42
+ return (
43
+ < div className = "root" >
44
+ < VSCodePanels activeid = { activeTab } className = "setting-panels" >
45
+ < VSCodePanelTab id = "source" onClick = { ( ) => onClickTab ( "source" ) } > Sources</ VSCodePanelTab >
46
+ < VSCodePanelTab id = "jdk" onClick = { ( ) => onClickTab ( "jdk" ) } > JDK Runtime</ VSCodePanelTab >
47
+ < VSCodePanelTab id = "libraries" onClick = { ( ) => onClickTab ( "libraries" ) } > Libraries</ VSCodePanelTab >
48
+ < VSCodePanelView className = "setting-panels-view" >
49
+ { [ ProjectType . Gradle , ProjectType . Maven ] . includes ( projectType ) && ( < Sources /> ) }
50
+ { projectType !== ProjectType . Gradle && projectType !== ProjectType . Maven && ( < UnmanagedFolderSources /> ) }
51
+ { projectType === ProjectType . UnmanagedFolder && ( < Output /> ) }
52
+ </ VSCodePanelView >
53
+ < VSCodePanelView className = "setting-panels-view" >
54
+ < JdkRuntime />
55
+ </ VSCodePanelView >
56
+ < VSCodePanelView className = "setting-panels-view" >
57
+ < Libraries />
58
+ </ VSCodePanelView >
59
+ </ VSCodePanels >
60
+ < Hint />
61
+ </ div >
62
+ ) ;
94
63
} ;
95
64
96
65
export default ClasspathConfigurationView ;
0 commit comments