Class CmsPreviewUtil


  • public final class CmsPreviewUtil
    extends java.lang.Object
    Utility class for resource preview.

    Since:
    8.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeDialog()
      Triggers the dialog OK action.
      static void enableEditorOk​(boolean enabled)
      Enables the dialog OK button within the rich text editor (FCKEditor, CKEditor, ...).
      static void exportFunctions​(java.lang.String previewName, I_CmsResourcePreview<?> preview)
      Exports the functions of I_CmsResourcePreview to the window object for use via JSNI.
      static java.lang.String getFieldId()
      Returns the xml-content field id.
      static java.lang.String[] getFormatNames()
      Returns the available image format names for gallery widget mode.
      static java.lang.String[] getFormats()
      Returns the available image formats for gallery widget mode.
      static CmsJSONMap getImageAttributes()
      Returns all available information of the selected image tag, or null, if no image is selected.
      static boolean hasEnhancedImageOptions()
      Returns the availability of enhanced image options.
      static boolean isAdvancedWidget()
      Returns if the gallery widget is used in advanced mode.
      static boolean isShowFormats()
      Returns if the image format selector should be shown within gallery widget mode.
      static void setDataAndCloseDialog()
      Triggers the dialog OK action.
      static void setImage​(java.lang.String path, java.util.Map<java.lang.String,​java.lang.String> attributes)
      Sets the image tag within the rich text editor (FCKEditor, CKEditor, ...).
      static void setImageLink​(java.lang.String path, java.util.Map<java.lang.String,​java.lang.String> attributes, java.lang.String linkPath, java.lang.String target)
      Sets the image link within the rich text editor (FCKEditor, CKEditor, ...).
      static void setLink​(java.lang.String path, java.lang.String title, java.lang.String target)
      Sets the resource link within the rich text editor (FCKEditor, CKEditor, ...).
      static void setResourcePath​(java.lang.String path)
      Sets the path of the selected resource in the input field of the xmlcontent.
      static void setVfsImage​(java.lang.String path, java.lang.String scale, java.lang.String formatName, java.lang.String ratio)
      Sets the path of the selected resource in the input field of the xmlcontent.
      static boolean shouldShowSelectButton()
      Returns if the select button should be shown.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • closeDialog

        public static void closeDialog()
        Triggers the dialog OK action.

      • enableEditorOk

        public static void enableEditorOk​(boolean enabled)
        Enables the dialog OK button within the rich text editor (FCKEditor, CKEditor, ...).

        Parameters:
        enabled - true to enable the button
      • getFieldId

        public static java.lang.String getFieldId()
        Returns the xml-content field id.

        Returns:
        the field id
      • getFormatNames

        public static java.lang.String[] getFormatNames()
        Returns the available image format names for gallery widget mode.

        Returns:
        the available image format names
      • getFormats

        public static java.lang.String[] getFormats()
        Returns the available image formats for gallery widget mode.

        Returns:
        the available image formats
      • getImageAttributes

        public static CmsJSONMap getImageAttributes()
        Returns all available information of the selected image tag, or null, if no image is selected.

        Returns:
        a map with the following keys:

        alt, class, height, hspace, linkPath, linkTarget, longDesc, style, title, vspace, width

        all keys represent a tag attribute by the same name, only linkPath and linkTarget contain information on an surrounding link tag

      • hasEnhancedImageOptions

        public static boolean hasEnhancedImageOptions()
        Returns the availability of enhanced image options.

        Returns:
        true if enhanced image options are available
      • isAdvancedWidget

        public static boolean isAdvancedWidget()
        Returns if the gallery widget is used in advanced mode.

        Returns:
        true if format selector should be shown
      • isShowFormats

        public static boolean isShowFormats()
        Returns if the image format selector should be shown within gallery widget mode.

        Returns:
        true if format selector should be shown
      • setImage

        public static void setImage​(java.lang.String path,
                                    java.util.Map<java.lang.String,​java.lang.String> attributes)
        Sets the image tag within the rich text editor (FCKEditor, CKEditor, ...).

        Parameters:
        path - the image path
        attributes - the image tag attributes
      • setImageLink

        public static void setImageLink​(java.lang.String path,
                                        java.util.Map<java.lang.String,​java.lang.String> attributes,
                                        java.lang.String linkPath,
                                        java.lang.String target)
        Sets the image link within the rich text editor (FCKEditor, CKEditor, ...).

        Parameters:
        path - the image path
        attributes - the image tag attributes
        linkPath - the link path
        target - the link target attribute
      • setLink

        public static void setLink​(java.lang.String path,
                                   java.lang.String title,
                                   java.lang.String target)
        Sets the resource link within the rich text editor (FCKEditor, CKEditor, ...).

        Parameters:
        path - the link path
        title - the link title
        target - the link target attribute
      • setResourcePath

        public static void setResourcePath​(java.lang.String path)
        Sets the path of the selected resource in the input field of the xmlcontent.

        Widget mode: Use this function inside the xmlcontent.

        Parameters:
        path - the path to the selected resource
      • setVfsImage

        public static void setVfsImage​(java.lang.String path,
                                       java.lang.String scale,
                                       java.lang.String formatName,
                                       java.lang.String ratio)
        Sets the path of the selected resource in the input field of the xmlcontent.

        Widget mode: Use this function inside the xmlcontent.

        Parameters:
        path - the path to the selected resource
        scale - the scale parameter
        formatName - the selected format name
        ratio - the image ratio (width/height)
      • shouldShowSelectButton

        public static boolean shouldShowSelectButton()
        Returns if the select button should be shown.

        Returns:
        true if the select button should be shown