File size: 3,216 Bytes
28b5ddf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import javax.swing.*;
import java.awt.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class ClearPassAIGUI extends JFrame {
    private CardLayout cardLayout;
    private JPanel mainPanel;
    private LoginPage loginPage;
    private WelcomeScreen welcomeScreen;
    private InterviewScreen interviewScreen;
    private ResultScreen resultScreen;
    private String role;
    private String currentUser;
    private int questionCount = 5;
    private GeminiClient geminiClient;
    private ESpeakTTSClient ttsClient;
    private DataModel dataModel;

    public ClearPassAIGUI() {
        setTitle("ClearPass AI - Interview Coach");
        setSize(900, 700);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        Properties props = loadConfig();
        String geminiApiKey = props.getProperty("GEMINI_API_KEY");
        
        geminiClient = new GeminiClient(geminiApiKey, "gemini-1.5-flash");
        ttsClient = new ESpeakTTSClient();
        dataModel = new DataModel();

        cardLayout = new CardLayout();
        mainPanel = new JPanel(cardLayout);

        loginPage = new LoginPage(this);
        welcomeScreen = new WelcomeScreen(this);
        resultScreen = new ResultScreen(this);

        mainPanel.add(loginPage, "Login");
        mainPanel.add(welcomeScreen, "Welcome");
        mainPanel.add(resultScreen, "Results");

        add(mainPanel);
        showScreen("Login");
    }

    private Properties loadConfig() {
        Properties props = new Properties();
        try (FileInputStream fis = new FileInputStream("config.properties")) {
            props.load(fis);
        } catch (IOException e) {
            JOptionPane.showMessageDialog(this, "Configuration file not found", "Error", JOptionPane.ERROR_MESSAGE);
        }
        return props;
    }

    public void showScreen(String screenName) {
        cardLayout.show(mainPanel, screenName);
    }

    public void startSession(String role, int questionCount) {
        this.role = role;
        this.questionCount = questionCount;
        this.dataModel = new DataModel();
        interviewScreen = new InterviewScreen(this, questionCount);
        JScrollPane scrollPane = new JScrollPane(interviewScreen);
        mainPanel.add(scrollPane, "Interview");
        showScreen("Interview");
    }

    public void finishSession() {
        resultScreen = new ResultScreen(this);
        mainPanel.add(resultScreen, "Results");
        showScreen("Results");
    }

    public GeminiClient getGeminiClient() {
        return geminiClient;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public DataModel getDataModel() {
        return dataModel;
    }

    public int getQuestionCount() {
        return questionCount;
    }

    public void setQuestionCount(int questionCount) {
        this.questionCount = questionCount;
    }

    public String getCurrentUser() {
        return currentUser;
    }

    public void setCurrentUser(String currentUser) {
        this.currentUser = currentUser;
    }

    public ESpeakTTSClient getTTSClient() {
        return ttsClient;
    }
}