Package at.bestsolution.efxclipse.runtime.demo.contacts

Examples of at.bestsolution.efxclipse.runtime.demo.contacts.Contact


  @Inject
  ContactsManager contactsManager;

  @Execute
  void execute() {
    Contact contact = ContactsFactory.eINSTANCE.createContact();
    Command command = AddCommand.create(contactsManager.getEditingDomain(), contactsManager.getRootGroup(), ContactsPackage.Literals.GROUP__CONTACTS, contact);
    if (command != null && command.canExecute())
      contactsManager.getEditingDomain().getCommandStack().execute(command);
  }
View Full Code Here


   * <!-- end-user-doc -->
   * @generated NOT
   */
  @Override
  public Object getImage(Object object) {
    Contact contact = (Contact) object;
    Diagnostic diagnostic = Diagnostician.INSTANCE.validate(contact);
    Object baseImage = getResourceLocator().getImage("silk/user.png");

    if (diagnostic.getSeverity() != Diagnostic.OK) {
      Object overlayImage = getResourceLocator().getImage("silk/bullet_error.png");
View Full Code Here

   * <!-- end-user-doc -->
   * @generated NOT
   */
  @Override
  public String getText(Object object) {
    Contact contact = (Contact)object;
    String firstName = contact.getFirstName();
    String lastName = contact.getLastName();
    return (firstName != null ? firstName : "") + " " + (lastName != null ? lastName : "");
  }
View Full Code Here

    return ContactsEditPlugin.INSTANCE;
  }
 
  @Override
  public String getColumnText(Object object, int columnIndex) {
    Contact contact = (Contact) object;

    String label = null;
    switch (columnIndex) {
    case 0:
      label = contact.getFirstName();
      break;
    case 1:
      label = contact.getLastName();
      break;
    }

    return label == null ? "n/a" : label;
  }
View Full Code Here

    super(URI.createPlatformResourceURI("at.bestsolution.efxclipse.runtime.demo.contacts/vcards", false));
   
    try {
      Group rootGroup = ContactsFactory.eINSTANCE.createGroup();
      for (File file : getContacts()) {
        Contact contact = readFromVCard(file.getAbsolutePath());
        rootGroup.getContacts().add(contact);
      }
      getContents().add(rootGroup);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

   * @param fileName
   *            the vcard file
   * @return the created Contact
   */
  public Contact readFromVCard(String fileName) {
    Contact contact = ContactsFactory.eINSTANCE.createContact();
    contact.setSourceFile(fileName);
    BufferedReader bufferedReader = null;
    String charSet = "Cp1252";

    /*
     * first try to guess the char set (currently not working under some
     * JVMs
     */

    /*
     * try { bufferedReader = new BufferedReader(new InputStreamReader( new
     * FileInputStream(fileName))); String line; while ((line =
     * bufferedReader.readLine()) != null) { int index =
     * line.indexOf("CHARSET="); if (index != -1) { int endIndex = index +
     * 8; while (line.charAt(endIndex) != ':' && line.charAt(endIndex) !=
     * ';') { endIndex += 1; } charSet = line.substring(index + 8,
     * endIndex); break; } } } catch (FileNotFoundException e) { // TODO
     * Auto-generated catch block e.printStackTrace();
     *
     * } catch (IOException e) { // TODO Auto-generated catch block
     * e.printStackTrace(); } finally { try { if (bufferedReader != null) {
     * bufferedReader.close(); } } catch (IOException e) { // TODO
     * Auto-generated catch block e.printStackTrace(); } }
     */

    // Then parse the vCard
    try {
      InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(fileName), charSet);
      bufferedReader = new BufferedReader(inputStreamReader);
      String line;
      String value;
      while ((line = bufferedReader.readLine()) != null) {
        value = getVCardValue(line, "N");
        if (value != null) {
          String[] result = value.split(";");

          if (result.length > 0) {
            contact.setLastName(result[0]);
          }
          if (result.length > 1) {
            contact.setFirstName(result[1]);
          }
          if (result.length > 2) {
            contact.setMiddleName(result[2]);
          }
          if (result.length > 3) {
            contact.setTitle(result[3]);
          }
          continue;
        }
        value = getVCardValue(line, "TEL;WORK");
        if (value != null) {
          contact.setPhone(value);
          continue;
        }
        value = getVCardValue(line, "TEL;CELL");
        if (value != null) {
          contact.setMobile(value);
          continue;
        }
        value = getVCardValue(line, "ADR;WORK");
        if (value != null) {
          String[] result = value.split(";");

          if (result.length > 2) {
            contact.setStreet(result[2]);
          }
          if (result.length > 3) {
            contact.setCity(result[3]);
          }
          if (result.length > 4) {
            contact.setState(result[4]);
          }
          if (result.length > 5) {
            contact.setZip(result[5]);
          }
          if (result.length > 6) {
            contact.setCountry(result[6]);
          }
          continue;
        }
        value = getVCardValue(line, "EMAIL;PREF;INTERNET");
        if (value != null) {
          contact.setEmail(value);
          continue;
        }
        value = getVCardValue(line, "URL;WORK");
        if (value != null) {
          contact.setWebPage(value);
          continue;
        }
        value = getVCardValue(line, "ORG");
        if (value != null) {
          contact.setCompany(value);
          continue;
        }
        value = getVCardValue(line, "TITLE");
        if (value != null) {
          contact.setJobTitle(value);
          continue;
        }
        value = getVCardValue(line, "NOTE");
        if (value != null) {
          contact.setNote(value);
          continue;
        }
        value = getVCardValue(line, "PHOTO;TYPE=JPEG;ENCODING=BASE64");
        if (value != null) {
          line = bufferedReader.readLine();
          StringBuilder builder = new StringBuilder();
          while (line != null && line.length() > 0 && line.charAt(0) == ' ') {
            builder.append(line.trim());
            line = bufferedReader.readLine();
          }
          String jpegString = builder.toString();

          contact.setJpegString(jpegString);
          continue;
        }
      }
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
View Full Code Here

    parent.setCenter(root);
  }

  @Inject
  public void setSelection(@Optional Object selectedItem) {
    Contact contact = selectedItem instanceof Contact ? (Contact) selectedItem : null;
    controller.updateBindings(contact, contactsManager.getEditingDomain());
  }
View Full Code Here

TOP

Related Classes of at.bestsolution.efxclipse.runtime.demo.contacts.Contact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.