Skip to content

Commit

Permalink
Updated software
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanashastri committed Jun 12, 2017
1 parent 6317064 commit d5d35de
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 1,254 deletions.
2 changes: 2 additions & 0 deletions src/JavaFXGUI/EnterInfoTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public void addData(ArrayList<String> option){
if(goingIn){
if (option.get(0).isEmpty()){
alert.play();
infoOptionSelect.submitFocus();
}else{
student.setReason(option.get(0));
data.get("in").add(student);
Expand Down Expand Up @@ -246,6 +247,7 @@ public void addData(ArrayList<String> option){
}else{
if(option.get(0).isEmpty() || option.get(1).isEmpty()){
alert.play();
infoOptionSelect.submitFocus();
}else{
student.setReason(option.get(0));
student.setExcused(option.get(1));
Expand Down
16 changes: 12 additions & 4 deletions src/JavaFXGUI/OptionSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public OptionSelect(int w, int h, EnterInfoTab close, Student st){
width = w;
student = st;
tabToBeClosed = close;

init();


Expand Down Expand Up @@ -94,6 +93,7 @@ public void init(){
submitButton = new Button("Submit");
submitButton.setAlignment(Pos.BOTTOM_CENTER);
submitButton.getStyleClass().add("submitButton");
submitButton.requestFocus();
submitButton.setDefaultButton(true);
submitButton.setOnAction(e -> handle());

Expand Down Expand Up @@ -201,7 +201,7 @@ else if (buttonList.get(page).size() == 1){
optionHBoxArray.get(page).setPrefWidth(buttonWidth);

buttonVBox.getChildren().add(optionHBoxArray.get(page));

submitButton.requestFocus();
}
/**
* Creates new page with two different questions: the first question's options are OptionButtons, while
Expand Down Expand Up @@ -266,7 +266,15 @@ public void addSubmitButton(int page){
bottomHBox.getChildren().add(submitButton);
}submitButton.requestFocus();
}

/**
*
* Allows other classes to request focus for the submit button.
*/
public void submitFocus(){
submitButton.requestFocus();
submitButton.defaultButtonProperty().bind(submitButton.focusedProperty());
System.out.println(submitButton.isFocused());
}
/**
* The method that handles submitting the data. It places focus on the submit button so it listens to key presses
* automatically.
Expand All @@ -275,7 +283,7 @@ public void addSubmitButton(int page){
*/
public void handle() {
submitButton.defaultButtonProperty().bind(submitButton.focusedProperty());
tabToBeClosed.addData(option);
tabToBeClosed.addData(option);
}


Expand Down
22 changes: 10 additions & 12 deletions src/JavaFXGUI/SettingHBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,9 @@ protected void updateItem(String item, boolean empty) {
}
};
});
// columnList.get(i).setSortable(true);
Comparator<Student> c = new TimeComparator();
// columnList.sort(c);
tableSignIn.sort();

}

tableSignIn.getColumns().add(columnList.get(i));
// tableSignIn.getColumns().size(), columnList.get(i));

Expand All @@ -611,10 +609,11 @@ protected void updateItem(String item, boolean empty) {
columnList.get(5).setCellValueFactory(new PropertyValueFactory<StudentProperty,
String>("time"));

columnList.get(5).setSortable(true);
// columnList.get(5).setComparator(new TimeComparator());
tableSignIn.setItems(goingIn);
// tableSignIn.sort();
columnList.get(5).setSortType(TableColumn.SortType.ASCENDING);
tableSignIn.getSortOrder().add(columnList.get(5));
tableSignIn.sort();
columnList.get(5).setSortable(true);
return tableSignIn;

}
Expand Down Expand Up @@ -650,7 +649,7 @@ protected void updateItem(String item, boolean empty) {
}
};
});
columnListOut.get(i).setSortable(false);
columnListOut.get(i).setSortable(true);
}
tableSignOut.getColumns().add(columnListOut.get(i));
}
Expand All @@ -673,6 +672,9 @@ protected void updateItem(String item, boolean empty) {
String>("arrTime"));

