org.pdfsam.guiclient.commons.models
Class VisualListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by org.pdfsam.guiclient.commons.models.VisualListModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ListModel

public class VisualListModel
extends javax.swing.AbstractListModel

Model for the JList in the JVisualPdfPageSelectionPanel

Author:
Andrea Vacondio
See Also:
Serialized Form

Field Summary
protected  java.util.Vector<VisualPageListItem> data
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
VisualListModel()
           
 
Method Summary
 void addAllElements(java.util.Collection<VisualPageListItem> c)
          delegated to the Vector addAll
 void addAllElements(int index, java.util.Collection<VisualPageListItem> c)
          Add elements in c at the given index
 void addElement(VisualPageListItem inputData)
          Add an item to the model and fire to Listeners
 void addElementAt(VisualPageListItem inputData, int index)
          Add an item to the model and fire to Listeners
 void appendAllElements(java.util.Collection<VisualPageListItem> c)
          same as addAllElements.
 void clearData()
          Removes any data source for the model
 void elementChanged(VisualPageListItem inputData)
          Look for the inputData and repaint it if found
 void elementsChanged()
          Repaints all the elements
 java.lang.Object getElementAt(int index)
           
 VisualPageListItem[] getElements()
           
 int getSize()
           
 java.util.List<VisualPageListItem> getValidElements()
           
 void moveDownIndex(int index)
          Moves down a item at the given index fire to Listeners
 void moveDownIndexes(int[] indexes)
          Moves down a set of items at the given indexes
 void moveUpIndex(int index)
          Moves up a item at the given index fire to Listeners
 void moveUpIndexes(int[] indexes)
          Moves up a set of items at the given indexes
 void prependAllElements(java.util.Collection<VisualPageListItem> c)
          Add elements at the beginning
 void removeElementAt(int index, boolean physicalDeletion)
          removes the element at the index
 void removeElements(int[] rows, boolean physicalDeletion)
          Remove a set of rows from the list data source and fire to Listeners
 void removeElements(int fromIndex, int toIndex, boolean physicalDeletion)
          Remove a set of rows from the list data source and fire to Listeners
 void reverseElements(int[] indexes)
          Reverse the given elements
 void rotateAnticlockwiseElements(int[] indexes)
          rotates anti clockwise the given elements
 void rotateClockwiseElements(int[] indexes)
          rotates the given elements
 void setData(java.util.Vector<VisualPageListItem> inputData)
          set data source for the model
 void setData(VisualPageListItem[] inputData)
          set data source for the model
 java.util.Collection<VisualPageListItem> subList(int fromIndex, int toIndex)
          delegated to the Vector subList
 java.util.Collection<VisualPageListItem> subList(int fromIndex, int toIndex, boolean newInstance)
           
 void undeleteElements(int[] indexes)
          Undelete the given elements
 void updateElementAt(int index, VisualPageListItem inputData)
          Replace an element of the model and fire to Listeners
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.util.Vector<VisualPageListItem> data
Constructor Detail

VisualListModel

public VisualListModel()
Method Detail

getElementAt

public java.lang.Object getElementAt(int index)

getSize

public int getSize()
Returns:
data size

setData

public void setData(VisualPageListItem[] inputData)
set data source for the model

Parameters:
inputData - array VisualPageListItem[] as data source

setData

public void setData(java.util.Vector<VisualPageListItem> inputData)
set data source for the model

Parameters:
inputData - Vector of VisualPageListItem

clearData

public void clearData()
Removes any data source for the model


removeElementAt

public void removeElementAt(int index,
                            boolean physicalDeletion)
removes the element at the index

Parameters:
index -
physicalDeletion - if true the element is removed, if false it's set as "deleted" (rendered with a red cross)

removeElements

public void removeElements(int[] rows,
                           boolean physicalDeletion)
                    throws java.lang.IndexOutOfBoundsException

Remove a set of rows from the list data source and fire to Listeners

Parameters:
rows - rows number to remove from the data source
physicalDeletion - if true the element is removed, if false it's set as "deleted" (rendered with a red cross)
Throws:
java.lang.Exception - if an exception occurs
java.lang.IndexOutOfBoundsException

removeElements

public void removeElements(int fromIndex,
                           int toIndex,
                           boolean physicalDeletion)
                    throws java.lang.IndexOutOfBoundsException

Remove a set of rows from the list data source and fire to Listeners

