File Source: ErrorPopup.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.components.statusbar.ErrorPopup__static_init
*/
1 /*
2 * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.addons.ui_swing.components.statusbar;
24
25 import com.dmdirc.logger.ErrorLevel;
26 import com.dmdirc.logger.ErrorManager;
27 import com.dmdirc.logger.ErrorReportStatus;
28 import com.dmdirc.logger.ProgramError;
29 import com.dmdirc.util.MapList;
30
31 import java.awt.Font;
32 import java.awt.Window;
33 import java.util.List;
34
35 import javax.swing.JLabel;
36 import javax.swing.JPanel;
37 import javax.swing.JSeparator;
38
39 /**
40 * Shows a breakdown of errors that have occured.
41 *
42 * @since 0.6.3m1
43 * @author chris
44 */
45 public class ErrorPopup extends StatusbarPopupWindow {
46
47 /**
48 * A version number for this class. It should be changed whenever the class
49 * structure is changed (or anything else that would prevent serialized
50 * objects being unserialized with the new class).
51 */
52 private static final long serialVersionUID = 1;
53
54 /**
55 * Creates a new error popup.
56 *
57 * @param parent Parent panel
58 * @param parentWindow Parent window
59 */
60 public ErrorPopup(final JPanel parent, final Window parentWindow) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.components.statusbar.ErrorPopup(JPanel, Window)
*
* Postconditions:
* this.parent == parent
* init'ed(this.parent)
* this.parentWindow == parentWindow
* init'ed(this.parentWindow)
*/
61 super(parent, parentWindow);
62 }
63
64 /** {@inheritDoc} */
65 @Override
66 protected void initContent(final JPanel panel) {
/*
P/P * Method: void initContent(JPanel)
*
* Preconditions:
* panel != null
*
* Presumptions:
* arr$.length@104 <= 232-1
* arr$.length@85 <= 232-1
* arr$[i$]@104 != null
* arr$[i$]@85 != null
* com.dmdirc.logger.ErrorLevel:values(...)@85 != null
* ...
*
* Test Vectors:
* com.dmdirc.util.MapList:containsKey(...)@105: {0}, {1}
* com.dmdirc.util.MapList:containsKey(...)@86: {0}, {1}
* java.util.Iterator:hasNext(...)@72: {0}, {1}
*/
67 final List<ProgramError> errors = ErrorManager.getErrorManager().getErrors();
68 final MapList<ErrorLevel, ProgramError> buckets = new MapList<ErrorLevel, ProgramError>();
69 final MapList<ErrorReportStatus, ProgramError> statuses
70 = new MapList<ErrorReportStatus, ProgramError>();
71
72 for (ProgramError error : errors) {
73 buckets.add(error.getLevel(), error);
74 statuses.add(error.getReportStatus(), error);
75 }
76
77 JLabel header = new JLabel("Severity");
78 header.setFont(header.getFont().deriveFont(Font.BOLD));
79 panel.add(header);
80
81 header = new JLabel("#", JLabel.RIGHT);
82 header.setFont(header.getFont().deriveFont(Font.BOLD));
83 panel.add(header, "growx, pushx, wrap");
84
85 for (ErrorLevel level : ErrorLevel.values()) {
86 if (buckets.containsKey(level)) {
87 final int count = buckets.values(level).size();
88
89 panel.add(new JLabel(level.toString(), level.getIcon(), JLabel.LEFT));
90 panel.add(new JLabel(String.valueOf(count), JLabel.RIGHT), "growx, pushx, wrap");
91 }
92 }
93
94 panel.add(new JSeparator(), "span, growx, pushx, wrap");
95
96 header = new JLabel("Report status");
97 header.setFont(header.getFont().deriveFont(Font.BOLD));
98 panel.add(header);
99
100 header = new JLabel("#", JLabel.RIGHT);
101 header.setFont(header.getFont().deriveFont(Font.BOLD));
102 panel.add(header, "growx, pushx, wrap");
103
104 for (ErrorReportStatus status : ErrorReportStatus.values()) {
105 if (statuses.containsKey(status)) {
106 final int count = statuses.values(status).size();
107
108 panel.add(new JLabel(status.toString(), JLabel.LEFT));
109 panel.add(new JLabel(String.valueOf(count), JLabel.RIGHT), "growx, pushx, wrap");
110 }
111 }
112 }
113
114 }
SofCheck Inspector Build Version : 2.17854
| ErrorPopup.java |
2009-Jun-25 01:54:24 |
| ErrorPopup.class |
2009-Sep-02 17:04:15 |