New Todo Item Stage update and New Todo Item Stage Test
This commit is contained in:
parent
fbdd18bb0c
commit
f7a420c997
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
|||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
||||
public class NewTodoItemStage implements Initializable {
|
||||
@FXML
|
||||
private ChoiceBox typeChoicebox;
|
||||
|
@ -28,12 +29,13 @@ public class NewTodoItemStage implements Initializable {
|
|||
private TextArea descriptionInput;
|
||||
private Button finish;
|
||||
private Button cancel;
|
||||
Stage addStage;
|
||||
|
||||
|
||||
private static final String FXML_FILE = "res/addTodoItemStage.fxml";
|
||||
private ClassLoader mClassLoader = getClass().getClassLoader();
|
||||
|
||||
@Override
|
||||
public void initialize(URL theLocation, ResourceBundle resources) {
|
||||
public void showNewTodoItemStage(){
|
||||
Parent root = null;
|
||||
try {
|
||||
root = FXMLLoader.load(mClassLoader.getResource(FXML_FILE));
|
||||
|
@ -41,14 +43,17 @@ public class NewTodoItemStage implements Initializable {
|
|||
e.printStackTrace();
|
||||
}
|
||||
Scene scene = new Scene(root, 400, 345);
|
||||
Stage addStage = new Stage();
|
||||
addStage = new Stage();
|
||||
addStage.setScene(scene);
|
||||
addStage.setTitle("Add a Todo Item");
|
||||
|
||||
|
||||
|
||||
ObservableList<String> ways = FXCollections.observableArrayList();
|
||||
ways.add("Conference");
|
||||
ways.add("Dates");
|
||||
ways.add("Others");
|
||||
|
||||
typeChoicebox = (ChoiceBox) root.lookup("#typeChoicebox");
|
||||
typeChoicebox.setItems(ways);
|
||||
typeChoicebox.setValue("Conference");
|
||||
|
@ -63,7 +68,6 @@ public class NewTodoItemStage implements Initializable {
|
|||
finish = (Button) root.lookup("#finish");
|
||||
cancel = (Button) root.lookup("#cancel");
|
||||
|
||||
finish = (Button) root.lookup("#finish");
|
||||
finish.setOnAction(e -> {
|
||||
String title = titleInput.getText(), bgn = bgnInput.getText(), end = endInput.getText(), location = locationInput.getText(), personnel = personnelInput.getText(), description = descriptionInput.getText();
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
|
@ -95,16 +99,90 @@ public class NewTodoItemStage implements Initializable {
|
|||
alert.show();
|
||||
addStage.close();
|
||||
} catch (IllegalStateException ex) {
|
||||
alert.setContentText("Fail" + ex.toString());
|
||||
alert.setContentText("Fail" + ex.getMessage());
|
||||
alert.show();
|
||||
}
|
||||
});
|
||||
|
||||
cancel = (Button) root.lookup("#cancel");
|
||||
cancel.setOnAction(e -> {
|
||||
addStage.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL theLocation, ResourceBundle resources) {
|
||||
// Parent root = null;
|
||||
// try {
|
||||
// root = FXMLLoader.load(mClassLoader.getResource(FXML_FILE));
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// Scene scene = new Scene(root, 400, 345);
|
||||
// addStage = new Stage();
|
||||
// addStage.setScene(scene);
|
||||
// addStage.setTitle("Add a Todo Item");
|
||||
//
|
||||
// ObservableList<String> ways = FXCollections.observableArrayList();
|
||||
// ways.add("Conference");
|
||||
// ways.add("Dates");
|
||||
// ways.add("Others");
|
||||
// typeChoicebox = (ChoiceBox) root.lookup("#typeChoicebox");
|
||||
// typeChoicebox.setItems(ways);
|
||||
// typeChoicebox.setValue("Conference");
|
||||
//
|
||||
// titleInput = (TextField) root.lookup("#titleInput");
|
||||
// bgnInput = (TextField) root.lookup("#bgnInput");
|
||||
// endInput = (TextField) root.lookup("#endInput");
|
||||
// locationInput = (TextField) root.lookup("#locationInput");
|
||||
// personnelInput = (TextField) root.lookup("#personnelInput");
|
||||
// descriptionInput = (TextArea) root.lookup("#descriptionInput");
|
||||
//
|
||||
// finish = (Button) root.lookup("#finish");
|
||||
// cancel = (Button) root.lookup("#cancel");
|
||||
//
|
||||
// finish = (Button) root.lookup("#finish");
|
||||
// finish.setOnAction(e -> {
|
||||
// String title = titleInput.getText(), bgn = bgnInput.getText(), end = endInput.getText(), location = locationInput.getText(), personnel = personnelInput.getText(), description = descriptionInput.getText();
|
||||
// Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
// if (title.equals("") || location.equals("") || personnel.equals("") || description.equals("")) {
|
||||
// alert.setContentText("Fail:You have some empty inputs.");
|
||||
// alert.show();
|
||||
// } else if (!CalendarUtil.isValidCalendarString(bgn) || !CalendarUtil.isValidCalendarString(end)) {
|
||||
// alert.setContentText("Fail:Your CalendarString input is not vaild.");
|
||||
// alert.show();
|
||||
// }
|
||||
//
|
||||
// TodoItemFactory factory = new TodoItemFactory();
|
||||
//
|
||||
// int type = typeChoicebox.getValue().equals("Conference") ? 1 : typeChoicebox.getValue().equals("Dates") ? 2 : 3;
|
||||
// String[] persons = personnel.split(",");
|
||||
// for (int i = 0; i < persons.length; i++)
|
||||
// factory.personnel(persons[i]);
|
||||
// factory.title(title);
|
||||
// factory.beginTime(CalendarUtil.constructCalendar(bgn));
|
||||
// factory.endTime(CalendarUtil.constructCalendar(end));
|
||||
// factory.type(type);
|
||||
// factory.location(location);
|
||||
// factory.description(description);
|
||||
// TodoItem newItem;
|
||||
// try {
|
||||
// newItem = factory.build();
|
||||
//// Presenter.addTodoItem(newItem);
|
||||
// alert.setContentText("Succeed");
|
||||
// alert.show();
|
||||
// addStage.close();
|
||||
// } catch (IllegalStateException ex) {
|
||||
// alert.setContentText("Fail" + ex.toString());
|
||||
// alert.show();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// cancel = (Button) root.lookup("#cancel");
|
||||
// cancel.setOnAction(e -> {
|
||||
// addStage.close();
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue