View Javadoc
1   package net.logAnalyzer.gui.messages;
2   
3   import java.awt.GridLayout;
4   import java.util.Hashtable;
5   
6   import javax.swing.Icon;
7   import javax.swing.JScrollPane;
8   
9   import net.logAnalyzer.LogAnalyzerGUI;
10  import net.logAnalyzer.gui.LAView;
11  import net.logAnalyzer.gui.LAViewContainer;
12  import net.logAnalyzer.gui.ViewDefinition;
13  import net.logAnalyzer.resources.LAResourceBundle;
14  
15  public class MessagesView extends LAView {
16      private static final long serialVersionUID = 1L;
17  
18      /***
19       * Table used to display messages.
20       */
21      private MessagesTable messagesTable;
22  
23      /***
24       * Creates a new view with the specified attributes.
25       * 
26       * @param attributes
27       *            View attributes.
28       */
29      public MessagesView(ViewDefinition definition, Hashtable attributes) {
30          super(definition, attributes);
31      }
32  
33      /***
34       * Adds view components. Called by
35       * {@link LAView#setViewContainer(LAViewContainer)}.
36       */
37      public void addComponents() {
38          setLayout(new GridLayout(1, 0));
39  
40          // Adds the messages table
41          messagesTable = new MessagesTable(this, getAttributes());
42          messagesTable.setModel(new MessagesModel(LogAnalyzerGUI.getHandler()));
43          // Adds the messages table in a scroll pane
44          JScrollPane messagesScrollPane = new JScrollPane(messagesTable);
45          messagesTable.setScrollPane(messagesScrollPane);
46          add(messagesScrollPane);
47      }
48  
49      /***
50       * Sets current messageLabel.
51       * 
52       * @param oldFirstIndex
53       *            Old first selected messageLabel index.
54       * @param oldLastIndex
55       *            Old last selected messageLabel index.
56       * @param newFirstIndex
57       *            New first selected messageLabel index.
58       * @param newLastIndex
59       *            New last selected messageLabel index.
60       */
61      protected void setCurrentMessage(int oldFirstIndex, int oldLastIndex,
62              int newFirstIndex, int newLastIndex) {
63          messagesTable.setCurrentMessage(newFirstIndex, newLastIndex);
64      }
65  
66      /***
67       * Returns the view icon.
68       * 
69       * @return View icon.
70       */
71      public Icon getIcon() {
72          return LAResourceBundle.getIcon("MessagesView.icon");
73      }
74  
75      /***
76       * Returns the view title.
77       * 
78       * @return View title.
79       */
80      public String getTitle() {
81          return LAResourceBundle.getLocalizedString("MessagesView.title",
82                  Integer.toString(LogAnalyzerGUI.getHandler().getSize()));
83      }
84  }