y.module
Class YPackage

java.lang.Object
  |
  +--y.module.YPackage

public class YPackage
extends Object

Represents a collection of YModule objects. Additionally a YPackage can contain YPackage objects itself.

This class provides a JMenu that holds entries for each YModule in the package.


Field Summary
protected  YList moduleNames
          The name of the modules in the order as they was inserted, important for menu creation
protected  Hashtable modules
          mapping of module-names to modules
protected  String name
          name of the package
protected  YList packages
          The subpackages of this package
protected  PropertyChangeSupport propertyChangeSupport
          the support which is used to notify listeners about changes in the modulelist and subpackagelist
 
Constructor Summary
YPackage(InputStream is)
          Read Package description from an InputStream.
YPackage(String name)
          Creates a new Package
YPackage(URL url)
          Initializes a YPackage from a resource located at the given url.
 
Method Summary
 void addModule(String className)
          Adds a module by its class name.
 void addModule(String moduleName, String className)
          Adds a module by its class name.
 void addModule(String modName, YModule module)
          Adds a module to this package.
 void addModule(YModule module)
          Adds a module to this package.
 void addPackage(YPackage pack)
          Adds a subpackage to the package This only affects menuhandling This method will fire a PropertyChangeEvent for "packageList"
 void addPropertyChangeListener(PropertyChangeListener listener)
          Registers PropertyChangeListener to receive events.
 void addToMenu(JMenu menu, YPackageMenuListener listener)
          Deprecated. yEd does not use this method any longer, just add and remove modules and subpackages, yEd will take care of the menus.
 JMenu createMenu(YPackageMenuListener listener)
          Deprecated. yEd does not use this method any longer, just add and remove modules and subpackages, yEd will take care of the menus.
static YPackage createPackage(String resourcePath)
           
 YModule getModule(String name)
          Get a registered module by name.
 YCursor getModuleNames()
          Get all module names
 Hashtable getModules()
          Get all Modules
 String getName()
          Get the name of the package
 YCursor getPackages()
          Get all subpackages
 void initPackage(InputStream is)
          Initializes a YPackage from a Input stream
 void listModules()
          Convenience method to print out the names of all modules in the package
 void removeModule(String moduleName)
          Removes a module by its name.
 void removePackage(YPackage pack)
          Removes a subpackage from the package This method will fire a PropertyChangeEvent for "packageList"
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes PropertyChangeListener from the list of listeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
name of the package


modules

protected Hashtable modules
mapping of module-names to modules


moduleNames

protected YList moduleNames
The name of the modules in the order as they was inserted, important for menu creation


packages

protected YList packages
The subpackages of this package


propertyChangeSupport

protected PropertyChangeSupport propertyChangeSupport
the support which is used to notify listeners about changes in the modulelist and subpackagelist

Constructor Detail

YPackage

public YPackage(String name)
Creates a new Package

Parameters:
name - The name of the package

YPackage

public YPackage(InputStream is)
Read Package description from an InputStream. The InputStream is scanned until the first tag is found.


YPackage

public YPackage(URL url)
Initializes a YPackage from a resource located at the given url.

Method Detail

initPackage

public void initPackage(InputStream is)
Initializes a YPackage from a Input stream


createPackage

public static YPackage createPackage(String resourcePath)

getName

public String getName()
Get the name of the package

Returns:
the name of the package

getModule

public YModule getModule(String name)
Get a registered module by name.


getModuleNames

public YCursor getModuleNames()
Get all module names

Returns:
An enumeration of all module names registered in the package

getPackages

public YCursor getPackages()
Get all subpackages


getModules

public Hashtable getModules()
Get all Modules

Returns:
A hashtable conaining all modules

addModule

public void addModule(YModule module)
Adds a module to this package. The module's getModuleName() method be used to to give the module a name.


addModule

public void addModule(String modName,
                      YModule module)
Adds a module to this package. The module's getModuleName() method be used to to give the module a name.


addModule

public void addModule(String className)
Adds a module by its class name. The class file is loaded on demand. The name of the base class is used as module name.

Parameters:
className - The complete name of the class of the module

addModule

public void addModule(String moduleName,
                      String className)
Adds a module by its class name. The class file is loaded on demand. This method will fire a PropertyChangeEvent for "moduleList"

Parameters:
className - The complete name of the class of the module
moduleName - The name of the module

removeModule

public void removeModule(String moduleName)
Removes a module by its name. This method will fire a PropertyChangeEvent for "moduleList"

Parameters:
moduleName - The name of the module

addPackage

public void addPackage(YPackage pack)
Adds a subpackage to the package This only affects menuhandling This method will fire a PropertyChangeEvent for "packageList"

Parameters:
pack - A YPackage

removePackage

public void removePackage(YPackage pack)
Removes a subpackage from the package This method will fire a PropertyChangeEvent for "packageList"

Parameters:
pack - A YPackage

createMenu

public JMenu createMenu(YPackageMenuListener listener)
Deprecated. yEd does not use this method any longer, just add and remove modules and subpackages, yEd will take care of the menus.

Creates a complete menu. This method can be used to place the menu of the package into an application.

Parameters:
listener - Specifies what to do is a module is selected
Returns:
A menu containing all modules in the package

addToMenu

public void addToMenu(JMenu menu,
                      YPackageMenuListener listener)
Deprecated. yEd does not use this method any longer, just add and remove modules and subpackages, yEd will take care of the menus.

Adds content of this package to a menu. This method can be used to place the menu of the package into an application.

Parameters:
listener - Specifies what to do is a module is selected
Returns:
A menu containing all modules in the package

listModules

public void listModules()
Convenience method to print out the names of all modules in the package


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers PropertyChangeListener to receive events.

Parameters:
listener - The listener to register.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes PropertyChangeListener from the list of listeners.

Parameters:
listener - The listener to remove.

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003