/* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ using System; using System.Windows.Forms; namespace org.jboss.net.samples.store { /** * * Controller for Reading and Manipulating the BusinessModel * through a ListView. * * @author jung * @created 21.03.2002 * @version $Revision: 1.1 $ */ public abstract class ListController { #region Attributes /** the parent form */ protected SampleView parent; /** the list view to which we belong */ protected ListView view; /** the objects that we are hosting */ Object[] items; /** the listview items that are shown from them */ ListViewItem[] listItems; #endregion /** creates a new ListController for the given view */ public ListController(SampleView parent,ListView view) { this.parent=parent; this.view=view; } #region Abstract Interface to Fill With Concrete Service Interaction /** create a new item **/ public abstract Object create(); /** creates a list view item for the given object */ public abstract ListViewItem createListItem(Object target); /** retrieve the whole set of objects **/ public abstract Object[] retrieveObjects(); /** deletes a single item */ public abstract void delete(Object target); #endregion #region Concrete Implementation of ListView Treatment /** is called to re-arrange the view **/ public virtual bool arrange() { view.Columns.Clear(); return false; } /** no editor */ public virtual void edit(Object target) { } /** no update */ public virtual void update(Object target) { } // is called whenever the view must be update public void populate() { view.Items.Clear(); items=retrieveObjects(); listItems=new ListViewItem[items.Length]; for(int count=0;count