Skip to content

Commit 1a064dd

Browse files
authored
Merge pull request #10 from Prem0707/GSoC18
Event listener added to UserAuthentication window
2 parents f4b88c3 + b93643e commit 1a064dd

4 files changed

Lines changed: 46 additions & 9 deletions

File tree

src/main/java/gov/doe/jgi/boost/client/constants/BOOSTConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ public class BOOSTConstants {
1212
public static final String SEQUENCE_TYPE = "sequence_type";
1313
public static final String VENDOR = "vendor";
1414
public static final String STRATEGY = "strategy";
15+
16+
// uri for signup
17+
public static final String SIGNUP_URI = "https://contacts.jgi.doe.gov/registration/new";
1518

1619
}

src/main/java/gov/doe/jgi/boost/ui/JWTAuthenticationFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class JWTAuthenticationFrame {
1313
public JWTAuthenticationFrame(){
1414
JFrame frame = new JFrame("JWTAuthentication");
1515
frame.setSize(300, 150);
16-
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16+
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1717
placeComponents(frame);
1818
frame.setVisible(true);
1919
}

src/main/java/gov/doe/jgi/boost/ui/LoginFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class LoginFrame {
1212
public LoginFrame(){
1313
JFrame frame = new JFrame("Login to BOOST");
1414
frame.setSize(300, 150);
15-
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
15+
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1616
placeComponents(frame);
1717
frame.setVisible(true);
1818
}

src/main/java/gov/doe/jgi/boost/ui/UserAuthentication.java

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
package gov.doe.jgi.boost.ui;
22

3+
import java.awt.event.ActionEvent;
4+
import java.awt.event.ActionListener;
5+
6+
import javax.swing.ButtonGroup;
37
import javax.swing.GroupLayout;
48
import javax.swing.JFrame;
59
import javax.swing.JLabel;
610
import javax.swing.JRadioButton;
711

12+
import gov.doe.jgi.boost.client.constants.BOOSTConstants;
13+
import gov.doe.jgi.boost.client.utils.UIUtils;
814

9-
public class UserAuthentication {
1015

11-
16+
public class UserAuthentication implements ActionListener {
17+
18+
private JLabel headingText;
19+
private JRadioButton buttonLogin;
20+
private JRadioButton buttonJWT;
21+
private JRadioButton buttonSignUp;
22+
1223
public UserAuthentication() {
1324

1425
JFrame jFrame= new JFrame();
1526
jFrame.setTitle("Prepare for Synthesis");
16-
jFrame.setResizable(false);
1727
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1828
placeComponents(jFrame);
1929
jFrame.setSize(400, 200);
@@ -31,10 +41,19 @@ private void placeComponents(JFrame jFrame) {
3141
layout.setAutoCreateGaps(true);
3242
layout.setAutoCreateContainerGaps(true);
3343

34-
JLabel headingText = new JLabel("Please choose one of the given way to Authenticate your Account:");
35-
JRadioButton buttonLogin = new JRadioButton("Login");
36-
JRadioButton buttonJWT = new JRadioButton("Provide your JWT");
37-
JRadioButton buttonSignUp = new JRadioButton("Sign Up");
44+
headingText = new JLabel("Please choose one of the given way to Authenticate your Account:");
45+
buttonLogin = new JRadioButton("Login");
46+
buttonJWT = new JRadioButton("Provide your JWT token");
47+
buttonSignUp = new JRadioButton("Sign Up");
48+
49+
ButtonGroup group = new ButtonGroup();
50+
group.add(buttonLogin);
51+
group.add(buttonJWT);
52+
group.add(buttonSignUp);
53+
54+
buttonLogin.addActionListener(this);
55+
buttonJWT.addActionListener(this);
56+
buttonSignUp.addActionListener(this);
3857

3958
layout.setHorizontalGroup(
4059
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
@@ -54,5 +73,20 @@ private void placeComponents(JFrame jFrame) {
5473

5574
jFrame.pack();
5675
jFrame.setLocationRelativeTo(null);
76+
jFrame.setResizable(false);
5777
}
78+
79+
@Override
80+
public void actionPerformed(ActionEvent event) {
81+
Object source = event.getSource();
82+
83+
if (source == buttonLogin) {
84+
System.out.println("Login button is clicked");
85+
new LoginFrame();
86+
} else if (source == buttonJWT) {
87+
new JWTAuthenticationFrame();
88+
} else if (source == buttonSignUp) {
89+
UIUtils.openWebPage(BOOSTConstants.SIGNUP_URI);
90+
}
91+
}
5892
}

0 commit comments

Comments
 (0)