1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
package ca.spaz.cron.summary; |
5 |
|
|
6 |
|
import java.awt.*; |
7 |
|
import java.util.*; |
8 |
|
import java.util.List; |
9 |
|
|
10 |
|
import javax.swing.*; |
11 |
|
|
12 |
0 |
public abstract class AbstractNutrientSummaryPanel extends JPanel implements Observer{ |
13 |
|
|
14 |
|
protected NutrientTable nutrientTable; |
15 |
|
protected JScrollPane scrollPane; |
16 |
|
protected abstract List getNutrientList(); |
17 |
|
|
18 |
|
private NutrientTable getNutrientTable() { |
19 |
0 |
if (nutrientTable == null) { |
20 |
0 |
nutrientTable = new NutrientTable(getNutrientList()); |
21 |
|
} |
22 |
0 |
return nutrientTable; |
23 |
|
} |
24 |
|
|
25 |
|
protected JScrollPane getNutrientTablePane() { |
26 |
0 |
if (scrollPane == null) { |
27 |
0 |
scrollPane = new JScrollPane(getNutrientTable()); |
28 |
0 |
scrollPane.setPreferredSize(new Dimension(300, 140)); |
29 |
0 |
scrollPane.getViewport().setBackground(Color.WHITE); |
30 |
0 |
scrollPane.setBorder(BorderFactory.createEtchedBorder()); |
31 |
0 |
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
32 |
|
} |
33 |
0 |
return scrollPane; |
34 |
|
} |
35 |
|
|
36 |
|
|
37 |
|
public void update(Observable source, Object message) { |
38 |
0 |
if (!(message instanceof List)) { |
39 |
0 |
return; |
40 |
|
} |
41 |
0 |
List consumed = (List) message; |
42 |
0 |
getNutrientTable().update(source, message); |
43 |
0 |
} |
44 |
|
|
45 |
|
|
46 |
|
} |