|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jbudget.gui.budget.BudgetTreeModel
public class BudgetTreeModel
An implementation of the TreeModel interface that is used to display a Budget class as a jTree.
| Nested Class Summary | |
|---|---|
private class |
BudgetTreeModel.AllocationsSignaler
implements the Signaler interface. |
private static interface |
BudgetTreeModel.Signaler
|
private class |
BudgetTreeModel.TransactionsSignaler
implements the Signaler interface. |
| Field Summary | |
|---|---|
(package private) static java.lang.String |
accounts
|
(package private) org.jbudget.Core.Budget |
budget
|
(package private) static java.lang.String |
expenseCategories
|
(package private) static java.lang.String |
incomeSources
|
private java.util.List<java.lang.Object> |
list
|
(package private) java.util.List<javax.swing.event.TreeModelListener> |
listeners
|
(package private) static java.lang.String |
root
|
private boolean |
showAllocations
|
private boolean |
showTransactions
|
private java.util.List<java.lang.Object> |
typesList
|
| Constructor Summary | |
|---|---|
BudgetTreeModel(org.jbudget.Core.Budget budget)
Creates a new instance of BudgetTreeModel |
|
| Method Summary | |
|---|---|
void |
addTreeModelListener(javax.swing.event.TreeModelListener listener)
Add a listener that will be notified when the model or underlying budget object change. |
private java.util.List<org.jbudget.Core.ExpenseCategory> |
getCategoryPath(org.jbudget.Core.ExpenseCategory category)
Returns a path to a given expense category |
java.lang.Object |
getChild(java.lang.Object parent,
int index)
returns a child object |
int |
getChildCount(java.lang.Object parent)
returns number of children of an object |
private java.util.List<java.lang.Object> |
getChildrenList(java.lang.Object parent)
get a list of children of a particular object. |
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
returns the index of a child |
java.lang.Object[] |
getPath(java.lang.Object object,
boolean bySource)
Returns a path that identifies a given object in the tree |
java.lang.Object |
getRoot()
returns the root of the tree |
boolean |
getShowAllcations()
Returns true if allocations are shown |
boolean |
getShowTransactions()
Returns true if deductions are shown |
javax.swing.tree.TreePath |
getTreePath(java.lang.Object object,
boolean bySource)
Returns a TreePath to the given Object |
boolean |
isLeaf(java.lang.Object node)
returns true if the object does not have any children |
void |
removeTreeModelListener(javax.swing.event.TreeModelListener listener)
Remove a listener. |
void |
setShowAllocations(boolean showAllocations)
Shows/hides allocations |
void |
setShowTransactions(boolean showTransactions)
Shows/hides automatic transactions |
private void |
signalDisplayAllocations(java.util.List<java.lang.Object> path,
boolean display)
A helper function that signals the tree model that allocations should be displayed or hidden |
private void |
signalDisplayTransactions(java.util.List<java.lang.Object> path,
boolean display)
A helper function that signals the tree model that automatic transactions should be displayed or hidden |
void |
signalNodeChanged(javax.swing.tree.TreePath path,
int index)
signals to all listeners that a node was updated. |
void |
signalNodeInserted(javax.swing.tree.TreePath path,
int index)
signals to all listeners that a node was inserted. |
void |
signalNodeRemoved(javax.swing.tree.TreePath path,
int index)
Removes a node. |
private void |
signalRecursively(java.util.List<java.lang.Object> path,
BudgetTreeModel.Signaler signaler)
Recursively applies a 'signal' function to a given node and to all its leafs |
void |
signalStructureChanged()
signals to all listeners that the structure of the whole tree has changed. |
void |
signalStructureChanged(javax.swing.tree.TreePath path,
int index)
signals to all listeners that the structure of the tree has changed. |
void |
valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
called when the object is changed |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
final org.jbudget.Core.Budget budget
java.util.List<javax.swing.event.TreeModelListener> listeners
static final java.lang.String root
static final java.lang.String expenseCategories
static final java.lang.String accounts
static final java.lang.String incomeSources
private boolean showAllocations
private boolean showTransactions
private final java.util.List<java.lang.Object> list
private final java.util.List<java.lang.Object> typesList
| Constructor Detail |
|---|
public BudgetTreeModel(org.jbudget.Core.Budget budget)
| Method Detail |
|---|
public void addTreeModelListener(javax.swing.event.TreeModelListener listener)
addTreeModelListener in interface javax.swing.tree.TreeModelpublic void removeTreeModelListener(javax.swing.event.TreeModelListener listener)
removeTreeModelListener in interface javax.swing.tree.TreeModel
public java.lang.Object getChild(java.lang.Object parent,
int index)
getChild in interface javax.swing.tree.TreeModelpublic int getChildCount(java.lang.Object parent)
getChildCount in interface javax.swing.tree.TreeModel
public int getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
getIndexOfChild in interface javax.swing.tree.TreeModelpublic java.lang.Object getRoot()
getRoot in interface javax.swing.tree.TreeModelpublic boolean isLeaf(java.lang.Object node)
isLeaf in interface javax.swing.tree.TreeModel
public void valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
valueForPathChanged in interface javax.swing.tree.TreeModelprivate java.util.List<java.lang.Object> getChildrenList(java.lang.Object parent)
public javax.swing.tree.TreePath getTreePath(java.lang.Object object,
boolean bySource)
object - the object the path to will be returned.bySource - some leaf nodes can appear in two places if they have both
source and destination. If this flag is true a path through the
source of a transaction will be returned. In the opposite case a
path through a destinaiton will be returned.
public java.lang.Object[] getPath(java.lang.Object object,
boolean bySource)
object - the object the path to will be returned.bySource - Some leaf nodes can appear in two places if they have both
source and destination. If this flag is true a path through the
source of a transaction will be returned. In the opposite case a
path through a destinaiton will be returned.private java.util.List<org.jbudget.Core.ExpenseCategory> getCategoryPath(org.jbudget.Core.ExpenseCategory category)
public void setShowAllocations(boolean showAllocations)
public boolean getShowAllcations()
public void setShowTransactions(boolean showTransactions)
public boolean getShowTransactions()
private void signalRecursively(java.util.List<java.lang.Object> path,
BudgetTreeModel.Signaler signaler)
private void signalDisplayAllocations(java.util.List<java.lang.Object> path,
boolean display)
private void signalDisplayTransactions(java.util.List<java.lang.Object> path,
boolean display)
public void signalNodeRemoved(javax.swing.tree.TreePath path,
int index)
path - the path to the node that will be removedindex - the index of the node that will be removed in the list of all
children of the node's parent.
public void signalNodeInserted(javax.swing.tree.TreePath path,
int index)
path - the path to the node that was inserted.index - the index given by getChildIndex(...).
public void signalNodeChanged(javax.swing.tree.TreePath path,
int index)
path - the path to the node that was updated.index - the index given by getChildIndex(...).
public void signalStructureChanged(javax.swing.tree.TreePath path,
int index)
path - the path to the node that is the root of the part of the tree
that has changed.index - the index given by getChildIndex(...).public void signalStructureChanged()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||