Skip to content

Commit

Permalink
Added sign out reason and excused by on same page
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanashastri committed Jun 7, 2017
1 parent 4ad1ca2 commit 557ad5c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 123 deletions.
47 changes: 9 additions & 38 deletions src/JavaFXGUI/EnterInfoTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public EnterInfoTab(MenuTabPane par, EnterStudentTab prev, String title,
// infoOptionSelect.removeChoiceBox();
if (stringData.equals("+++")){
v ++;
infoOptionSelect.removeChoiceBox();
// infoOptionSelect.addChoiceBox(true, infoOptionSelect);
}
else if (stringData.equals("++")&& version == v){
page++;
Expand All @@ -106,7 +106,7 @@ else if (stringData.equals("++")&& version == v){
else{
infoOptionSelect.addPage(stringData);
}
infoOptionSelect.removeChoiceBox();
// infoOptionSelect.addChoiceBox(true, infoOptionSelect);
}
else if (stringData.equals("++++")){
stringData=file.nextLine();
Expand All @@ -129,22 +129,21 @@ else if (stringData.equals("++++")){
data2.add(stringData);
stringData=file.nextLine();
}
infoOptionSelect.splitScreen(page+1, title1, title2, data1, data2);
infoOptionSelect.addChoiceBox();
infoOptionSelect.splitScreen(page+1, title1, title2, data1, data2, infoOptionSelect);
}
// infoOptionSelect.addChoiceBox(false, infoOptionSelect);
}
else if (version == v){
infoOptionSelect.addButton(page, stringData, stringData);
infoOptionSelect.removeChoiceBox();
// infoOptionSelect.addChoiceBox(true, infoOptionSelect);
}
}
file.close();


Button backButton = new Button("Back to Start");
backButton.setOnAction(e -> goBackToHome());
backButton.setPrefSize(150, 20);
// backButton.getStylesheets().add(getClass().getResource("backButton").toString());
backButton.setPrefSize(175, 20);

HBox navHBox = new HBox();
navHBox.setPadding(new Insets(15, 12, 15, 12));
Expand Down Expand Up @@ -172,36 +171,6 @@ else if (version == v){
setContent(content);
}

