Class AbstractView<C extends com.vaadin.flow.component.Component>
- java.lang.Object
-
- org.neotropic.kuwaiba.core.apis.integration.modules.views.AbstractView<C>
-
- Type Parameters:
C- The class of the visual component returned by this view.
- Direct Known Subclasses:
FiberSplitterView,MplsView,ObjectView,OutsidePlantView,PhysicalPathView,PhysicalTreeView,RackView,SdhView,SpliceBoxView,TopologyView
public abstract class AbstractView<C extends com.vaadin.flow.component.Component> extends Object
Defines the behavior of views that can be plugged and played such as End to End views.- Author:
- Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
-
-
Field Summary
Fields Modifier and Type Field Description protected List<ViewEventListener>lstDeselectEventsList for deselect events.protected List<ViewEventListener>lstSelectionEventsList of selection events.protected PropertiespropertiesThe properties associated an instance of the view, typically an id, a name and a description.protected ViewMapviewMapThe default view map.
-
Constructor Summary
Constructors Constructor Description AbstractView()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDeselectionListener(ViewEventListener listener)Adds a deselect to any selection event.abstract AbstractViewEdgeaddEdge(BusinessObjectLight businessObject, BusinessObjectLight sourceBusinessObject, BusinessObjectLight targetBusinessObject, Properties properties)Adds an edge to views that are not generated automatically.abstract AbstractViewNodeaddNode(BusinessObjectLight businessObject, Properties properties)Adds a node to views that are not generated automatically.voidaddSelectionListener(ViewEventListener listener)Adds a listener to any selection event.abstract voidbuildFromSavedView(byte[] view)Builds the view.abstract voidclean()Cleans the view so some other thing can be painted on the canvas.abstract voidedgeClickListener(ViewEventListener listener)Adds a listener to the edge click events.voidfireDeselectEvents(Object source)Fire all deselect events with the given data.voidfireSelectionEvents(Object source)Fire all selection events with the given data.abstract byte[]getAsImage(AbstractImageExporter exporter)Exports the view as image using the given exporter.abstract CgetAsUiElement()Gets an embeddable visual component that can be rendered in a dashboard.It most likely will have to be called after calling#build()or#build(java.lang.Object).ViewMapgetAsViewMap()Exports the view as a ViewMap (a representation of the view as a set of Java objects related to each other).abstract byte[]getAsXml()Exports the view to XML.PropertiesgetProperties()The properties associated to an instance of the view, typically an id, a name and a description.abstract voidnodeClickListener(ViewEventListener listener)Adds a listener to the node click events.voidremoveDeselectListener(ViewEventListener listener)remove a deselect listener.abstract voidremoveEdge(BusinessObjectLight businessObject)remove a edge from the viewMapabstract voidremoveNode(BusinessObjectLight businessObject)remove a node from the viewMapvoidremoveSelectionListener(ViewEventListener listener)remove selection listener.
-
-
-
Field Detail
-
viewMap
protected ViewMap viewMap
The default view map. This view map must be created when either#buildEmptyView()or#buildWithBusinessObject(java.lang.Object)is called.
-
properties
protected Properties properties
The properties associated an instance of the view, typically an id, a name and a description.
-
lstSelectionEvents
protected List<ViewEventListener> lstSelectionEvents
List of selection events.
-
lstDeselectEvents
protected List<ViewEventListener> lstDeselectEvents
List for deselect events.
-
-
Method Detail
-
clean
public abstract void clean()
Cleans the view so some other thing can be painted on the canvas. Typically this is used in refresh buttons.
-
getProperties
public Properties getProperties()
The properties associated to an instance of the view, typically an id, a name and a description.- Returns:
- The set or properties.
-
getAsXml
public abstract byte[] getAsXml()
Exports the view to XML. It most likely will have to be called after calling#build()or#build(java.lang.Object).- Returns:
- A byte array with an XML document representing the view. The format of the document must follow the Standard Kuwaiba View Text Format (SKTF)
-
getAsImage
public abstract byte[] getAsImage(AbstractImageExporter exporter)
Exports the view as image using the given exporter. It most likely will have to be called after calling#build()or#build(java.lang.Object).- Parameters:
exporter- The exporter used to generate the byte array.- Returns:
- A byte array with a formated byte array of the view.
-
getAsUiElement
public abstract C getAsUiElement() throws InvalidArgumentException
Gets an embeddable visual component that can be rendered in a dashboard.It most likely will have to be called after calling#build()or#build(java.lang.Object).- Returns:
- An embeddable component (Panel, VerticalLayout, etc)
- Throws:
InvalidArgumentException- If the component could not be created for some reason (most likely, misconfiguration).
-
getAsViewMap
public ViewMap getAsViewMap()
Exports the view as a ViewMap (a representation of the view as a set of Java objects related to each other). It most likely will have to be called after calling#build()or#build(java.lang.Object).- Returns:
- The view map of the view.
-
buildFromSavedView
public abstract void buildFromSavedView(byte[] view)
Builds the view. Call this method if no business object is required to build the view. It just loads the elements from an view definition structure (like an XML document).- Parameters:
view- The view to be rendered.
-
addNode
public abstract AbstractViewNode addNode(BusinessObjectLight businessObject, Properties properties)
Adds a node to views that are not generated automatically.- Parameters:
businessObject- The business object behind the node to be added. Nodes that already exist will not be added.properties- The properties associated to this object, such as the location that will be used to place it or the URL of the icon that will represent the node.- Returns:
- A reference to the newly added node.
-
addEdge
public abstract AbstractViewEdge addEdge(BusinessObjectLight businessObject, BusinessObjectLight sourceBusinessObject, BusinessObjectLight targetBusinessObject, Properties properties)
Adds an edge to views that are not generated automatically.- Parameters:
businessObject- The business object behind the edge to be added. Edges that already exist will not be added.sourceBusinessObject- The business object behind the source node to the edge to be created.targetBusinessObject- The business object behind the target node to the edge to be created.properties- The properties associated to this object, such as the control points of the edge, or its color.- Returns:
- A reference to the newly added edge.
-
removeNode
public abstract void removeNode(BusinessObjectLight businessObject)
remove a node from the viewMap- Parameters:
businessObject- The business object behind the node to be removed
-
removeEdge
public abstract void removeEdge(BusinessObjectLight businessObject)
remove a edge from the viewMap- Parameters:
businessObject- The business object behind the edge to be removed
-
nodeClickListener
public abstract void nodeClickListener(ViewEventListener listener)
Adds a listener to the node click events.- Parameters:
listener- The listener object.
-
edgeClickListener
public abstract void edgeClickListener(ViewEventListener listener)
Adds a listener to the edge click events.- Parameters:
listener- The listener object.
-
addSelectionListener
public void addSelectionListener(ViewEventListener listener)
Adds a listener to any selection event.- Parameters:
listener- The listener object.
-
addDeselectionListener
public void addDeselectionListener(ViewEventListener listener)
Adds a deselect to any selection event.- Parameters:
listener- The listener object.
-
removeSelectionListener
public void removeSelectionListener(ViewEventListener listener)
remove selection listener.- Parameters:
listener- The listener object.
-
removeDeselectListener
public void removeDeselectListener(ViewEventListener listener)
remove a deselect listener.- Parameters:
listener- The listener object.
-
fireSelectionEvents
public void fireSelectionEvents(Object source)
Fire all selection events with the given data.- Parameters:
source- The selected object
-
fireDeselectEvents
public void fireDeselectEvents(Object source)
Fire all deselect events with the given data.- Parameters:
source- The deselected object
-
-