Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/app/AppBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,15 @@ public AppBuilder addDashboardUseCase() {
DynamoDbClientSingleton.getInstance());

final DashboardOutputBoundary dashboardOutputBoundary = new DashboardPresenter(
dashboardViewModel);
dashboardViewModel, viewManagerModel, choreCreationViewModel);

final DashboardInputBoundary dashboardInteractor = new DashboardInteractor(dashboardOutputBoundary, userService,
roomDataAccess, commitDataAccess);

final DashboardController dashboardController = new DashboardController(
dashboardInteractor);

dashboardView.setDashboardController(dashboardController);
mainView.setDashboardController(dashboardController);
return this;
}
Expand Down Expand Up @@ -398,7 +399,7 @@ public AppBuilder addChoreCreationUseCase() {
final RoomDataAccessInterface roomDataAccess = new RoomDataAccessObject(DynamoDbClientSingleton.getInstance());
final ChoreCreationOutputBoundary choreCreationOutputBoundary = new ChoreCreationPresenter(
choreCreationViewModel,
viewManagerModel);
viewManagerModel, loggedInViewModel);
final ChoreCreationInputBoundary choreCreationInteractor = new ChoreCreationInteractor(
choreCreationOutputBoundary,
choreDataAccess,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/app/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public static void main(String[] args) {
.addGitConsoleView()
.addProfileView()
.addMainView()
.addChoreCreationView()
.addSignupUseCase()
.addLoginUseCase()
.addGitConsoleUseCase()
.addRoomUseCases()
.addProfileUseCase()
.addDashboardUseCase()
.addChoreCreationView()
.addChoreCreationUseCase()
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package interface_adapter.chore_creation;

import interface_adapter.ViewManagerModel;
import interface_adapter.logged_in.LoggedInViewModel;
import use_case.chore_creation.ChoreCreationOutputBoundary;
import use_case.chore_creation.ChoreCreationOutputData;

public class ChoreCreationPresenter implements ChoreCreationOutputBoundary {

private final ChoreCreationViewModel viewModel;
private final ViewManagerModel viewManagerModel;
private final LoggedInViewModel loggedInViewModel;

public ChoreCreationPresenter(ChoreCreationViewModel viewModel,
ViewManagerModel viewManagerModel) {
ViewManagerModel viewManagerModel, LoggedInViewModel loggedInViewModel) {
this.viewModel = viewModel;
this.viewManagerModel = viewManagerModel;
this.loggedInViewModel = loggedInViewModel;
}

@Override
public void prepareSuccessView(ChoreCreationOutputData outputData) {
final ChoreCreationState state = new ChoreCreationState();
viewModel.setState(state);
viewModel.firePropertyChange();
viewManagerModel.setState("main");
viewManagerModel.setState(loggedInViewModel.getViewName());
viewManagerModel.firePropertyChange();
}

Expand All @@ -34,7 +37,7 @@ public void prepareFailView(String errorMessage) {

@Override
public void switchToDashboardView() {
viewManagerModel.setState("main");
viewManagerModel.setState(loggedInViewModel.getViewName());
viewManagerModel.firePropertyChange();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package interface_adapter.chore_creation;

import java.awt.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import javax.swing.*;

import interface_adapter.ViewModel;

/**
Expand All @@ -22,31 +16,8 @@ public class ChoreCreationViewModel extends ViewModel<ChoreCreationState> {
public static final String CREATE_BUTTON_LABEL = "Create Chore";
public static final String CANCEL_BUTTON_LABEL = "Cancel Creation";

private final PropertyChangeSupport support = new PropertyChangeSupport(this);
private ChoreCreationState state = new ChoreCreationState();

public ChoreCreationViewModel() {
super("chore creation");
setState(new ChoreCreationState());
}

@Override
public ChoreCreationState getState() {
return state;
}

@Override
public void setState(ChoreCreationState state) {
this.state = state;
}

@Override
public void firePropertyChange() {
support.firePropertyChange("state", null, this.state);
}

@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
support.addPropertyChangeListener(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ public void execute() {
final DashboardInputData inputData = new DashboardInputData();
dashboardInteractor.execute(inputData);
}

/**
* Switches the view to the Chore Creation View.
*/
public void switchToChoreCreationView() {
dashboardInteractor.switchToChoreCreationView();
}
}
16 changes: 14 additions & 2 deletions src/main/java/interface_adapter/dashboard/DashboardPresenter.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package interface_adapter.dashboard;

import interface_adapter.ViewManagerModel;
import interface_adapter.chore_creation.ChoreCreationViewModel;
import use_case.dashboard.DashboardOutputBoundary;
import use_case.dashboard.DashboardOutputData;

public class DashboardPresenter implements DashboardOutputBoundary {
private final DashboardViewModel dashboardViewModel;
private final ViewManagerModel viewManagerModel;
private final ChoreCreationViewModel choreCreationViewModel;

public DashboardPresenter(DashboardViewModel dashboardViewModel) {
public DashboardPresenter(DashboardViewModel dashboardViewModel, ViewManagerModel viewManagerModel,
ChoreCreationViewModel choreCreationViewModel) {
this.dashboardViewModel = dashboardViewModel;

this.viewManagerModel = viewManagerModel;
this.choreCreationViewModel = choreCreationViewModel;
}

@Override
Expand All @@ -32,4 +38,10 @@ public void prepareFailView(String errorMessage) {
dashboardViewModel.setState(dashboardState);
dashboardViewModel.firePropertyChange();
}

@Override
public void presentChoreCreationView() {
viewManagerModel.setState(choreCreationViewModel.getViewName());
viewManagerModel.firePropertyChange();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public void execute(ChoreCreationInputData inputData) {
inputData.getDescription(),
dueDate,
ChoreStatus.PENDING,
false
);
false);
choreDao.saveChore(chore);
final ChoreCreationOutputData output = new ChoreCreationOutputData(chore.getTitle());
presenter.prepareSuccessView(output);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/use_case/dashboard/DashboardInputBoundary.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ public interface DashboardInputBoundary {
* @param dashboardInputData the input data for the login use case
*/
void execute(DashboardInputData dashboardInputData);

/**
* Switches the view to the Chore Creation View.
*/
void switchToChoreCreationView();
}
5 changes: 5 additions & 0 deletions src/main/java/use_case/dashboard/DashboardInteractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ public void execute(DashboardInputData dashboardInputData) {

dashboardPresenter.prepareSuccessView(dashboardOutputData);
}

@Override
public void switchToChoreCreationView() {
dashboardPresenter.presentChoreCreationView();
}
}
5 changes: 5 additions & 0 deletions src/main/java/use_case/dashboard/DashboardOutputBoundary.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ public interface DashboardOutputBoundary {
* @param errorMessage the explanation of the failure
*/
void prepareFailView(String errorMessage);

/**
* Presents the Chore Creation View.
*/
void presentChoreCreationView();
}
5 changes: 2 additions & 3 deletions src/main/java/view/ChoreCreationView.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ChoreCreationView extends JPanel implements ActionListener, Propert
*
* @param choreCreationViewModel the ChoreCreationViewModel
*/
@SuppressWarnings({"checkstyle:ExecutableStatementCountCheck", "JavaNCSS"})
@SuppressWarnings({ "checkstyle:ExecutableStatementCountCheck", "JavaNCSS" })
public ChoreCreationView(ChoreCreationViewModel choreCreationViewModel) {
this.choreCreationViewModel = choreCreationViewModel;
choreCreationViewModel.addPropertyChangeListener(this);
Expand Down Expand Up @@ -280,8 +280,7 @@ public void actionPerformed(ActionEvent evt) {
currentState.getDescription(),
currentState.getPriority(),
currentState.getDueDate(),
currentState.getAssignedUser()
);
currentState.getAssignedUser());

} else if (evt.getSource() == cancelButton) {
choreCreationController.switchToDashboardView();
Expand Down
31 changes: 29 additions & 2 deletions src/main/java/view/DashboardView.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package view;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.*;

import interface_adapter.dashboard.DashboardController;
import interface_adapter.dashboard.DashboardState;
import interface_adapter.dashboard.DashboardViewModel;

Expand All @@ -14,6 +17,7 @@ public class DashboardView extends JPanel implements PropertyChangeListener {

private final ActivityTilesPanel activityTilesPanel;
private final DashboardViewModel dashboardViewModel;
private DashboardController dashboardController;

public DashboardView(DashboardViewModel dashboardViewModel) {
this.dashboardViewModel = dashboardViewModel;
Expand Down Expand Up @@ -56,12 +60,31 @@ private JPanel createSection(Component content) {
BorderFactory.createEmptyBorder(ViewConstants.DASHBOARD_BORDER, ViewConstants.DASHBOARD_BORDER,
ViewConstants.DASHBOARD_BORDER, ViewConstants.DASHBOARD_BORDER)));

final JPanel headerPanel = new JPanel(new BorderLayout());
headerPanel.setBackground(ViewColors.SAND_BACKGROUND);
headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, ViewConstants.DASHBOARD_BORDER, 0));

final JLabel titleLabel = new JLabel("Chore Activity");
titleLabel.setFont(ViewConstants.TITLE_FONT);
titleLabel.setForeground(ViewColors.DARK_BLUE);
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, ViewConstants.DASHBOARD_BORDER, 0));

section.add(titleLabel, BorderLayout.NORTH);
final JButton createChoreButton = new ButtonBuilder()
.setText("Create Chore")
.setFont(ViewConstants.LABEL_FONT)
.setBackground(ViewColors.ORANGE)
.setForeground(Color.WHITE)
.build();

createChoreButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dashboardController.switchToChoreCreationView();
}
});

headerPanel.add(titleLabel, BorderLayout.WEST);
headerPanel.add(createChoreButton, BorderLayout.EAST);
section.add(headerPanel, BorderLayout.NORTH);
section.add(content, BorderLayout.CENTER);

return section;
Expand Down Expand Up @@ -89,4 +112,8 @@ public void propertyChange(PropertyChangeEvent evt) {
public String getViewName() {
return "dashboard";
}

public void setDashboardController(DashboardController dashboardController) {
this.dashboardController = dashboardController;
}
}
Loading