1 18 package sync4j.syncclient.demo; 19 20 import java.awt.Button ; 21 import java.awt.BorderLayout ; 22 import java.awt.CardLayout ; 23 import java.awt.CheckboxGroup ; 24 import java.awt.GridLayout ; 25 import java.awt.Label ; 26 import java.awt.Panel ; 27 import java.awt.ScrollPane ; 28 import java.awt.TextField ; 29 import java.awt.event.ActionEvent ; 30 import java.awt.event.ActionListener ; 31 import java.awt.event.MouseEvent ; 32 import java.awt.event.MouseListener ; 33 34 import java.util.List ; 35 import java.util.Iterator ; 36 37 import sync4j.foundation.pdi.contact.Contact; 38 import sync4j.foundation.pdi.contact.Email; 39 import sync4j.foundation.pdi.contact.Note; 40 import sync4j.foundation.pdi.contact.Phone; 41 import sync4j.foundation.pdi.contact.Title; 42 import sync4j.foundation.pdi.contact.WebPage; 43 import sync4j.foundation.pdi.common.*; 44 45 53 public class ContactForm extends Panel 54 implements ActionListener , MouseListener , ConfigurationParameters { 55 56 58 public static final int TF_COLUMNS = 10 ; 63 64 private static final String TK_MOBILEPHONE = "MobileTelephoneNumber" ; 65 private static final String TK_HOMEPHONE = "HomeTelephoneNumber" ; 66 private static final String TK_HOME2PHONE = "Home2TelephoneNumber" ; 67 private static final String TK_HOMEFAX = "HomeFaxNumber" ; 68 private static final String TK_OTHERPHONE = "OtherTelephoneNumber" ; 69 private static final String TK_BUSINESSPHONE = "BusinessTelephoneNumber" ; 70 private static final String TK_BUSINESS2PHONE = "Business2TelephoneNumber"; 71 private static final String TK_BUSINESSFAX = "BusinessFaxNumber" ; 72 private static final String TK_PAGERNUMBER = "PagerNumber" ; 73 private static final String TK_EMAIL1 = "Email1Address" ; 74 private static final String TK_EMAIL2 = "Email2Address" ; 75 private static final String TK_EMAIL3 = "Email3Address" ; 76 77 79 private MainWindow mw = null; 83 84 private Language ln = new Language(); 85 86 private String currentTab = null; 90 91 private TextField tf2 = null; 92 private TextField tf3 = null; 93 private TextField tf4 = null; 94 private TextField tf5 = null; 95 private TextField tf6 = null; 96 private TextField tf7 = null; 97 private TextField tf11 = null; 98 private TextField tf13 = null; 99 private TextField tf14 = null; 100 private TextField tf15 = null; 101 private TextField tf16 = null; 102 private TextField tf17 = null; 103 private TextField tf19 = null; 104 private TextField tf20 = null; 105 private TextField tf22 = null; 106 private TextField tf23 = null; 107 private TextField tf24 = null; 108 private TextField tf25 = null; 109 private TextField tf31 = null; 110 private TextField tf32 = null; 111 private TextField tf33 = null; 112 private TextField tf34 = null; 113 private TextField tf35 = null; 114 private TextField tf36 = null; 115 private TextField tf37 = null; 116 private TextField tf38 = null; 117 private TextField tf39 = null; 118 private TextField tf41 = null; 119 private TextField tf42 = null; 120 private TextField tf45 = null; 121 private TextField tf46 = null; 122 private TextField tf47 = null; 123 private TextField tf48 = null; 124 private TextField tf49 = null; 125 private TextField tf50 = null; 126 127 private Button butGeneral = null; 128 private Button butPersonal = null; 129 private Button butBusiness = null; 130 private CardLayout cardLayout = null; 131 private Panel fieldPanel = null; 132 private ScrollPane scrollGeneralPane = null; 133 private ScrollPane scrollPersonalPane = null; 134 private ScrollPane scrollBusinessPane = null; 135 136 138 public String getBirthdayDate() { 139 return tf19.getText(); 140 } 141 142 147 public ContactForm(MainWindow mw) { 148 149 Panel generalPanel = null; 150 Panel personalPanel = null; 151 Panel businessPanel = null; 152 153 Label lb2 = null; 157 Label lb3 = null; 158 Label lb4 = null; 159 Label lb5 = null; 160 Label lb6 = null; 161 Label lb7 = null; 162 Label lb11 = null; 163 164 Label lb13 = null; 168 Label lb14 = null; 169 Label lb15 = null; 170 Label lb16 = null; 171 Label lb17 = null; 172 Label lb19 = null; 173 Label lb20 = null; 174 Label lb22 = null; 175 Label lb23 = null; 176 Label lb24 = null; 177 Label lb25 = null; 178 179 Label lb31 = null; 183 Label lb32 = null; 184 Label lb33 = null; 185 Label lb34 = null; 186 Label lb35 = null; 187 Label lb36 = null; 188 Label lb37 = null; 189 Label lb38 = null; 190 Label lb39 = null; 191 Label lb41 = null; 192 Label lb42 = null; 193 Label lb45 = null; 194 Label lb46 = null; 195 Label lb47 = null; 196 Label lb48 = null; 197 Label lb49 = null; 198 Label lb50 = null; 199 200 this.mw = mw; 201 202 Panel buttonMenu = new Panel (); 203 buttonMenu.setLayout(new GridLayout (1,3)); 204 205 butGeneral = new Button (ln.getString("general") ); 206 butGeneral.setActionCommand ("general" ); 207 butGeneral.addActionListener (this ); 208 butGeneral.setEnabled (false ); 209 butPersonal = new Button (ln.getString("personal")); 210 butPersonal.setActionCommand ("personal" ); 211 butPersonal.addActionListener(this ); 212 butBusiness = new Button (ln.getString("business")); 213 butBusiness.setActionCommand ("business" ); 214 butBusiness.addActionListener(this ); 215 216 buttonMenu.add(butGeneral ); 217 buttonMenu.add(butPersonal); 218 buttonMenu.add(butBusiness); 219 220 tf2 = new TextField (TF_COLUMNS); 224 tf3 = new TextField (TF_COLUMNS); 225 tf4 = new TextField (TF_COLUMNS); 226 tf5 = new TextField (TF_COLUMNS); 227 tf6 = new TextField (TF_COLUMNS); 228 tf7 = new TextField (TF_COLUMNS); 229 tf11 = new TextField (TF_COLUMNS); 230 231 tf2.addMouseListener (this); 232 tf3.addMouseListener (this); 233 tf4.addMouseListener (this); 234 tf5.addMouseListener (this); 235 tf6.addMouseListener (this); 236 tf7.addMouseListener (this); 237 tf11.addMouseListener(this); 238 239 tf13 = new TextField (TF_COLUMNS); 243 tf14 = new TextField (TF_COLUMNS); 244 tf15 = new TextField (TF_COLUMNS); 245 tf16 = new TextField (TF_COLUMNS); 246 tf17 = new TextField (TF_COLUMNS); 247 tf19 = new TextField (TF_COLUMNS); 248 tf20 = new TextField (TF_COLUMNS); 249 tf22 = new TextField (TF_COLUMNS); 250 tf23 = new TextField (TF_COLUMNS); 251 tf24 = new TextField (TF_COLUMNS); 252 tf25 = new TextField (TF_COLUMNS); 253 254 tf13.addMouseListener(this); 255 tf14.addMouseListener(this); 256 tf15.addMouseListener(this); 257 tf16.addMouseListener(this); 258 tf17.addMouseListener(this); 259 tf19.addMouseListener(this); 260 tf20.addMouseListener(this); 261 tf22.addMouseListener(this); 262 tf23.addMouseListener(this); 263 tf24.addMouseListener(this); 264 tf25.addMouseListener(this); 265 266 tf31 = new TextField (TF_COLUMNS); 270 tf32 = new TextField (TF_COLUMNS); 271 tf33 = new TextField (TF_COLUMNS); 272 tf34 = new TextField (TF_COLUMNS); 273 tf35 = new TextField (TF_COLUMNS); 274 tf36 = new TextField (TF_COLUMNS); 275 tf37 = new TextField (TF_COLUMNS); 276 tf38 = new TextField (TF_COLUMNS); 277 tf39 = new TextField (TF_COLUMNS); 278 tf41 = new TextField (TF_COLUMNS); 279 tf42 = new TextField (TF_COLUMNS); 280 tf45 = new TextField (TF_COLUMNS); 281 tf46 = new TextField (TF_COLUMNS); 282 tf47 = new TextField (TF_COLUMNS); 283 tf48 = new TextField (TF_COLUMNS); 284 tf49 = new TextField (TF_COLUMNS); 285 tf50 = new TextField (TF_COLUMNS); 286 287 tf31.addMouseListener(this); 288 tf32.addMouseListener(this); 289 tf33.addMouseListener(this); 290 tf34.addMouseListener(this); 291 tf35.addMouseListener(this); 292 tf36.addMouseListener(this); 293 tf37.addMouseListener(this); 294 tf38.addMouseListener(this); 295 tf39.addMouseListener(this); 296 tf41.addMouseListener(this); 297 tf42.addMouseListener(this); 298 tf45.addMouseListener(this); 299 tf46.addMouseListener(this); 300 tf47.addMouseListener(this); 301 tf48.addMouseListener(this); 302 tf49.addMouseListener(this); 303 tf50.addMouseListener(this); 304 305 lb2 = new Label (ln.getString("title" )); 309 lb3 = new Label (ln.getString("first_name" )); 310 lb4 = new Label (ln.getString("middle_name" )); 311 lb5 = new Label (ln.getString("last_name" )); 312 lb6 = new Label (ln.getString("suffix" )); 313 lb7 = new Label (ln.getString("nickname" )); 314 lb11 = new Label (ln.getString("note" )); 315 316 lb13 = new Label (ln.getString("street" )); 320 lb14 = new Label (ln.getString("city" )); 321 lb15 = new Label (ln.getString("state" )); 322 lb16 = new Label (ln.getString("postal_code" )); 323 lb17 = new Label (ln.getString("country" )); 324 lb19 = new Label (ln.getString("birthday" )); 325 lb20 = new Label (ln.getString("cell_phone" )); 326 lb22 = new Label (ln.getString("home_phone" )); 327 lb23 = new Label (ln.getString("home_phone2" )); 328 lb24 = new Label (ln.getString("home_fax" )); 329 lb25 = new Label (ln.getString("gen_phone" )); 330 331 lb31 = new Label (ln.getString("street" )); 335 lb32 = new Label (ln.getString("city" )); 336 lb33 = new Label (ln.getString("state" )); 337 lb34 = new Label (ln.getString("postal_code" )); 338 lb35 = new Label (ln.getString("country" )); 339 lb36 = new Label (ln.getString("role" )); 340 lb37 = new Label (ln.getString("job_title" )); 341 lb38 = new Label (ln.getString("company" )); 342 lb39 = new Label (ln.getString("department" )); 343 lb41 = new Label (ln.getString("business_phone" )); 344 lb42 = new Label (ln.getString("business_phone2")); 345 lb45 = new Label (ln.getString("business_fax" )); 346 lb46 = new Label (ln.getString("pager_number" )); 347 lb47 = new Label (ln.getString("email1" )); 348 lb48 = new Label (ln.getString("email2" )); 349 lb49 = new Label (ln.getString("email3" )); 350 lb50 = new Label (ln.getString("webpage" )); 351 352 generalPanel = new Panel (); 356 generalPanel.setLayout(new GridLayout (17, 2)); 357 358 generalPanel.add(lb2 ); 359 generalPanel.add(tf2 ); 360 generalPanel.add(lb3 ); 361 generalPanel.add(tf3 ); 362 generalPanel.add(lb4 ); 363 generalPanel.add(tf4 ); 364 generalPanel.add(lb5 ); 365 generalPanel.add(tf5 ); 366 generalPanel.add(lb6 ); 367 generalPanel.add(tf6 ); 368 generalPanel.add(lb7 ); 369 generalPanel.add(tf7 ); 370 generalPanel.add(lb11 ); 371 generalPanel.add(tf11 ); 372 generalPanel.add(new Label ()); 373 generalPanel.add(new Label ()); 374 generalPanel.add(new Label ()); 375 generalPanel.add(new Label ()); 376 generalPanel.add(new Label ()); 377 generalPanel.add(new Label ()); 378 generalPanel.add(new Label ()); 379 generalPanel.add(new Label ()); 380 generalPanel.add(new Label ()); 381 generalPanel.add(new Label ()); 382 383 personalPanel = new Panel (); 387 personalPanel.setLayout(new GridLayout (22, 2)); 388 389 personalPanel.add(lb13 ); 390 personalPanel.add(tf13 ); 391 personalPanel.add(lb14 ); 392 personalPanel.add(tf14 ); 393 personalPanel.add(lb15 ); 394 personalPanel.add(tf15 ); 395 personalPanel.add(lb16 ); 396 personalPanel.add(tf16 ); 397 personalPanel.add(lb17 ); 398 personalPanel.add(tf17 ); 399 personalPanel.add(lb19 ); 400 personalPanel.add(tf19 ); 401 personalPanel.add(lb25 ); 402 personalPanel.add(tf25 ); 403 personalPanel.add(lb20 ); 404 personalPanel.add(tf20 ); 405 personalPanel.add(lb22 ); 406 personalPanel.add(tf22 ); 407 personalPanel.add(lb23 ); 408 personalPanel.add(tf23 ); 409 personalPanel.add(lb24 ); 410 personalPanel.add(tf24 ); 411 personalPanel.add(new Label ()); 412 personalPanel.add(new Label ()); 413 personalPanel.add(new Label ()); 414 personalPanel.add(new Label ()); 415 personalPanel.add(new Label ()); 416 personalPanel.add(new Label ()); 417 personalPanel.add(new Label ()); 418 personalPanel.add(new Label ()); 419 personalPanel.add(new Label ()); 420 personalPanel.add(new Label ()); 421 422 businessPanel = new Panel (); 426 businessPanel.setLayout(new GridLayout (27, 2)); 427 428 businessPanel.add(lb31 ); 429 businessPanel.add(tf31 ); 430 businessPanel.add(lb32 ); 431 businessPanel.add(tf32 ); 432 businessPanel.add(lb33 ); 433 businessPanel.add(tf33 ); 434 businessPanel.add(lb34 ); 435 businessPanel.add(tf34 ); 436 businessPanel.add(lb35 ); 437 businessPanel.add(tf35 ); 438 businessPanel.add(lb36 ); 439 businessPanel.add(tf36 ); 440 businessPanel.add(lb37 ); 441 businessPanel.add(tf37 ); 442 businessPanel.add(lb38 ); 443 businessPanel.add(tf38 ); 444 businessPanel.add(lb39 ); 445 businessPanel.add(tf39 ); 446 businessPanel.add(lb41 ); 447 businessPanel.add(tf41 ); 448 businessPanel.add(lb42 ); 449 businessPanel.add(tf42 ); 450 businessPanel.add(lb45 ); 451 businessPanel.add(tf45 ); 452 businessPanel.add(lb46 ); 453 businessPanel.add(tf46 ); 454 businessPanel.add(lb47 ); 455 businessPanel.add(tf47 ); 456 businessPanel.add(lb48 ); 457 businessPanel.add(tf48 ); 458 businessPanel.add(lb49 ); 459 businessPanel.add(tf49 ); 460 businessPanel.add(lb50 ); 461 businessPanel.add(tf50 ); 462 businessPanel.add(new Label ()); 463 businessPanel.add(new Label ()); 464 businessPanel.add(new Label ()); 465 businessPanel.add(new Label ()); 466 businessPanel.add(new Label ()); 467 businessPanel.add(new Label ()); 468 businessPanel.add(new Label ()); 469 businessPanel.add(new Label ()); 470 businessPanel.add(new Label ()); 471 businessPanel.add(new Label ()); 472 473 scrollGeneralPane = new ScrollPane (ScrollPane.SCROLLBARS_NEVER ); 474 scrollGeneralPane.add(generalPanel ); 475 476 scrollPersonalPane = new ScrollPane (ScrollPane.SCROLLBARS_NEVER ); 477 scrollPersonalPane.add(personalPanel); 478 479 scrollBusinessPane = new ScrollPane (ScrollPane.SCROLLBARS_AS_NEEDED); 480 scrollBusinessPane.add(businessPanel); 481 482 fieldPanel = new Panel (); 483 fieldPanel.setSize(100,100); 484 cardLayout = new CardLayout (); 485 fieldPanel.setLayout(cardLayout); 486 487 fieldPanel.add(scrollGeneralPane , "general" ); 488 fieldPanel.add(scrollPersonalPane, "personal"); 489 fieldPanel.add(scrollBusinessPane, "business"); 490 491 cardLayout.show(fieldPanel, "general"); 492 currentTab = "general"; 493 494 setLayout(new BorderLayout ()); 495 496 add (buttonMenu, BorderLayout.NORTH ); 497 add (fieldPanel, BorderLayout.CENTER); 498 } 499 500 505 public void actionPerformed(ActionEvent evt) { 506 507 if (evt.getActionCommand().equals ("general")) { 508 butGeneral.setEnabled (false); 509 butPersonal.setEnabled(true ); 510 butBusiness.setEnabled(true ); 511 cardLayout.show(fieldPanel,"general"); 512 currentTab = "general"; 513 } else if (evt.getActionCommand().equals ("personal")) { 514 butGeneral.setEnabled (true ); 515 butPersonal.setEnabled(false); 516 butBusiness.setEnabled(true ); 517 cardLayout.show(fieldPanel,"personal"); 518 currentTab = "personal"; 519 } else if (evt.getActionCommand().equals ("business")) { 520 butGeneral.setEnabled (true ); 521 butPersonal.setEnabled(true ); 522 butBusiness.setEnabled(false); 523 cardLayout.show(fieldPanel,"business"); 524 currentTab = "business"; 525 } 526 } 527 528 537 public void mouseClicked(MouseEvent evt) { 538 TextField tmptxt = (TextField )evt.getComponent(); 539 if (currentTab.equals("business")) { 540 scrollBusinessPane.setScrollPosition(0, tmptxt.getLocation().y); 541 } 542 } 543 544 551 public void mousePressed(MouseEvent evt) { 552 } 554 555 562 public void mouseReleased(MouseEvent evt) { 563 } 565 566 572 public void mouseEntered(MouseEvent evt) { 573 } 575 576 582 public void mouseExited(MouseEvent evt) { 583 } 585 586 588 594 protected void setFields(Contact contact) { 595 596 tf2.setText((String )contact.getName().getSalutation().getPropertyValue()); 600 tf3.setText((String )contact.getName().getFirstName().getPropertyValue()); 601 tf4.setText((String )contact.getName().getMiddleName().getPropertyValue()); 602 tf5.setText((String )contact.getName().getLastName().getPropertyValue()); 603 tf6.setText((String )contact.getName().getSuffix().getPropertyValue()); 604 tf7.setText((String )contact.getName().getNickname().getPropertyValue()); 605 606 List notes = contact.getNotes(); 607 if (notes != null && notes.size() > 0) { 608 Note tmpNote = (Note)notes.get(0); 609 tf11.setText((String )tmpNote.getPropertyValue()); 610 } else { 611 tf11.setText(""); 612 } 613 614 tf13.setText((String )contact.getPersonalDetail() 618 .getAddress().getStreet().getPropertyValue()); 619 tf14.setText((String )contact.getPersonalDetail() 620 .getAddress().getCity().getPropertyValue()); 621 tf15.setText((String )contact.getPersonalDetail() 622 .getAddress().getState().getPropertyValue()); 623 tf16.setText((String )contact.getPersonalDetail() 624 .getAddress().getPostalCode().getPropertyValue()); 625 tf17.setText((String )contact.getPersonalDetail() 626 .getAddress().getCountry().getPropertyValue()); 627 628 String birthday = null; 629 birthday = FieldsHelper.convertBirthdayFrom( 630 (String )contact.getPersonalDetail().getBirthday() 631 ); 632 633 if (birthday.length() > 10) { 634 birthday = birthday.substring(0, 10); 635 } 636 637 if (birthday.indexOf("01/01/4501") != -1) { 641 birthday = ""; 642 } 643 644 tf19.setText(birthday); 645 646 List phones = contact.getPersonalDetail().getPhones(); 647 648 tf20.setText(""); 649 tf22.setText(""); 650 tf23.setText(""); 651 tf24.setText(""); 652 tf25.setText(""); 653 654 if (phones != null) { 655 Iterator itPhones = phones.iterator(); 656 while(itPhones.hasNext()) { 657 Phone phone = (Phone)itPhones.next(); 658 if (phone.getPhoneType() == null) { 659 continue; 660 } 661 if (phone.getPhoneType().equals(TK_MOBILEPHONE)) { 662 tf20.setText((String )phone.getPropertyValue()); 663 } else if (phone.getPhoneType().equals(TK_HOMEPHONE)) { 664 tf22.setText((String )phone.getPropertyValue()); 665 } else if (phone.getPhoneType().equals(TK_HOME2PHONE)) { 666 tf23.setText((String )phone.getPropertyValue()); 667 } else if (phone.getPhoneType().equals(TK_HOMEFAX)) { 668 tf24.setText((String )phone.getPropertyValue()); 669 } else if (phone.getPhoneType().equals(TK_OTHERPHONE)) { 670 tf25.setText((String )phone.getPropertyValue()); 671 } 672 } 673 } 674 675 tf31.setText((String )contact.getBusinessDetail() 679 .getAddress().getStreet().getPropertyValue()); 680 tf32.setText((String )contact.getBusinessDetail() 681 .getAddress().getCity().getPropertyValue()); 682 tf33.setText((String )contact.getBusinessDetail() 683 .getAddress().getState().getPropertyValue()); 684 tf34.setText((String )contact.getBusinessDetail() 685 .getAddress().getPostalCode().getPropertyValue()); 686 tf35.setText((String )contact.getBusinessDetail() 687 .getAddress().getCountry().getPropertyValue()); 688 tf36.setText((String )contact.getBusinessDetail() 689 .getRole().getPropertyValue()); 690 tf38.setText((String )contact.getBusinessDetail() 691 .getCompany().getPropertyValue()); 692 tf39.setText((String )contact.getBusinessDetail() 693 .getDepartment().getPropertyValue()); 694 695 List titles = contact.getBusinessDetail().getTitles(); 696 if (titles != null && titles.size() > 0) { 697 Title title = (Title)titles.get(0); 698 tf37.setText((String )title.getPropertyValue()); 699 } else { 700 tf37.setText(""); 701 } 702 703 List phonesBus = contact.getBusinessDetail().getPhones(); 704 705 tf41.setText(""); 706 tf42.setText(""); 707 tf45.setText(""); 708 tf46.setText(""); 709 710 if (phonesBus != null) { 711 Iterator itPhones = phonesBus.iterator(); 712 while(itPhones.hasNext()) { 713 Phone phone = (Phone)itPhones.next(); 714 if (phone.getPhoneType() == null) { 715 continue; 716 } 717 if (phone.getPhoneType().equals(TK_BUSINESSPHONE)) { 718 tf41.setText((String )phone.getPropertyValue()); 719 } else if (phone.getPhoneType().equals(TK_BUSINESS2PHONE)) { 720 tf42.setText((String )phone.getPropertyValue()); 721 } else if (phone.getPhoneType().equals(TK_BUSINESSFAX)) { 722 tf45.setText((String )phone.getPropertyValue()); 723 } else if (phone.getPhoneType().equals(TK_PAGERNUMBER)) { 724 tf46.setText((String )phone.getPropertyValue()); 725 } 726 } 727 } 728 729 tf47.setText(""); 730 tf48.setText(""); 731 tf49.setText(""); 732 733 List emails = contact.getPersonalDetail().getEmails(); 734 735 if (emails != null) { 736 Iterator itEmails = emails.iterator(); 737 while(itEmails.hasNext()) { 738 Email email = (Email)itEmails.next(); 739 if (email.getEmailType() == null) { 740 continue; 741 } 742 if (email.getEmailType().equals(TK_EMAIL1)) { 743 tf47.setText((String )email.getPropertyValue()); 744 } else if (email.getEmailType().equals(TK_EMAIL2)) { 745 tf48.setText((String )email.getPropertyValue()); 746 } 747 } 748 } 749 750 List emailsBus = contact.getBusinessDetail().getEmails(); 751 752 if (emailsBus != null) { 753 Iterator itEmails = emailsBus.iterator(); 754 while(itEmails.hasNext()) { 755 Email email = (Email)itEmails.next(); 756 if (email.getEmailType() == null) { 757 continue; 758 } 759 if (email.getEmailType().equals(TK_EMAIL3)) { 760 tf49.setText((String )email.getPropertyValue()); 761 } 762 } 763 } 764 765 List webpages = contact.getBusinessDetail().getWebPages(); 766 if (webpages != null && webpages.size() > 0) { 767 WebPage webpage = (WebPage)webpages.get(0); 768 tf50.setText((String )webpage.getPropertyValue()); 769 } else { 770 tf50.setText(""); 771 } 772 } 773 774 782 protected Contact getFields() { 783 784 Contact contact = new Contact (); 785 StringBuffer display_name = new StringBuffer (""); 786 787 contact.getName().getSalutation().setPropertyValue(tf2.getText()); 791 contact.getName().getFirstName ().setPropertyValue(tf3.getText()); 792 contact.getName().getMiddleName().setPropertyValue(tf4.getText()); 793 contact.getName().getLastName ().setPropertyValue(tf5.getText()); 794 contact.getName().getSuffix ().setPropertyValue(tf6.getText()); 795 contact.getName().getNickname ().setPropertyValue(tf7.getText()); 796 797 String lastname = contact.getName().getLastName().getPropertyValueAsString(); 798 String firstname = contact.getName().getFirstName().getPropertyValueAsString(); 799 800 if (lastname != null && !lastname.equals("")) { 801 display_name.append(lastname); 802 } 803 if (firstname != null && !firstname.equals("")) { 804 805 if (!display_name.equals("")) { 806 display_name.append(","); 807 } 808 display_name.append(firstname); 809 } 810 811 if (display_name.equals("")) { 812 display_name.append("Unknow"); 813 } 814 contact.getName().getDisplayName().setPropertyValue(display_name.toString()); 815 816 if (!tf11.getText().equals("")) { 817 Note tmpNote = new Note(); 818 tmpNote.setPropertyValue(tf11.getText()); 819 tmpNote.setNoteType("Body"); 820 contact.addNote(tmpNote); 821 } 822 823 if (!tf13.getText().equals("")) { 827 contact.getPersonalDetail().getAddress() 828 .getStreet().setPropertyValue(tf13.getText()); 829 } 830 if (!tf14.getText().equals("")) { 831 contact.getPersonalDetail().getAddress() 832 .getCity().setPropertyValue(tf14.getText()); 833 } 834 if (!tf15.getText().equals("")) { 835 contact.getPersonalDetail().getAddress() 836 .getState().setPropertyValue(tf15.getText()); 837 } 838 if (!tf16.getText().equals("")) { 839 contact.getPersonalDetail().getAddress() 840 .getPostalCode().setPropertyValue(tf16.getText()); 841 } 842 if (!tf17.getText().equals("")) { 843 contact.getPersonalDetail().getAddress() 844 .getCountry().setPropertyValue(tf17.getText()); 845 } 846 if (!tf19.getText().equals("")) { 847 try { 848 contact.getPersonalDetail().setBirthday( 849 FieldsHelper.convertBirthdayTo(tf19.getText()) 850 ); 851 } catch(Exception e) { 852 e.printStackTrace(); 853 } 854 } 855 if (!tf20.getText().equals("")) { 856 Phone tmpPhone = new Phone(); 857 tmpPhone.setPropertyValue(tf20.getText()); 858 tmpPhone.setPhoneType(TK_MOBILEPHONE); 859 contact.getPersonalDetail().addPhone(tmpPhone); 860 } 861 862 if (!tf22.getText().equals("")) { 863 Phone tmpPhone = new Phone(); 864 tmpPhone.setPropertyValue(tf22.getText()); 865 tmpPhone.setPhoneType(TK_HOMEPHONE); 866 contact.getPersonalDetail().addPhone(tmpPhone); 867 } 868 if (!tf23.getText().equals("")) { 869 Phone tmpPhone = new Phone(); 870 tmpPhone.setPropertyValue(tf23.getText()); 871 tmpPhone.setPhoneType(TK_HOME2PHONE); 872 contact.getPersonalDetail().addPhone(tmpPhone); 873 } 874 if (!tf24.getText().equals("")) { 875 Phone tmpPhone = new Phone(); 876 tmpPhone.setPropertyValue(tf24.getText()); 877 tmpPhone.setPhoneType(TK_HOMEFAX); 878 contact.getPersonalDetail().addPhone(tmpPhone); 879 } 880 if (!tf25.getText().equals("")) { 881 Phone tmpPhone = new Phone(); 882 tmpPhone.setPropertyValue(tf25.getText()); 883 tmpPhone.setPhoneType(TK_OTHERPHONE); 884 contact.getPersonalDetail().addPhone(tmpPhone); 885 } 886 887 if (!tf31.getText().equals("")) { 891 contact.getBusinessDetail().getAddress() 892 .getStreet().setPropertyValue(tf31.getText()); 893 } 894 if (!tf32.getText().equals("")) { 895 contact.getBusinessDetail().getAddress() 896 .getCity().setPropertyValue(tf32.getText()); 897 } 898 if (!tf33.getText().equals("")) { 899 contact.getBusinessDetail().getAddress() 900 .getState().setPropertyValue(tf33.getText()); 901 } 902 if (!tf34.getText().equals("")) { 903 contact.getBusinessDetail().getAddress() 904 .getPostalCode().setPropertyValue(tf34.getText()); 905 } 906 if (!tf35.getText().equals("")) { 907 contact.getBusinessDetail().getAddress() 908 .getCountry().setPropertyValue(tf35.getText()); 909 } 910 if (!tf36.getText().equals("")) { 911 contact.getBusinessDetail() 912 .getRole().setPropertyValue(tf36.getText()); 913 } 914 if (!tf38.getText().equals("")) { 915 contact.getBusinessDetail() 916 .getCompany().setPropertyValue(tf38.getText()); 917 } 918 if (!tf39.getText().equals("")) { 919 contact.getBusinessDetail() 920 .getDepartment().setPropertyValue(tf39.getText()); 921 } 922 if (!tf37.getText().equals("")) { 923 Title tmpTitle = new Title(); 924 tmpTitle.setPropertyValue(tf37.getText()); 925 tmpTitle.setTitleType("JobTitle"); 926 contact.getBusinessDetail().addTitle(tmpTitle); 927 } 928 if (!tf41.getText().equals("")) { 929 Phone tmpPhone = new Phone(); 930 tmpPhone.setPropertyValue(tf41.getText()); 931 tmpPhone.setPhoneType(TK_BUSINESSPHONE); 932 contact.getBusinessDetail().addPhone(tmpPhone); 933 } 934 if (!tf42.getText().equals("")) { 935 Phone tmpPhone = new Phone(); 936 tmpPhone.setPropertyValue(tf42.getText()); 937 tmpPhone.setPhoneType(TK_BUSINESS2PHONE); 938 contact.getBusinessDetail().addPhone(tmpPhone); 939 } 940 if (!tf45.getText().equals("")) { 941 Phone tmpPhone = new Phone(); 942 tmpPhone.setPropertyValue(tf45.getText()); 943 tmpPhone.setPhoneType(TK_BUSINESSFAX); 944 contact.getBusinessDetail().addPhone(tmpPhone); 945 } 946 if (!tf46.getText().equals("")) { 947 Phone tmpPhone = new Phone(); 948 tmpPhone.setPropertyValue(tf46.getText()); 949 tmpPhone.setPhoneType(TK_PAGERNUMBER); 950 contact.getBusinessDetail().addPhone(tmpPhone); 951 } 952 if (!tf47.getText().equals("")) { 953 Email tmpEmail = new Email(); 954 tmpEmail.setPropertyValue(tf47.getText()); 955 tmpEmail.setEmailType(TK_EMAIL1); 956 contact.getPersonalDetail().addEmail(tmpEmail); 957 } 958 if (!tf48.getText().equals("")) { 959 Email tmpEmail = new Email(); 960 tmpEmail.setPropertyValue(tf48.getText()); 961 tmpEmail.setEmailType(TK_EMAIL2); 962 contact.getPersonalDetail().addEmail(tmpEmail); 963 } 964 if (!tf49.getText().equals("")) { 965 Email tmpEmail = new Email(); 966 tmpEmail.setPropertyValue(tf49.getText()); 967 tmpEmail.setEmailType(TK_EMAIL3); 968 contact.getBusinessDetail().addEmail(tmpEmail); 969 } 970 971 if (!tf50.getText().equals("")) { 972 WebPage tmpWebPage = new WebPage(); 973 tmpWebPage.setPropertyValue(tf50.getText()); 974 tmpWebPage.setWebPageType("BusinessWebPage"); 975 contact.getBusinessDetail().addWebPage(tmpWebPage); 976 } 977 978 if (!tf13.getText().equals("") && 982 !tf14.getText().equals("") && !tf15.getText().equals("") && 983 !tf16.getText().equals("") && !tf17.getText().equals("")) { 984 StringBuffer tmpPersonalLabel = new StringBuffer (""); 985 986 tmpPersonalLabel.append(tf13.getText()).append("\r\n"); 990 tmpPersonalLabel.append(tf14.getText()).append(", "); 994 tmpPersonalLabel.append(tf15.getText()).append(" "); 998 tmpPersonalLabel.append(tf16.getText()).append("\r\n"); 1002 tmpPersonalLabel.append(tf17.getText()); 1006 contact.getPersonalDetail() 1007 .getAddress() 1008 .getLabel().setPropertyValue(tmpPersonalLabel.toString()); 1009 } 1010 1011 if (!tf31.getText().equals("") && 1015 !tf32.getText().equals("") && !tf33.getText().equals("") && 1016 !tf34.getText().equals("") && !tf35.getText().equals("")) { 1017 StringBuffer tmpBusinessLabel = new StringBuffer (""); 1018 1019 tmpBusinessLabel.append(tf31.getText()).append("\r\n"); 1023 tmpBusinessLabel.append(tf32.getText()).append(", "); 1027 tmpBusinessLabel.append(tf33.getText()).append(" "); 1031 tmpBusinessLabel.append(tf34.getText()).append("\r\n"); 1035 tmpBusinessLabel.append(tf35.getText()); 1039 contact.getBusinessDetail() 1040 .getAddress() 1041 .getLabel().setPropertyValue(tmpBusinessLabel.toString()); 1042 } 1043 1044 return contact; 1045 } 1046 1047 1050 protected void blankFields() { 1051 1052 tf2.setText (""); 1053 tf3.setText (""); 1054 tf4.setText (""); 1055 tf5.setText (""); 1056 tf6.setText (""); 1057 tf7.setText (""); 1058 tf11.setText(""); 1059 tf13.setText(""); 1060 tf14.setText(""); 1061 tf15.setText(""); 1062 tf16.setText(""); 1063 tf17.setText(""); 1064 tf19.setText(""); 1065 tf20.setText(""); 1066 tf22.setText(""); 1067 tf23.setText(""); 1068 tf24.setText(""); 1069 tf25.setText(""); 1070 tf31.setText(""); 1071 tf32.setText(""); 1072 tf33.setText(""); 1073 tf34.setText(""); 1074 tf35.setText(""); 1075 tf36.setText(""); 1076 tf37.setText(""); 1077 tf38.setText(""); 1078 tf39.setText(""); 1079 tf41.setText(""); 1080 tf42.setText(""); 1081 tf45.setText(""); 1082 tf46.setText(""); 1083 tf47.setText(""); 1084 tf48.setText(""); 1085 tf49.setText(""); 1086 tf50.setText(""); 1087 } 1088 1089} | Popular Tags |