protected void addPosition(IDocument doc, Position position) {
   try {
     doc.addPosition(CLASS_POSITIONS, position);
   } catch (BadLocationException e) {
     e.printStackTrace();
   } catch (BadPositionCategoryException e) {
     e.printStackTrace();
   }
 }
示例#2
0
 public boolean removeTextLocation(String category, MateTextLocation location) {
   try {
     mateText.getDocument().removePosition(category, (SwtMateTextLocation) location);
     return true;
   } catch (BadPositionCategoryException e) {
     e.printStackTrace();
   }
   return false;
 }
示例#3
0
  public boolean addTextLocation(String category, MateTextLocation location) {
    try {
      mateText.getDocument().addPosition(category, (SwtMateTextLocation) location);
      return true;
    } catch (BadLocationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (BadPositionCategoryException e) {
      e.printStackTrace();
    }

    return false;
  }
示例#4
0
  public XMLNode getPreviousSiblingTag(String allowed) {
    if (parent == null || parent.getType().equals("/") || allowed == null) return null;
    Position[] pos = null;
    try {
      pos = document.getPositions(XMLDocumentPartitioner.CONTENT_TYPES_CATEGORY);
    } catch (BadPositionCategoryException e) {
      e.printStackTrace();
      return null;
    }
    Arrays.sort(pos, COMPARATOR);
    int index = 0;
    while (pos[index] != this) index++;
    if (index > 0) {
      XMLNode result = null;
      for (int i = index - 1; i >= 0; i--) {
        result = (XMLNode) pos[i];
        if (result == parent) return null;
        String type = result.getType();
        if (result.getParent() != parent
            || (type.equals(ITypeConstants.TEXT)
                || type.equals(ITypeConstants.COMMENT)
                || type.equals(ITypeConstants.DECL))) {
          continue;
        }

        String name = result.getName();
        if (name == null) continue;
        if (type.equals(ITypeConstants.ENDTAG)) {
          XMLNode corresponding = result.getCorrespondingNode();
          if (allowed.indexOf(corresponding.getName().toLowerCase()) >= 0) return corresponding;
        } else if (allowed.indexOf(name) >= 0) {
          return result;
        }
      }
    }

    return null;
  }