Package jp.aonir.fuzzyxml

Examples of jp.aonir.fuzzyxml.FuzzyXMLElement


    public void run() {
      try {
        ITextSelection templateSelection = (ITextSelection) getSelectionProvider().getSelection();
        if (templateSelection != null) {
          int offset = templateSelection.getOffset();
          FuzzyXMLElement element = getElementAtOffset(offset, true);
          if (element != null) {
            BuildProperties buildProperties = (BuildProperties)getParserCache().getProject().getAdapter(BuildProperties.class);
            DeleteTagRefactoring.run(element, true, buildProperties, getParserCache(), new NullProgressMonitor());
          }
        }
View Full Code Here


    public void run(){
      try {
        IDocument xmlDocument = getDocumentProvider().getDocument(getEditorInput());
        String xmlString = xmlDocument.get();
        FuzzyXMLDocument htmlModel = new FuzzyXMLParser(false, false).parse(xmlString);
        FuzzyXMLElement documentElement = htmlModel.getDocumentElement();

        IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
        RenderContext renderContext = new RenderContext(true);
        renderContext.setShowNewlines(true);
        renderContext.setIndentSize(prefs.getInt(PreferenceConstants.INDENT_SIZE));
        renderContext.setIndentTabs(prefs.getBoolean(PreferenceConstants.INDENT_TABS));
        renderContext.setTrim(true);
        renderContext.setLowercaseAttributes(prefs.getBoolean(PreferenceConstants.LOWERCASE_ATTRIBUTES));
        renderContext.setLowercaseTags(prefs.getBoolean(PreferenceConstants.LOWERCASE_TAGS));
        renderContext.setSpacesAroundEquals(prefs.getBoolean(PreferenceConstants.SPACES_AROUND_EQUALS));
        renderContext.setSpaceInEmptyTags(true);
        renderContext.setAddMissingQuotes(true);
        renderContext.setDelegate(new WOHTMLRenderDelegate(prefs.getBoolean(PreferenceConstants.STICKY_WOTAGS)));

        StringBuffer xmlBuffer = new StringBuffer();
        FuzzyXMLDocType docType = htmlModel.getDocumentType();
        if (docType != null) {
          docType.toXMLString(renderContext, xmlBuffer);
        }
        for (FuzzyXMLNode node : documentElement.getChildren()) {
          node.toXMLString(renderContext, xmlBuffer);
          //htmlBuffer.append("\n");
        }
        xmlDocument.set(xmlBuffer.toString().trim());
View Full Code Here

  }

  public boolean filter(FuzzyXMLNode node) {
    boolean matches = false;
    if (node instanceof FuzzyXMLElement) {
      FuzzyXMLElement element = (FuzzyXMLElement) node;
      String elementTagName = element.getName();
      if (WodHtmlUtils.isWOTag(elementTagName)) {
        boolean inline = WodHtmlUtils.isInline(elementTagName);
        boolean wod = !inline;
        if (inline == _findInline && wod == _findWod) {
          matches = matches(element, inline);
View Full Code Here

  public void updateBreadcrumb() {
    try {
      WodParserCache cache = _editor.getParserCache();
      Point selectionRange = _editor.getSelectedRange();

      FuzzyXMLElement element = null;
      FuzzyXMLDocument document = cache.getHtmlEntry().getModel();
      if (document != null) {
        element = document.getElementByOffset(selectionRange.x);
      }

      Control[] children = getChildren();
      for (int i = children.length - 1; i >= 0; i--) {
        children[i].dispose();
      }

      boolean emptyBreadcrumb = true;
      if (element != null) {
        List<FuzzyXMLNode> elementStack = new LinkedList<FuzzyXMLNode>();
        FuzzyXMLNode currentNode = element;
        do {
          elementStack.add(currentNode);
          currentNode = currentNode.getParentNode();
        } while (currentNode != null);

        for (int i = elementStack.size() - 2; i >= 0; i--) {
          FuzzyXMLNode stackNode = elementStack.get(i);
          if (stackNode instanceof FuzzyXMLElement) {
            emptyBreadcrumb = false;
            FuzzyXMLElement stackElement = (FuzzyXMLElement) stackNode;

            FuzzyXMLElementWithWodElement data;
            String tagName = stackElement.getName();
            boolean isWOTag = WodHtmlUtils.isWOTag(tagName);
            String displayName = null;
            if (isWOTag) {
              BuildProperties buildProperties = (BuildProperties)cache.getProject().getAdapter(BuildProperties.class);
              IWodElement wodElement = WodHtmlUtils.getWodElement(stackElement, buildProperties, true, cache);
View Full Code Here

  public void mouseDown(MouseEvent event) {
    Label label = (Label) event.getSource();
    FuzzyXMLElementWithWodElement data = (FuzzyXMLElementWithWodElement) label.getData();
    if (data != null && data.getElement() != null) {
      FuzzyXMLElement element = data.getElement();
      int offset = element.getOffset();
      int length = element.getLength();
      _editor.selectAndReveal(offset, length);
    }
  }
View Full Code Here

    }
  }

  public static void renameHtmlSelection(int offset, ITextViewer htmlViewer, ITextViewer wodViewer, WodParserCache cache) throws Exception {
    FuzzyXMLDocument htmlModel = cache.getHtmlEntry().getModel();
    FuzzyXMLElement element = htmlModel.getElementByOffset(offset);
    if (element != null) {
      String tagName = element.getName();
      if (tagName != null && element.getOffset() + element.getNameOffset() + 1 <= offset && element.getOffset() + element.getNameOffset() + element.getNameLength() >= offset) {
        QuickRenameRefactoring.renameHtmlTag(element, htmlViewer, cache);
      }
      else if (WodHtmlUtils.isWOTag(tagName)) {
        FuzzyXMLAttribute nameAttribute = element.getAttributeNode("name");
        if (nameAttribute != null) {
          String woElementName = nameAttribute.getValue();
          if (woElementName != null && element.getOffset() + nameAttribute.getValueDataOffset() + 1 <= offset && element.getOffset() + nameAttribute.getValueDataOffset() + nameAttribute.getValueDataLength() >= offset) {
            QuickRenameRefactoring.renameElement(woElementName, htmlViewer, wodViewer, cache, true);
          }
        }
      }
    }
View Full Code Here

  protected static int linkHtml(String woElementName, IDocument htmlDocument, LinkedPositionGroup linkedGroup, WodParserCache cache, int sequence) throws Exception {
    FuzzyXMLDocument htmlModel = cache.getHtmlEntry().getModel();
    FuzzyXMLNode[] woTags = NodeSelectUtil.getNodeByFilter(htmlModel.getDocumentElement(), new NamedWebobjectTagFilter(woElementName));
    LinkedModeModel.closeAllModels(htmlDocument);
    for (FuzzyXMLNode woTag : woTags) {
      FuzzyXMLElement woElement = (FuzzyXMLElement) woTag;
      FuzzyXMLAttribute woNameAttr = woElement.getAttributeNode("name");
      if (woNameAttr != null) {
        int offset = woElement.getOffset() + woNameAttr.getValueDataOffset() + 1;
        int length = woNameAttr.getValueDataLength();
        linkedGroup.addPosition(new LinkedPosition(htmlDocument, offset, length, sequence++));
      }
    }
    return sequence;
View Full Code Here

  public void run(IProgressMonitor monitor) throws InvocationTargetException {
    try {
      _cache.clearCache();

      FuzzyXMLDocument htmlModel = _cache.getHtmlEntry().getModel();
      FuzzyXMLElement documentElement = htmlModel.getDocumentElement();
      IDocument htmlDocument = _cache.getHtmlEntry().getDocument();

      IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
      RenderContext renderContext = new RenderContext(true);
      renderContext.setShowNewlines(true);
      renderContext.setIndentSize(prefs.getInt(PreferenceConstants.INDENT_SIZE));
      renderContext.setIndentTabs(prefs.getBoolean(PreferenceConstants.INDENT_TABS));
      renderContext.setTrim(true);
      renderContext.setLowercaseAttributes(prefs.getBoolean(PreferenceConstants.LOWERCASE_ATTRIBUTES));
      renderContext.setLowercaseTags(prefs.getBoolean(PreferenceConstants.LOWERCASE_TAGS));
      renderContext.setSpacesAroundEquals(prefs.getBoolean(PreferenceConstants.SPACES_AROUND_EQUALS));
      renderContext.setSpaceInEmptyTags(true);
      renderContext.setAddMissingQuotes(true);
      renderContext.setDelegate(new WOHTMLRenderDelegate(prefs.getBoolean(PreferenceConstants.STICKY_WOTAGS)));

      StringBuffer htmlBuffer = new StringBuffer();
      FuzzyXMLDocType docType = htmlModel.getDocumentType();
      for (FuzzyXMLNode node : documentElement.getChildren()) {
        if (docType != null) {
          if (!(node instanceof FuzzyXMLProcessingInstruction || FuzzyXMLFormatComposite.isHidden(node))) {
            docType.toXMLString(renderContext, htmlBuffer);
            docType = null;
          }
View Full Code Here

      try {
        FuzzyXMLDocument doc = new FuzzyXMLParser(false).parse(new FileInputStream(webXML));
        FuzzyXMLNode[] nodes = XPath.selectNodes(doc.getDocumentElement(),"/web-app/taglib|/web-app/jsp-config/taglib");
       
        for(int i=0;i<nodes.length;i++){
          FuzzyXMLElement element = (FuzzyXMLElement)nodes[i];
          String taglibUri = HTMLUtil.getXPathValue(element,"/taglib-uri/child::text()");
          String taglibLoc = HTMLUtil.getXPathValue(element,"/taglib-location/child::text()");
          if(uri.equals(taglibUri)){
            if(taglibLoc!=null && taglibLoc.endsWith(".tld")){
              File file = new File(basedir,taglibLoc);
View Full Code Here

  }

  public void run(IProgressMonitor monitor) throws InvocationTargetException {
    try {
      FuzzyXMLDocument htmlModel = _cache.getHtmlEntry().getModel();
      FuzzyXMLElement element = htmlModel.getElementByOffset(_offset);
      if (element != null) {
        IWodModel wodModel = _cache.getWodEntry().getModel();
        String tagName = element.getName();
        if (WodHtmlUtils.isInline(tagName)) {
          SimpleWodElement wodElement = new FuzzyXMLWodElement(element, _buildProperties);
          ElementRename elementRename = ElementRename.newUniqueName(wodModel, wodElement, true);
          wodElement.setElementName(elementRename.getNewName());

          List<ElementRename> elementRenames = new LinkedList<ElementRename>();
          elementRenames.add(elementRename);

          ConvertInlineToWodRefactoring.appendWodElement(_cache, wodElement);

          IDocument htmlDocument = _cache.getHtmlEntry().getDocument();
          List<TextEdit> edits = new LinkedList<TextEdit>();
          int openTagLength = element.getOpenTagLength();
          if (element.hasCloseTag()) {
            edits.add(new ReplaceEdit(element.getCloseTagOffset() + element.getCloseNameOffset() + 1, element.getCloseNameLength(), "webobject"));
          }
          else {
            openTagLength--;
          }
          edits.add(new ReplaceEdit(element.getOffset() + 1, openTagLength, "webobject name = \"" + elementRename.getNewName() + "\""));
          WodDocumentUtils.applyEdits(htmlDocument, edits);
        }
      }
    }
    catch (Exception e) {
View Full Code Here

TOP

Related Classes of jp.aonir.fuzzyxml.FuzzyXMLElement

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.