tableSignOut.setItems(goingOutIn);
columnListOut.get(6).setSortType(TableColumn.SortType.ASCENDING);
tableSignOut.getSortOrder().add(columnListOut.get(6));
columnListOut.get(6).setSortable(true);
return tableSignOut;
}
/**
Expand All @@ -689,10 +691,6 @@ public void sendEmail(){
emailTextArea.setWrapText(true);
ArrayList<String> emailList = EmailHandler.readEmailList();





dialog.getDialogPane().setContent(emailTextArea);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
Expand Down
2 changes: 2 additions & 0 deletions src/JavaFXGUI/StartApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ else if (opt == "i"){
String name = student.get(field.get("NAME"));
int grade = Integer.parseInt(student.get(field.get("GR")));
Student st = new Student (name,grade,id);
System.out.println(student.get(field.get("TIME")));
st.setTime(student.get(field.get("TIME")));
System.out.println(student.get(field.get("TIME")));
st.setReason(student.get(field.get("REASON")));
st.setDate(student.get(field.get("DATE")));
list.add(st);
Expand Down
38 changes: 22 additions & 16 deletions src/JavaFXGUI/StartTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void handle(MouseEvent click) {
if (click.getClickCount() == 2) {
String currentItemSelected = (String) list.getSelectionModel().getSelectedItem();
list.getSelectionModel().select(-1);
submit(currentItemSelected);
submit(currentItemSelected, false);
}
}
});
Expand All @@ -187,26 +187,27 @@ public void handle(MouseEvent click) {
contentHBox.setPadding(new Insets(15, 12, 15, 12));
contentHBox.setSpacing(10);


Button buttonSignIn = new Button("Student Sign In");
buttonSignIn.setPrefSize(200, 40);
buttonSignIn.setPrefSize(300, 50);
buttonSignIn.setOnAction(e -> moveOn(true));

buttonSignIn.getStyleClass().add("signButton");

Button buttonSignOut = new Button("Student Sign Out");
buttonSignOut.setPrefSize(200, 40);
buttonSignOut.setPrefSize(300, 50);
buttonSignOut.setOnAction(e -> moveOn(false));
buttonSignOut.getStyleClass().add("signButton");

Image photoID = new Image("img//image.png");
ImageView photoIDView = new ImageView();
photoIDView.setImage(photoID);
photoIDView.setFitWidth(350);
photoIDView.setFitWidth(400);
photoIDView.setPreserveRatio(true);
photoIDView.setSmooth(true);
photoIDView.setCache(true);
VBox v = new VBox();
v.getChildren().add(photoIDView);


contentHBox.getChildren().addAll(buttonSignIn, buttonSignOut);
content.setCenter(contentHBox);

Expand Down Expand Up @@ -261,7 +262,6 @@ public void searchStudent(ObservableList<String> entries, String oldVal, String
* the submit button will be triggered.
*/
public void submitButton(){

searchTextField.requestFocus();
String selected = (String) list.getSelectionModel().getSelectedItem();
String submittedText = "";
Expand All @@ -271,7 +271,7 @@ public void submitButton(){
submittedText = subentries.get(0);
ArrayList<String> toStringList = data.get("database").getInfoList();
if (toStringList.contains(submittedText)){
submit(submittedText);
submit(submittedText, false);
}
}
else{
Expand All @@ -280,9 +280,12 @@ public void submitButton(){
}
}
else{
if (searchTextField.getText().isEmpty()){
submittedText = searchTextField.getText();
if(data.get("database").getIDList().contains(submittedText)){
submit(submittedText,true);
}
else if (searchTextField.getText().isEmpty()){
alert.setWarning(true);

alert.play("Please submit your name.");
}
else{
Expand All @@ -292,22 +295,25 @@ public void submitButton(){
}
}
else{
submit(selected);
submit(selected, false);
}
}
/**
* Handles late bus entries. The student's reason is automatically set as "Late Bus," and their time
* of arrival is recorded in the log.
* @param txt Name of student
*/
public void submit(String txt){
public void submit(String txt, boolean id){
searchTextField.clear();
LocalDate todayDate = LocalDate.now();
String date = todayDate.toString();

String date = todayDate.toString();


Student newStudent = data.get("database").getStudentByToString(txt);
Student newStudent;
if(id){
newStudent = data.get("database").getStudentByID(txt);
}else{
newStudent = data.get("database").getStudentByToString(txt);
}
newStudent.setReason("Late Bus");
data.get("in").add(newStudent);

Expand Down
34 changes: 10 additions & 24 deletions src/backend/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ public class Student implements Comparable<Student>{
private String reason;
private String note;
private String date;
private String time;
private String time = "None";
private String excused = "";
private String arrTime = "None";
private int i;


/**
Expand All @@ -41,7 +40,6 @@ public Student(String n, int g, String sID){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("hh:mm a", Locale.US);
LocalTime todayTime = LocalTime.now();
time = formatter.format(todayTime);
i=0;
}


Expand Down Expand Up @@ -91,20 +89,18 @@ public String getReason() {


public void setReason(String reason) {
if(this.reason != null){
this.reason += ", " +reason;
}else{
// if(this.reason != null){
// this.reason += ", " +reason;
// }else{
this.reason=reason;
}
// }
}


public String getNote() {
return note;
}



public void setNote(String note) {
this.note = note;
}
Expand All @@ -114,20 +110,14 @@ public String getTime(){
}

public void setTime(String t){
// if(t != null){
// if(!this.time.contains("None")){
// System.out.println("time: " + this.time + " --> " + t);
// time += ", " + t;
// }else{
// System.out.println("time: " + this.time);
this.time=t;
System.out.println("time: " + this.time + " --> " + t);
// System.out.println("time: " + this.time + " --> " + t);
// }
addCount();
}
public void addCount(){
i+=1;
}
public int getCount(){
return i;
}
public String getDate(){
return date;
Expand All @@ -142,16 +132,12 @@ public void setExcused(String excused) {
this.excused = excused;
}
public void setArrTime(String arrTime) {
// if(this.arrTime.equals("None")){
// if(this.arrTime.contains("None")){
this.arrTime = arrTime;
// }else{
// this.arrTime += ", " + arrTime;
// }
System.out.println("time: " + this.arrTime + " --> " + arrTime);
if(arrTime!=this.arrTime){
addCount();
}
System.out.println(name + " - count: " + i);
// System.out.println("time: " + this.arrTime + " --> " + arrTime);
}
public String getArrTime() {
return arrTime;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/StudentProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String getStudentID() {
}

public void setStudentID(String studentID) {
this.studentID.concat("\n"+studentID);
this.studentID.set(studentID);
}

public String getReason() {
Expand Down
Loading

0 comments on commit d5d35de

Please sign in to comment.