-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from CSC207-2022F-UofT/Feature-5-scheduling-co…
…llaborative-tasks Feature 5 scheduling collaborative tasks
- Loading branch information
Showing
13 changed files
with
578 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package scheduling_ct_screens; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionListener; | ||
import java.awt.event.ActionEvent; | ||
|
||
/** | ||
* The View for the Scheduling Collaborative Tasks Use Case | ||
*/ | ||
|
||
public class EnterTimeAndTask extends JFrame implements ActionListener { | ||
|
||
ScheduleCTController scheduleCTController; | ||
JTextField taskTitle = new JTextField(15); | ||
JTextField startTime = new JTextField(15); | ||
JTextField endTime = new JTextField(15); | ||
|
||
|
||
public EnterTimeAndTask(ScheduleCTController scheduleCTController) { | ||
|
||
this.scheduleCTController = scheduleCTController; | ||
|
||
|
||
JLabel title = new JLabel("Scheduling Collaborative Tasks"); | ||
title.setAlignmentX(Component.CENTER_ALIGNMENT); | ||
|
||
LabelTextPanel taskInfo = new LabelTextPanel(new JLabel("Enter task title"), taskTitle); | ||
|
||
LabelTextPanel startInfo = new LabelTextPanel(new JLabel("Enter start time"), startTime); | ||
|
||
LabelTextPanel endInfo = new LabelTextPanel(new JLabel("Enter end time"), endTime); | ||
|
||
|
||
JButton submit = new JButton("Submit"); | ||
|
||
JPanel buttons = new JPanel(); | ||
buttons.add(submit); | ||
|
||
submit.addActionListener(this); | ||
|
||
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); | ||
|
||
JPanel main = new JPanel(); | ||
main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); | ||
|
||
main.add(title); | ||
main.add(taskInfo); | ||
main.add(startInfo); | ||
main.add(endInfo); | ||
main.add(buttons); | ||
this.setContentPane(main); | ||
|
||
this.pack(); | ||
setVisible(true); | ||
} | ||
|
||
// React to button click that results in evt | ||
public void actionPerformed(ActionEvent evt) { | ||
// System.out.println("Click" + evt.getActionCommand()); | ||
scheduleCTController.isConflict(taskTitle.getText(), startTime.getText(), endTime.getText()); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package scheduling_ct_screens; | ||
|
||
import javax.swing.*; | ||
|
||
// Frameworks/Drivers layer | ||
|
||
/** | ||
* UI helper class that creates labeled text panel | ||
*/ | ||
|
||
public class LabelTextPanel extends JPanel { | ||
public LabelTextPanel(JLabel label, JTextField textField) { | ||
this.add(label); | ||
this.add(textField); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package scheduling_ct_screens; | ||
|
||
import javax.swing.*; | ||
|
||
public class PresentOutput extends JFrame { | ||
|
||
String message; | ||
|
||
public PresentOutput(String message) { | ||
this.message = message; | ||
|
||
JLabel text = new JLabel(message); | ||
|
||
JPanel main = new JPanel(); | ||
main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); | ||
|
||
main.add(text); | ||
setVisible(true); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/scheduling_ct_screens/ScheduleCTController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package scheduling_ct_screens; | ||
import entities.StudentUser; | ||
import entities.Task; | ||
import scheduling_ct_use_case.*; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* Controller for the Scheduling Collaborative Tasks Use Case | ||
* Triggers the interactor | ||
*/ | ||
|
||
public class ScheduleCTController { | ||
|
||
final ScheduleCTInputBoundary scheduleInput; | ||
|
||
private final HashMap<String, Task> hashMap; | ||
|
||
private final StudentUser studentUser; | ||
|
||
public ScheduleCTController(ScheduleCTInputBoundary scheduleInput, HashMap<String, Task> hashMap, StudentUser studentUser) { | ||
this.scheduleInput = scheduleInput; | ||
this.hashMap = hashMap; | ||
this.studentUser = studentUser; | ||
} | ||
|
||
public HashMap<String, Task> getTaskMap() { | ||
return hashMap; | ||
} | ||
|
||
public StudentUser getStudentUser() { | ||
return studentUser; | ||
} | ||
|
||
public ScheduleCTResponseModel isConflict(String taskName, String startTime, String endTime) { | ||
ScheduleCTRequestModel inputData = new ScheduleCTRequestModel(taskName, startTime, endTime, studentUser); | ||
return scheduleInput.schedule(inputData, this.hashMap); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/scheduling_ct_screens/ScheduleCTPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package scheduling_ct_screens; | ||
import scheduling_ct_use_case.*; | ||
|
||
/** | ||
* Presenter for the Collaborative Scheduling Use Case | ||
* Implements the Output Boundary as part of the dependency inversion | ||
*/ | ||
|
||
public class ScheduleCTPresenter implements ScheduleCTOutputBoundary { | ||
|
||
@Override | ||
public ScheduleCTResponseModel prepareNoConflictView(ScheduleCTResponseModel responseModel) { | ||
if ((!responseModel.getIsConflict())) { | ||
responseModel.setDisplayString("Successful input"); | ||
} | ||
return responseModel; | ||
} | ||
|
||
@Override | ||
public ScheduleCTResponseModel prepareFailView(String error) { | ||
throw new SchedulingTimesFailed(error); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/scheduling_ct_screens/SchedulingTimesFailed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package scheduling_ct_screens; | ||
|
||
public class SchedulingTimesFailed extends RuntimeException{ | ||
public SchedulingTimesFailed(String error){ | ||
super(error); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/scheduling_ct_use_case/ScheduleCTInputBoundary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package scheduling_ct_use_case; | ||
|
||
import entities.Task; | ||
import java.util.HashMap; | ||
|
||
/** | ||
* Input Boundary interface for the Scheduling Collaborative Tasks Use Case | ||
* (inverts dependency from Controller to Interactor) | ||
*/ | ||
|
||
public interface ScheduleCTInputBoundary { | ||
|
||
ScheduleCTResponseModel schedule(ScheduleCTRequestModel scheduleCTRequestModel, HashMap<String, Task> hashMap); | ||
} |
Oops, something went wrong.