Class AbstractContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- java.lang.Object
- com.iizix.prop.content.AbstractContentProvider<ITEM,ITEM_CONTENT>
 
- All Implemented Interfaces:
- IContentProvider<ITEM,ITEM_CONTENT>,- IContentProviderAPI<ITEM,ITEM_CONTENT>
 - Direct Known Subclasses:
- MapMarkerContentProvider,- MLContentProvider
 - public abstract class AbstractContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>> extends java.lang.Object implements IContentProviderAPI<ITEM,ITEM_CONTENT> The default content provider.- Author:
- Christopher Mindus
 
- Field Summary- Fields - Modifier and Type - Field - Description - protected AbstractContentUIContainer<ITEM,ITEM_CONTENT>- cnrThe container.
 - Constructor Summary- Constructors - Constructor - Description - AbstractContentProvider(int selectionType, java.lang.Class<ITEM_CONTENT> itemContentClass)Constructor.
 - Method Summary- All Methods Instance Methods Abstract Methods Concrete Methods - Modifier and Type - Method - Description - void- add(int index, ITEM_CONTENT item)Inserts a new item before the specified index.- void- beginChanges()Begins a mass change operation of the content by means of the API.- boolean- canModifyWithAPI()Returns if API is enabled for this content provider or not.- java.lang.String- clearSelection()Clear the selection.- void- commitChanges()Commits a mass change operation of the content by means of the API.- protected abstract ITEM_CONTENT- createContentItem(VSRow row)Creates a new content item for a VS row.- void- dispose()Called when the content provider is no longer required by the container.- ITEM_CONTENT- get(int index)Gets an item at the specified index.- ITEM_CONTENT[]- getAll()Gets the content items.- int[]- getColumns()Gets the connected table columns indicies.- int- getFirstSelectedIndex()Gets the first selected index.- int- getItemCount()Gets the item count.- AbstractContentUIContainer<ITEM,ITEM_CONTENT>- getItemsContainer()Returns the items container.- int[]- getSelectedIndicies()Gets the selected indicies.- VSTable- getTable()Gets the VSTable connected.- int- indexOf(ITEM_CONTENT item)Returns the index of an item.- void- initialize(AbstractContentUIContainer<ITEM,ITEM_CONTENT> cnr)Called to initialize the content provider for the container instance.- protected boolean- isEnabledStateSynchronized()Returns if the enabled state is synchronized with the table.- protected boolean- isReadOnlyStateSynchronized()Returns if the read-only state is synchronized with the table.- protected boolean- isVisibleStateSynchronized()Returns if the visible state is synchronized with the table.- boolean- onAdded(VSRow row, int index)Called when a VSRow is added in the connected table.- boolean- onRemoved(VSRow row, int index)Called when a VSRow is removed in the connected table.- void- onSelectionChanged(ITEM_CONTENT item, boolean isSelected)Called from the items when they are selected or unselected from their- setSelection(boolean)method.- void- onSelectionTypeChanged(int selectionType)Called when the content provider changes selection type.- protected void- refreshContent()Refreshes the contents with the container.- protected void- refreshContentItemFromVS(ITEM_CONTENT itemData, int[] columns)Refresh the content item after a potential change in the VirtualSpace with an existing item.- void- reinitialize()This method is called when the content provider needs re-initialization due to e.g.- ITEM_CONTENT- remove(int index)Removes an item at the specified index.- boolean- remove(ITEM_CONTENT item)Removes an item.- boolean- removeAll()Removes all items.- java.lang.String- setSelection(int index)Sets the selection as a single selected item at specified index.- java.lang.String- setSelection(int[] indicies)Sets the selection to the specified indicies.- void- updateContents()Updates all the items to match the current contents.- protected void- updateContentsFromVS(int[] columns)Called to update the items from the VirtualSpace only if such a connection exists.- protected boolean- useVSConnection(int[] columnIndicies)Called during initialization to determine if content items will need to use the VS row connection or not.- Methods inherited from class java.lang.Object- clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - Methods inherited from interface com.iizix.prop.content.IContentProviderAPI- add
 
 
- Field Detail- cnr- protected AbstractContentUIContainer<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>> cnr The container.
 
 - Constructor Detail- AbstractContentProvider- public AbstractContentProvider(int selectionType, java.lang.Class<ITEM_CONTENT> itemContentClass)Constructor.- Parameters:
