I need to make a java application that use MVC model ( I won't use the controler to avoid taht thigs get complicated ) .
So as you can see in the class diagram below I have 2 package but I had some problems when I try to interact between the model and the view .
the model.Main is composed of model.Files and model.Files is composed of ConfigFile,DivaConnector and FilesUploader.
Can you help to put the right links between those classes ?
the controler allows to communicate between the model and the view. So you put the main class in an extern package as a launcher and you instanciate the controler with model and view as args. Your main controler can instanciate some controlers specific of each view.
class Main
{
public static void main(String args[]) throws IOException
{
Model model = new Model();
View view = new View();
Controller controller = new Controller(view, model);
}
}
EDIT : here an example of main controler, in each specific controler builder you will put some listeners (button, tableview, textfield ...), as you have both model and view, you can alter chart elements according to the model.
package Controller;
import Model.Data;
import View.Frame;
public class Controller{
private Frame frame;
private Data data;
//controller
private GraphCtrl graphCtrl;
private MenuCtrl menuCtrl;
private EditCtrl editCtrl;
private TableCtrl tableCtrl;
//builder
public Controller(Frame frame, Data data){
this.frame=frame;
this.data=data;
build();
}
public void build(){
graphCtrl = new GraphCtrl(frame.getPanelG(), data);
menuCtrl = new MenuCtrl(frame, data);
editCtrl = new EditCtrl(frame.getPanelS().getPanelEdit(), frame.getPanelG(), data);
tableCtrl = new TableCtrl(frame.getPanelS().getPanelTable(), frame.getPanelG(), data);
}
}