1 package org.telscenter.pas.ui.dialog;
2
3 import java.awt.BorderLayout;
4
5 import javax.swing.BorderFactory;
6 import javax.swing.ImageIcon;
7 import javax.swing.JButton;
8 import javax.swing.JComponent;
9 import javax.swing.JLabel;
10 import javax.swing.JPanel;
11 import javax.swing.JTextArea;
12
13 import org.telscenter.pas.common.ui.CommonUI;
14 import org.telscenter.pas.common.ui.layouts.EqualsLayout;
15 import org.telscenter.pas.steps.actions.DialogSaveAction;
16 import org.telscenter.pas.ui.util.PasColors;
17 import org.xito.dialog.DialogManager;
18
19
20 public class PasMessageDialogUI {
21
22
23 public static boolean OK = true;
24 public static boolean CANCEL = false;
25 protected JPanel messagePanel;
26 protected JPanel buttonPanel;
27 private String message;
28 protected JButton cancelButton;
29 protected JButton okButton;
30 private boolean result;
31 protected JPanel contentPanel;
32 private boolean showOkButtonOnly;
33
34 public PasMessageDialogUI() {
35 super();
36
37 }
38 public PasMessageDialogUI(boolean showOkButtonOnly) {
39 super();
40 this.showOkButtonOnly = showOkButtonOnly;
41
42 }
43 public JPanel createDialogPanel() {
44 contentPanel = new JPanel(new BorderLayout(0,0));
45 contentPanel.setBorder(BorderFactory.createLineBorder(PasColors.messageDialogContentBorderColor, 2));
46 contentPanel.setBackground(PasColors.messageDialogContentBackgroundColor);
47 messagePanel = (JPanel)createMessagePanel();
48 buttonPanel = createButtonPanel();
49 contentPanel.add(messagePanel,BorderLayout.CENTER);
50 contentPanel.add(buttonPanel,BorderLayout.SOUTH);
51 JPanel cp = new JPanel();
52 cp.setLayout(new BorderLayout(0,0));
53 cp.setBackground(PasColors.messageDialogBackgroundColor);
54 cp.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
55 cp.add(contentPanel,BorderLayout.CENTER);
56 cp.requestFocus();
57 return cp;
58 }
59
60
61 protected JComponent createMessagePanel() {
62 messagePanel = new JPanel(new BorderLayout(5,5));
63 ImageIcon icon = new ImageIcon(DialogManager.class
64 .getResource("images/important32.png"));
65 JLabel iconLabel = new JLabel(icon);
66 iconLabel.setOpaque(false);
67 messagePanel.add(iconLabel,BorderLayout.WEST);
68
69 JTextArea messageArea = new JTextArea(getMessage());
70
71 messageArea.setEditable(false);
72 messageArea.setOpaque(false);
73 messageArea.setWrapStyleWord(false);
74 messagePanel.add(messageArea,BorderLayout.CENTER);
75 messagePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
76 messagePanel.setOpaque(false);
77 return messagePanel;
78 }
79
80 protected JPanel createButtonPanel() {
81 initButtonsLayout();
82 arrangeButtons();
83 return buttonPanel;
84 }
85
86 protected void initButtonsLayout() {
87 cancelButton = new JButton();
88 okButton = new JButton();
89
90 makePasButtons();
91
92 }
93
94 protected void makePasButtons() {
95 addButtonActions();
96 CommonUI.makeEnhancedButton(okButton);
97 CommonUI.makeEnhancedButton(cancelButton);
98
99 }
100 protected void arrangeButtons() {
101 buttonPanel = new JPanel(new EqualsLayout(
102 EqualsLayout.HORIZONTAL, EqualsLayout.RIGHT, 1));
103 if(!showOkButtonOnly)
104 buttonPanel.add(cancelButton);
105
106 buttonPanel.add(okButton);
107 buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
108 buttonPanel.setBackground(PasColors.messageDialogButtonPanelBackgroundColor);
109 buttonPanel.setOpaque(false);
110 }
111 protected void addButtonActions() {
112 cancelButton.setAction(new DialogSaveAction("Cancel"));
113 okButton.setAction(new DialogSaveAction("Ok"));
114 }
115
116
117
118
119
120
121
122
123
124
125
126 protected void calcScreen() {
127
128
129
130 }
131
132
133 public JPanel getButtonPanel() {
134 return buttonPanel;
135 }
136
137
138 public void setButtonPanel(JPanel buttonPanel) {
139 this.buttonPanel = buttonPanel;
140 }
141
142
143 public JPanel getMessagePanel() {
144 return messagePanel;
145 }
146
147 public void setMessagePanel(JPanel messagePanel) {
148 this.messagePanel = messagePanel;
149 }
150
151 public String getMessage() {
152 return message;
153 }
154
155
156 public void setMessage(String message) {
157 this.message = message;
158 }
159
160
161 public JButton getCancelButton() {
162 return cancelButton;
163 }
164
165
166 public void setCancelButton(JButton cancelButton) {
167 this.cancelButton = cancelButton;
168 }
169
170
171 public JButton getOkButton() {
172 return okButton;
173 }
174
175
176 public void setOkButton(JButton okButton) {
177 this.okButton = okButton;
178 }
179
180
181 public boolean isResult() {
182 return result;
183 }
184
185
186 public void setResult(boolean result) {
187 this.result = result;
188 }
189
190 }