Package org.emftrace.metamodel.EMFfitModel

Examples of org.emftrace.metamodel.EMFfitModel.TextElement


   * @see emffit_commands.EMFfitCommand#doRun()
   */
  @Override
  protected void doRun() {

    TextElement textElement = HypertextHelpers
    .findTextElementAtOffset(hypertext, offset);

    textElement.setVisibleContent(newVisibleContent);

  }
View Full Code Here


   
    if (oldContent.size() != newContent.size()){
      return false;
   
    for (int i = 0; i < newContent.size(); i++) {
      TextElement oldElement = oldContent.get(i);
      TextElement newElement = newContent.get(i);
      if (oldElement.eClass() != newElement.eClass()){
        return false;
      }
    }
    return true;
  }
View Full Code Here

      return;
    }
   
    if (checkInputs(oldContent,newContent )){
      for (int i = 0; i < newContent.size(); i++) {
        TextElement oldElement = oldContent.get(i);
        TextElement newElement = newContent.get(i);
        if (newElement instanceof Term){
          String newVisibleContent = ((Term) newElement).getVisibleContent();
          if (newVisibleContent != ((Term) oldElement).getVisibleContent()){
            ((Term) oldElement).setVisibleContent(newVisibleContent);
          }
View Full Code Here

    }

    int linkIndex = hypertext.getContent().indexOf(linkToRemove);

    // get prev. & succ. element
    TextElement prevElement = null;
    TextElement succElement = null;
    if (linkIndex > 0) { // linkElement is not first
      prevElement = hypertext.getContent().get(linkIndex - 1);
      if (prevElement instanceof Link) {
        prevElement = null;
      }
    } // else prevElement = null;

    if (linkIndex < hypertext.getContent().size() - 1) {// linkElement is
                              // not last
      succElement = hypertext.getContent().get(linkIndex + 1);
      if (succElement instanceof Link) {
        succElement = null;
      }
    } // else succElement = null;

    if (prevElement == null && succElement == null) { // [Term] -> [Link]

      Term newTerm = EMFfitModelFactory.eINSTANCE.createTerm();
      newTerm.setVisibleContent(text);

      hypertext.getContent().add(linkIndex, newTerm);
      linkToRemove.delete();

    } else if (prevElement == null) {// [Link,Term] -> [Term]

      linkToRemove.delete();
      succElement.setVisibleContent(text
          + succElement.getVisibleContent());

    } else if (succElement == null) { // [Term, Link] -> [Term]

      prevElement.setVisibleContent(prevElement.getVisibleContent()
          + text);
      linkToRemove.delete();

    } else { // [Term, Link, Term] -> [Term]
      // [Term, Link, Term] -> [Term, Term]
      prevElement.setVisibleContent(prevElement.getVisibleContent()
          + text);
      linkToRemove.delete();

      // [Term, Term] -> [Term]
      prevElement.setVisibleContent(prevElement.getVisibleContent()
          + succElement.getVisibleContent());
      succElement.delete();
    }

  }
View Full Code Here

   * @see emffit_commands.EMFfitCommand#doRun()
   */
  @Override
  protected void doRun() {
    for (int i = hypertext.getContent().size()-1; i >=0; i--) {   
      TextElement element = hypertext.getContent().get(i);
      if (element instanceof Term && element.getVisibleContent() == null || element.getVisibleContent() == "" ){
        element.delete();
      }
    }
   
  }
View Full Code Here

  @Test
  public void testFindTextElementAtOffset(){

    Hypertext hypertext = createTestHypertext();
   
    TextElement result = HypertextHelpers.findTextElementAtOffset(hypertext, 4);
    assertNotNull(result);
    assertTrue(result instanceof Link);
    assertEquals("link", result.getVisibleContent());
  }
View Full Code Here

   */
  @Override
  protected void doRun() {
    // find term by offset (global to whole text)

  TextElement textElement = HypertextHelpers
  .findTextElementAtOffset(hypertext, offset);
  if (! (textElement instanceof Term))
    try {
    throw new Exception("TextElement at offset=" + offset+ " is no link");
  } catch (Exception e) {
View Full Code Here

    if (offset == 0) {
      index = 0;
    } else
      for (int i = 0; i <= hypertext.getContent().size() - 1; i++) {
        index++;
        TextElement textElement = hypertext.getContent().get(i);
        if (textElement instanceof Term) {
          count += (textElement).getVisibleContent().length();
        } else {
          count += 1;
        }
View Full Code Here

      }

    int linkIndex = hypertext.getContent().indexOf(textElementToRemove);

    //get prev. & succ. element
    TextElement prevElement = null;
    TextElement succElement = null;
    if (linkIndex > 0) { // linkElement is not first
      prevElement = hypertext.getContent().get(linkIndex-1);
    } //else prevElement = null;
   
    if (linkIndex < hypertext.getContent().size()-1) {// linkElement is not last
      succElement = hypertext.getContent().get(linkIndex+1);
    // else succElement = null;

    textElementToRemove.delete();
    if (prevElement != null && succElement != null && prevElement instanceof Term && succElement instanceof Term){ // [Term] -> [Link]
      prevElement.setVisibleContent(prevElement.getVisibleContent()+succElement.getVisibleContent());
      succElement.delete();
    }
  }
View Full Code Here

TOP

Related Classes of org.emftrace.metamodel.EMFfitModel.TextElement

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.