-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskView.java
More file actions
133 lines (105 loc) · 3.89 KB
/
Copy pathTaskView.java
File metadata and controls
133 lines (105 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import javax.swing.*;
import java.util.ArrayList;
public class TaskView extends JPanel {
ArrayList<UnitView> unitViews;
SuperModel myModel;
JFrame myFrame;
SumTableView sumTableView;
Controller myController;
public TaskView(SuperModel myModel, JFrame myFrame, Controller myController) {
this.myFrame = myFrame;
this.myModel = myModel;
this.myController= myController;
unitViews = new ArrayList<>();
// ez egy ures teszt model
//test
// UnitView uv1 = new UnitView(this);
// UnitView uv2 = new UnitView(this);
// UnitView uv3 = new UnitView(this);
//
// unitViews.add(uv1); //unitViews.add(uv2); unitViews.add(uv3);
//idaig tartott
sumTableView = new SumTableView(this);
buildFromModel();
this.setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
// for(UnitView unitView : unitViews){
// this.add(unitView);
// }
//this.add(sumTableView);
//test vege
}
public void refreshUnits(){
//REMOVES ALL UNITS FROM THE PANEL AND READDS ALL UNITS IN THE LIST
this.removeAll();
this.revalidate();
for(UnitView unitView : unitViews){
this.add(unitView);
}
this.add(sumTableView);
this.revalidate();
this.repaint();
}
// public void addUnit(){
// addEmptyUnit();
// //KELL MODOSITANI
//
// refreshUnits();
// }
public void addEmptyUnit(){
//to-do
unitViews.add(new UnitView(this));
refreshUnits();
}
public void notifyController(String candidateCode){
System.out.println("New code insterted:"+candidateCode);
Integer newIndex = unitViews.size() - 1;// azert kell ide a - 1 mert az utolso unit az szellem unit es en azelotti vagyok, marmint a most beillesztette uj unit az az utolso elotti mivel az utolso az a szellem unit
System.out.println("new index:" + newIndex);
if(!myController.taskViewEdited(newIndex,-1,-1,2,candidateCode)){
//ez boolt terit vissza de egyelore az if minden agan ugyanaz lenne
JOptionPane.showMessageDialog(myFrame,
"Format incorect.",
"Caracter invalid",
JOptionPane.ERROR_MESSAGE);
}
buildFromModel();
//addEmptyUnit();
}
public void buildFromModel() {
TaskTableCreator taskTableCreator = new TaskTableCreator((TaskModel) myModel);
unitViews.clear();
for(int i = 0; i < taskTableCreator.getUnitHeaderTs().length; i++){
//int unitIndex = Integer.parseInt(taskTableCreator.getUnitHeaderTs()[i][0][0]) - 1;//1tol indexelunk a headerekben
unitViews.add(new UnitView(this,i));
}
addEmptyUnit();
sumTableView = new SumTableView(this);
refreshUnits();
}
public void cellChanged(Integer unitIndex, Integer subUnitIndex, Integer rowIndex, Integer columnIndex, String data){
if(!myController.taskViewEdited(unitIndex,subUnitIndex,rowIndex,columnIndex,data)){
JOptionPane.showMessageDialog(myFrame,
"Format incorect.",
"Caracter invalid",
JOptionPane.ERROR_MESSAGE);
}
buildFromModel();
}
public void amplifiersEdited(int amplifierIndex, String data){
if(!myController.amplifiersEdited(amplifierIndex,data)){
JOptionPane.showMessageDialog(myFrame,
"Format incorect.",
"Caracter invalid",
JOptionPane.ERROR_MESSAGE);
}
buildFromModel();
}
public void deleteUnitClicked(int unitIndex){
myController.deleteUnit(unitIndex);
}
public TaskModel getMyModel() {
return (TaskModel)myModel;
}
public ArrayList<UnitView> getUnitViews() {
return unitViews;
}
}