org.stringtemplate.v4.StringRenderer Java Examples

The following examples show how to use org.stringtemplate.v4.StringRenderer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #2
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState !=null && st.debugState.addAttrEvents !=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #3
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
                       st.debugState.newSTEvent.getLine();
        return "<html><b>" +
            StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #4
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #5
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
                       st.debugState.newSTEvent.getLine();
        return "<html><b>"+
               StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #6
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #7
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
                       st.debugState.newSTEvent.getLine();
        return "<html><b>" +
            StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #8
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #9
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
                       st.debugState.newSTEvent.getLine();
        return "<html><b>" +
            StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #10
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
                       st.debugState.newSTEvent.getLine();
        return "<html><b>" +
            StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #11
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label =
            st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
            st.debugState.newSTEvent.getLine();
        return "<html><b>" +
               StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #12
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #13
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
                       st.debugState.newSTEvent.getLine();
        return "<html><b>"+
               StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #14
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #15
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":" +
                       st.debugState.newSTEvent.getLine();
        return "<html><b>" +
            StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #16
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
	Map<String, Object> attrs = st.getAttributes();
	if ( attrs==null ) return;
	for (String a : attrs.keySet()) {
		String descr;
		if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
			List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
			StringBuilder locations = new StringBuilder();
			int i = 0;
			if ( events!=null ) {
				for (AddAttributeEvent ae : events) {
					if ( i>0 ) locations.append(", ");
					locations.append(ae.getFileName()+":"+ae.getLine());
					i++;
				}
			}
			if ( locations.length()>0 ) {
				descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
			}
			else {
				descr = a + " = " +attrs.get(a);
			}
		}
		else {
			descr = a + " = " +attrs.get(a);
		}

		if (!names.add(a)) {
			StringBuilder builder = new StringBuilder();
			builder.append("<html><font color=\"gray\">");
			builder.append(StringRenderer.escapeHTML(descr));
			builder.append("</font></html>");
			descr = builder.toString();
		}

		node.addChild( new StringTree(descr) );
	}
}
 
Example #17
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
	ST st = event.scope.st;
	if ( st.isAnonSubtemplate() ) return "{...}";
	if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
		String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":"+
			   st.debugState.newSTEvent.getLine();
		return "<html><b>" + StringRenderer.escapeHTML(label) + "</b></html>";
	}
	else {
		return st.toString();
	}
}
 
Example #18
Source File: TemplateMaker.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
public TemplateMaker(Locale locale, char delimiterStartChar, char delimiterStopChar) {
  this.locale = locale;
  this.stGroup = new STGroup(delimiterStartChar, delimiterStopChar);
  // Custom renderer
  this.stGroup.registerModelAdaptor(Model.class, new ModelFormatRenderer());
  this.stGroup.registerRenderer(LocalDate.class, new LocalDateRenderer());
  this.stGroup.registerRenderer(LocalDateTime.class, new LocalDateTimeRenderer());
  this.stGroup.registerRenderer(LocalTime.class, new LocalTimeRenderer());
  // Default renderer provide by ST
  this.stGroup.registerRenderer(String.class, new StringRenderer());
  this.stGroup.registerRenderer(Number.class, new NumberRenderer());
  this.stGroup.registerRenderer(Date.class, new DateRenderer());
}
 
Example #19
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":"+st.debugState.newSTEvent.getLine();
        return "<html><b>"+StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #20
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":"+st.debugState.newSTEvent.getLine();
        return "<html><b>"+StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #21
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #22
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":"+st.debugState.newSTEvent.getLine();
        return "<html><b>"+StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #23
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length() >0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #24
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":"+st.debugState.newSTEvent.getLine();
        return "<html><b>"+StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #25
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #26
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":"+st.debugState.newSTEvent.getLine();
        return "<html><b>"+StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}
 
Example #27
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #28
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #29
Source File: JTreeScopeStackModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addAttributeDescriptions(ST st, StringTree node, Set<String> names) {
    Map<String, Object> attrs = st.getAttributes();
    if ( attrs==null ) return;
    for (String a : attrs.keySet()) {
        String descr;
        if ( st.debugState!=null && st.debugState.addAttrEvents!=null ) {
            List<AddAttributeEvent> events = st.debugState.addAttrEvents.get(a);
            StringBuilder locations = new StringBuilder();
            int i = 0;
            if ( events!=null ) {
                for (AddAttributeEvent ae : events) {
                    if ( i>0 ) locations.append(", ");
                    locations.append(ae.getFileName()+":"+ae.getLine());
                    i++;
                }
            }
            if ( locations.length()>0 ) {
                descr = a+" = "+attrs.get(a)+" @ "+locations.toString();
            }
            else {
                descr = a+" = "+attrs.get(a);
            }
        }
        else {
            descr = a+" = "+attrs.get(a);
        }
        if ( !names.add(a) ) {
            StringBuilder builder = new StringBuilder();
            builder.append("<html><font color=\"gray\">");
            builder.append(StringRenderer.escapeHTML(descr));
            builder.append("</font></html>");
            descr = builder.toString();
        }
        node.addChild(new StringTree(descr));
    }
}
 
Example #30
Source File: JTreeSTModel.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    ST st = event.scope.st;
    if ( st.isAnonSubtemplate() ) return "{...}";
    if ( st.debugState!=null && st.debugState.newSTEvent!=null ) {
        String label = st.toString()+" @ "+st.debugState.newSTEvent.getFileName()+":"+st.debugState.newSTEvent.getLine();
        return "<html><b>"+StringRenderer.escapeHTML(label)+"</b></html>";
    }
    else {
        return st.toString();
    }
}