- selectionType- The selection type: 0=none, 1=single, 2=multiple.
- itemContentClass- The class for item content.
 
 
 - Method Detail- onSelectionTypeChanged- public void onSelectionTypeChanged(int selectionType) Called when the content provider changes selection type.- Specified by:
- onSelectionTypeChangedin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- selectionType- The selection type: 0=none, 1=single, 2=multiple.
 
 - initialize- public void initialize(AbstractContentUIContainer<ITEM,ITEM_CONTENT> cnr) Called to initialize the content provider for the container instance.- The default content provides saves the - cnrreference and calls- reinitialize()- Specified by:
- initializein interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- cnr- The container.
 
 - getItemsContainer- public AbstractContentUIContainer<ITEM,ITEM_CONTENT> getItemsContainer() Returns the items container.- Specified by:
- getItemsContainerin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- The container that stores the item properties. This method will return null if not yet initialized.
 
 - reinitialize- public void reinitialize() This method is called when the content provider needs re-initialization due to e.g. a change of its properties, e.g. the VSTable or one of the columns.- The default content retrieves the VS table and columns and saves them for future reference. - Specified by:
- reinitializein interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
 
 - dispose- public void dispose() Called when the content provider is no longer required by the container.- Specified by:
- disposein interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
 
 - canModifyWithAPI- public boolean canModifyWithAPI() Returns if API is enabled for this content provider or not. If the content provider is connected to VirtualSpace, this method will return false.- Specified by:
- canModifyWithAPIin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- true if the API methods for modification can be used, false otherwise.
 
 - getTable- public VSTable getTable() Gets the VSTable connected.- Returns:
- The table, or null for none.
 
 - getColumns- public int[] getColumns() Gets the connected table columns indicies.- Returns:
- The array of connected table column indicies, null if not VS-connected. A column index in the array may be -1 if it is not referenced or used.
 
 - beginChanges- public void beginChanges() Begins a mass change operation of the content by means of the API. Call this method to avoid updates being fired to the client before all changes are committed.- A call to this method must be followed by a call to - commitChanges()- Specified by:
- beginChangesin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
 
 - commitChanges- public void commitChanges() Commits a mass change operation of the content by means of the API. This method will fire the updates to the client.- Each call to - beginChanges()- Specified by:
- commitChangesin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
 
 - refreshContent- protected void refreshContent() Refreshes the contents with the container. If one or more mass change operations are taking place, this method flags changes to be performed when all mass change operations are committed.
 - add- public void add(int index, ITEM_CONTENT item)Inserts a new item before the specified index. Duplicates are not allowed.- Specified by:
- addin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- index- The insertion point index, -1 for last.
- item- The item to insert.
- Throws:
- java.lang.IllegalArgumentException- If the index is not valid.
 
 - remove- public ITEM_CONTENT remove(int index) Removes an item at the specified index.- Specified by:
- removein interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- index- The item to remove.
- Returns:
- The removed item.
- Throws:
- java.lang.IllegalArgumentException- If the index is not valid.
 
 - remove- public boolean remove(ITEM_CONTENT item) Removes an item.- Specified by:
- removein interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- item- The item to remove.
- Returns:
- true for success, false if not found.
 
 - removeAll- public boolean removeAll() Removes all items.- Specified by:
- removeAllin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- true for changed, false when no items were present.
 
 - get- public ITEM_CONTENT get(int index) Gets an item at the specified index.- Specified by:
- getin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- index- The index of the item.
- Returns:
- The item.
- Throws:
- java.lang.IllegalArgumentException- If the index is not valid.
 
 - indexOf- public int indexOf(ITEM_CONTENT item) Returns the index of an item.- Specified by:
- indexOfin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- item- The item to look-up.
- Returns:
- The index of the item, or -1 if not found.
 
 - getFirstSelectedIndex- public int getFirstSelectedIndex() Gets the first selected index.- Specified by:
- getFirstSelectedIndexin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- The first index in the current selection, or -1 for none.
 
 - getSelectedIndicies- public int[] getSelectedIndicies() Gets the selected indicies.- Specified by:
