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 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 if (nutrientTable == null) {
20 nutrientTable = new NutrientTable(getNutrientList());
21 }
22 return nutrientTable;
23 }
24
25 protected JScrollPane getNutrientTablePane() {
26 if (scrollPane == null) {
27 scrollPane = new JScrollPane(getNutrientTable());
28 scrollPane.setPreferredSize(new Dimension(300, 140));
29 scrollPane.getViewport().setBackground(Color.WHITE);
30 scrollPane.setBorder(BorderFactory.createEtchedBorder());
31 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
32 }
33 return scrollPane;
34 }
35
36
37 public void update(Observable source, Object message) {
38 if (!(message instanceof List)) {
39 return;
40 }
41 List consumed = (List) message;
42 getNutrientTable().update(source, message);
43 }
44
45
46 }