| Line | Hits | Source |
|---|---|---|
| 1 | /******************************************************************************* | |
| 2 | * InternetCafe is a software solution that helps the management of Cybercafes | |
| 3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
| 4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
| 5 | ||
| 6 | * This program is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU General Public License | |
| 8 | * as published by the Free Software Foundation; either version 2 | |
| 9 | * of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 19 | *******************************************************************************/ | |
| 20 | package ui.panel; | |
| 21 | ||
| 22 | import java.awt.BorderLayout; | |
| 23 | import java.awt.Color; | |
| 24 | import java.awt.Dimension; | |
| 25 | import java.awt.GridLayout; | |
| 26 | import java.awt.event.ActionEvent; | |
| 27 | import java.awt.event.ActionListener; | |
| 28 | import java.util.Date; | |
| 29 | ||
| 30 | import javax.swing.ImageIcon; | |
| 31 | import javax.swing.JButton; | |
| 32 | import javax.swing.JComboBox; | |
| 33 | import javax.swing.JLabel; | |
| 34 | import javax.swing.JPanel; | |
| 35 | import javax.swing.JPasswordField; | |
| 36 | import javax.swing.JSplitPane; | |
| 37 | import javax.swing.JTextField; | |
| 38 | import javax.swing.border.EtchedBorder; | |
| 39 | import javax.swing.border.TitledBorder; | |
| 40 | ||
| 41 | import org.apache.log4j.Logger; | |
| 42 | ||
| 43 | import ui.Messages; | |
| 44 | import ui.command.CommandExecutor; | |
| 45 | import ui.command.IO.ExportUserAsVCardCommand; | |
| 46 | import ui.command.creation.ShowUserAddressBookDialogCommand; | |
| 47 | import ui.command.creation.ShowUserDocumentDialogCommand; | |
| 48 | import ui.dialog.DocumentDialog; | |
| 49 | import base.user.Document; | |
| 50 | import base.user.User; | |
| 51 | import base.user.UserCredential; | |
| 52 | import base.user.UserFactory; | |
| 53 | import base.user.UserGender; | |
| 54 | ||
| 55 | import com.toedter.calendar.JDateChooser; | |
| 56 | ||
| 57 | 0 | @SuppressWarnings("serial")//$NON-NLS-1$ |
| 58 | 0 | public class UserPanel extends JPanel { |
| 59 | 0 | |
| 60 | 0 | private static final transient Logger logger = Logger |
| 61 | 0 | .getLogger(UserPanel.class.getName()); |
| 62 | ||
| 63 | private JPanel topPanel; | |
| 64 | ||
| 65 | private JPanel bottomPanel; | |
| 66 | ||
| 67 | private JPanel contentPanel; | |
| 68 | ||
| 69 | private JPanel buttonPanel; | |
| 70 | ||
| 71 | private JButton documentButton; | |
| 72 | ||
| 73 | private JButton exportVCardButton; | |
| 74 | ||
| 75 | private JButton addressBookButton; | |
| 76 | ||
| 77 | private JPanel namePanel; | |
| 78 | ||
| 79 | private JTextField nameTextField; | |
| 80 | ||
| 81 | private JPanel surnamePanel; | |
| 82 | ||
| 83 | private JTextField surnameTextField; | |
| 84 | ||
| 85 | private JPanel birthdayPanel; | |
| 86 | ||
| 87 | private JDateChooser birthdayDateChooser; | |
| 88 | ||
| 89 | private JPanel imagePanel; | |
| 90 | ||
| 91 | private JPanel nicknamePanel; | |
| 92 | ||
| 93 | private JTextField nicknameTextField; | |
| 94 | ||
| 95 | private JPanel passwordPanel; | |
| 96 | ||
| 97 | private JPasswordField passwordField; | |
| 98 | ||
| 99 | private JPanel retypedPasswordPanel; | |
| 100 | ||
| 101 | private JPasswordField retypedPasswordField; | |
| 102 | ||
| 103 | private JPanel credentialPanel; | |
| 104 | ||
| 105 | private JComboBox credentialComboBox; | |
| 106 | ||
| 107 | private JPanel genderPanel; | |
| 108 | ||
| 109 | private JComboBox genderComboBox; | |
| 110 | 0 | |
| 111 | 0 | private final DocumentDialog documentDialog; |
| 112 | 0 | |
| 113 | 0 | private final User user; |
| 114 | 0 | |
| 115 | 0 | public UserPanel(User user) { |
| 116 | 0 | this.user = user; |
| 117 | 0 | documentDialog = new DocumentDialog(user == null ? user = UserFactory |
| 118 | 0 | .newUser() : user, user.getDocument()); |
| 119 | 0 | initialize(); |
| 120 | 0 | } |
| 121 | ||
| 122 | 0 | protected void initialize() { |
| 123 | 0 | this.setBorder(new TitledBorder(Messages.getString("common.user"))); //$NON-NLS-1$ |
| 124 | 0 | this.setLayout(new BorderLayout()); |
| 125 | 0 | this.add(getContentPanel(), BorderLayout.CENTER); |
| 126 | 0 | |
| 127 | 0 | } |
| 128 | ||
| 129 | /** | |
| 130 | * @return Returns the credentialPanel. | |
| 131 | */ | |
| 132 | 0 | protected JPanel getCredentialPanel() { |
| 133 | 0 | if (credentialPanel == null) { |
| 134 | 0 | credentialPanel = new JPanel(); |
| 135 | 0 | credentialPanel.setLayout(new BorderLayout()); |
| 136 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 137 | 0 | .getString("common.credential")); //$NON-NLS-1$ |
| 138 | 0 | credentialPanel.setBorder(titledBorder); |
| 139 | 0 | credentialPanel.add(getCredentialComboBox(), BorderLayout.CENTER); |
| 140 | 0 | } |
| 141 | 0 | return credentialPanel; |
| 142 | } | |
| 143 | ||
| 144 | /** | |
| 145 | * @return Returns the credentialComboBox. | |
| 146 | 0 | */ |
| 147 | 0 | protected JComboBox getCredentialComboBox() { |
| 148 | 0 | if (credentialComboBox == null) { |
| 149 | 0 | credentialComboBox = new JComboBox(); |
| 150 | 0 | for (int i = 0; i < UserCredential.USER_CREDENTIAL.length; i++) |
| 151 | 0 | credentialComboBox.addItem(UserCredential.USER_CREDENTIAL[i]); |
| 152 | 0 | |
| 153 | 0 | credentialComboBox |
| 154 | 0 | .setSelectedItem(user == null ? UserCredential.USER_CREDENTIAL[UserCredential.USER] |
| 155 | 0 | : user.getCredential()); |
| 156 | 0 | } |
| 157 | 0 | return credentialComboBox; |
| 158 | } | |
| 159 | ||
| 160 | /** | |
| 161 | * @return Returns the genderPanel. | |
| 162 | 0 | */ |
| 163 | 0 | protected JPanel getGenderPanel() { |
| 164 | 0 | if (genderPanel == null) { |
| 165 | 0 | genderPanel = new JPanel(); |
| 166 | 0 | genderPanel.setLayout(new BorderLayout()); |
| 167 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 168 | 0 | .getString("common.gender")); //$NON-NLS-1$ |
| 169 | 0 | genderPanel.setBorder(titledBorder); |
| 170 | 0 | genderPanel.add(getGenderComboBox(), BorderLayout.CENTER); |
| 171 | } | |
| 172 | 0 | return genderPanel; |
| 173 | } | |
| 174 | ||
| 175 | /** | |
| 176 | 0 | * @return Returns the genderComboBox. |
| 177 | 0 | */ |
| 178 | 0 | protected JComboBox getGenderComboBox() { |
| 179 | 0 | if (genderComboBox == null) { |
| 180 | 0 | genderComboBox = new JComboBox(); |
| 181 | 0 | for (int i = 0; i < UserGender.USER_GENDER.length; i++) |
| 182 | 0 | genderComboBox.addItem(UserGender.USER_GENDER[i]); |
| 183 | 0 | genderComboBox |
| 184 | 0 | .setSelectedItem(user == null ? UserGender.USER_GENDER[UserGender.MALE] |
| 185 | 0 | : user.getGender()); |
| 186 | } | |
| 187 | 0 | return genderComboBox; |
| 188 | } | |
| 189 | ||
| 190 | /** | |
| 191 | 0 | * @return Returns the namePanel. |
| 192 | 0 | */ |
| 193 | 0 | protected JPanel getNamePanel() { |
| 194 | 0 | if (namePanel == null) { |
| 195 | 0 | namePanel = new JPanel(); |
| 196 | 0 | namePanel.setPreferredSize(new Dimension(100, 30)); |
| 197 | 0 | namePanel.setLayout(new BorderLayout()); |
| 198 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 199 | 0 | .getString("common.name")); //$NON-NLS-1$ |
| 200 | 0 | namePanel.setBorder(titledBorder); |
| 201 | 0 | namePanel.add(getNameTextField(), BorderLayout.CENTER); |
| 202 | } | |
| 203 | 0 | return namePanel; |
| 204 | } | |
| 205 | ||
| 206 | 0 | /** |
| 207 | 0 | * @return Returns the nameTextField. |
| 208 | 0 | */ |
| 209 | 0 | protected JTextField getNameTextField() { |
| 210 | 0 | if (nameTextField == null) { |
| 211 | 0 | nameTextField = new JTextField(); |
| 212 | 0 | nameTextField.setText(user == null ? "" : user.getName()); //$NON-NLS-1$ |
| 213 | 0 | nameTextField.setDragEnabled(true); |
| 214 | } | |
| 215 | 0 | return nameTextField; |
| 216 | } | |
| 217 | 0 | |
| 218 | 0 | /** |
| 219 | 0 | * @return Returns the nicknamePanel. |
| 220 | 0 | */ |
| 221 | 0 | protected JPanel getNicknamePanel() { |
| 222 | 0 | if (nicknamePanel == null) { |
| 223 | 0 | nicknamePanel = new JPanel(); |
| 224 | 0 | nicknamePanel.setLayout(new BorderLayout()); |
| 225 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 226 | 0 | .getString("common.nickname")); //$NON-NLS-1$ |
| 227 | 0 | nicknamePanel.setBorder(titledBorder); |
| 228 | 0 | nicknamePanel.add(getNicknameTextField(), BorderLayout.CENTER); |
| 229 | } | |
| 230 | 0 | return nicknamePanel; |
| 231 | 0 | } |
| 232 | 0 | |
| 233 | 0 | /** |
| 234 | 0 | * @return Returns the nicknameTextField. |
| 235 | 0 | */ |
| 236 | protected JTextField getNicknameTextField() { | |
| 237 | 0 | if (nicknameTextField == null) { |
| 238 | 0 | nicknameTextField = new JTextField(); |
| 239 | 0 | nicknameTextField.setText(user == null ? "" : user.getNickname()); //$NON-NLS-1$ |
| 240 | } | |
| 241 | 0 | return nicknameTextField; |
| 242 | 0 | } |
| 243 | 0 | |
| 244 | 0 | /** |
| 245 | 0 | * @return Returns the passwordPanel. |
| 246 | 0 | */ |
| 247 | 0 | protected JPanel getPasswordPanel() { |
| 248 | 0 | if (passwordPanel == null) { |
| 249 | 0 | passwordPanel = new JPanel(); |
| 250 | 0 | passwordPanel.setLayout(new BorderLayout()); |
| 251 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 252 | .getString("common.password")); //$NON-NLS-1$ | |
| 253 | 0 | passwordPanel.setBorder(titledBorder); |
| 254 | 0 | passwordPanel.add(getPasswordField(), BorderLayout.CENTER); |
| 255 | } | |
| 256 | 0 | return passwordPanel; |
| 257 | 0 | } |
| 258 | 0 | |
| 259 | 0 | /** |
| 260 | 0 | * @return Returns the passwordField. |
| 261 | */ | |
| 262 | 0 | protected JPasswordField getPasswordField() { |
| 263 | 0 | if (passwordField == null) { |
| 264 | 0 | passwordField = new JPasswordField(); |
| 265 | 0 | passwordField.setText(user == null ? "" : user.getPassword()); //$NON-NLS-1$ |
| 266 | } | |
| 267 | 0 | return passwordField; |
| 268 | 0 | } |
| 269 | 0 | |
| 270 | 0 | /** |
| 271 | 0 | * @return Returns the retypedPasswordPanel. |
| 272 | 0 | */ |
| 273 | 0 | protected JPanel getRetypedPasswordPanel() { |
| 274 | 0 | if (retypedPasswordPanel == null) { |
| 275 | 0 | retypedPasswordPanel = new JPanel(); |
| 276 | 0 | retypedPasswordPanel.setLayout(new BorderLayout()); |
| 277 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 278 | .getString("common.password.retype")); //$NON-NLS-1$ | |
| 279 | 0 | retypedPasswordPanel.setBorder(titledBorder); |
| 280 | 0 | retypedPasswordPanel.add(getRetypedPasswordField(), |
| 281 | BorderLayout.CENTER); | |
| 282 | 0 | } |
| 283 | 0 | return retypedPasswordPanel; |
| 284 | 0 | } |
| 285 | 0 | |
| 286 | 0 | /** |
| 287 | 0 | * @return Returns the retypedPasswordField. |
| 288 | */ | |
| 289 | 0 | protected JPasswordField getRetypedPasswordField() { |
| 290 | 0 | if (retypedPasswordField == null) { |
| 291 | 0 | retypedPasswordField = new JPasswordField(); |
| 292 | 0 | retypedPasswordField |
| 293 | .setText(user == null ? "" : user.getPassword()); //$NON-NLS-1$ | |
| 294 | 0 | } |
| 295 | 0 | return retypedPasswordField; |
| 296 | 0 | } |
| 297 | 0 | |
| 298 | 0 | /** |
| 299 | 0 | * @return Returns the surnamePanel. |
| 300 | 0 | */ |
| 301 | 0 | protected JPanel getSurnamePanel() { |
| 302 | 0 | if (surnamePanel == null) { |
| 303 | 0 | surnamePanel = new JPanel(); |
| 304 | 0 | surnamePanel.setLayout(new BorderLayout()); |
| 305 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 306 | .getString("common.surname")); //$NON-NLS-1$ | |
| 307 | 0 | surnamePanel.setBorder(titledBorder); |
| 308 | 0 | surnamePanel.add(getSurnameTextField(), BorderLayout.CENTER); |
| 309 | 0 | } |
| 310 | 0 | return surnamePanel; |
| 311 | 0 | } |
| 312 | 0 | |
| 313 | /** | |
| 314 | 0 | * @return Returns the surnameTextField. |
| 315 | */ | |
| 316 | protected JTextField getSurnameTextField() { | |
| 317 | 0 | if (surnameTextField == null) { |
| 318 | 0 | surnameTextField = new JTextField(); |
| 319 | 0 | surnameTextField.setText(user == null ? "" : user.getSurname()); //$NON-NLS-1$ |
| 320 | 0 | } |
| 321 | 0 | return surnameTextField; |
| 322 | 0 | } |
| 323 | 0 | |
| 324 | 0 | /** |
| 325 | 0 | * @return Returns the contentPanel. |
| 326 | */ | |
| 327 | 0 | protected JPanel getContentPanel() { |
| 328 | 0 | if (contentPanel == null) { |
| 329 | 0 | contentPanel = new JPanel(); |
| 330 | 0 | contentPanel.setLayout(new GridLayout(2, 1)); |
| 331 | 0 | contentPanel.add(getTopPanel()); |
| 332 | 0 | contentPanel.add(getBottomPanel()); |
| 333 | 0 | } |
| 334 | 0 | return contentPanel; |
| 335 | 0 | } |
| 336 | 0 | |
| 337 | 0 | /** |
| 338 | 0 | * @return Returns the birthdayPanel. |
| 339 | 0 | */ |
| 340 | protected JPanel getBirthdayPanel() { | |
| 341 | 0 | if (birthdayPanel == null) { |
| 342 | 0 | birthdayPanel = new JPanel(); |
| 343 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 344 | .getString("common.birthday")); //$NON-NLS-1$ | |
| 345 | 0 | birthdayPanel.setBorder(titledBorder); |
| 346 | 0 | birthdayPanel.setLayout(new BorderLayout()); |
| 347 | 0 | birthdayPanel.add(getBirthdayDateChooser()); |
| 348 | 0 | } |
| 349 | 0 | return birthdayPanel; |
| 350 | 0 | } |
| 351 | 0 | |
| 352 | /** | |
| 353 | 0 | * @return Returns the birthdayDateChooser. |
| 354 | */ | |
| 355 | protected JDateChooser getBirthdayDateChooser() { | |
| 356 | 0 | if (birthdayDateChooser == null) { |
| 357 | 0 | birthdayDateChooser = new JDateChooser(); |
| 358 | 0 | birthdayDateChooser.setDate(user == null ? new Date() : user |
| 359 | 0 | .getBirthday()); |
| 360 | 0 | } |
| 361 | 0 | return birthdayDateChooser; |
| 362 | 0 | } |
| 363 | 0 | |
| 364 | /** | |
| 365 | 0 | * @return Returns the imagePanel. |
| 366 | */ | |
| 367 | protected JPanel getImagePanel() { | |
| 368 | 0 | if (imagePanel == null) { |
| 369 | 0 | imagePanel = new ImagePanel(user == null ? "" : user.getImagePath()); //$NON-NLS-1$ |
| 370 | 0 | TitledBorder titledBorder = new TitledBorder(Messages |
| 371 | 0 | .getString("common.photo")); //$NON-NLS-1$ |
| 372 | 0 | imagePanel.setBorder(titledBorder); |
| 373 | 0 | } |
| 374 | 0 | return imagePanel; |
| 375 | 0 | } |
| 376 | 0 | |
| 377 | 0 | /** |
| 378 | 0 | * @return Returns the buttonPanel. |
| 379 | 0 | */ |
| 380 | 0 | protected JPanel getButtonPanel() { |
| 381 | 0 | if (buttonPanel == null) { |
| 382 | 0 | buttonPanel = new JPanel(); |
| 383 | 0 | buttonPanel.setBorder(new EtchedBorder()); |
| 384 | 0 | buttonPanel.setLayout(new GridLayout(5, 1)); |
| 385 | 0 | buttonPanel.add(new JLabel("")); //$NON-NLS-1$ |
| 386 | 0 | buttonPanel.add(getDocumentButton()); |
| 387 | 0 | buttonPanel.add(getAddressBookButton()); |
| 388 | 0 | buttonPanel.add(getExportVCardButton()); |
| 389 | 0 | buttonPanel.add(new JLabel("")); //$NON-NLS-1$ |
| 390 | 0 | } |
| 391 | 0 | return buttonPanel; |
| 392 | 0 | } |
| 393 | ||
| 394 | public void clearUserData() { | |
| 395 | 0 | getNameTextField().setText(""); //$NON-NLS-1$ |
| 396 | 0 | getSurnameTextField().setText(""); //$NON-NLS-1$ |
| 397 | 0 | getBirthdayDateChooser().setDate(new Date()); |
| 398 | 0 | getNicknameTextField().setText(""); //$NON-NLS-1$ |
| 399 | 0 | getPasswordField().setText(""); //$NON-NLS-1$ |
| 400 | 0 | getRetypedPasswordField().setText(""); //$NON-NLS-1$ |
| 401 | 0 | } |
| 402 | 0 | |
| 403 | /** | |
| 404 | 0 | * @return Returns the documentButton. |
| 405 | */ | |
| 406 | protected JButton getDocumentButton() { | |
| 407 | 0 | if (documentButton == null) { |
| 408 | 0 | documentButton = new JButton(); |
| 409 | 0 | documentButton.setToolTipText(Messages |
| 410 | .getString("panel.userpanel.userdocument")); //$NON-NLS-1$ | |
| 411 | 0 | documentButton.setIcon(new ImageIcon(this.getClass().getResource( |
| 412 | "/icon/16x16/apps/accessories-text-editor.png"))); //$NON-NLS-1$ | |
| 413 | ||
| 414 | 0 | documentButton.addActionListener(new ActionListener() { |
| 415 | 0 | public void actionPerformed(ActionEvent arg0) { |
| 416 | logger.debug("actionPerformed documentButton"); //$NON-NLS-1$ | |
| 417 | 0 | // If there was an error on the document we must reset it... |
| 418 | setUserDocumentError(false); | |
| 419 | 0 | ShowUserDocumentDialogCommand showUserDocumentDialogCommand = new ShowUserDocumentDialogCommand( |
| 420 | documentDialog, user); | |
| 421 | 0 | CommandExecutor.getInstance().executeCommand( |
| 422 | showUserDocumentDialogCommand, false); | |
| 423 | 0 | } |
| 424 | }); | |
| 425 | 0 | |
| 426 | } | |
| 427 | 0 | return documentButton; |
| 428 | } | |
| 429 | 0 | |
| 430 | public String getUserName() { | |
| 431 | 0 | return getNameTextField().getText(); |
| 432 | } | |
| 433 | 0 | |
| 434 | public String getUserSurname() { | |
| 435 | 0 | return getSurnameTextField().getText(); |
| 436 | } | |
| 437 | 0 | |
| 438 | public Date getUserBirthday() { | |
| 439 | 0 | return getBirthdayDateChooser().getDate(); |
| 440 | } | |
| 441 | 0 | |
| 442 | public String getUserNickname() { | |
| 443 | 0 | return getNicknameTextField().getText(); |
| 444 | } | |
| 445 | 0 | |
| 446 | public String getUserPassword() { | |
| 447 | 0 | return new String(getPasswordField().getPassword()); |
| 448 | } | |
| 449 | 0 | |
| 450 | public String getRetypedPassword() { | |
| 451 | 0 | return new String(getRetypedPasswordField().getPassword()); |
| 452 | } | |
| 453 | 0 | |
| 454 | public String getUserCredential() { | |
| 455 | 0 | return (String) getCredentialComboBox().getSelectedItem(); |
| 456 | } | |
| 457 | 0 | |
| 458 | public String getUserGender() { | |
| 459 | 0 | return (String) getGenderComboBox().getSelectedItem(); |
| 460 | 0 | } |
| 461 | 0 | |
| 462 | 0 | public String getUserImagePath() { |
| 463 | 0 | return ((ImagePanel) getImagePanel()).getImagePath(); |
| 464 | 0 | } |
| 465 | 0 | |
| 466 | 0 | public Document getUserDocument() { |
| 467 | 0 | return documentDialog == null ? null : documentDialog.getDocument(); |
| 468 | 0 | } |
| 469 | 0 | |
| 470 | 0 | public void setUserNameError(boolean isError) { |
| 471 | 0 | if (isError) |
| 472 | 0 | ((TitledBorder) this.getNamePanel().getBorder()) |
| 473 | 0 | .setTitleColor(Color.RED); |
| 474 | 0 | else |
| 475 | 0 | ((TitledBorder) this.getNamePanel().getBorder()) |
| 476 | 0 | .setTitleColor(new TitledBorder("").getTitleColor()); //$NON-NLS-1$ |
| 477 | 0 | this.getNamePanel().updateUI(); |
| 478 | 0 | } |
| 479 | 0 | |
| 480 | 0 | public void setUserSurnameError(boolean isError) { |
| 481 | 0 | if (isError) |
| 482 | 0 | ((TitledBorder) this.getSurnamePanel().getBorder()) |
| 483 | 0 | .setTitleColor(Color.RED); |
| 484 | 0 | else |
| 485 | 0 | ((TitledBorder) this.getSurnamePanel().getBorder()) |
| 486 | 0 | .setTitleColor(new TitledBorder("").getTitleColor()); //$NON-NLS-1$ |
| 487 | 0 | this.getSurnamePanel().updateUI(); |
| 488 | 0 | } |
| 489 | 0 | |
| 490 | 0 | public void setUserBirthdayError(boolean isError) { |
| 491 | 0 | if (isError) |
| 492 | 0 | ((TitledBorder) this.getBirthdayPanel().getBorder()) |
| 493 | 0 | .setTitleColor(Color.RED); |
| 494 | 0 | else |
| 495 | 0 | ((TitledBorder) this.getBirthdayPanel().getBorder()) |
| 496 | 0 | .setTitleColor(new TitledBorder("").getTitleColor()); //$NON-NLS-1$ |
| 497 | 0 | this.getBirthdayPanel().updateUI(); |
| 498 | 0 | } |
| 499 | 0 | |
| 500 | 0 | public void setUserNicknameError(boolean isError) { |
| 501 | 0 | if (isError) |
| 502 | 0 | ((TitledBorder) this.getNicknamePanel().getBorder()) |
| 503 | 0 | .setTitleColor(Color.RED); |
| 504 | 0 | else |
| 505 | 0 | ((TitledBorder) this.getNicknamePanel().getBorder()) |
| 506 | 0 | .setTitleColor(new TitledBorder("").getTitleColor()); //$NON-NLS-1$ |
| 507 | 0 | this.getNicknamePanel().updateUI(); |
| 508 | 0 | } |
| 509 | 0 | |
| 510 | 0 | public void setUserPasswordError(boolean isError) { |
| 511 | 0 | if (isError) { |
| 512 | 0 | ((TitledBorder) this.getPasswordPanel().getBorder()) |
| 513 | 0 | .setTitleColor(Color.RED); |
| 514 | 0 | ((TitledBorder) this.getRetypedPasswordPanel().getBorder()) |
| 515 | 0 | .setTitleColor(Color.RED); |
| 516 | 0 | } else { |
| 517 | 0 | ((TitledBorder) this.getPasswordPanel().getBorder()) |
| 518 | 0 | .setTitleColor(new TitledBorder("").getTitleColor()); //$NON-NLS-1$ |
| 519 | 0 | ((TitledBorder) this.getRetypedPasswordPanel().getBorder()) |
| 520 | 0 | .setTitleColor(new TitledBorder("").getTitleColor()); //$NON-NLS-1$ |
| 521 | 0 | } |
| 522 | 0 | this.getPasswordPanel().updateUI(); |
| 523 | 0 | this.getRetypedPasswordPanel().updateUI(); |
| 524 | 0 | } |
| 525 | ||
| 526 | public void setUserDocumentError(boolean isError) { | |
| 527 | 0 | if (isError) |
| 528 | 0 | this.getDocumentButton().setBackground(Color.RED); |
| 529 | 0 | else |
| 530 | 0 | this.getDocumentButton().setBackground( |
| 531 | 0 | new JButton().getBackground()); |
| 532 | 0 | |
| 533 | 0 | } |
| 534 | ||
| 535 | 0 | /** |
| 536 | * @return Returns the addressBookButton. | |
| 537 | */ | |
| 538 | protected JButton getAddressBookButton() { | |
| 539 | 0 | if (addressBookButton == null) { |
| 540 | 0 | addressBookButton = new JButton(); |
| 541 | 0 | addressBookButton.setToolTipText(Messages |
| 542 | .getString("common.addressbook")); //$NON-NLS-1$ | |
| 543 | 0 | addressBookButton.setIcon(new ImageIcon(this.getClass() |
| 544 | .getResource("/icon/16x16/actions/address-book-new.png"))); //$NON-NLS-1$ | |
| 545 | ||
| 546 | 0 | addressBookButton.addActionListener(new ActionListener() { |
| 547 | public void actionPerformed(ActionEvent arg0) { | |
| 548 | 0 | logger.debug("actionPerformed documentButton"); //$NON-NLS-1$ |
| 549 | 0 | CommandExecutor.getInstance().executeCommand( |
| 550 | 0 | new ShowUserAddressBookDialogCommand(user), false); |
| 551 | 0 | } |
| 552 | 0 | }); |
| 553 | 0 | } |
| 554 | 0 | return addressBookButton; |
| 555 | } | |
| 556 | 0 | |
| 557 | /** | |
| 558 | * @return Returns the exportVCardButton. | |
| 559 | */ | |
| 560 | protected JButton getExportVCardButton() { | |
| 561 | 0 | if (exportVCardButton == null) { |
| 562 | 0 | exportVCardButton = new JButton(); |
| 563 | 0 | exportVCardButton.setToolTipText(Messages |
| 564 | 0 | .getString("common.export.vcard")); //$NON-NLS-1$ |
| 565 | 0 | exportVCardButton.setIcon(new ImageIcon(this.getClass() |
| 566 | .getResource("/icon/16x16/actions/contact-new.png"))); //$NON-NLS-1$ | |
| 567 | ||
| 568 | 0 | exportVCardButton.addActionListener(new ActionListener() { |
| 569 | 0 | public void actionPerformed(ActionEvent arg0) { |
| 570 | 0 | logger.debug("actionPerformed exportVCardButton"); //$NON-NLS-1$ |
| 571 | 0 | CommandExecutor.getInstance().executeCommand( |
| 572 | 0 | new ExportUserAsVCardCommand(user), false); |
| 573 | 0 | } |
| 574 | 0 | }); |
| 575 | 0 | } |
| 576 | 0 | return exportVCardButton; |
| 577 | 0 | } |
| 578 | 0 | |
| 579 | 0 | /** |
| 580 | 0 | * @return Returns the bottomPanel. |
| 581 | 0 | */ |
| 582 | 0 | protected JPanel getBottomPanel() { |
| 583 | 0 | if (bottomPanel == null) { |
| 584 | 0 | bottomPanel = new JPanel(); |
| 585 | 0 | bottomPanel.setLayout(new BorderLayout()); |
| 586 | 0 | |
| 587 | 0 | JPanel bottomLeftPanel = new JPanel(); |
| 588 | 0 | bottomLeftPanel.setLayout(new GridLayout(4, 1)); |
| 589 | 0 | bottomLeftPanel.add(getNicknamePanel()); |
| 590 | 0 | bottomLeftPanel.add(getPasswordPanel()); |
| 591 | 0 | bottomLeftPanel.add(getRetypedPasswordPanel()); |
| 592 | 0 | bottomLeftPanel.add(getCredentialPanel()); |
| 593 | ||
| 594 | 0 | JPanel bottomRightPanel = new JPanel(); |
| 595 | 0 | bottomRightPanel.setLayout(new BorderLayout()); |
| 596 | 0 | bottomRightPanel.add(getButtonPanel(), BorderLayout.CENTER); |
| 597 | 0 | |
| 598 | 0 | bottomPanel.add(bottomLeftPanel, BorderLayout.CENTER); |
| 599 | 0 | bottomPanel.add(bottomRightPanel, BorderLayout.EAST); |
| 600 | 0 | } |
| 601 | 0 | return bottomPanel; |
| 602 | 0 | } |
| 603 | 0 | |
| 604 | 0 | /** |
| 605 | 0 | * @return Returns the topPanel. |
| 606 | 0 | */ |
| 607 | 0 | protected JPanel getTopPanel() { |
| 608 | 0 | if (topPanel == null) { |
| 609 | 0 | topPanel = new JPanel(); |
| 610 | 0 | topPanel.setLayout(new GridLayout(1, 2)); |
| 611 | 0 | JPanel topLeftPanel = new JPanel(); |
| 612 | 0 | topLeftPanel.setLayout(new GridLayout(4, 1)); |
| 613 | 0 | topLeftPanel.add(getNamePanel(), null); |
| 614 | 0 | topLeftPanel.add(getSurnamePanel(), null); |
| 615 | 0 | topLeftPanel.add(getGenderPanel(), null); |
| 616 | 0 | topLeftPanel.add(getBirthdayPanel(), null); |
| 617 | 0 | |
| 618 | 0 | JPanel topRightPanel = new JPanel(); |
| 619 | 0 | topRightPanel.setLayout(new BorderLayout()); |
| 620 | 0 | topRightPanel.add(getImagePanel(), BorderLayout.CENTER); |
| 621 | ||
| 622 | 0 | JSplitPane splitPane = new JSplitPane(); |
| 623 | 0 | splitPane.setLeftComponent(topLeftPanel); |
| 624 | 0 | splitPane.setRightComponent(topRightPanel); |
| 625 | 0 | splitPane.setOneTouchExpandable(true); |
| 626 | 0 | topPanel.add(splitPane); |
| 627 | ||
| 628 | } | |
| 629 | 0 | return topPanel; |
| 630 | } | |
| 631 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |