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 void
addViewItem(ViewItem item)
Add a view item in the accessorvoid
clear()
Removes all items of this accessorvoid
copyTo(View view)
Copy the current view in the given one.boolean
equals(Object obj)
boolean
equals(Object obj, boolean checkDetails)
Indicates whether some other object is "equal to" this one.I18nizableText
getDescription()
Retrieves the description.String
getIconDecorator()
Retrieves the CSS class to use for decorator above the main iconString
getIconGlyph()
Retrieves the CSS class to use for glyph iconI18nizableText
getLabel()
Retrieves the label.String
getLargeIcon()
Retrieves the URL of the small icon without the context path.String
getMediumIcon()
Retrieves the URL of the small icon without the context path.String
getName()
Get the name.String
getSmallIcon()
Retrieves the URL of the small icon without the context path.List<ViewItem>
getViewItems()
Retrieves all the view items of this accessorint
hashCode()
void
includeView(View viewToInclude)
Include the given view to the current one.void
insertViewItem(ViewItem item, int index)
Insert a view item in the accessor at the given indexboolean
isInternal()
Determines if the view is for internal use onlystatic View
of(Collection<? extends Model> models)
static View
of(Collection<? extends Model> models, String... itemPaths)
Creates aView
with the given itemsstatic View
of(Model model)
static View
of(ModelItem... modelItems)
Creates aView
with the given items.static View
of(Model model, String... itemPaths)
Creates aView
with the given itemsboolean
removeViewItem(ViewItem item)
Removes the given items of this accessorvoid
setDescription(I18nizableText description)
Set the description.void
setIconDecorator(String iconDecorator)
Set the CSS class to use for decorator above the main iconvoid
setIconGlyph(String iconGlyph)
Set the CSS class to use for glyph iconvoid
setInternal(boolean isInternal)
Set the internal statusvoid
setLabel(I18nizableText label)
Set the label.void
setLargeIcon(String largeIcon)
Set the URL of the large icon.void
setMediumIcon(String mediumIcon)
Set the URL of the medium icon.void
setName(String name)
Set the name.void
setSmallIcon(String smallIcon)
Set the URL of the small icon.Map<String,Object>
toJSON(DefinitionContext context)
Converts the view in a JSON mapvoid
toSAX(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 aView
with 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 isnull
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(Collection<? extends Model> models, String... itemPaths) throws IllegalArgumentException, BadItemTypeException
Creates aView
with 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 aView
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
-
setName
public void setName(String name)
Description copied from interface:ModifiableLabelable
Set the name.- Specified by:
setName
in interfaceModifiableLabelable
- Parameters:
name
- the name.
-
getLabel
public I18nizableText getLabel()
Description copied from interface:Labelable
Retrieves the label.
-
setLabel
public void setLabel(I18nizableText label)
Description copied from interface:ModifiableLabelable
Set the label.- Specified by:
setLabel
in interfaceModifiableLabelable
- Parameters:
label
- the label.
-
getDescription
public I18nizableText getDescription()
Description copied from interface:Labelable
Retrieves the description.- Specified by:
getDescription
in interfaceLabelable
- Returns:
- the description.
-
setDescription
public void setDescription(I18nizableText description)
Description copied from interface:ModifiableLabelable
Set the description.- Specified by:
setDescription
in 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:
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
public List<ViewItem> getViewItems()
Description copied from interface:ViewItemAccessor
Retrieves all the view items of this accessor- Specified by:
getViewItems
in interfaceViewItemAccessor
- 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 interfaceViewItemAccessor
- 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 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:ViewItemAccessor
Removes the given items of this accessor- Specified by:
removeViewItem
in interfaceViewItemAccessor
- 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 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
- theContentHandler
that 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
-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.
-
-