Package org.objectstyle.wolips.bindings.wod

Examples of org.objectstyle.wolips.bindings.wod.IWodElement


      String className = "element";

      boolean woTag = WodHtmlUtils.isWOTag(nodeName);
      boolean woSimpleString = false;

      IWodElement wodElement = null;
      if (woTag) {
        className = className + " wo";
        try {
          BuildProperties buildProperties = (BuildProperties)_editor.getParserCache().getProject().getAdapter(BuildProperties.class);
          wodElement = WodHtmlUtils.getWodElement(element, buildProperties, true, cache);
        }
        catch (Throwable t) {
          // IGNORE
          t.printStackTrace();
        }
        if (wodElement != null) {
          className = className + " " + wodElement.getElementType();

          if ("WOString".equals(wodElement.getElementType()) || "ERXLocalizedString".equals(wodElement.getElementType())) {
            if (wodElement.getBindingNamed("value") != null) {
              if (wodElement.getBindingNamed("escapeHTML") != null && wodElement.getBindings().size() == 2) {
                woSimpleString = true;
              }
              else if (wodElement.getBindings().size() == 1) {
                woSimpleString = true;
              }
            }

            // MS: FORCE OFF FOR NOW
            //woSimpleString = false;

            if (woSimpleString) {
              className = className + " simple";
            }
          }
        }
      }
      else {
        className = className + " " + nodeName.toLowerCase();
      }

      boolean showExpandCollapse = !empty;
      if ("script".equalsIgnoreCase(nodeName)) {
        // don't show script
        showExpandCollapse = false;
      }
      else if ("style".equalsIgnoreCase(nodeName)) {
        // don't show style
        showExpandCollapse = false;
      }

      if (!showExpandCollapse) {
        className += " empty";
      }

      //renderBuffer.append("<div id = \"" + nodeID + "\" class = \"" + className + "\" onmouseover = \"window.status = 'over:" + nodeID + "';\" onmouseout = \"window.status = 'out:" + nodeID + "';\" >");
      renderBuffer.append("<div id = \"" + nodeID + "\" class = \"" + className + "\">");

      if (showExpandCollapse) {
        renderBuffer.append("<div id = \"" + nodeID + "_toggle\" class = \"expandcollapse\" onclick = \"expandCollapse('" + nodeID + "')\">");
        if (_collapsedIDs.contains(nodeID)) {
          renderBuffer.append(TemplateOutlinePage.EXPAND_STRING);
        }
        else {
          renderBuffer.append(TemplateOutlinePage.COLLAPSE_STRING);
        }
        renderBuffer.append("</div>");
      }

      renderBuffer.append("<div class = \"summary\" onclick = \"window.status = 'select:" + nodeID + "'\">");

      // ... a simple string tag
      if (woSimpleString) {
        IWodBinding valueBinding = wodElement.getBindingNamed("value");
        String text = valueBinding.getValue();
        String textClassName;
        if (valueBinding.isLiteral()) {
          //text = text.replaceAll("^\"([^\"]+)\"", "$1");
          textClassName = "text literal";
        }
        else if (valueBinding.isOGNL()) {
          textClassName = "text ognl";
        }
        else {
          textClassName = "text keypath";
        }
        renderBuffer.append("<div class = \"title\"></div> <div class = \"" + textClassName + "\">[" + text + "]</div>");
      }
      // ... a WO tag
      else if (woTag) {
        if (wodElement != null) {
          if (WodHtmlUtils.isInline(nodeName)) {

            String summaryName = wodElement.getElementType();
            renderBuffer.append("<div class = \"title\"><span class = \"nodeName verbose\">" + summaryName + "</span></div>");

            // Special case for the compact display of a conditional
            if ("WOConditional".equals(summaryName)) {
              String conditionValue = wodElement.getBindingValue("condition");
              if (conditionValue != null) {
                summaryName = conditionValue;
                boolean negated = false;
                IWodBinding negateBinding = wodElement.getBindingNamed("negate");
                if (negateBinding != null) {
                  if (negateBinding.isTrueValue()) {
                    negated = true;
                  }
                }
                else if (nodeName.equals("wo:not")) {
                  negated = true;
                }

                if (negated) {
                  summaryName = "<span class = \"negate\">not</span> " + summaryName;
                }
                else if (negateBinding != null) {
                  summaryName = summaryName + " <span class = \"negate\">not = " + negateBinding.getValue() + "</span>";
                }
              }
            }
            // Special case for the compact display of a string
            else if ("WOString".equals(summaryName)) {
              String value = wodElement.getBindingValue("value");
              if (value != null) {
                summaryName = "WOString: " + value;
              }
            }
            // Special case for the compact display of a localized string
            else if ("ERXLocalizedString".equals(summaryName)) {
              String value = wodElement.getBindingValue("value");
              if (value != null) {
                summaryName = "ERXLocalizedString: " + value;
              }
            }
            // Special case for the compact display of links, buttons, etc
            else if (wodElement.getBindingNamed("action") != null) {
              String action = wodElement.getBindingValue("action");
              summaryName = wodElement.getElementType() + ": " + action;
            }
            // Special case for the compact display of form fields
            else if (wodElement.getBindingNamed("value") != null) {
              String value = wodElement.getBindingValue("value");
              summaryName = wodElement.getElementType() + ": " + value;
            }
            // Special case for the compact display of checkboxes
            else if (wodElement.getBindingNamed("checked") != null) {
              String checked = wodElement.getBindingValue("checked");
              summaryName = wodElement.getElementType() + ": " + checked;
            }
            // Special case for the compact display of repetitions and popup buttons
            else if (wodElement.getBindingNamed("list") != null) {
              String list = wodElement.getBindingValue("list");
              summaryName = wodElement.getElementType() + ": " + list;
            }
            renderBuffer.append("<div class = \"title\"><span class = \"nodeName compact\">" + summaryName + "</span></div>");
          }
          else {
            renderBuffer.append("<div class = \"title\"><span class = \"nodeName\">" + wodElement.getElementName() + "</span> <span class = \"type\">: " + wodElement.getElementType() + "</span></div>");
          }

          // WO bindings
          List<IWodBinding> wodBindings = wodElement.getBindings();
          if (wodBindings.size() > 0) {
            renderBuffer.append("<table class = \"bindings\">");
            for (IWodBinding wodBinding : wodBindings) {
              renderBuffer.append("<tr>");
              renderBuffer.append("<th>" + wodBinding.getName() + "</th>");
View Full Code Here


      String tagName = element.getName();
      if (WodHtmlUtils.isWOTag(tagName)) {
        try {
          WodParserCache cache = _caches.peek();
          BuildProperties buildProperties = (BuildProperties)cache.getProject().getAdapter(BuildProperties.class);
          IWodElement wodElement = WodHtmlUtils.getWodElement(element, buildProperties, true, cache);
          if (wodElement == null) {
            return true;
          }

          String elementTypeName = wodElement.getElementType();
         
          TagDelegate tagDelegate = _tagDelegates.get(elementTypeName);
          if (tagDelegate != null) {
            tagDelegate.renderNode(wodElement, element, renderContext, xmlBuffer, _cssBuffer, _caches, _nodes);
          }
          else {
            IType type = BindingReflectionUtils.findElementType(cache.getJavaProject(), elementTypeName, false, WodParserCache.getTypeCache());
            LocalizedComponentsLocateResult componentsLocateResults = LocatePlugin.getDefault().getLocalizedComponentsLocateResult(type.getJavaProject().getProject(), wodElement.getElementType());
            IFile htmlFile = componentsLocateResults.getFirstHtmlFile();
            if (htmlFile != null) {
              WodParserCache nestedCache = WodParserCache.parser(htmlFile);
              if (nestedCache != null) {
                Wo apiModel = ApiUtils.findApiModelWo(type, WodParserCache.getTypeCache().getApiCache(cache.getJavaProject()));
                if (apiModel != null) {
                  String preview = apiModel.getPreview();
                  if (preview != null) {
                    StringBuffer previewBuffer = new StringBuffer();
                    Pattern bindingPattern = Pattern.compile("\\$([a-zA-Z0-9_]+)");
                    Matcher matcher = bindingPattern.matcher(preview);
                    while (matcher.find()) {
                      String bindingName = matcher.group(1);
                      IWodBinding binding = wodElement.getBindingNamed(bindingName);
                      if (binding == null) {
                        matcher.appendReplacement(previewBuffer, "");
                      } else {
                        matcher.appendReplacement(previewBuffer, binding.getValue());
                      }
View Full Code Here

      if (wodDocument != null) {
        IWodModel wodModel = _cache.getWodEntry().getModel();
        List<TextEdit> wodEdits = new LinkedList<TextEdit>();
        MultiTextEdit multiEdit = new MultiTextEdit();
        for (ElementRename rename : _renames) {
          IWodElement wodElement = wodModel.getElementNamed(rename.getOldName());
          wodEdits.add(new ReplaceEdit(wodElement.getElementNamePosition().getOffset(), wodElement.getElementNamePosition().getLength(), rename.getNewName()));
        }
        WodDocumentUtils.applyEdits(wodDocument, wodEdits);
      }
    }
    catch (Exception e) {
View Full Code Here

  public int getEndOffset() {
    return _document.getLength();
  }

  public IWodElement getWodElementAtIndex(int index) {
    IWodElement elementAtIndex = null;
    Iterator<IWodElement> elementsIter = getElements().iterator();
    while (elementAtIndex == null && elementsIter.hasNext()) {
      IWodElement element = elementsIter.next();
      if (isIndexContainedByWodUnit(index, element)) {
        elementAtIndex = element;
      }
    }
    return elementAtIndex;
View Full Code Here

  }

  public IWodUnit getWodUnitAtIndex(int index) {
    IWodUnit wodUnit = null;

    IWodElement elementAtIndex = getWodElementAtIndex(index);
    if (elementAtIndex != null) {
      Iterator<IWodBinding> bindingsIter = elementAtIndex.getBindings().iterator();
      while (wodUnit == null && bindingsIter.hasNext()) {
        IWodBinding binding = bindingsIter.next();
        if (isIndexContainedByWodUnit(index, binding)) {
          wodUnit = binding;
        }
View Full Code Here

    // DO NOTHING
  }

  public void webObjectTagSelected(String name) {
    try {
      IWodElement wodElement = getWodModel(false).getElementNamed(name);
      if (wodElement instanceof DocumentWodElement) {
        DocumentWodElement docWodElement = (DocumentWodElement)wodElement;
        Position namePosition = docWodElement.getElementNamePosition();
        getSourceViewer().setSelectedRange(namePosition.getOffset(), namePosition.getLength());
        getSourceViewer().revealRange(namePosition.getOffset(), namePosition.getLength());
View Full Code Here

    return model;
  }

  public IWodElement getWodElementAtPoint(Point point, boolean resolveWodElement, boolean refreshModel) throws Exception {
    int offset = getOffsetAtPoint(point);
    IWodElement element = getWodModel(refreshModel).getWodElementAtIndex(offset);
    return element;
  }
View Full Code Here

    IWodElement element = getWodModel(refreshModel).getWodElementAtIndex(offset);
    return element;
  }

  public IWodElement getSelectedElement(boolean resolveWodElement, boolean refreshModel) throws Exception {
    IWodElement element = null;
    ISelectionProvider selectionProvider = getSelectionProvider();
    if (selectionProvider != null) {
      ISelection selection = selectionProvider.getSelection();
      if (selection instanceof ITextSelection) {
        int offset = ((ITextSelection) selection).getOffset();
View Full Code Here

          int endOffset = startOffset + woElement.getNameLength() - 1;
          HtmlElementName elementName = new HtmlElementName(htmlCacheEntry.getFile(), woElementName, startOffset, endOffset);
          htmlCacheEntry.getHtmlElementCache().addHtmlElement(elementName);

          if (wodModel != null) {
            IWodElement wodElement = wodModel.getElementNamed(woElementName);
            if (wodElement == null) {
              WodProblem undefinedElement = new WodBindingValueProblem(wodElement, new SimpleWodBinding(null, "name", null), "name", "The element '" + woElementName + "' is not defined in " + wodFile.getName(), null, -1, false);
              inlineProblems.add(new InlineWodProblem(woElement, undefinedElement, _cache));
            }
          }
View Full Code Here

    }

    String elementName = element.getName();
    if (WodHtmlUtils.isInline(elementName)) {
      if (validate) {
        IWodElement wodElement = new FuzzyXMLWodElement(element, _buildProperties);
        if (wodElement != null) {
          boolean validateBindingValues = Activator.getDefault().getPluginPreferences().getBoolean(PreferenceConstants.VALIDATE_BINDING_VALUES);
          //String invalidOGNLSeverity = Activator.getDefault().getPluginPreferences().getString(PreferenceConstants.INVALID_OGNL_SEVERITY_KEY);
          List<WodProblem> wodProblems = new LinkedList<WodProblem>();
          try {
            wodElement.fillInProblems(_cache.getJavaProject(), _cache.getComponentType(), validateBindingValues, wodProblems, WodParserCache.getTypeCache(), _cache.getHtmlEntry().getHtmlElementCache());
            inlineProblems.add(new InlineWodProblem(element, wodProblems, _cache));
          }
          catch (JavaModelException e) {
            try {
              WodParserCache.getTypeCache().clearCacheForType(_cache.getComponentType());
View Full Code Here

TOP

Related Classes of org.objectstyle.wolips.bindings.wod.IWodElement

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.