- getSelectedIndiciesin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- A new array of the selected indices (that may be modified to your liking), or a static zero in length array for no selection.
 
 - setSelection- public java.lang.String setSelection(int index) Sets the selection as a single selected item at specified index.- Specified by:
- setSelectionin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- index- The single item to select at index, -1 to clear the selection.
- Returns:
- null for success, otherwise an error message why the selection failed.
 
 - setSelection- public java.lang.String setSelection(int[] indicies) Sets the selection to the specified indicies.- Specified by:
- setSelectionin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- indicies- The indicies.
- Returns:
- null for success, otherwise the error message with the reason why it failed.
 
 - clearSelection- public java.lang.String clearSelection() Clear the selection.- Specified by:
- clearSelectionin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- null for success, otherwise the error message with the reason why it failed.
 
 - onSelectionChanged- public void onSelectionChanged(ITEM_CONTENT item, boolean isSelected) Called from the items when they are selected or unselected from their- setSelection(boolean)method.- The method is NOT intended to be called. - Specified by:
- onSelectionChangedin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- item- The item who's selection changed.
- isSelected- The new selection state.
 
 - getItemCount- public int getItemCount() Gets the item count.- Specified by:
- getItemCountin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- The count of items that will be provided.
 
 - getAll- public ITEM_CONTENT[] getAll() Gets the content items.- Specified by:
- getAllin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Specified by:
- getAllin interface- IContentProviderAPI<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Returns:
- The array of content items.
 
 - updateContents- public void updateContents() Updates all the items to match the current contents.- This method is not intended to be called, it is used by the framework -- DO NOT CALL THE METHOD! - Override this method to perform specialized processing. - Note: this method is always called from the content updater thread, i.e. the client worker thread. - Specified by:
- updateContentsin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
 
 - updateContentsFromVS- protected void updateContentsFromVS(int[] columns) Called to update the items from the VirtualSpace only if such a connection exists.- Parameters:
- columns- The connected table columns.
 
 - onAdded- public boolean onAdded(VSRow row, int index) Called when a VSRow is added in the connected table.- Specified by:
- onAddedin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- row- The row added.
- index- The row index added (-1 or table size for last).
- Returns:
- true for success, false to cause a refresh of the containers content.
 
 - onRemoved- public boolean onRemoved(VSRow row, int index) Called when a VSRow is removed in the connected table.- Specified by:
- onRemovedin interface- IContentProvider<ITEM extends IContentItem,ITEM_CONTENT extends IContentData<ITEM>>
- Parameters:
- row- The row removed.
- index- The row index removed.
- Returns:
- true for success, false to cause a refresh of the containers content.
 
 - useVSConnection- protected boolean useVSConnection(int[] columnIndicies) Called during initialization to determine if content items will need to use the VS row connection or not. By default, VS connection is used only when at least one column is connected to a row.- A custom content provider can override this method to return - true.- The default implementation is to return true if at least one column index is larger than -1. - Parameters:
- columnIndicies- The column indicies, null for none.
- Returns:
- true to use a VS connection, false not to use a VS connection.
 
 - createContentItem- protected abstract ITEM_CONTENT createContentItem(VSRow row) Creates a new content item for a VS row.- Parameters:
- row- The row.
- Returns:
- The new content item associated with the row.
 
 - refreshContentItemFromVS- protected void refreshContentItemFromVS(ITEM_CONTENT itemData, int[] columns) Refresh the content item after a potential change in the VirtualSpace with an existing item.- A custom content provider can override this method to provide an alternate refresh method for it's items. - By default, the item's method - refreshFromVS(int [] columns)is called.- Parameters:
- itemData- The item previously created.
- columns- The connected table columns indicies, -1 for none.
 
 - isVisibleStateSynchronized- protected boolean isVisibleStateSynchronized() Returns if the visible state is synchronized with the table.- Returns:
- true by default, override for other functionality.
 
 - isEnabledStateSynchronized- protected boolean isEnabledStateSynchronized() Returns if the enabled state is synchronized with the table.- Returns:
- true by default, override for other functionality.
 
 - isReadOnlyStateSynchronized- protected boolean isReadOnlyStateSynchronized() Returns if the read-only state is synchronized with the table.- Returns:
- true by default, override for other functionality.