Class View

java.lang.Object
org.ametys.runtime.model.View
All Implemented Interfaces:
ViewItemAccessor, ViewItemContainer, Labelable, ModifiableLabelable

public class View extends Object implements ViewItemContainer, ModifiableLabelable
View of items
  • Constructor Details

    • View

      public View()
  • Method Details

    • of

      public static View of(Model model) throws IllegalArgumentException
      Creates a View with the items of the given Model
      Parameters:
      model - the model
      Returns:
      the created View
      Throws:
      IllegalArgumentException - if the model is null
    • of

      public static View of(Collection<? extends Model> models) throws IllegalArgumentException
      Creates a View with the items of the given Models
      Parameters:
      models - the models
      Returns:
      the created View
      Throws:
      IllegalArgumentException - if the models collection is empty
    • of

      public static View of(Model model, String... itemPaths) throws IllegalArgumentException, BadItemTypeException
      Creates a View with the given items
      Parameters:
      model - the model containing items definitions
      itemPaths - the paths of the items to put in the view
      Returns:
      the created View
      Throws:
      IllegalArgumentException - if the model is null or if an item path is null, empty, or is not defined in the given models
      BadItemTypeException - if a segment in a path (but not the last) does not represent a group item
    • of

      public static View of(Collection<? extends Model> models, String... itemPaths) throws IllegalArgumentException, BadItemTypeException
      Creates a View with the given items
      Parameters:
      models - the models containing items definitions
      itemPaths - the paths of the items to put in the view
      Returns:
      the created View
      Throws:
      IllegalArgumentException - if the models collection is empty or if an item path is null, empty, or is not defined in the given models
      BadItemTypeException - if a segment in a path (but not the last) does not represent a group item
    • of

      public static View of(ModelItem... modelItems)
      Creates a View with the given items. If the items are in a group, the hierarchy will be kept and the corresponding containers will be created
      Parameters:
      modelItems - the items to put in the view
      Returns:
      the created View
    • copyTo

      public void copyTo(View view)
      Copy the current view in the given one. Its view items are not copied
      Parameters:
      view - the copy
    • getName

      public String getName()
      Description copied from interface: Labelable
      Get the name.
      Specified by:
      getName in interface Labelable
      Returns:
      the name.
    • setName

      public void setName(String name)
      Description copied from interface: ModifiableLabelable
      Set the name.
      Specified by:
      setName in interface ModifiableLabelable
      Parameters:
      name - the name.
    • getLabel

      Description copied from interface: Labelable
      Retrieves the label.
      Specified by:
      getLabel in interface Labelable
      Returns:
      the label.
    • setLabel

      public void setLabel(I18nizableText label)
      Description copied from interface: ModifiableLabelable
      Set the label.
      Specified by:
      setLabel in interface ModifiableLabelable
      Parameters:
      label - the label.
    • getDescription

      Description copied from interface: Labelable
      Retrieves the description.
      Specified by:
      getDescription in interface Labelable
      Returns:
      the description.
    • setDescription

      public void setDescription(I18nizableText description)
      Description copied from interface: ModifiableLabelable
      Set the description.
      Specified by:
      setDescription in interface ModifiableLabelable
      Parameters:
      description - the description.
    • getIconGlyph

      public String getIconGlyph()
      Retrieves the CSS class to use for glyph icon
      Returns:
      the glyph name.
    • setIconGlyph

      public void setIconGlyph(String iconGlyph)
      Set the CSS class to use for glyph icon
      Parameters:
      iconGlyph - the glyph name.
    • getIconDecorator

      Retrieves the CSS class to use for decorator above the main icon
      Returns:
      the glyph name.
    • setIconDecorator

      public void setIconDecorator(String iconDecorator)
      Set the CSS class to use for decorator above the main icon
      Parameters:
      iconDecorator - the glyph name.
    • getSmallIcon

      public String getSmallIcon()
      Retrieves the URL of the small icon without the context path.
      Returns:
      the icon URL for the small image 16x16.
    • setSmallIcon

      public void setSmallIcon(String smallIcon)
      Set the URL of the small icon.
      Parameters:
      smallIcon - the URL of the small icon, without the context path.
    • getMediumIcon

      Retrieves the URL of the small icon without the context path.
      Returns:
      the icon URL for the medium sized image 32x32.
    • setMediumIcon

      public void setMediumIcon(String mediumIcon)
      Set the URL of the medium icon.
      Parameters:
      mediumIcon - the URL of the medium icon, without the context path.
    • getLargeIcon

      public String getLargeIcon()
      Retrieves the URL of the small icon without the context path.
      Returns:
      the icon URL for the large image 48x48.
    • setLargeIcon

      public void setLargeIcon(String largeIcon)
      Set the URL of the large icon.
      Parameters:
      largeIcon - the URL of the large icon, without the context path.
    • isInternal

      public boolean isInternal()
      Determines if the view is for internal use only
      Returns:
      true if the view is for internal use only, false otherwise
    • setInternal

      public void setInternal(boolean isInternal)
      Set the internal status
      Parameters:
      isInternal - true to make the view for internal use only, false otherwise
    • getViewItems

      Description copied from interface: ViewItemAccessor
      Retrieves all the view items of this accessor
      Specified by:
      getViewItems in interface ViewItemAccessor
      Returns:
      the view items
    • addViewItem

      public void addViewItem(ViewItem item)
      Description copied from interface: ViewItemAccessor
      Add a view item in the accessor
      Specified by:
      addViewItem in interface ViewItemAccessor
      Parameters:
      item - the item to add
    • insertViewItem

      public void insertViewItem(ViewItem item, int index)
      Description copied from interface: ViewItemAccessor
      Insert a view item in the accessor at the given index
      Specified by:
      insertViewItem in interface ViewItemAccessor
      Parameters:
      item - the item to insert
      index - index at which the item has to be inserted
    • removeViewItem

      public boolean removeViewItem(ViewItem item)
      Description copied from interface: ViewItemAccessor
      Removes the given items of this accessor
      Specified by:
      removeViewItem in interface ViewItemAccessor
      Parameters:
      item - the item to remove
      Returns:
      true if this accessor contained the given item, false otherwise
    • clear

      public void clear()
      Description copied from interface: ViewItemAccessor
      Removes all items of this accessor
      Specified by:
      clear in interface ViewItemAccessor
    • toJSON

      Converts the view in a JSON map
      Parameters:
      context - the context of the definitions included in the view
      Returns:
      The view as a JSON map
      Throws:
      ProcessingException - If an error occurs when converting the view
    • toSAX

      public void toSAX(ContentHandler contentHandler, DefinitionContext context) throws SAXException
      Generates SAX events for the view
      Parameters:
      contentHandler - the ContentHandler that will receive the SAX events
      context - the context of the definitions included in the view
      Throws:
      SAXException - if an error occurs during the SAX events generation
    • includeView

      public void includeView(View viewToInclude)
      Include the given view to the current one. Add the items of the view to include if they are not already present in the current view
      Parameters:
      viewToInclude - the view to include
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(Object obj, boolean checkDetails)
      Indicates whether some other object is "equal to" this one.
      Parameters:
      obj - the reference object with which to compare.
      checkDetails - true to check the view's details during comparison (label, description, icon, ...)
      Returns:
      true if this object is the same as the given obj, false otherwise.