Skip to content

Package: ExceptionView

ExceptionView

nameinstructionbranchcomplexitylinemethod
ExceptionView(Exception)
M: 95 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 23 C: 0
0%
M: 1 C: 0
0%
configLayout()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
configPanelCancelBtn()
M: 41 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
configPanelIcon()
M: 47 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
configTextArea()
M: 55 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
fillTextArea(Exception)
M: 41 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getBtnCancel()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTextArea()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package gui.view;
2:
3: import java.awt.FlowLayout;
4: import java.awt.Toolkit;
5:
6: import javax.swing.ImageIcon;
7: import javax.swing.JButton;
8: import javax.swing.JDialog;
9: import javax.swing.JLabel;
10: import javax.swing.JPanel;
11: import javax.swing.JTextArea;
12: import javax.swing.SpringLayout;
13:
14: /**
15: * The ExceptionView.
16: *
17: * @author Lukas
18: *
19: */
20: public class ExceptionView extends JDialog {
21:
22:         /**
23:          *
24:          */
25:         private static final long serialVersionUID = -153520520069331713L;
26:
27:         /**
28:          * @return the textArea
29:          */
30:         public final JTextArea getTextArea() {
31:                 return textArea;
32:         }
33:
34:         /**
35:          * @return the btnCancel
36:          */
37:         public final JButton getBtnCancel() {
38:                 return btnCancel;
39:         }
40:
41:         /**
42:          * This is the Text Area.
43:          */
44:         private final JTextArea textArea;
45:         /**
46:          * This is the panel for the Cancel Button.
47:          */
48:         private final JPanel panelCancelBtn;
49:         /**
50:          * This is the panelIcon.
51:          */
52:         private final JPanel panelIcon;
53:         /**
54:          * This is the Cancel Button.
55:          */
56:         private final JButton btnCancel;
57:         /**
58:          * This is the Spring Layout that enables the arrangement of the other components.
59:          */
60:         private final SpringLayout springLayout;
61:         /**
62:          * This is the JLabel that contains the Error Icon.
63:          */
64:         private final JLabel lblLblerroricon;
65:         /**
66:          * This is the Flow Layout for the Icon Panel.
67:          */
68:         private final FlowLayout flowLayout;
69:
70:         /**
71:          * Launch the application.
72:          */
73:
74:         /**
75:          * Create the dialog.
76:          *
77:          * @param exception
78:          * The exception to show.
79:          */
80:         public ExceptionView(final Exception exception) {
81:                 super();
82:
83:                 // Set a title, a icon and the look and feel for this JDialog
84:                 setTitle(basic.GuiConstants.ERRMTEXT);
85:                 setIconImage(Toolkit.getDefaultToolkit().getImage(
86:                                 ExceptionView.class.getResource("/com/sun/java/swing/plaf/motif/icons/Warn.gif")));
87:                 // Initiate springLayout
88:                 this.springLayout = new SpringLayout();
89:                 this.configLayout();
90:                 // Initiate textArea
91:                 this.textArea = new JTextArea();
92:                 // Initiate panelCancelButton
93:                 this.panelCancelBtn = new JPanel();
94:                 // Initiate flowLayout for panelCancelBtn
95:                 this.flowLayout = (FlowLayout) this.panelCancelBtn.getLayout();
96:                 // Set Alignment of flowLayout to Right
97:                 this.flowLayout.setAlignment(FlowLayout.RIGHT);
98:                 // Initiate panelIcon
99:                 this.panelIcon = new JPanel();
100:
101:                 this.configPanelIcon();
102:                 this.lblLblerroricon =
103:                                 new JLabel(new ImageIcon(
104:                                                 ExceptionView.class
105:                                                                 .getResource("/com/sun/java/swing/plaf/windows/icons/Error.gif")));
106:                 this.panelIcon.add(this.lblLblerroricon);
107:                 // Initiate btnCancel
108:                 this.btnCancel = new JButton("Cancel");
109:
110:                 this.configPanelCancelBtn();
111:                 this.panelCancelBtn.add(this.btnCancel);
112:
113:                 this.panelIcon.add(this.lblLblerroricon);
114:                 getContentPane().add(this.panelCancelBtn);
115:
116:                 this.configTextArea();
117:
118:                 this.fillTextArea(exception);
119:
120:         }
121:
122:         /**
123:          * Fills the textarea with informations.
124:          *
125:          * @param exception
126:          * The exception.
127:          */
128:         private void fillTextArea(final Exception exception) {
129:                 final StringBuffer text = new StringBuffer(55);
130:                 text.append("Error-Message (User-Info):");
131:                 text.append(basic.PrinterConstants.LINEBREAK);
132:                 text.append(exception.getMessage());
133:                 text.append(basic.PrinterConstants.LINEBREAK);
134:                 text.append("Caused by (Developer-Info): ");
135:                 text.append(basic.PrinterConstants.LINEBREAK);
136:                 text.append(exception.getCause());
137:                 this.textArea.setText(text.toString());
138:         }
139:
140:         /**
141:          * method for set padding, width and height of CancelButton.
142:          */
143:         private void configPanelCancelBtn() {
144:                 this.springLayout.putConstraint(SpringLayout.NORTH, this.panelCancelBtn,
145:                                 basic.GuiConstants.PADDING212, SpringLayout.NORTH, getContentPane());
146:                 this.springLayout.putConstraint(SpringLayout.SOUTH, this.panelCancelBtn,
147:                                 basic.GuiConstants.WESTPAD, SpringLayout.SOUTH, getContentPane());
148:                 this.springLayout.putConstraint(SpringLayout.WEST, this.panelCancelBtn,
149:                                 basic.GuiConstants.PADDING40, SpringLayout.EAST, this.panelIcon);
150:                 this.springLayout.putConstraint(SpringLayout.EAST, this.panelCancelBtn,
151:                                 basic.GuiConstants.WESTPAD, SpringLayout.EAST, getContentPane());
152:         }
153:
154:         /**
155:          * method for set padding, width and height of Layout.
156:          */
157:         private void configLayout() {
158:                 setBounds(basic.GuiConstants.BOUNDSX, basic.GuiConstants.BOUNDSY,
159:                                 basic.GuiConstants.BOUNDSWIDTH, basic.GuiConstants.BOUNDSHEIGHT);
160:                 getContentPane().setLayout(this.springLayout);
161:         }
162:
163:         /**
164:          * method for set padding, width and height of PanelIcon.
165:          */
166:         private void configPanelIcon() {
167:                 this.springLayout.putConstraint(SpringLayout.NORTH, this.panelIcon,
168:                                 basic.GuiConstants.SEPHOZWESTPAD, SpringLayout.NORTH, getContentPane());
169:                 this.springLayout.putConstraint(SpringLayout.WEST, this.panelIcon,
170:                                 basic.GuiConstants.SEPHOZWESTPAD, SpringLayout.WEST, getContentPane());
171:                 this.springLayout.putConstraint(SpringLayout.SOUTH, this.panelIcon,
172:                                 basic.GuiConstants.PADDING252, SpringLayout.NORTH, getContentPane());
173:                 this.springLayout.putConstraint(SpringLayout.EAST, this.panelIcon,
174:                                 basic.GuiConstants.PADDING61, SpringLayout.WEST, getContentPane());
175:                 getContentPane().add(this.panelIcon);
176:         }
177:
178:         /**
179:          * method for set padding, width and height of TextArea.
180:          */
181:         private void configTextArea() {
182:                 this.springLayout.putConstraint(SpringLayout.NORTH, this.textArea,
183:                                 basic.GuiConstants.SEPHOZWESTPAD, SpringLayout.NORTH, getContentPane());
184:                 this.springLayout.putConstraint(SpringLayout.SOUTH, this.textArea,
185:                                 basic.GuiConstants.EASTPAD, SpringLayout.NORTH, this.panelCancelBtn);
186:                 this.springLayout.putConstraint(SpringLayout.WEST, this.textArea,
187:                                 basic.GuiConstants.PADDING6, SpringLayout.EAST, this.panelIcon);
188:                 this.springLayout.putConstraint(SpringLayout.EAST, this.textArea,
189:                                 basic.GuiConstants.WESTPAD, SpringLayout.EAST, getContentPane());
190:
191:                 this.textArea.setLineWrap(true);
192:                 this.textArea.setWrapStyleWord(true);
193:
194:                 getContentPane().add(this.textArea);
195:         }
196: }