net.rim.device.api.ui.component.pane
Class PaneManagerModel

java.lang.Object
  extended by net.rim.device.api.ui.component.pane.PaneManagerModel

public class PaneManagerModel
extends Object

PaneManagerModel stores the data for each tabbed pane an associated PaneManagerView can present.

The Pane Manager classes conform to the Model-View-Controller design pattern. PaneManagerModel implements the Model. It maintains the Pane objects that represent the data and tracks the current position within the model. PaneManagerView implements the View. It lays out and renders the panes.PaneManagerController implements the Controller. It handles all user input received by the Pane Manager. If the Controller cannot handle a user event, PaneManagerView forwards the event to the contained Field objects. The pane data is stored in a list can be accessed bi-directionally. You can make the list cyclical by using PaneManagerModel.enableLooping(boolean). The data for an individual pane can be accessed by index by using PaneManagerModel.getPane(int). You can navigate the list by using PaneManagerModel.getLeftIndexOf(int), PaneManagerModel.getRightIndexOf(int), PaneManagerModel.nextIndex(), and PaneManagerModel.previousIndex().

Since:
BlackBerry API 6.0.0

Constructor Summary
PaneManagerModel()
          Class constructor that initializes an empty list and sets the current index to -1.
 
Method Summary
 void addPane(Pane pane)
           Adds a Pane object to the end of the data list.
 int currentlySelectedIndex()
           Returns the index of the Pane object that represents the currently-selected pane.
 void deletePane(Pane pane)
           Deletes a Pane object from the data list.
 void enableLooping(boolean enable)
           Configures the data list to be either cyclical or non-cyclical.
 PaneManagerController getController()
          Returns the PaneManagerController for this model.
 int getLeftIndexOf(int index)
           Returns the Pane that preceeds the one at the provided index.
 Pane getPane(int index)
          Provides access to the Pane located at the provided index.
 int getRightIndexOf(int index)
           Returns the Pane that follows the one at the provided index.
 PaneManagerView getView()
          Provides access to the PaneManagerView associated to this model.
 void insertPane(Pane pane, int index)
          Inserts a new Pane object to the current set.
 boolean isLoopingEnabled()
           Indicates if the data list is configured as a cyclical list.
 int nextIndex()
           Returns the index of the Pane that is after the currently-selected index.
 int numberOfPanes()
           Returns the number of elements in the data list.
 int previousIndex()
          Provides the index of the Pane that preceeds that of the currently selected index.
 void replacePane(Pane newPane, Pane oldPane)
          Replaced a Pane that exists in this model with a new Pane object.
 void setController(PaneManagerController controller)
          Allows for a PaneManagerController to be associated with this model.
 void setCurrentlySelectedIndex(int index)
          Allows for the index of the currently selected Pane to be updated.
 void setCurrentlySelectedIndex(int index, boolean update)
          Allows for the index of the currently selected Pane to be updated.
 void setView(PaneManagerView view)
          Allows for a PaneManagerView to be associated with this model.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

PaneManagerModel

public PaneManagerModel()

Class constructor that initializes an empty list and sets the current index to -1.

Since:
BlackBerry API 6.0.0


Method Detail

addPane

public void addPane(Pane pane)

Adds a Pane object to the end of the data list. If the list has been made cyclical by using PaneManagerModel.isLoopingEnabled(), then addPane() inserts the new Pane after the Pane at index PaneManagerModel.numberOfPanes() - 1 and before the Pane at index 0.

The title and content of the pane are added to the TitleView and PaneView of the associated PaneManagerView.

Parameters:
pane - Pane to add to the data list.
Since:
BlackBerry API 6.0.0

currentlySelectedIndex

public int currentlySelectedIndex()

Returns the index of the Pane object that represents the currently-selected pane.

Returns:
Index of currently-selected Pane (between 0 and PaneManagerModel.numberOfPanes() - 1).

Since:
BlackBerry API 6.0.0

deletePane

public void deletePane(Pane pane)

Deletes a Pane object from the data list.

Does nothing if the Pane is not in the data list.

The title and content of the pane are removed from the TitleView and PaneView of the associated PaneManagerView.

Parameters:
pane - Pane to delete from the data list.
Throws:
IllegalArgumentException - if the pane provided to delete is invalid (null or not found).
Since:
BlackBerry API 6.0.0

enableLooping

public void enableLooping(boolean enable)

Configures the data list to be either cyclical or non-cyclical.

Parameters:
enable - true to make the data list cyclical, false to make the data list non-cyclical.
Since:
BlackBerry API 6.0.0

getController

public PaneManagerController getController()
Returns the PaneManagerController for this model.

Returns:
PaneManagerController associated with this model or null if none has been set.
Since:
BlackBerry API 6.0.0

getLeftIndexOf

public int getLeftIndexOf(int index)

Returns the Pane that preceeds the one at the provided index. This method takes into account whether the data list is cyclical or non-cyclical PaneManagerModel.isLoopingEnabled(). If the list is cyclical, then the index left of 0 is the last index. If the list is non-cyclical, then the index left of 0 is the invalid index (-1).

The index parameter must be between 0 and PaneManagerModel.numberOfPanes() - 1.

