1 package org.telscenter.pas.ui.beans.issueReporter;
2
3 import java.awt.Dimension;
4 import java.awt.Frame;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
7 import java.awt.event.WindowAdapter;
8 import java.awt.event.WindowEvent;
9
10 import javax.swing.JButton;
11 import javax.swing.JDialog;
12 import javax.swing.JFrame;
13
14 import org.telscenter.pas.ui.beans.issueReporter.actions.ReportIssueAction;
15 import org.telscenter.pas.ui.dialog.PasDialogManager;
16 import org.telscenter.pas.ui.dialog.PasIssueReporterMessageDialogUI;
17 import org.telscenter.pas.ui.util.PasColors;
18 import org.xito.dialog.CustomDialog;
19 import org.xito.dialog.DialogDescriptor;
20 import org.xito.dialog.DialogManager;
21
22
23 public class IssueReporter {
24
25 private IssueUI issueReportUI;
26
27 public IssueReporter() {
28 useDefaultUI();
29 }
30
31 public IssueReporter(IssueUI issueReportUI) {
32 setIssueReportUI(issueReportUI);
33 }
34
35 public IssueUI getIssueReportUI() {
36 return issueReportUI;
37 }
38
39 public void setIssueReportUI(IssueUI issueReportUI) {
40 this.issueReportUI = issueReportUI;
41 }
42
43 public void useDefaultUI() {
44 this.setIssueReportUI(new IssueUI());
45 }
46
47 public void showIssueReporter() {
48 DialogDescriptor descriptor = new DialogDescriptor();
49
50 descriptor.setWindowTitle(Messages.getString("IssueReporter.issue_reporter"));
51 descriptor.setTitle(Messages.getString("IssueReporter.issue_reporter"));
52 descriptor.setSubtitle(Messages.getString("IssueReporter.report_issue"));
53 descriptor.setCustomPanel(getIssueReportUI());
54 descriptor.setGradiantColor(PasColors.issueReportGradientColor);
55
56
57
58 descriptor.setWidth(500);
59 descriptor.setHeight(300);
60 descriptor.setShowButtonSeparator(true);
61 descriptor.setGradiantOffsetRatio(0.99f);
62 descriptor.setResizable(true);
63 descriptor.setType(DialogManager.NONE);
64
65
66
67 final CustomDialog cd = new CustomDialog(null, descriptor, false);
68 cd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
69
70 cd.addWindowListener(new WindowAdapter() {
71
72 public void windowActivated(WindowEvent e) {
73 cd.toFront();
74 getIssueReportUI().requestFocusInWindow();
75 }
76 public void windowClosing(WindowEvent we) {
77 PasIssueReporterMessageDialogUI ui = new PasIssueReporterMessageDialogUI(new ReportIssueAction(getIssueReportUI()));
78 ui.setMessage(Messages.getString("IssueReporter.your_issue_has_been_sent"));
79 PasDialogManager.showPasMessageDialog(Messages.getString("IssueReporter.question"), ui.createDialogPanel(), null);
80 }
81 });
82
83 cd.setFocusable(true);
84 cd.pack();
85 cd.setSize(getIssueReportUI().getPreferredSize());
86 cd.setVisible(true);
87 }
88
89 public static CustomDialog showAboutDialog(Frame frame) {
90 DialogDescriptor descriptor = new DialogDescriptor();
91
92 descriptor.setWindowTitle("About WISE");
93 descriptor.setTitle("About WISE");
94 descriptor.setSubtitle("PLACE TEXT HERE");
95 descriptor.setCustomPanel(new AboutUI());
96 descriptor.setGradiantColor(PasColors.issueReportGradientColor);
97
98 descriptor.setShowButtonSeparator(false);
99 descriptor.setGradiantOffsetRatio(0.99f);
100 descriptor.setResizable(false);
101 descriptor.setType(DialogManager.NONE);
102
103
104
105 final CustomDialog cd = new CustomDialog(frame, descriptor, true);
106 cd.setFocusable(true);
107 cd.setSize(450, 400);
108 cd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
109 cd.pack();
110 cd.setVisible(true);
111 return cd;
112 }
113 public static void main(String[] args) {
114 JFrame f = new JFrame();
115 f.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
116
117 JButton goButton = new JButton(Messages.getString("IssueReporter.bug"));
118 goButton.addActionListener(new ActionListener() {
119
120 public void actionPerformed(ActionEvent e) {
121 IssueReporter ir = new IssueReporter();
122 ir.showIssueReporter();
123 }});
124
125 f.getContentPane().add(goButton);
126 f.setSize(300, 300);
127 f.setVisible(true);
128 }
129 }