jetbrains.buildServer.web.util.lazytree
Class DefaultLazyTreeElementRenderer

java.lang.Object
  extended by jetbrains.buildServer.web.util.lazytree.DefaultLazyTreeElementRenderer
All Implemented Interfaces:
LazyTreeElementRenderer

public class DefaultLazyTreeElementRenderer
extends java.lang.Object
implements LazyTreeElementRenderer

Since:
6.0
Author:
Maxim Podkolzine (maxim.podkolzine@jetbrains.com)

Constructor Summary
DefaultLazyTreeElementRenderer()
           
 
Method Summary
protected  java.lang.String encodePath(java.lang.String path)
           
 java.lang.String getCssClassForElement(Element element)
          Returns the CSS class of the element to use.
 java.lang.String getCustomHtmlForElement(Element element, java.lang.String id)
          Returns the custom HTML (instead of standard span sequence) representing the element.
protected  java.lang.String getDefaultTextForElement(Element element)
           
 java.lang.String getHrefForLeaf(Element leaf)
          Returns the href attribute value of the element's link.
 java.lang.String getOnClickForLeaf(Element leaf)
          Returns the onclick handler of the element's link.
 java.lang.String getOnClickForNonLeaf(Element element)
          Returns the onclick handler of the non-leaf element's link.
protected  java.lang.String getSize(Element element)
           
 java.lang.String getTextForElement(Element element)
          Returns the text representation of an element (usually name).
 boolean ignoreElement(Element element)
          If returns true, the element and its subtree won't appear in web UI.
protected  boolean isInsideZip(Element element)
           
protected  boolean isMakeLinkFromLeaf(Element element)
           
protected  boolean isMakeOnclickFromLeaf(Element element)
           
protected  boolean isZipElement(Element element)
           
 void prepareForRequest(javax.servlet.http.HttpServletRequest request)
          Allows the renderer to customize its behavious depending on current request.
protected  boolean showSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLazyTreeElementRenderer

public DefaultLazyTreeElementRenderer()
Method Detail

prepareForRequest

public void prepareForRequest(@NotNull
                              javax.servlet.http.HttpServletRequest request)
Description copied from interface: LazyTreeElementRenderer
Allows the renderer to customize its behavious depending on current request.

Specified by:
prepareForRequest in interface LazyTreeElementRenderer
Parameters:
request - http request

ignoreElement

public boolean ignoreElement(@NotNull
                             Element element)
Description copied from interface: LazyTreeElementRenderer
If returns true, the element and its subtree won't appear in web UI. Useful for filtering redundant elements, such as ".svn".

Specified by:
ignoreElement in interface LazyTreeElementRenderer
Parameters:
element - the element
Returns:
true if the element should be ignored, false otherwise

getTextForElement

@NotNull
public java.lang.String getTextForElement(@NotNull
                                                  Element element)
Description copied from interface: LazyTreeElementRenderer
Returns the text representation of an element (usually name). Default implementation returns: StringUtil.escapeHTML(element.getName(), false)).

Specified by:
getTextForElement in interface LazyTreeElementRenderer
Parameters:
element - the element to render
Returns:
string representation of the element

getOnClickForLeaf

public java.lang.String getOnClickForLeaf(@NotNull
                                          Element leaf)
Description copied from interface: LazyTreeElementRenderer
Returns the onclick handler of the element's link. Method is optional. Applies only to leaf elements.

Specified by:
getOnClickForLeaf in interface LazyTreeElementRenderer
Parameters:
leaf - the element to render
Returns:
string representation of the onclick handler, or null

getHrefForLeaf

public java.lang.String getHrefForLeaf(@NotNull
                                       Element leaf)
Description copied from interface: LazyTreeElementRenderer
Returns the href attribute value of the element's link. Method is optional. Applies only to leaf elements.

Updatd since 7.0: some leaf elements can act as non-leaf ones (e.g. archives). Technically they are not leaves in a tree, but the href attribute is still valid for them.

Specified by:
getHrefForLeaf in interface LazyTreeElementRenderer
Parameters:
leaf - the element to render
Returns:
string represetation of the href attribute, or null

getOnClickForNonLeaf

@Nullable
public java.lang.String getOnClickForNonLeaf(@NotNull
                                                      Element element)
Description copied from interface: LazyTreeElementRenderer
Returns the onclick handler of the non-leaf element's link. Method is optional.

Specified by:
getOnClickForNonLeaf in interface LazyTreeElementRenderer
Parameters:
element - the non-leaf element to render
Returns:
stirng representationof the onclick handler, or null if default handler should be used

getCssClassForElement

public java.lang.String getCssClassForElement(@NotNull
                                              Element element)
Description copied from interface: LazyTreeElementRenderer
Returns the CSS class of the element to use. May be applied to all elements.

Specified by:
getCssClassForElement in interface LazyTreeElementRenderer
Parameters:
element - the element to render
Returns:
CSS class, or null if no additional class should be used

getCustomHtmlForElement

@Nullable
public java.lang.String getCustomHtmlForElement(@NotNull
                                                         Element element,
                                                         @NotNull
                                                         java.lang.String id)
Description copied from interface: LazyTreeElementRenderer
Returns the custom HTML (instead of standard span sequence) representing the element. Note that in this case the renderer is responsible to attach proper javascript handlers.

Specified by:
getCustomHtmlForElement in interface LazyTreeElementRenderer
Parameters:
element - the element (can be a leaf, can be an intermediate one)
id - its id
Returns:
the HTML for the element, or null

encodePath

@NotNull
protected java.lang.String encodePath(@Nullable
                                              java.lang.String path)

isInsideZip

protected boolean isInsideZip(@NotNull
                              Element element)

isZipElement

protected boolean isZipElement(@NotNull
                               Element element)

getDefaultTextForElement

@NotNull
protected java.lang.String getDefaultTextForElement(@NotNull
                                                            Element element)

showSize

protected boolean showSize()

getSize

@NotNull
protected java.lang.String getSize(@NotNull
                                           Element element)

isMakeLinkFromLeaf

protected boolean isMakeLinkFromLeaf(@NotNull
                                     Element element)

isMakeOnclickFromLeaf

protected boolean isMakeOnclickFromLeaf(@NotNull
                                        Element element)