1 package net.logAnalyzer.gui.reports;
2
3 import java.awt.BorderLayout;
4 import java.util.Hashtable;
5
6 import javax.swing.Icon;
7 import javax.swing.JComponent;
8 import javax.swing.JLabel;
9 import javax.swing.JPanel;
10 import javax.swing.JScrollPane;
11 import javax.swing.JSplitPane;
12
13 import net.logAnalyzer.LogAnalyzerGUI;
14 import net.logAnalyzer.gui.LAView;
15 import net.logAnalyzer.gui.ViewDefinition;
16 import net.logAnalyzer.reports.LAReport;
17 import net.logAnalyzer.resources.LAResourceBundle;
18 import net.logAnalyzer.utils.gui.GraphicsDecoratorPanel;
19 import net.logAnalyzer.utils.gui.IQuickBarComponent;
20 import net.logAnalyzer.utils.gui.quickbar.QuickPanel;
21
22 /***
23 * View component used to display generated reports.
24 *
25 * @author David Vicente
26 * @version 0.1
27 */
28 public class ReportsView extends LAView implements ReportsTreeListener{
29 private static final long serialVersionUID = 1L;
30
31 private JScrollPane reportScrollPane;
32
33 private GraphicsDecoratorPanel quickBarComponent;
34
35 private String title="";
36
37 /***
38 * Creates a new view with the specified attributes.
39 *
40 * @param attributes
41 * View attributes.
42 */
43 public ReportsView(ViewDefinition definition, Hashtable attributes) {
44 super(definition, attributes);
45 }
46
47 /***
48 * Adds view components. Called by
49 * {@link #setViewContainer(LAViewContainer)}.
50 */
51 public void addComponents() {
52 setLayout(new BorderLayout());
53
54 title = LAResourceBundle.getLocalizedString("ReportsView.title", Integer
55 .toString(LogAnalyzerGUI.getReports().length));
56
57
58 JPanel panel = new JPanel();
59 panel.add(new JLabel("No displayed report"));
60 reportScrollPane = new JScrollPane(panel);
61 reportScrollPane
62 .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
63 reportScrollPane
64 .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
65
66
67
68
69
70
71
72 add(reportScrollPane, BorderLayout.CENTER);
73 }
74
75 /***
76 * Sets current messageLabel.
77 *
78 * @param oldFirstIndex
79 * Old first selected messageLabel index.
80 * @param oldLastIndex
81 * Old last selected messageLabel index.
82 * @param newFirstIndex
83 * New first selected messageLabel index.
84 * @param newLastIndex
85 * New last selected messageLabel index.
86 */
87 protected void setCurrentMessage(int oldFirstIndex, int oldLastIndex,
88 int newFirstIndex, int newLastIndex) {
89 }
90
91 /***
92 * Returns the view icon.
93 *
94 * @return View icon.
95 */
96 public Icon getIcon() {
97 return LAResourceBundle.getIcon("ReportsView.icon");
98 }
99
100 /***
101 * Returns the view title.
102 *
103 * @return View title.
104 */
105 public String getTitle() {
106 return title;
107 }
108
109 protected void displayReport(JComponent component) {
110
111 title = LAResourceBundle.getLocalizedString("ReportsView.title.report",component.getName());
112 this.getViewContainer().viewModified();
113 this.removeAll();
114 this.add(component);
115
116
117
118
119 this.updateUI();
120 }
121
122 public void displayReport(LAReport report) {
123 if(report != null){
124 JComponent component = report.createGUI();
125 displayReport(component);
126 }
127 }
128
129 public JPanel getQuickBarComponent(){
130 if(quickBarComponent == null){
131
132 ReportsTreePanel reportstree = new ReportsTreePanel(this);
133 quickBarComponent = new GraphicsDecoratorPanel(reportstree);
134 }
135 return quickBarComponent;
136 }
137
138 }