Skip to content

Commit

Permalink
Merge pull request #45 from CSC207-2022F-UofT/Feature-5-scheduling-co…
Browse files Browse the repository at this point in the history
…llaborative-tasks

Feature 5 scheduling collaborative tasks
  • Loading branch information
celinelumqr authored Nov 22, 2022
2 parents c75d476 + f5458a7 commit ee74c0e
Show file tree
Hide file tree
Showing 13 changed files with 578 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/main/java/entities/CollaborativeTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,6 @@ public void setDeclinedTeammates(ArrayList<StudentUser> declinedTeammates) {
this.declinedTeammates = declinedTeammates;
}


}

65 changes: 65 additions & 0 deletions src/main/java/scheduling_ct_screens/EnterTimeAndTask.java
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());


}
}
16 changes: 16 additions & 0 deletions src/main/java/scheduling_ct_screens/LabelTextPanel.java
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);
}
}
20 changes: 20 additions & 0 deletions src/main/java/scheduling_ct_screens/PresentOutput.java
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 src/main/java/scheduling_ct_screens/ScheduleCTController.java
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 src/main/java/scheduling_ct_screens/ScheduleCTPresenter.java
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);
}
}
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 src/main/java/scheduling_ct_use_case/ScheduleCTInputBoundary.java
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);
}
Loading

0 comments on commit ee74c0e

Please sign in to comment.