Package jp.aonir.fuzzyxml

Examples of jp.aonir.fuzzyxml.FuzzyXMLDocument


    WodParserCache cache = getParserCache();
    if (getSelectionProvider() != null) {
      ISelection realSelection = getSelectionProvider().getSelection();
      if (realSelection instanceof ITextSelection) {
        ITextSelection textSelection = (ITextSelection) realSelection;
        FuzzyXMLDocument document = getHtmlXmlDocument(refreshModel);
        if (document != null) {
          FuzzyXMLElement element = document.getElementByOffset(textSelection.getOffset());
          BuildProperties buildProperties = (BuildProperties)cache.getProject().getAdapter(BuildProperties.class);
          wodElement = WodHtmlUtils.getWodElement(element, buildProperties, resolveWodElement, cache);
        }
      }
      else if (realSelection instanceof IStructuredSelection) {
View Full Code Here


  }

  public FuzzyXMLElement getElementAtOffset(int offset, boolean refreshModel) throws Exception {
    FuzzyXMLElement element = null;
    if (offset >= 0) {
      FuzzyXMLDocument xmlDocument = getHtmlXmlDocument(refreshModel);
      if (xmlDocument != null) {
        element = xmlDocument.getElementByOffset(offset);
      }
    }
    return element;
  }
View Full Code Here

 
  /**
   * Extracts the first element name in the given xml source.
   */
  private static String getFirstTag(String xml){
    FuzzyXMLDocument doc = new FuzzyXMLParser(false).parse(xml);
    FuzzyXMLNode[] nodes = doc.getDocumentElement().getChildren();
    for(int i=0;i<nodes.length;i++){
      if(nodes[i] instanceof FuzzyXMLElement){
        return ((FuzzyXMLElement)nodes[i]).getName();
      }
    }
View Full Code Here

    @Override
    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);
View Full Code Here

    try {
      IDocument htmlDocument = _cache.getHtmlEntry().getDocument();
      if (htmlDocument != null) {
        List<TextEdit> htmlEdits = new LinkedList<TextEdit>();
        for (ElementRename rename : _renames) {
          FuzzyXMLDocument htmlModel = _cache.getHtmlEntry().getModel();
          FuzzyXMLNode[] woTags = NodeSelectUtil.getNodeByFilter(htmlModel.getDocumentElement(), new NamedWebobjectTagFilter(rename.getOldName()));

          for (FuzzyXMLNode woTag : woTags) {
            FuzzyXMLElement woElement = (FuzzyXMLElement) woTag;
            FuzzyXMLAttribute woNameAttr = woElement.getAttributeNode("name");
            if (woNameAttr != null) {
View Full Code Here

    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();
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);
      }
View Full Code Here

    QuickRenameRefactoring.enterLinkedMode(linkedGroup, cache, htmlViewer);
  }

  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) {
View Full Code Here

  private static byte[] getTLDFromWebXML(File basedir,String uri){
    File webXML = new File(basedir,"/WEB-INF/web.xml");
   
    if(webXML.exists() && webXML.isFile()){
      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()");
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

TOP

Related Classes of jp.aonir.fuzzyxml.FuzzyXMLDocument

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.