Class AbstractListViewer

    • Constructor Detail

      • AbstractListViewer

        public AbstractListViewer()
    • Method Detail

      • listAdd

        protected abstract void listAdd​(String string,
                                        int index)
        Adds the given string to the underlying widget at the given index
        Parameters:
        string - the string to add
        index - position to insert the string into
      • listSetItem

        protected abstract void listSetItem​(int index,
                                            String string)
        Sets the text of the item at the given index in the underlying widget.
        Parameters:
        index - index to modify
        string - new text
      • listGetSelectionIndices

        protected abstract int[] listGetSelectionIndices()
        Returns the zero-relative indices of the items which are currently selected in the underlying widget. The array is empty if no items are selected.

        Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.

        Returns:
        the array of indices of the selected items
      • listGetItemCount

        protected abstract int listGetItemCount()
        Returns the number of items contained in the underlying widget.
        Returns:
        the number of items
      • listSetItems

        protected abstract void listSetItems​(String[] labels)
        Sets the underlying widget's items to be the given array of items.
        Parameters:
        labels - the array of label text
      • listRemoveAll

        protected abstract void listRemoveAll()
        Removes all of the items from the underlying widget.
      • listRemove

        protected abstract void listRemove​(int index)
        Removes the item from the underlying widget at the given zero-relative index.
        Parameters:
        index - the index for the item
      • listSetSelection

        protected abstract void listSetSelection​(int[] ixs)
        Selects the items at the given zero-relative indices in the underlying widget. The current selection is cleared before the new items are selected.

        Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.

        Parameters:
        ixs - the indices of the items to select
      • listShowSelection

        protected abstract void listShowSelection()
        Shows the selection. If the selection is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled until the selection is visible.
      • listDeselectAll

        protected abstract void listDeselectAll()
        Deselects all selected items in the underlying widget.
      • add

        public void add​(Object[] elements)
        Adds the given elements to this list viewer. If this viewer does not have a sorter, the elements are added at the end in the order given; otherwise the elements are inserted at appropriate positions.

        This method should be called (by the content provider) when elements have been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.

        Parameters:
        elements - the elements to add
      • insert

        public void insert​(Object element,
                           int position)
        Inserts the given element into this list viewer at the given position. If this viewer has a sorter, the position is ignored and the element is inserted at the correct position in the sort order.

        This method should be called (by the content provider) when elements have been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.

        Parameters:
        element - the element
        position - a 0-based position relative to the model, or -1 to indicate the last position
        Since:
        3.3
      • add

        public void add​(Object element)
        Adds the given element to this list viewer. If this viewer does not have a sorter, the element is added at the end; otherwise the element is inserted at the appropriate position.

        This method should be called (by the content provider) when a single element has been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous addition of multiple elements.

        Parameters:
        element - the element
      • doFindInputItem

        protected Widget doFindInputItem​(Object element)
        Description copied from class: StructuredViewer
        Returns the widget in this viewer's control which represents the given element if it is the viewer's input.

        This method is internal to the framework; subclassers should not call this method.

        Specified by:
        doFindInputItem in class StructuredViewer
        Returns:
        the corresponding widget, or null if none
      • doFindItem

        protected Widget doFindItem​(Object element)
        Description copied from class: StructuredViewer
        Returns the widget in this viewer's control which represent the given element. This method searches all the children of the input element.

        This method is internal to the framework; subclassers should not call this method.

        Specified by:
        doFindItem in class StructuredViewer
        Returns:
        the corresponding widget, or null if none
      • doUpdateItem

        protected void doUpdateItem​(Widget data,
                                    Object element,
                                    boolean fullMap)
        Description copied from class: StructuredViewer
        Copies the attributes of the given element into the given SWT item. The element map is updated according to the value of fullMap. If fullMap is true then the current mapping from element to widgets is removed and the new mapping is added. If full map is false then only the new map gets installed. Installing only the new map is necessary in cases where only the order of elements changes but not the set of elements.

        This method is internal to the framework; subclassers should not call this method.

        Specified by:
        doUpdateItem in class StructuredViewer
        element - element
        fullMap - true if mappings are added and removed, and false if only the new map gets installed
      • getElementAt

        public Object getElementAt​(int index)
        Returns the element with the given index from this list viewer. Returns null if the index is out of range.
        Parameters:
        index - the zero-based index
        Returns:
        the element at the given index, or null if the index is out of range
      • getLabelProvider

        public IBaseLabelProvider getLabelProvider()
        The list viewer implementation of this Viewer framework method returns the label provider, which in the case of list viewers will be an instance of ILabelProvider.
        Overrides:
        getLabelProvider in class ContentViewer
        Returns:
        a label provider
      • indexForElement

        protected int indexForElement​(Object element)
        Parameters:
        element - the element to insert
        Returns:
        the index where the item should be inserted.
      • inputChanged

        protected void inputChanged​(Object input,
                                    Object oldInput)
        Description copied from class: Viewer
        Internal hook method called when the input to this viewer is initially set or subsequently changed.

        The default implementation does nothing. Subclassers may override this method to do something when a viewer's input is set. A typical use is populate the viewer.

        Overrides:
        inputChanged in class Viewer
        Parameters:
        input - the new input of this viewer, or null if none
        oldInput - the old input element or null if there was previously no input
      • listGetTopIndex

        protected int listGetTopIndex()
        Returns the index of the item currently at the top of the viewable area.

        Default implementation returns -1.

        Returns:
        index, -1 for none
        Since:
        3.3
      • listSetTopIndex

        protected void listSetTopIndex​(int index)
        Sets the index of the item to be at the top of the viewable area.

        Default implementation does nothing.

        Parameters:
        index - the given index. -1 for none. index will always refer to a valid index.
        Since:
        3.3
      • remove

        public void remove​(Object[] elements)
        Removes the given elements from this list viewer. The selection is updated if required.

        This method should be called (by the content provider) when elements have been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.

        Parameters:
        elements - the elements to remove
      • remove

        public void remove​(Object element)
        Removes the given element from this list viewer. The selection is updated if necessary.

        This method should be called (by the content provider) when a single element has been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous removal of multiple elements.

        Parameters:
        element - the element
      • setLabelProvider

        public void setLabelProvider​(IBaseLabelProvider labelProvider)
        The list viewer implementation of this Viewer framework method ensures that the given label provider is an instance of ILabelProvider. The optional interfaces IColorProvider and IFontProvider have no effect for this type of viewer
        Overrides:
        setLabelProvider in class StructuredViewer
        Parameters:
        labelProvider - the label provider, or null if none
      • setSelectionToWidget

        protected void setSelectionToWidget​(List in,
                                            boolean reveal)
        Description copied from class: StructuredViewer
        Parlays the given list of selected elements into selections on this viewer's control.

        Subclasses should override to set their selection based on the given list of elements.

        Specified by:
        setSelectionToWidget in class StructuredViewer
        Parameters:
        in - list of selected elements (element type: Object) or null if the selection is to be cleared
        reveal - true if the selection is to be made visible, and false otherwise