com.atlassian.confluence.content.ui
Class AttachmentUiSupport

java.lang.Object
  extended by com.atlassian.confluence.content.ui.AttachmentUiSupport
All Implemented Interfaces:
ContentUiSupport<Attachment>

public class AttachmentUiSupport
extends java.lang.Object
implements ContentUiSupport<Attachment>

Since:
4.3

Nested Class Summary
static class AttachmentUiSupport.AttachmentInfo
          Deprecated. Since 4.3. This class is only public because it is used by ContentTypesDisplayMapper. Avoid using this class directly and use a ContentUiSupport object instead. This class will be made private when ContentTypesDisplayMapper is removed.
 
Constructor Summary
AttachmentUiSupport(com.atlassian.plugin.webresource.WebResourceUrlProvider webResourceUrlProvider)
           
 
Method Summary
static AttachmentUiSupport.AttachmentInfo getAttachmentInfo(java.lang.String mimeType, java.lang.String fileExtension)
          Deprecated. Since 4.3 This method is only public because it is used by ContentTypesDisplayMapper. Avoid using this method directly and use a ContentUiSupport object instead. This method will be made private when ContentTypesDisplayMapper is removed. TODO Undeprecate and make this private when ContentTypesDisplayMapper is removed.
 java.lang.String getContentCssClass(Attachment content)
          Get the CSS class that can be applied to some inline element describing the given content
 java.lang.String getContentCssClass(java.lang.String contentType, java.lang.String contentPluginKey)
          Get the CSS class that can be applied to add an icon to some inline element describing the given content.
 java.lang.String getContentTypeI18NKey(Attachment content)
          Get the I18N key for the name of the given content.
 java.lang.String getContentTypeI18NKey(SearchResult result)
          Get the I18N key for the content that is being referred to by this search result
 java.lang.String getIconCssClass(Attachment content)
          Get the CSS class that can be applied to add an icon to some inline element describing the given content.
 java.lang.String getIconCssClass(SearchResult result)
          Get the CSS class that can be applied to add an icon to some inline element describing the given result.
 java.lang.String getIconFilePath(Attachment content, int size)
          Get the URL path to the icon for the gtiven piece of content, without prepending context or web static hashes.
 java.lang.String getIconPath(Attachment content, int size)
          Get the URL path to the icon for the given piece of content.
 java.lang.String getLegacyIconPath(java.lang.String contentType, int size)
          Get the URL path to the icon for the given type of content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachmentUiSupport

public AttachmentUiSupport(com.atlassian.plugin.webresource.WebResourceUrlProvider webResourceUrlProvider)
Method Detail

getIconFilePath

public java.lang.String getIconFilePath(Attachment content,
                                        int size)
Description copied from interface: ContentUiSupport
Get the URL path to the icon for the gtiven piece of content, without prepending context or web static hashes. This method is usedful in conjunction with the DataSourceFactory, which does not handle context and web static hashes in the url.

Specified by:
getIconFilePath in interface ContentUiSupport<Attachment>
Parameters:
content - the content to find an icon for
size - the size. Currently, only 16 is supported, and thus this parameter is ignored.
Returns:
a URL for the icon.

getIconPath

public java.lang.String getIconPath(Attachment content,
                                    int size)
Description copied from interface: ContentUiSupport
Get the URL path to the icon for the given piece of content. Paths are relative to the site root, and will already have the context path prepended to them.

All icons are square. If no icon is available at the requested size, the implementation should use the following priority to determine what to return:

  1. The smallest icon with width larger than the requested size
  2. If no icon is larger than the requested size, return the largest icon available

In general you can only assume a 16x16 icon will be available, but this may change in the future.

Specified by:
getIconPath in interface ContentUiSupport<Attachment>
Parameters:
content - the content to find an icon for
size - the intended width/height at which the icon will be displayed in pixels
Returns:
the path to the icon that best suits the requested size

getLegacyIconPath

public java.lang.String getLegacyIconPath(java.lang.String contentType,
                                          int size)