public void updateScrollPane(ArrayList<String> option){

summaryLeftVBox.getChildren().clear();
summariesOptions = new ArrayList<AnimatedLabel>();

Separator separator = new Separator();
summaryLeftVBox.getChildren().add(separator);
ArrayList<String> titleList = infoOptionSelect.getPageTitles();
for (int i = 0; i < titleList.size(); i++){
summariesOptions.add(new AnimatedLabel (titleList.get(i) +" "+option.get(i)));
}

for (int i = 0; i < summariesOptions.size(); i++){
summariesOptions.get(i).getStyleClass().add("summaryLabel");
summariesOptions.get(i).setWrapText(true);
summaryLeftVBox.getChildren().add(summariesOptions.get(i));
}
}
public void updateAnimation(int page){

for (int i = 0; i < summariesOptions.size(); i++){
if ( page == i){
summariesOptions.get(i).play();

}
else{
summariesOptions.get(i).stop();
}
}
}
/**
* Transfers focus to the previous tab.
*/
Expand All @@ -223,13 +192,15 @@ public void die(){
*/
public void addData(ArrayList<String> option){

if (option.get(0).isEmpty()){
if (option.get(0).isEmpty() || option.get(1).isEmpty()){
alert.play();
}
else{
if (!goingIn){
student.setReason(option.get(0));
student.setExcused(option.get(1));
System.out.println(option.get(0));
System.out.println(option.get(1));
data.get("outin").add(student);
}
else{
Expand Down
29 changes: 9 additions & 20 deletions src/JavaFXGUI/EnterStudentTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,11 @@ private void moveOn(boolean signIn, Student student){
int j = 0;
for (int i =0; i < data.get("outin").getStudentList().size(); i++){
if (student.equals(data.get("outin").getStudentList().get(i))){
System.out.println(student.getArrTime());
System.out.println(student.getArrTime().equals("None"));
// System.out.println(student.getArrTime());
// System.out.println(student.getArrTime().equals("None"));
if(student.getArrTime().equals("None")){
j = i;
outin=true;
}else{
if (signIn){
tab3= new EnterInfoTab(parent, this, "Enter Information", data, signIn, student);
}
else{
tab3 = new EnterInfoTab(parent, this, "Enter Information", data, signIn, student);
}
setDisable(true);
parent.getTabs().add(tab3);
parent.getSelectionModel().select(tab3);
}
}
}
Expand All @@ -304,8 +294,11 @@ private void moveOn(boolean signIn, Student student){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("hh:mm a", Locale.US);
LocalTime todayTime = LocalTime.now();
String time = formatter.format(todayTime);

data.get("outin").getStudentList().get(j).setArrTime(time);
if(data.get("outin").getStudentList().get(j).getArrTime().length()>data.get("outin").getStudentList().get(j).getTime().length()){
data.get("outin").getStudentList().get(j).setTime(time);
}else{
data.get("outin").getStudentList().get(j).setArrTime(time);
}
LocalDate todayDate = LocalDate.now();
String date = todayDate.toString();
File f = new File("src/backup/" + date+"-OUT.csv");
Expand Down Expand Up @@ -337,8 +330,7 @@ private void moveOn(boolean signIn, Student student){
}
goBack(true);
}
else
{
else{
if (signIn){
tab3= new EnterInfoTab(parent, this, "Enter Information", data, signIn, student);
}
Expand All @@ -349,9 +341,6 @@ private void moveOn(boolean signIn, Student student){
parent.getTabs().add(tab3);
parent.getSelectionModel().select(tab3);
}

}



}

107 changes: 44 additions & 63 deletions src/JavaFXGUI/OptionSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class OptionSelect extends VBox{
private FadeTransition ftOut;
private ArrayList<OptionHBox> optionHBoxArray = new ArrayList<OptionHBox>();
private ChoiceBox c;
private HBox hb;
private ToggleGroup tg;
/**
* Constructor. The data of the optionSelect is represented by an ArrayList of Strings that indicates what options where selected.
* @param w Width of the optionSelect
Expand Down Expand Up @@ -105,19 +107,10 @@ public void init(){
getStyleClass().add("optionSelect");
HBox contentHBox = new HBox();

// pageButtonLeft = new Button();
// pageButtonLeft.getStyleClass().add("pageButton-left");
// pageButtonLeft.setOnAction(new NextHandler(false));

// pageButtonRight = new Button();
// pageButtonRight.getStyleClass().add("pageButton-right");
// pageButtonRight.setOnAction(new NextHandler(true));

// contentHBox.getChildren().add(pageButtonLeft);
buttonVBox = new VBox();
buttonVBox.getStyleClass().add("buttonVBox");

contentHBox.getChildren().addAll(buttonVBox);//, pageButtonRight);
contentHBox.getChildren().addAll(buttonVBox);
getChildren().add(contentHBox);

bottomHBox = new HBox();
Expand Down Expand Up @@ -159,31 +152,11 @@ public void addPage(String t){
* @param pg The page to be displayed
*/
private void updateState(int pg){
// if(pg == 0 && pg == buttonList.size()-1){
// pageButtonLeft.setDisable(true);
// pageButtonRight.setDisable(true);
// }
// else if(pg == 0 && pg == buttonList.size()-2){
// pageButtonLeft.setDisable(true);
// pageButtonRight.setDisable(true);
// }
// else if (pg == 0){
// pageButtonLeft.setDisable(true);
// pageButtonRight.setDisable(false);
// }
// else if (pg == buttonList.size()-1){
// pageButtonLeft.setDisable(false);
// pageButtonRight.setDisable(true);
// }
// else{
// pageButtonLeft.setDisable(false);
// pageButtonRight.setDisable(false);
// }
titleLabel.setText(title.get(pg));
page = pg;

buttonVBox.getChildren().clear();
double buttonHeight = (double)(height-80)/ (buttonList.get(page).size()+1);
double buttonHeight = (double)(height-100)/ (buttonList.get(page).size()+1);
double buttonWidth = (double)(width);

if (buttonList.get(page).size() >=3){
Expand Down Expand Up @@ -235,57 +208,65 @@ else if (buttonList.get(page).size() == 1){
optionHBoxArray.get(page).setPrefWidth(buttonWidth);

buttonVBox.getChildren().add(optionHBoxArray.get(page));
tabToBeClosed.updateScrollPane(option);
tabToBeClosed.updateAnimation(pg);

}
public void splitScreen(int page, String title1, String title2, ArrayList<String> data1, ArrayList<String> data2){
public void splitScreen(int page, String title1, String title2, ArrayList<String> data1, ArrayList<String> data2, OptionSelect o){
ArrayList<OptionButton> left = new ArrayList<OptionButton>();
for(int i =0;i<data1.size()-1;i++){
OptionButton opt = new OptionButton(data1.get(i), data1.get(i), page);
left.add(opt);
}
ArrayList<OptionButton> right = new ArrayList<OptionButton>();
VBox bV = new VBox();
for(int i = 0; i< data2.size();i++){
OptionButton opt = new OptionButton(data2.get(i), data2.get(i), page);
opt.setPrefWidth((double)width-100);
opt.setPrefHeight((double)(height-80)/(buttonList.get(page).size()+1));
right.add(opt);
}
bV.getChildren().add(right.get(page));
bV.getChildren().add(left.get(page));


buttonList.get(page).addAll(left) ;
option.add("");
OptionHBox textFieldOtherHBox = new OptionHBox(width, this, buttonList.size()-1);
textFieldOtherHBox.getStyleClass().add("optionTextFieldOther");
optionHBoxArray.add(textFieldOtherHBox);

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

updateState(0);

addChoiceBox(false,o);
buttonVBox.getChildren().remove(optionHBoxArray.get(page));

}
public void addChoiceBox(){
c = new ChoiceBox(FXCollections.observableArrayList("Health Room", "Parent", "Other"));
c.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue ov, Number value, Number new_value) {
// new ChoiceHandler(c.getSelectionModel().getSelectedItem().toString(),this);
addInfo(c.getSelectionModel().getSelectedItem().toString());
public void addChoiceBox(boolean rem, OptionSelect o){
RadioButton h = new RadioButton("Health Room");
h.getStyleClass().add("RadioButton");
RadioButton p = new RadioButton("Parent");
p.getStyleClass().add("RadioButton");

Label l = new Label("Enter who you were excused by: ");
l.getStyleClass().add("RadioButton");

tg = new ToggleGroup();
h.setToggleGroup(tg); p.setToggleGroup(tg);
tg.selectedToggleProperty().addListener((ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) -> {
for(String opt: option){
System.out.println(opt);
}
String[] pts = tg.getSelectedToggle().toString().split("'");
option.add(1,pts[1]);
submitButton.requestFocus();
});
c.setMaxSize(100,100);
buttonVBox.getChildren().add(c);
JRadioButton h = new JRadioButton("Health Room");
JRadioButton p = new JRadioButton("Parent");
ButtonGroup bg = new ButtonGroup();
bg.add(p); bg.add(h);

HBox hb = new HBox(70);
hb.getChildren().addAll(l,h,p);
hb.setAlignment(Pos.CENTER);

buttonVBox.getChildren().add(hb);
System.out.println("called1");

submitButton.requestFocus();
if(rem){
removeChoiceBox();
}
}
public void removeChoiceBox(){
if(buttonVBox.getChildren().contains(optionHBoxArray)){
buttonVBox.getChildren().remove(hb);
}
System.out.println("called");
// if(buttonVBox.getChildren().contains(c)){
buttonVBox.getChildren().remove(c);
//// System.out.println(buttonVBox.getChildren().contains(c));
// c.setDisable(true);
// buttonVBox.getChildren().remove(c);
// }
}
/**
Expand Down
4 changes: 2 additions & 2 deletions src/JavaFXGUI/StartApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ public StudentList readStudentDatabase(String fileName, String opt){
int i = 0;
for(String fieldName: file.nextLine().split(",")){
field.put(fieldName.trim(), i++);
System.out.println(field);
}

//Load in student data
ArrayList<ArrayList<String>> studentData = new ArrayList<ArrayList<String>>();
while(file.hasNext()){
ArrayList<String> aStudent = new ArrayList<String>();
String line = file.nextLine();
// System.out.println(line);
// System.out.println("nl"+line);
line = line.substring(1);
line = line.substring(0,line.length()-1);
Expand Down
3 changes: 3 additions & 0 deletions src/css/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@
-fx-alignment: center;
}

.RadioButton {
-fx-font-size: 15px;
}
.tab{
-fx-background-color: #FFF;
-fx-border-color: #eeeeee;
Expand Down

0 comments on commit 557ad5c

Please sign in to comment.