public class Controller {
private Model model;
private UsersView usersView;
private EditUserView editUserView;
public void setModel(Model model) {
this.model = model;
}
public void setUsersView(UsersView usersView) {
this.usersView = usersView;
}
public void setEditUserView(EditUserView editUserView) {
this.editUserView = editUserView;
}
public void onShowAllUsers(){
model.loadUsers();
usersView.refresh(model.getDataModel());
}
public void onShowAllDeletedUsers() {
model.loadDeletedUsers();
usersView.refresh(model.getDataModel());
}
public void onOpenUserEditForm(long userId) {
model.loadUserById(userId);
usersView.refresh(model.getDataModel());
}
}
package com.codegym.task.task36.task3608;
import com.codegym.task.task36.task3608.controller.Controller;
//import com.codegym.task.task36.task3608.model.FakeModel;
import com.codegym.task.task36.task3608.model.MainModel;
import com.codegym.task.task36.task3608.model.Model;
import com.codegym.task.task36.task3608.view.UsersView;
public class Solution {
public static void main(String[] args) {
Model model = new MainModel();
UsersView usersView = new UsersView();
Controller controller = new Controller();
usersView.setController(controller);
controller.setModel(model);
controller.setUsersView(usersView);
usersView.fireShowAllUsersEvent();
usersView.fireOpenUserEditFormEvent(126L);
usersView.fireShowDeletedUsersEvent();
}
}