3D PLM Enterprise Architecture |
Webtop |
Handling Selections in Your CATletsThe selection management with the CSO object |
Technical Article |
As your CATlets can display data, most of the time the user will want to
select one or several of these data to work on this selection. Your CATlets will
then have to handle this set of selected data and warn other third parties as
commands that data have been selected or unselected. To ease your development
work, the Portal infrastructure offers you a CSO java class that will handle the
selected data for you.
By using this CSO object, developers will benefit from a unified selection
mechanism in all their CATlets and in this way will more easily share components
or commands between their CATlets (like cut, copy and paste commands)
This CSO class is located in the com.dassault_systemes.catweb.base.catlet
package of the PortalBase framework. The CSO object can store a set of
select java.lang.Object and fire a CSOEvent each time its content
has changed (objects in selection added or removed ...).
Each CATlet has one and only one instance of a CSO object. To get an instance of
the CATlet CSO just call the getCSO method on the ICATlet
interface (implemented by CATlet and JCATlet):
CATlet myCATlet; ... CSO myCSO = myCATlet.getCSO(); |
The CSO can be manipulated through these different methods:
/** * Adds an element in the CSO. If this element is already in CSO nothing is done. A CSOEvent is fired * to warn a new element has been added in cso */ public void addElement(Object element); /** * Removes an element from CSO. A CSOEvent is fired to warn an element has been removed from the CSO */ public void removeElement(Object element); /** * Removes all elements from CSO. An event is fired to warn that all elements have been removed from the CSO */ public void empty(); /** * Replaces all elements in the CSO by the specified element. A CSO event is fired to warn that an element * has replaced the current selection in CSO */ public void replace(Object element); /** * returns the number of elements contained in the CSO */ public int getSize(); /** * returns the element located at the specified index. Returns null if index is not valid */ public Object getElement(int index); /** * Returns all the elements contained in the CSO */ public Object[] getElements(); /** * returns the position in CSO of the specified element * returns -1 if element is not in CSO */ public int locate(Object element); /** * CSOEvent publishing methods */ public synchronized void addCSOListener(CSOListener l); public synchronized void removeCSOListener(CSOListener l); |
Components that want to be warned when the CSO content change must implement the com.dassault_systemes.catweb.base.event.CSOListener interface in order to receive com.dassault_systemes.catweb.base.event.CSOEvent
public interface CSOListener extends EventListener { /** * Called each time the CSO content on which this object is subscribed is changed */ public abstract void csoChanged(CSOEvent evt); } |
public class CSOEvent extends EventObject { /** * Type used when elements have been removed from CSO */ public final static int CSO_ADD; /** * Type used when elements have been added in CSO */ public final static int CSO_REMOVE; /** * Type used when all elements have removed from CSO and CSO is left empty */ public final static int CSO_EMPTY; /** * Type used when all the cso's elements have been replaced by an element */ public final static int CSO_REPLACE; /** * Constructs a CSO event * @param source the CSO instance on which the modification occured * @type the type of modification * @elements the elements on which the modification occured */ public CSOEvent(Object source,int type,Object[] elements); /** * Returns the type of modification that occured on the CSO */ public int getType(); /** * Returns the elements on which the modification occured */ public Object[] getElements(); } |
[Top]
Version: 1 [Feb 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.