Class AbstractContentProvider<ITEM extends IContentItem,​ITEM_CONTENT extends IContentData<ITEM>>

    • 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

      • 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:
        reinitialize in 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:
        canModifyWithAPI in 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.
      • 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:
        add in 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.
      • setSelection

        public java.lang.String setSelection​(int index)
        Sets the selection as a single selected item at specified index.
        Specified by:
        setSelection in 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.
      • 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:
        updateContents in 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:
        onAdded in 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:
        onRemoved in 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.