Description copied from interface: ContentUiSupport
Get the URL path to the icon for the given type of content. Paths are relative to the site root, and will already have the context path prepended to them. This method will always return the generic icon for the given content: if you want to inspect the content and return different icons based on its state, use ContentUiSupport.getIconPath(com.atlassian.confluence.core.ConfluenceEntityObject, int)

Icon size selection follows the same rule as its sister method.

Specified by:
getLegacyIconPath in interface ContentUiSupport<Attachment>
Parameters:
contentType - the type of content to find an icon for as would be returned from ContentEntityObject.getType()
size - the intended width/height at which the icon will be displayed in pixels
Returns:
the path to the icon that best suits the requested size

getIconCssClass

public java.lang.String getIconCssClass(Attachment content)
Description copied from interface: ContentUiSupport
Get the CSS class that can be applied to add an icon to some inline element describing the given content.

Specified by:
getIconCssClass in interface ContentUiSupport<Attachment>
Parameters:
content - the content to find an icon for
Returns:
the CSS class to add that icon to the element

getContentCssClass

public java.lang.String getContentCssClass(java.lang.String contentType,
                                           java.lang.String contentPluginKey)
Description copied from interface: ContentUiSupport
Get the CSS class that can be applied to add an icon to some inline element describing the given content. The existence of both IconCssClass (used in the velocity macros) and ContentCssClass (used by the ContentTypesDisplayMapper) is redundant and confusing, and should be reconciled somehow.

Specified by:
getContentCssClass in interface ContentUiSupport<Attachment>
Parameters:
contentType - the content to find an icon for
contentPluginKey - the plugin key for the content it it is a ContentType plugin
Returns:
the CSS class to add that icon to the element

getContentCssClass

public java.lang.String getContentCssClass(Attachment content)
Description copied from interface: ContentUiSupport
Get the CSS class that can be applied to some inline element describing the given content

Specified by:
getContentCssClass in interface ContentUiSupport<Attachment>
Parameters:
content - the content to find the css for
Returns:
the CSS class for this content

getIconCssClass

public java.lang.String getIconCssClass(SearchResult result)
Description copied from interface: ContentUiSupport
Get the CSS class that can be applied to add an icon to some inline element describing the given result.

Specified by:
getIconCssClass in interface ContentUiSupport<Attachment>
Parameters:
result - the search result to find an icon for
Returns:
the CSS class to add that icon to the element

getContentTypeI18NKey

public java.lang.String getContentTypeI18NKey(Attachment content)
Description copied from interface: ContentUiSupport
Get the I18N key for the name of the given content.

Specified by:
getContentTypeI18NKey in interface ContentUiSupport<Attachment>
Parameters:
content - the content to get the name of
Returns:
the I18N key that can be used to name that content

getContentTypeI18NKey

public java.lang.String getContentTypeI18NKey(SearchResult result)
Description copied from interface: ContentUiSupport
Get the I18N key for the content that is being referred to by this search result

Specified by:
getContentTypeI18NKey in interface ContentUiSupport<Attachment>
Parameters:
result - the search result being displayed
Returns:
the I18N key that can be used to name that content

getAttachmentInfo

@Deprecated
public static AttachmentUiSupport.AttachmentInfo getAttachmentInfo(java.lang.String mimeType,
                                                                              java.lang.String fileExtension)
Deprecated. Since 4.3 This method is only public because it is used by ContentTypesDisplayMapper. Avoid using this method directly and use a ContentUiSupport object instead. This method will be made private when ContentTypesDisplayMapper is removed. TODO Undeprecate and make this private when ContentTypesDisplayMapper is removed.

Tries to find a matching CSS class and i18n key based on the mime type. If that fails, it tries to find a match based on the extension. If that fails, it returns AttachmentUiSupport.AttachmentInfo.UNKNOWN. Never returns null.

Parameters:
mimeType - The mime type of the attachment
fileExtension - The filename of the attachment
Returns:
An AttachmentInfo representing the content or AttachmentUiSupport.AttachmentInfo.UNKNOWN if none were found.


Copyright © 2003-2014 Atlassian. All Rights Reserved.