Synergy Home Page

au.edu.swin.synergy.plugin.packager
Class BPackageModel

java.lang.Object
  |
  +--au.edu.swin.synergy.plugin.packager.BPackageModel

public class BPackageModel
extends Object
implements BTreeModelInterface, BTreeNode, Serializable, BSaveable

Data structure for the package model. Keeps track of the p-nodes, p-arcs, and p-terminators that make up the package. Also has a meta-model. Implements the TreeModel interface, so that the data can be viewed from inside a JTree.

Author:
Imron Alston
Copyright Belongs To:
 
See Also:
Serialized Form

Field Summary
static int kArcBranch
           
protected static String kDefaultName
           
protected static String kKeyName
           
static int kNodeBranch
           
static int kNumBranches
           
static int kTerminatorBranch
           
 
Constructor Summary
BPackageModel()
           
BPackageModel(BMetaModel metaModel, String packageName)
          When you create a package model, you must specify the meta model on which it is based.
 
Method Summary
 void addBGroupsToVector(int branch, Vector groupList)
          This will add all BGroups in a branch of the model to the vector provided.
 void addPackageArc(BTreeNode node)
          Adds a package arc to the package model..
 void addPackageNode(BTreeNode node)
          Adds a package node to the package model..
 void addPackageTerminator(BTreeNode node)
          Adds a package terminator to the package model..
 void addTreeModelListener(TreeModelListener l)
           
 void fireInserted(TreeModelEvent e)
           
 void fireRemoved(TreeModelEvent e)
           
protected  void fireStructureChanged()
           
 Object getChild(Object parent, int index)
           
 Object getChildAt(int index)
           
 int getChildCount()
           
 int getChildCount(Object parent)
           
 int getIndexOf(Object node)
           
 int getIndexOfChild(Object parent, Object child)
           
 BMetaModel getMetaModel()
           
 String getName()
           
 Object getPackageArcByName(String name)
          Gets a package arc from the package model..
 Object getPackageItemByName(String name)
          Gets a package element from the package model..
 Object getPackageNodeByName(String name)
          Gets a package node from the package model..
 Object getPackageTerminatorByName(String name)
          Gets a package terminator from the package model..
 Object getParent()
           
 Object getRoot()
           
 boolean isLeaf()
           
 boolean isLeaf(Object node)
           
 boolean load(BDataFile file)
           
static BPackageModel loadFromFile(String fileName)
          loads a package from a file..
 void removeAllChildren()
           
 void removeTreeModelListener(TreeModelListener l)
           
 boolean save(BDataFile file)
           
 void saveToFile(String fileName)
          saves this package to a file..
 void setMetaModel(BMetaModel metaModel)
          This will set the meta model this tree represents to the given meta model.
 void setName(String newPackageName)
          Sets the name of the package to the value specified.
 void setParent(Object parent)
           
 String toString()
           
 void valueForPathChanged(TreePath path, Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

kKeyName

protected static final String kKeyName

kDefaultName

protected static final String kDefaultName

kNumBranches

public static final int kNumBranches

kNodeBranch

public static final int kNodeBranch

kArcBranch

public static final int kArcBranch

kTerminatorBranch

public static final int kTerminatorBranch
Constructor Detail

BPackageModel

public BPackageModel(BMetaModel metaModel,
                     String packageName)
When you create a package model, you must specify the meta model on which it is based. You cannot have a package without a meta model.
Parameters:
metaModel - The model this package is based on

BPackageModel

public BPackageModel()
Method Detail

setMetaModel

public void setMetaModel(BMetaModel metaModel)
This will set the meta model this tree represents to the given meta model. It will also re-initialise the nodes and so forth that represent the meta elements on screen. This should be considered a resetting of the package editor and therefore anything already in this package will be replaced. That is to say, this is to be used for new Packages only.
Parameters:
metaModel - The new meta model

getMetaModel

public BMetaModel getMetaModel()

setName

public void setName(String newPackageName)
Sets the name of the package to the value specified. This will be reflected on the screen straight away.
Specified by:
setName in interface BTreeNode
Parameters:
newPackageName - The name of the package

addBGroupsToVector

public void addBGroupsToVector(int branch,
                               Vector groupList)
This will add all BGroups in a branch of the model to the vector provided. Used to build up a list of all groups that can be added to a tool-palette. It is the job of the caller to clear the vector. That way the groups from a number of different branches can be added to the one list.

getPackageItemByName

public Object getPackageItemByName(String name)
Gets a package element from the package model..
Parameters:
String - name - the name of the package item..
Returns:
the first item that matches name..

getPackageNodeByName

public Object getPackageNodeByName(String name)
Gets a package node from the package model..
Parameters:
String - name - the name of the package node..
Returns:
the first item that matches name..

getPackageArcByName

public Object getPackageArcByName(String name)
Gets a package arc from the package model..
Parameters:
String - name - the name of the package arc..
Returns:
the first item that matches name..

getPackageTerminatorByName

public Object getPackageTerminatorByName(String name)
Gets a package terminator from the package model..
Parameters:
String - name - the name of the package terminator..
Returns:
the first item that matches name..

addPackageNode

public void addPackageNode(BTreeNode node)
Adds a package node to the package model..

addPackageArc

public void addPackageArc(BTreeNode node)
Adds a package arc to the package model..

addPackageTerminator

public void addPackageTerminator(BTreeNode node)
Adds a package terminator to the package model..

loadFromFile

public static BPackageModel loadFromFile(String fileName)
loads a package from a file..
Parameters:
String - fileName - the file to load
Returns:
the loaded package, or null on error..

saveToFile

public void saveToFile(String fileName)
saves this package to a file..

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)

getChild

public Object getChild(Object parent,
                       int index)

getChildCount

public int getChildCount(Object parent)

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)

getRoot

public Object getRoot()

isLeaf

public boolean isLeaf(Object node)

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)

fireInserted

public void fireInserted(TreeModelEvent e)
Specified by:
fireInserted in interface BTreeModelInterface

fireRemoved

public void fireRemoved(TreeModelEvent e)
Specified by:
fireRemoved in interface BTreeModelInterface

fireStructureChanged

protected void fireStructureChanged()

toString

public String toString()
Overrides:
toString in class Object

getName

public String getName()
Specified by:
getName in interface BTreeNode

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface BTreeNode

getChildAt

public Object getChildAt(int index)
Specified by:
getChildAt in interface BTreeNode

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface BTreeNode

getParent

public Object getParent()
Specified by:
getParent in interface BTreeNode

getIndexOf

public int getIndexOf(Object node)
Specified by:
getIndexOf in interface BTreeNode

setParent

public void setParent(Object parent)
Specified by:
setParent in interface BTreeNode

removeAllChildren

public void removeAllChildren()
Specified by:
removeAllChildren in interface BTreeNode

load

public boolean load(BDataFile file)
Specified by:
load in interface BSaveable

save

public boolean save(BDataFile file)
Specified by:
save in interface BSaveable

Synergy Home Page