Parameters:
index - Index of the reference Pane.
Returns:
Index of the Pane preceding the reference Pane or -1 if the data list is non-cyclical and the index parameter is 0.
Throws:
IllegalArgumentException - if index is negative or out-of-bounds.
Since:
BlackBerry API 6.0.0

getRightIndexOf

public int getRightIndexOf(int index)

Returns the Pane that follows the one at the provided index. This accounts for if the data set is cyclical PaneManagerModel.isLoopingEnabled(). If enabled then the index will loop from the last possible index to 0. If not enabled then this will return and invalid index.

The provided index must be between 0 and PaneManagerModel.numberOfPanes() - 1.

Parameters:
index - The index for the Pane for which the one following it is desired.
Returns:
The index of the following Pane or -1 if looping is not enabled and there is no following index.
Throws:
IllegalArgumentException - if the index is invalid.
Since:
BlackBerry API 6.0.0

getPane

public Pane getPane(int index)

Provides access to the Pane located at the provided index.

Parameters:
index - the index of the Pane to retrieve.
Returns:
the Pane located at the index provided.
Throws:
IllegalArgumentException - when the index is invalid.
Since:
BlackBerry API 6.0.0

getView

public PaneManagerView getView()

Provides access to the PaneManagerView associated to this model.

Returns:
the PaneManagerView that is associated to this model or null if none is set.
Since:
BlackBerry API 6.0.0

insertPane

public void insertPane(Pane pane,
                       int index)

Inserts a new Pane object to the current set.

The title and content of the pane are inserted in the TitleView and PaneView contained within the associated PaneManagerView respectively.

Parameters:
pane - the new Pane to insert in the current data set.
index - the index to insert the Pane at.
Throws:
IllegalArgumentException - if the pane is null or if an invalid index is provided.
Since:
BlackBerry API 6.0.0

isLoopingEnabled

public boolean isLoopingEnabled()

Indicates if the data list is configured as a cyclical list.

Returns:
true if the data list is configured as a cyclical list and false if it is not.
Since:
BlackBerry API 6.0.0

nextIndex

public int nextIndex()

Returns the index of the Pane that is after the currently-selected index.

PaneManagerModel.getRightIndexOf(int).

Returns:
Index of the Pane that follows the currently selected one, or an invalid index if there is none.
Since:
BlackBerry API 6.0.0

numberOfPanes

public int numberOfPanes()

Returns the number of elements in the data list.

Returns:
The number of Panes in the data list of this model.

Since:
BlackBerry API 6.0.0

previousIndex

public int previousIndex()

Provides the index of the Pane that preceeds that of the currently selected index.

PaneManagerModel.getLeftIndexOf(int).

Returns:
the index of the Pane that preceeds the currently selected one, or an invalid index if there is none.
Since:
BlackBerry API 6.0.0

replacePane

public void replacePane(Pane newPane,
                        Pane oldPane)

Replaced a Pane that exists in this model with a new Pane object.

The title and content of the new pane replace those of the old one in the TitleView and PaneView contained within the associated PaneManagerView respectively.

Parameters:
newPane - the new Pane to add to the data set.
oldPane - the Pane in the current data set to be replaced.
Throws:
IllegalArgumentException - if either the newPane or the oldPane is null.
IllegalStateException - if the oldPane is not in the current data set.
Since:
BlackBerry API 6.0.0

setController

public void setController(PaneManagerController controller)

Allows for a PaneManagerController to be associated with this model.

Parameters:
controller - the PaneManagerController to associate to this model.
Since:
BlackBerry API 6.0.0

setCurrentlySelectedIndex

public void setCurrentlySelectedIndex(int index)

Allows for the index of the currently selected Pane to be updated.

This will tell the associated view to update itself with no specified animation direction. If you wish to animate changes call PaneManagerModel.setCurrentlySelectedIndex(int, boolean) followed by an animation control within the view PaneManagerView.drag(int, int) or PaneManagerView.jumpTo(int, int).

Parameters:
index - the new index
Throws:
IllegalArgumentException - if the index is invalid.
Since:
BlackBerry API 6.0.0

setCurrentlySelectedIndex

public void setCurrentlySelectedIndex(int index,
                                      boolean update)

Allows for the index of the currently selected Pane to be updated.

To have this cause the associated view to update itself provide true. There will be no specified direction for this update to happen. PaneManagerModel.setCurrentlySelectedIndex(int).

This will not tell the associated view to update itself if false. The view will not reflect the new index unless you have it animate. To animate changes call an animation control within the view PaneManagerView.drag(int, int) or PaneManagerView.jumpTo(int, int).

Parameters:
index - the new index
update - true to have this model tell the view to update the positions, see PaneManagerModel.setCurrentlySelectedIndex(int) false to not have this model tell the view to update the positions. If false then the calling code is responsible for calling methods to perform the transitions.
Throws:
IllegalArgumentException - if the index is invalid.
Since:
BlackBerry API 6.0.0

setView

public void setView(PaneManagerView view)

Allows for a PaneManagerView to be associated with this model.

Parameters:
view - the PaneManagerView to associate to this model.
Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal