1
19 package com.qasystems.qstudio.java.gui.dialog;
20
21 import com.qasystems.international.MessageResource;
22 import com.qasystems.qstudio.java.QStudioGlobal;
23 import com.qasystems.qstudio.java.gui.ErrorLog;
24 import com.qasystems.qstudio.java.gui.ErrorLogPane;
25 import com.qasystems.swing.ButtonDialog;
26
27 import java.awt.Dimension;
28
29 import javax.swing.event.ChangeEvent;
30 import javax.swing.event.ChangeListener;
31
32
36 public class ErrorLogDialog extends ButtonDialog implements ChangeListener {
37 public static final int CLEAR = 0;
38 public static final int SETTINGS = 1;
39 public static final int CLOSE = 2;
40 private static final MessageResource RESOURCES =
41 MessageResource.getClientInstance();
42 private static final String TITLE = RESOURCES.getString("WINDOWTITLE_026");
43 private static final String[] BUTTONS =
44 {
45 RESOURCES.getString("BUTTON_015"), RESOURCES.getString("BUTTON_016"),
46 RESOURCES.getString("BUTTON_007")
47 };
48 private ErrorLogPane logPane = new ErrorLogPane();
49
50
53 public ErrorLogDialog() {
54 super(new QStudioGlobal().getFrame());
55
56 try {
57 jbInit();
58 } catch (Exception ex) {
59 ex.printStackTrace();
60 }
61
62 pack();
63 }
64
65
70 private void jbInit() throws Exception {
71 setModal(false);
72 setResizable(true);
73 setTitle(TITLE);
74 setButtons(BUTTONS);
75 setInitialButton(CLOSE);
76 logPane.setPreferredSize(new Dimension(500, 200));
77 setContent(logPane);
78 }
79
80 protected void onActionPerformed(int action) {
81 if (action == CLOSE) {
82 close();
83 } else if (action == CLEAR) {
84 clear();
85 } else if (action == SETTINGS) {
86 new DebugLevelDialog(this).show();
87 } else {
88 }
90 }
91
92 private void clear() {
93 logPane.getLog().clear();
94 }
95
96 private void close() {
97 if (isVisible()) {
98 setVisible(false);
99 }
100 }
101
102
107 public void setLog(ErrorLog newLog) {
108 newLog.addChangeListener(this);
109 logPane.setLog(newLog);
110 }
111
112
118 public void stateChanged(ChangeEvent event) {
119 setVisible(true);
120 toFront();
121 }
122 }
123