Package org.ametys.runtime.model
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 Summary
Constructors Constructor Description View()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddViewItem(ViewItem item)Add a view item in the accessorvoidclear()Removes all items of this accessorvoidcopyTo(View view)Copy the current view in the given one.booleanequals(Object obj)booleanequals(Object obj, boolean checkDetails)Indicates whether some other object is "equal to" this one.I18nizableTextgetDescription()Retrieves the description.StringgetIconDecorator()Retrieves the CSS class to use for decorator above the main iconStringgetIconGlyph()Retrieves the CSS class to use for glyph iconI18nizableTextgetLabel()Retrieves the label.StringgetLargeIcon()Retrieves the URL of the small icon without the context path.StringgetMediumIcon()Retrieves the URL of the small icon without the context path.StringgetName()Get the name.StringgetSmallIcon()Retrieves the URL of the small icon without the context path.List<ViewItem>getViewItems()Retrieves all the view items of this accessorinthashCode()voidincludeView(View viewToInclude)Include the given view to the current one.voidinsertViewItem(ViewItem item, int index)Insert a view item in the accessor at the given indexbooleanisInternal()Determines if the view is for internal use onlystatic Viewof(Collection<? extends Model> models)static Viewof(Collection<? extends Model> models, String... itemPaths)Creates aViewwith the given itemsstatic Viewof(Model model)static Viewof(ModelItem... modelItems)Creates aViewwith the given items.static Viewof(Model model, String... itemPaths)Creates aViewwith the given itemsbooleanremoveViewItem(ViewItem item)Removes the given items of this accessorvoidsetDescription(I18nizableText description)Set the description.voidsetIconDecorator(String iconDecorator)Set the CSS class to use for decorator above the main iconvoidsetIconGlyph(String iconGlyph)Set the CSS class to use for glyph iconvoidsetInternal(boolean isInternal)Set the internal statusvoidsetLabel(I18nizableText label)Set the label.voidsetLargeIcon(String largeIcon)Set the URL of the large icon.voidsetMediumIcon(String mediumIcon)Set the URL of the medium icon.voidsetName(String name)Set the name.voidsetSmallIcon(String smallIcon)Set the URL of the small icon.Map<String,Object>toJSON(DefinitionContext context)Converts the view in a JSON mapvoidtoSAX(ContentHandler contentHandler, DefinitionContext context)Generates SAX events for the view-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.runtime.model.ViewItemAccessor
addViewItems, getModelViewItem, hasModelViewItem, hasModelViewItem, hasModelViewItem
-
-
-
-
Constructor Detail
-
View
public View()
-
-
Method Detail
-
of
public static View of(Model model) throws IllegalArgumentException
- Parameters:
model- the model- Returns:
- the created
View - Throws:
IllegalArgumentException- if the model isnull
-
of
public static View of(Collection<? extends Model> models) throws IllegalArgumentException
- 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 aViewwith the given items- Parameters:
model- the model containing items definitionsitemPaths- the paths of the items to put in the view- Returns:
- the created
View - Throws:
IllegalArgumentException- if the model isnullor if an item path isnull, empty, or is not defined in the given modelsBadItemTypeException- 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 aViewwith the given items- Parameters:
models- the models containing items definitionsitemPaths- 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 isnull, empty, or is not defined in the given modelsBadItemTypeException- if a segment in a path (but not the last) does not represent a group item
-
of
public static View of(ModelItem... modelItems)
Creates aViewwith 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
-
setName
public void setName(String name)
Description copied from interface:ModifiableLabelableSet the name.- Specified by:
setNamein interfaceModifiableLabelable- Parameters:
name- the name.
-
getLabel
public I18nizableText getLabel()
Description copied from interface:LabelableRetrieves the label.
-
setLabel
public void setLabel(I18nizableText label)
Description copied from interface:ModifiableLabelableSet the label.- Specified by:
setLabelin interfaceModifiableLabelable- Parameters:
label- the label.
-
getDescription
public I18nizableText getDescription()
Description copied from interface:LabelableRetrieves the description.- Specified by:
getDescriptionin interfaceLabelable- Returns:
- the description.
-
setDescription
public void setDescription(I18nizableText description)
Description copied from interface:ModifiableLabelableSet the description.- Specified by:
setDescriptionin interfaceModifiableLabelable- 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
public String 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
public String 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:
trueif the view is for internal use only,falseotherwise
-
setInternal
public void setInternal(boolean isInternal)
Set the internal status- Parameters:
isInternal-trueto make the view for internal use only,falseotherwise
-
getViewItems
public List<ViewItem> getViewItems()
Description copied from interface:ViewItemAccessorRetrieves all the view items of this accessor- Specified by:
getViewItemsin interfaceViewItemAccessor- Returns:
- the view items
-
addViewItem
public void addViewItem(ViewItem item)
Description copied from interface:ViewItemAccessorAdd a view item in the accessor- Specified by:
addViewItemin interfaceViewItemAccessor- Parameters:
item- the item to add
-
insertViewItem
public void insertViewItem(ViewItem item, int index)
Description copied from interface:ViewItemAccessorInsert a view item in the accessor at the given index- Specified by:
insertViewItemin interfaceViewItemAccessor- Parameters:
item- the item to insertindex- index at which the item has to be inserted
-
removeViewItem
public boolean removeViewItem(ViewItem item)
Description copied from interface:ViewItemAccessorRemoves the given items of this accessor- Specified by:
removeViewItemin interfaceViewItemAccessor- Parameters:
item- the item to remove- Returns:
trueif this accessor contained the given item,falseotherwise
-
clear
public void clear()
Description copied from interface:ViewItemAccessorRemoves all items of this accessor- Specified by:
clearin interfaceViewItemAccessor
-
toJSON
public Map<String,Object> toJSON(DefinitionContext context) throws ProcessingException
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- theContentHandlerthat will receive the SAX eventscontext- 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
-
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-trueto check the view's details during comparison (label, description, icon, ...)- Returns:
trueif this object is the same as the given obj,falseotherwise.
-
-