Parameters:
fromIndex - remove from the index (inclusive)
toIndex - remove to the index (inclusive)
physicalDeletion - if true the element is removed, if false it's set as "deleted" (rendered with a red cross)
Throws:
java.lang.Exception - if an exception occurs
java.lang.IndexOutOfBoundsException

addElementAt

public void addElementAt(VisualPageListItem inputData,
                         int index)
Add an item to the model and fire to Listeners

Parameters:
index - index to add to
inputData - VisualPageListItem to add to the data source

addElement

public void addElement(VisualPageListItem inputData)
Add an item to the model and fire to Listeners

Parameters:
inputData - VisualPageListItem to add to the data source

addAllElements

public void addAllElements(java.util.Collection<VisualPageListItem> c)
delegated to the Vector addAll

Parameters:
c -
See Also:
Vector.addAll(Collection)

appendAllElements

public void appendAllElements(java.util.Collection<VisualPageListItem> c)
same as addAllElements. Appends elements to the end

Parameters:
c -

prependAllElements

public void prependAllElements(java.util.Collection<VisualPageListItem> c)
Add elements at the beginning

Parameters:
c -

addAllElements

public void addAllElements(int index,
                           java.util.Collection<VisualPageListItem> c)
Add elements in c at the given index

Parameters:
index -
c -

subList

public java.util.Collection<VisualPageListItem> subList(int fromIndex,
                                                        int toIndex)
delegated to the Vector subList

Parameters:
fromIndex - start inclusive
toIndex - end exclusive
Returns:
null if limits are not corrected
See Also:
Vector.subList(int, int)

subList

public java.util.Collection<VisualPageListItem> subList(int fromIndex,
                                                        int toIndex,
                                                        boolean newInstance)
Parameters:
fromIndex - start inclusive
toIndex - end exclusive
newInstance - if false delegates to the Vector#subList(int, int) if true return a new Vector
Returns:
a portion of the data Vector, null if limits are not corrected
See Also:
Vector.subList(int, int)

getElements

public VisualPageListItem[] getElements()
Returns:
items of the model

updateElementAt

public void updateElementAt(int index,
                            VisualPageListItem inputData)
Replace an element of the model and fire to Listeners

Parameters:
index - index to be replaced
inputData - new VisualPageListItem to replace the data source

elementChanged

public void elementChanged(VisualPageListItem inputData)
Look for the inputData and repaint it if found

Parameters:
inputData -

elementsChanged

public void elementsChanged()
Repaints all the elements


undeleteElements

public void undeleteElements(int[] indexes)
                      throws java.lang.IndexOutOfBoundsException
Undelete the given elements

Parameters:
indexes -
Throws:
java.lang.IndexOutOfBoundsException

reverseElements

public void reverseElements(int[] indexes)
                     throws java.lang.IndexOutOfBoundsException
Reverse the given elements

Parameters:
indexes -
Throws:
java.lang.IndexOutOfBoundsException

rotateClockwiseElements

public void rotateClockwiseElements(int[] indexes)
                             throws java.lang.IndexOutOfBoundsException
rotates the given elements

Parameters:
indexes -
Throws:
java.lang.IndexOutOfBoundsException

rotateAnticlockwiseElements

public void rotateAnticlockwiseElements(int[] indexes)
                                 throws java.lang.IndexOutOfBoundsException
rotates anti clockwise the given elements

Parameters:
indexes -
Throws:
java.lang.IndexOutOfBoundsException

moveUpIndex

public void moveUpIndex(int index)
                 throws java.lang.IndexOutOfBoundsException
Moves up a item at the given index fire to Listeners

Parameters:
index - element index to move from the data source
Throws:
java.lang.IndexOutOfBoundsException

moveUpIndexes

public void moveUpIndexes(int[] indexes)
                   throws java.lang.IndexOutOfBoundsException
Moves up a set of items at the given indexes

Parameters:
indexes - Indexes to move from the data source
Throws:
java.lang.IndexOutOfBoundsException

moveDownIndex

public void moveDownIndex(int index)
                   throws java.lang.IndexOutOfBoundsException
Moves down a item at the given index fire to Listeners

Parameters:
index - element index to move from the data source
Throws:
java.lang.IndexOutOfBoundsException

moveDownIndexes

public void moveDownIndexes(int[] indexes)
                     throws java.lang.IndexOutOfBoundsException
Moves down a set of items at the given indexes

Parameters:
indexes - Indexes to move from the data source
Throws:
java.lang.IndexOutOfBoundsException

getValidElements

public java.util.List<VisualPageListItem> getValidElements()
Returns:
a List of elements with the isDeleted=false, null if there are no elements