Package de.innovationgate.eclipse.editors.config

Examples of de.innovationgate.eclipse.editors.config.TMLTag


        if (partition.getType().equals(TMLPartitionScanner.TML_TAG_START)) {
          try {
            TMLRegion tmlInfo = TMLRegion.parse(partition, document);
            TMLTagDefinitions tagDef = TMLTagDefinitions.getInstance(_versionCompliance);
            if (tagDef != null) {
                TMLTag tag = tagDef.getTagByName(tmlInfo.getTagName());
                if (tag != null) {
                  List<String> tmpAttributes = new ArrayList<String>();
                  tmpAttributes.addAll(tmlInfo.getAttributeNames());
                  tmpAttributes.addAll(tmlInfo.getValuelessAttributes());
                 
                  Iterator<String> attributes = tmpAttributes.iterator();
                  while (attributes.hasNext()) {
                    String attribute = attributes.next();
                    if (tag.getName().equals("include") || tag.getName().equals("portlet")) {
                      if (attribute.startsWith("o_")) {
                        // attributes starting with "o_" mean implicit options - do not validate
                        continue;
                      }
                    }
                    int charStart = partition.getOffset();
                                    int charEnd = charStart + partition.getLength();
                                    int attributeStart = tmlInfo.getContent().indexOf(attribute);
                                    if (attributeStart != -1) {
                                        charStart = charStart + attributeStart;
                                        charEnd = charStart + attribute.length();
                                    }
                    if (tag.getAttribute(attribute) == null) {                                 
                      MarkerFactory.createErrorMarker(MARKER_ID, file, charStart, charEnd, "Unknown attribute '" + attribute + "'.");
                    } else {
                        TMLTagAttribute attrib  = tag.getAttribute(attribute);
                        if (attrib.isDeprecated()) {
                            MarkerFactory.createWarningMarker(MARKER_ID, file, charStart, charEnd, "Attribute '" + attribute + "' is deprecated. " + attrib.getDeprecated());
                        }
                    }
                  }
View Full Code Here


              int charEnd = charStart + partition.getLength();
              MarkerFactory.createErrorMarker(MARKER_ID, file, charStart, charEnd, "Unknown TML-Tag '" + tmlInfo.getTagName() + "'.");
            } else {
                TMLTagDefinitions tagDef = TMLTagDefinitions.getInstance(_versionCompliance);
                if (tagDef != null) {
                    TMLTag tag = tagDef.getTagByName(tmlInfo.getTagName());
                    if (tag.isDeprecated()) {
                        int charStart = partition.getOffset();
                                int charEnd = charStart + partition.getLength();
                                MarkerFactory.createWarningMarker(MARKER_ID, file, charStart, charEnd, "TML-Tag '" + tmlInfo.getTagName() + "' is deprecated. " + tag.getDeprecated());
                    }
                }
            }
          } catch (ParseException e) {
          }
View Full Code Here

      ITypedRegion[] partitions = document.computePartitioning(0, document.getLength());
      for (ITypedRegion partition : partitions) {
        if (partition.getType().equals(TMLPartitionScanner.TML_TAG_START)) {
          try {           
            TMLRegion tmlInfo = TMLRegion.parse(partition, document);
            TMLTag tag = TMLTagDefinitions.getInstance(versionCompliance).getTagByName(tmlInfo.getTagName());
            if (tag != null) {
              executeValidators(file, document, partition, tmlInfo, tag, versionCompliance);             
            }
          } catch (ParseException e) {
          }         
View Full Code Here

                IFile activeFile = Plugin.getDefault().getActiveFile();
                String tagName = tmlInfo.getTagName();
                if (activeFile != null && tagName != null) {
                    VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(activeFile);
                    if (versionCompliance != null) {
                        TMLTag tag = TMLTagDefinitions.getInstance(versionCompliance).getTagByName(tagName);
                        if (tag != null) {
                            String attributeAtCursor = tmlInfo.getAttributeAtCursor();
                            if (attributeAtCursor != null) {
                                TMLTagAttribute attribute = tag.getAttribute(attributeAtCursor);
                                if (attribute != null && attribute.isTmlscriptExpression()) {
                                    return _tmlScriptProcessor.getCompletionProposalAutoActivationCharacters();
                                }
                            }
                        }
View Full Code Here

      String alreadyTyped = getTagName();
      if (alreadyTyped != null) {
        if (!alreadyTyped.startsWith("[")) {
          Iterator<TMLTag> it = TMLTagDefinitions.getInstance(WGADesignStructureHelper.getWGAVersionCompliance(activeFile)).getTagsByPrefix(alreadyTyped).iterator();
          while (it.hasNext()) {
            TMLTag tag = it.next();
            proposals.addAll(createTagProposals(alreadyTyped, tag, _document, _cursorAbsolute,activeFile));
          }
        } else {
          Version wgaVersion = (Version) WGADesignConfigurationModel.VERSIONCOMPLIANCE_TO_WGA_VERSION.get(WGADesignStructureHelper.getWGAVersionCompliance(activeFile).getKey())
          if (wgaVersion.isAtLeast(4, 1)) {
            proposals.addAll(createIncludeModuleProposals(alreadyTyped, _document, _cursorAbsolute, activeFile));
          }
        }
      }     
    } else if (!isCursorInAttributeValue()) {
      // create attribute name proposals
      String search = _content.substring(0, _cursorRelative);
      int attributePrefixStartPos = searchBackwards(" ", search, "<");
      if (attributePrefixStartPos != -1) {
        attributePrefixStartPos += 1;
        String typed = search.substring(attributePrefixStartPos, _cursorRelative);
        TMLTag tag = TMLTagDefinitions.getInstance(WGADesignStructureHelper.getWGAVersionCompliance(activeFile)).getTagByName(getTagName());
        if (tag != null) {
          Iterator<TMLTagAttribute> it = tag.getAttributesByPrefix(typed).iterator();
          while (it.hasNext()) {
            TMLTagAttribute attrib = it.next();
            if (!_attributes.containsKey(attrib.getName()) && !attrib.isDeprecated()) {
              String attName  = attrib.getName();
              String display = attName;
              StringBuffer replacement = new StringBuffer();
              replacement.append(attName);
              replacement.append("=\"\"");
              int cursorPosAfterReplace = replacement.toString().length() - 1;
              ContextInformation contextInfo = Plugin.getDefault().getContextInformationProvider().getAttributeInformation(tag.getName(), attrib.getName(), activeFile);
              proposals.add(new TMLCompletionProposal(replacement.toString(), _cursorAbsolute - typed.length(), typed.length(), cursorPosAfterReplace, null, display, contextInfo));
            }
          }
        }
      }
    } else if (getAttributeNameOfValueCursorPosition() != null) {
      // create attribute value proposals
      String attribute = getAttributeNameOfValueCursorPosition();
      String search = _content.substring(0, _cursorRelative);
      int attributeValueStartPos = searchBackwards("\"", search, "=");
      String typed = "";
      if (attributeValueStartPos != -1) {
        typed = _content.substring(attributeValueStartPos + 1, _cursorRelative)
      } else {
        typed = "";
      }     
      TMLTag tag = TMLTagDefinitions.getInstance(WGADesignStructureHelper.getWGAVersionCompliance(activeFile)).getTagByName(getTagName());
      if (tag != null) {
          TMLTagAttribute tagAttribute = tag.getAttribute(attribute);
          if (tagAttribute != null) {
              if (tagAttribute.isTmlscriptExpression()) {
                  // perform tmlscript code completion
                  try {
                            IRegion region = getAttributeValueRegion(attribute);
                            TMLScriptRegion tmlScriptRegion = TMLScriptRegion.parse(region, _document, _cursorAbsolute, WGADesignStructureHelper.getWGAVersionCompliance(activeFile));
                            proposals.addAll(tmlScriptRegion.createProposals());
                        }
                        catch (BadLocationException e) {
                        }
              } else {
                  // lookup attribute values
                    Iterator<String> values = tag.getAttributeValuesByPrefix(attribute, typed, _document, this, viewer, activeFile).iterator();
                    while (values.hasNext()) {
                        String value = values.next();
                        String display = value;
                        StringBuffer replacement = new StringBuffer();
                        replacement.append(value);
                        int cursorPosAfterReplace = replacement.toString().length() + 1;
                        ContextInformation info = Plugin.getDefault().getContextInformationProvider().getAttributeInformation(tag.getName(), attribute, value,activeFile);
          proposals.add(new TMLCompletionProposal(replacement.toString(), _cursorAbsolute - typed.length(), typed.length(), cursorPosAfterReplace, null, display, info));
                    }                 
              }
          }         
      }
View Full Code Here

  public ContextInformation getAttributeInformation(String tagname, String attribute, String value, IFile tmlFile) {
      VersionCompliance versionCompliance = retrieveVersionCompliance(tmlFile);     
    if (value != null) {
      // check if attribute value help is available - otherwise disable value lookup (set value to null)
      TMLTag tag = TMLTagDefinitions.getInstance(versionCompliance).getTagByName(tagname);
      if (tag != null) {
        TMLTagAttribute tagAttribute = tag.getAttribute(attribute);
        if (tagAttribute != null) {
          if (!tagAttribute.isValueHelpEnabled()) {
            value = null;
          }
        }
View Full Code Here

TOP

Related Classes of de.innovationgate.eclipse.editors.config.TMLTag

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.