net.datacrow.core.modules
Class DcModule

java.lang.Object
  extended by net.datacrow.core.modules.DcModule
All Implemented Interfaces:
java.lang.Comparable<DcModule>
Direct Known Subclasses:
DcAssociateModule, DcChildModule, DcMediaModule, DcParentModule, DcPropertyModule, LoanModule, MappingModule, PictureModule, TemplateModule

public class DcModule
extends java.lang.Object
implements java.lang.Comparable<DcModule>

A module represents items. The module dictates among other things where the items are stored, which views they can be displayed, which fields they have and which online services are available to update or search for new items. The module is where it all comes together.
Modules can have relationships between each other and come in different types. An important property of the module is the top module boolean which indicates if the module can be displayed within module bar and if the module can be disabled and or enabled by the user.
Furthermore is it important to know that modules are generic. They can be created from an XmlModule which holds a flexible XML definition of the module.
The DcModules class creates and holds all modules.

Author:
Robert Jan van der Waals
See Also:
XmlModule, DcModules, DcPropertyModule, DcMediaModule, DcChildModule, DcMediaChildModule, DcParentModule, DcMediaParentModule

Field Summary
static int _TYPE_ASSOCIATE_MODULE
           
static int _TYPE_EXTERNALREFERENCE_MODULE
           
static int _TYPE_MAPPING_MODULE
           
static int _TYPE_MEDIA_MODULE
           
static int _TYPE_MODULE
           
static int _TYPE_PROPERTY_MODULE
           
static int _TYPE_TEMPLATE_MODULE
           
protected  MasterView insertView
           
protected  MasterView searchView
           
 
Constructor Summary
  DcModule(int index, boolean topModule, java.lang.String name, java.lang.String description, java.lang.String objectName, java.lang.String objectNamePlural, java.lang.String tableName, java.lang.String tableShortName)
          Creates a new instance.
protected DcModule(int index, java.lang.String name, java.lang.String description, java.lang.String objectName, java.lang.String objectNamePlural, java.lang.String tableName, java.lang.String tableShortName, boolean topModule)
          Creates a new instance.
  DcModule(XmlModule module)
          Creates a new module based on a XML definition.
 
Method Summary
 void addField(DcField field)
          Adds a field to this module.
 void addValueEnhancer(IValueEnhancer enhancer, int field)
          Registers a value enhancer for a specific field.
 void applySettings()
          Applies the field settings on this module.
 boolean canBeLend()
          Indicates if items belonging to this module can be lend.
 int compareTo(DcModule module)
          Compares the supplied module with the current module.
protected  DcObject createItem()
          Creates a new instance of an item belonging to this module.
 void delete()
          Deletes this module.
 boolean deliversOnlineService()
          Indicates if this module has online services at its disposal.
 boolean equals(java.lang.Object o)
           
 ChartPanel getChartPanel(boolean create)
          Creates the chart panel (if not created already).
 DcModule getChild()
          Retrieves the child module instance.
 View getCurrentInsertView()
          Returns the current insert view.
 View getCurrentSearchView()
          Returns the current search view.
 java.util.Collection<DcObject> getDefaultData()
          Retrieves the default data for this module.
 int getDefaultSortFieldIdx()
          Retrieves the index of the field on which is sorted by default.
 java.lang.String getDescription()
          The description for this module.
 int getDisplayFieldIdx()
          Educated guess..
 int getDisplayIndex()
          The location of the module in the module bar.
 DcField getField(int index)
          Retrieves the field definition for the given index.
 DcField getField(java.lang.String columnName)
          Retrieves the field definition for the given index.
 int getFieldCount()
          The number of fields belonging to this module.
 DcFieldDefinitions getFieldDefinitions()
          Gets the field definitions.
 int[] getFieldIndices()
          Retrieves all field indices.
 java.util.Collection<DcField> getFields()
          Retrieves all fields.
 DcField getFileField()
           
 FileRenamerDialog getFileRenamerDialog(boolean create)
          Creates the file renamer dialog (if not created already).
 FilterDialog getFilterForm(boolean create)
          Creates the filter form (if not created already).
 DcImageIcon getIcon16()
          The small icon used to represent the module.
 java.lang.String getIcon16Filename()
           
 DcImageIcon getIcon32()
          The large icon used to represent the module.
 java.lang.String getIcon32Filename()
           
 DcField getIconField()
           
 FileImporter getImporter()
          Creates a new instance of the file importer.
 java.lang.Class getImporterClass()
          The import class.
 int getIndex()
          Retrieves the index of the module (unique!)
 MasterView getInsertView()
          The insert view (shown in the new tab)
 DcObject getItem()
          Creates a new instance of an item belonging to this module.
 ItemForm getItemForm(DcTemplate template, boolean readonly, boolean update, DcObject o, boolean applyTemplate)
          Creates a new item form.
 java.lang.String getItemPluralResourceKey()
           
 java.lang.String getItemResourceKey()
           
 javax.swing.KeyStroke getKeyStroke()
          The keys combination associated with this module.
 java.lang.String getLabel()
           
 MainFrameMenuBar getMenuBar()
          Creates the menu bar for this module.
 int[] getMinimalFields(java.util.Collection<java.lang.Integer> include)
           
 java.lang.String getModuleResourceKey()
           
 java.lang.String getName()
          The name of this module.
 int getNameFieldIdx()
          The field index holding the title of the item.
 java.lang.String getObjectName()
          The name of the items belonging to this module.
 java.lang.String getObjectNamePlural()
          The plural name of the items belonging to this module.
 OnlineServices getOnlineServices()
          The online services available for this module.
 DcModule getParent()
          Retrieves the parent module instance.
 int getParentReferenceFieldIndex()
          Retrieves the index for the field holding the reference to the parent item.
 DcField getPersistentField(int fieldIdx)
           
 DcPropertyModule getPropertyModule(int modIdx)
          Retrieve the property module for the given index used by this module.
 QuickViewPanel getQuickView()
          Creates a new quick view panel.
 QuickViewFieldDefinitions getQuickViewFieldDefinitions()
          Retrieves the quick view field definitions / settings
 MasterView getSearchView()
          Returns the search view.
 java.lang.Object getSetting(java.lang.String key)
          Retrieves the module setting value.
 Settings getSettings()
          The module settings.
 int[] getSupportedViews()
           
 Synchronizer getSynchronizer()
          The mass updater or synchronizer.
 int getSystemDisplayFieldIdx()
           
 DcField getSystemField(int index)
          Retrieves the system field for the given index.
 java.lang.String getSystemObjectName()
          The name of the items belonging to this module without translating it.
 java.lang.String getSystemObjectNamePlural()
          The plural name of the items belonging to this module without translating it.
 java.lang.String getTableName()
          The name of the table used to store its items.
 java.lang.String getTableShortName()
          The short name of the table used to store its items.
 TemplateModule getTemplateModule()
          Returns the template module.
 int getType()
           
 MasterView[] getViews()
          Returns all views.
 WebFieldDefinitions getWebFieldDefinitions()
          Retrieves the web field definitions / settings
 XmlModule getXmlModule()
          Retrieves the XML definition of this module.
 boolean hasActualReferenceTo(int module)
          Tells if the module holds a reference to the given module.
 boolean hasDependingModules()
          Indicates if other modules depend on this module.
 int hashCode()
           
 boolean hasInsertView()
          Indicates if this module has an insert view available.
 boolean hasReferenceTo(int module)
          Tells if the module holds a reference to the given module.
 boolean hasReports()
           
 boolean hasSearchView()
          Indicates if this module has a search view available.
protected  void initializeFields()
          Initializes the default fields.
 void initializeMultiReferenceFields()
          Creates a simple reference field for each multiple references field for ordering purposes.
 void initializeSettings()
          Initializes and corrects the module settings (if necessary)
protected  void initializeSystemFields()
          Initializes the system fields.
protected  void initializeUI()
          Creates the various views.
 boolean isAbstract()
          Indicates if the module is abstract.
 boolean isChildModule()
          Indicates if this module is a child of another module.
 boolean isContainerManaged()
          Indicates if the module is managed by (can belong to) a container.
 boolean isCustomFieldsAllowed()
          Indicates if this module is allowed to be customized.
 boolean isCustomModule()
          Tells if the module is created by a user.
 boolean isDefaultDataLoaded()
           
 boolean isEditingAllowed()
          Indicates if the user is allowed to edit items belonging to this module.
 boolean isEnabled()
          Tells whether the module is enabled.
 void isEnabled(boolean b)
          Marks the module as enabled or disabled.
 boolean isFileBacked()
          Indicates if the module holds items with a reference to a file.
 boolean isHasImages()
           
 boolean isHasReferences()
           
 boolean isNew()
          Returns whether this module is new for this installation.
 boolean isParentModule()
          Indicates if this module is a parent to another module.
 boolean isSearchViewInitialized()
           
 boolean isSelectableInUI()
          Indicates if the module can be selected from the module bar.
 boolean isServingMultipleModules()
          Indicates if this module is used by multiple modules.
 boolean isTopModule()
          Indicates if this module is a top module.
 boolean isValid()
          Indicate if this module is valid (fully functional).
 void release(DcObject dco)
           
 void removeEnhancers()
          Removes all enhancers.
 void setChild(int module)
          Register a child module.
 void setDefaultDataLoaded(boolean b)
           
 void setIcon16(DcImageIcon icon16)
          Sets the small icon used to represent this module.
 void setIcon32(DcImageIcon icon32)
          Sets the large icon used to represent this module.
 void setNew(boolean isNew)
          Indicate this module as new for this installation
 void setServingMultipleModules(boolean isServingMultipleModules)
          Indicates if this module is used by multiple modules.
 void setSetting(java.lang.String key, java.lang.Object value)
          Sets the module setting value.
 void setValid(boolean isValid)
          Indicate if this module is valid (fully functional).
 void setXmlModule(XmlModule xmlModule)
          Sets the XML definition for this module.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_TYPE_MODULE

public static final int _TYPE_MODULE
See Also:
Constant Field Values

_TYPE_PROPERTY_MODULE

public static final int _TYPE_PROPERTY_MODULE
See Also:
Constant Field Values

_TYPE_MEDIA_MODULE

public static final int _TYPE_MEDIA_MODULE
See Also:
Constant Field Values

_TYPE_ASSOCIATE_MODULE

public static final int _TYPE_ASSOCIATE_MODULE
See Also:
Constant Field Values

_TYPE_EXTERNALREFERENCE_MODULE

public static final int _TYPE_EXTERNALREFERENCE_MODULE
See Also:
Constant Field Values

_TYPE_MAPPING_MODULE

public static final int _TYPE_MAPPING_MODULE
See Also:
Constant Field Values

_TYPE_TEMPLATE_MODULE

public static final int _TYPE_TEMPLATE_MODULE
See Also:
Constant Field Values

insertView

protected MasterView insertView

searchView

protected MasterView searchView
Constructor Detail

DcModule

protected DcModule(int index,
                   java.lang.String name,
                   java.lang.String description,
                   java.lang.String objectName,
                   java.lang.String objectNamePlural,
                   java.lang.String tableName,
                   java.lang.String tableShortName,
                   boolean topModule)
Creates a new instance.

Parameters:
index - The module index.
name - The internal unique name of the module.
description - The module description
objectName - The name of the items belonging to this module.
objectNamePlural - The plural name of the items belonging to this module.
tableName - The database table name for this module.
tableShortName - The database table short name for this module.
topModule - Indicates if the module is a top module. Top modules are allowed to be displayed in the module bar and can be enabled or disabled.

DcModule

public DcModule(int index,
                boolean topModule,
                java.lang.String name,
                java.lang.String description,
                java.lang.String objectName,
                java.lang.String objectNamePlural,
                java.lang.String tableName,
                java.lang.String tableShortName)
Creates a new instance.

Parameters:
index - The module index.
topModule - Indicates if the module is a top module. Top modules are allowed to be displayed in the module bar and can be enabled or disabled.
name - The internal unique name of the module.
description - The module description
objectName - The name of the items belonging to this module.
objectNamePlural - The plural name of the items belonging to this module.
tableName - The database table name for this module.
tableShortName - The database table short name for this module.

DcModule

public DcModule(XmlModule module)
Creates a new module based on a XML definition.

Parameters:
module -
Method Detail

hasReports

public boolean hasReports()

getType

public int getType()

isHasImages

public boolean isHasImages()

isHasReferences

public boolean isHasReferences()

getIconField

public DcField getIconField()

isAbstract

public boolean isAbstract()
Indicates if the module is abstract. An abstract module represents items belonging to other modules; it represents items from multiple modules. An abstract module does not dictate where the items should be stored in the database, this is done by its actual module. The media module is a good example of an abstract module.


getSupportedViews

public int[] getSupportedViews()

isNew

public boolean isNew()
Returns whether this module is new for this installation. New means that it was registered on startup.


setNew

public void setNew(boolean isNew)
Indicate this module as new for this installation

Parameters:
isNew -

isValid

public boolean isValid()
Indicate if this module is valid (fully functional). Some processes register a new module temporarily. Since in that case the table has not been created yet or not all referenced exist the module is in an invalid state.


setValid

public void setValid(boolean isValid)
Indicate if this module is valid (fully functional). Some processes register a new module temporarily. Since in that case the table has not been created yet or not all referenced exist the module is in an invalid state.

Parameters:
isValid -

isDefaultDataLoaded

public boolean isDefaultDataLoaded()

setDefaultDataLoaded

public void setDefaultDataLoaded(boolean b)

isEditingAllowed

public boolean isEditingAllowed()
Indicates if the user is allowed to edit items belonging to this module.


isChildModule

public boolean isChildModule()
Indicates if this module is a child of another module.


isParentModule

public boolean isParentModule()
Indicates if this module is a parent to another module.


getIndex

public int getIndex()
Retrieves the index of the module (unique!)


getIcon16

public DcImageIcon getIcon16()
The small icon used to represent the module.


getIcon32

public DcImageIcon getIcon32()
The large icon used to represent the module.


getModuleResourceKey

public java.lang.String getModuleResourceKey()

getItemResourceKey

public java.lang.String getItemResourceKey()

getItemPluralResourceKey

public java.lang.String getItemPluralResourceKey()

getObjectName

public java.lang.String getObjectName()
The name of the items belonging to this module.


getSystemObjectName

public java.lang.String getSystemObjectName()
The name of the items belonging to this module without translating it.


getObjectNamePlural

public java.lang.String getObjectNamePlural()
The plural name of the items belonging to this module.


getSystemObjectNamePlural

public java.lang.String getSystemObjectNamePlural()
The plural name of the items belonging to this module without translating it.


getKeyStroke

public javax.swing.KeyStroke getKeyStroke()
The keys combination associated with this module.


setIcon16

public void setIcon16(DcImageIcon icon16)
Sets the small icon used to represent this module.

Parameters:
icon16 -

setIcon32

public void setIcon32(DcImageIcon icon32)
Sets the large icon used to represent this module.

Parameters:
icon16 -

isEnabled

public boolean isEnabled()
Tells whether the module is enabled.

See Also:
DcModuleSettings

isEnabled

public void isEnabled(boolean b)
Marks the module as enabled or disabled.

See Also:
DcModuleSettings

getName

public java.lang.String getName()
The name of this module.

Returns:

getDescription

public java.lang.String getDescription()
The description for this module.


getTableName

public java.lang.String getTableName()
The name of the table used to store its items.


getTableShortName

public java.lang.String getTableShortName()
The short name of the table used to store its items.


getOnlineServices

public OnlineServices getOnlineServices()
The online services available for this module.


deliversOnlineService

public boolean deliversOnlineService()
Indicates if this module has online services at its disposal.


isCustomModule

public boolean isCustomModule()
Tells if the module is created by a user.


createItem

protected DcObject createItem()
Creates a new instance of an item belonging to this module.


release

public void release(DcObject dco)

getItem

public final DcObject getItem()
Creates a new instance of an item belonging to this module.


getFileField

public DcField getFileField()

getSystemDisplayFieldIdx

public int getSystemDisplayFieldIdx()

getDisplayFieldIdx

public int getDisplayFieldIdx()
Educated guess..


getMinimalFields

public int[] getMinimalFields(java.util.Collection<java.lang.Integer> include)

getItemForm

public ItemForm getItemForm(DcTemplate template,
                            boolean readonly,
                            boolean update,
                            DcObject o,
                            boolean applyTemplate)
Creates a new item form.

Parameters:
template - The template to be applied on the item.
readonly - Indicates if the item form should be opened in read only mode.
update - Indicates if the item is an existing or a new item.
o - The item to be displayed in the form.
applyTemplate - Indicates if the supplied template should be applied.

getSynchronizer

public Synchronizer getSynchronizer()
The mass updater or synchronizer.

Returns:
A synchronizer or null of not available.

isSearchViewInitialized

public boolean isSearchViewInitialized()

getInsertView

public MasterView getInsertView()
The insert view (shown in the new tab)


getSearchView

public MasterView getSearchView()
Returns the search view.


getCurrentSearchView

public View getCurrentSearchView()
Returns the current search view.


getCurrentInsertView

public View getCurrentInsertView()
Returns the current insert view.


getPropertyModule

public DcPropertyModule getPropertyModule(int modIdx)
Retrieve the property module for the given index used by this module.

Parameters:
modIdx -

getTemplateModule

public TemplateModule getTemplateModule()
Returns the template module.

Returns:
Template module or null.

isSelectableInUI

public boolean isSelectableInUI()
Indicates if the module can be selected from the module bar.


addField

public void addField(DcField field)
Adds a field to this module.

Parameters:
field -

getViews

public MasterView[] getViews()
Returns all views.


getField

public DcField getField(int index)
Retrieves the field definition for the given index.

Parameters:
index - The field index.

getField

public DcField getField(java.lang.String columnName)
Retrieves the field definition for the given index.

Parameters:
columnName - The database column name.

addValueEnhancer

public void addValueEnhancer(IValueEnhancer enhancer,
                             int field)
Registers a value enhancer for a specific field.

Parameters:
enhancer -
field -

removeEnhancers

public void removeEnhancers()
Removes all enhancers.


getSystemField

public DcField getSystemField(int index)
Retrieves the system field for the given index.

Parameters:
index - The field index.

setChild

public void setChild(int module)
Register a child module.

Parameters:
module -

getMenuBar

public MainFrameMenuBar getMenuBar()
Creates the menu bar for this module.

Returns:
The menu bar or null if not supported.

getParent

public DcModule getParent()
Retrieves the parent module instance.

Returns:
The parent module or null if not applicable.

getChild

public DcModule getChild()
Retrieves the child module instance.

Returns:
The child module or null if not applicable.

getParentReferenceFieldIndex

public int getParentReferenceFieldIndex()
Retrieves the index for the field holding the reference to the parent item.

Returns:
The field index or -1 if not found.

getFilterForm

public FilterDialog getFilterForm(boolean create)
Creates the filter form (if not created already).

Parameters:
create - Indicates if the form should be created when it does not yet exist.
Returns:
The form or null if not available.

getFileRenamerDialog

public FileRenamerDialog getFileRenamerDialog(boolean create)
Creates the file renamer dialog (if not created already).

Parameters:
create - Indicates if the dialog should be created when it does not yet exist.
Returns:
The dialog or null if not available.

getChartPanel

public ChartPanel getChartPanel(boolean create)
Creates the chart panel (if not created already).

Parameters:
create - Indicates if the panel should be created when it does not yet exist.
Returns:
The panel or null if not available.

isServingMultipleModules

public boolean isServingMultipleModules()
Indicates if this module is used by multiple modules.


setServingMultipleModules

public void setServingMultipleModules(boolean isServingMultipleModules)
Indicates if this module is used by multiple modules.

Parameters:
isServingMultipleModules -

isTopModule

public boolean isTopModule()
Indicates if this module is a top module. Top modules are allowed to be displayed in the module bar and can be enabled or disabled.


getFieldCount

public int getFieldCount()
The number of fields belonging to this module.


canBeLend

public boolean canBeLend()
Indicates if items belonging to this module can be lend.


hasDependingModules

public boolean hasDependingModules()
Indicates if other modules depend on this module.


getSetting

public java.lang.Object getSetting(java.lang.String key)
Retrieves the module setting value.

Parameters:
key - The setting key DcRepository.ModuleSettings.

setSetting

public void setSetting(java.lang.String key,
                       java.lang.Object value)
Sets the module setting value.

Parameters:
key - The setting key DcRepository.ModuleSettings.
value - The value to set.

getQuickView

public QuickViewPanel getQuickView()
Creates a new quick view panel.

Returns:
New quick view panel or null.

hasReferenceTo

public boolean hasReferenceTo(int module)
Tells if the module holds a reference to the given module. This check is based on the original module index.

Parameters:
module - The module index.

hasActualReferenceTo

public boolean hasActualReferenceTo(int module)
Tells if the module holds a reference to the given module. This check is based on the calculated module index.

Parameters:
module - The module index.

getFields

public java.util.Collection<DcField> getFields()
Retrieves all fields.


getFieldDefinitions

public DcFieldDefinitions getFieldDefinitions()
Gets the field definitions. The field definitions contain the user settings such as the modified label and the enabled setting.

See Also:
DcFieldDefinition

getWebFieldDefinitions

public WebFieldDefinitions getWebFieldDefinitions()
Retrieves the web field definitions / settings

See Also:
WebFieldDefinition

getQuickViewFieldDefinitions

public QuickViewFieldDefinitions getQuickViewFieldDefinitions()
Retrieves the quick view field definitions / settings

See Also:
QuickViewFieldDefinition

getFieldIndices

public int[] getFieldIndices()
Retrieves all field indices.


getImporterClass

public java.lang.Class getImporterClass()
The import class.


getImporter

public FileImporter getImporter()
Creates a new instance of the file importer.


isCustomFieldsAllowed

public boolean isCustomFieldsAllowed()
Indicates if this module is allowed to be customized.


getSettings

public Settings getSettings()
The module settings.

See Also:
DcRepository.ModuleSettings

applySettings

public void applySettings()
Applies the field settings on this module.


isContainerManaged

public boolean isContainerManaged()
Indicates if the module is managed by (can belong to) a container.

See Also:
ContainerModule, Container

getPersistentField

public DcField getPersistentField(int fieldIdx)

initializeMultiReferenceFields

public void initializeMultiReferenceFields()
Creates a simple reference field for each multiple references field for ordering purposes. It does need to have all modules registered before this method can be called.


initializeFields

protected void initializeFields()
Initializes the default fields.


initializeSettings

public void initializeSettings()
Initializes and corrects the module settings (if necessary)


initializeSystemFields

protected void initializeSystemFields()
Initializes the system fields.


hasInsertView

public boolean hasInsertView()
Indicates if this module has an insert view available.


hasSearchView

public boolean hasSearchView()
Indicates if this module has a search view available.


initializeUI

protected void initializeUI()
Creates the various views.


isFileBacked

public boolean isFileBacked()
Indicates if the module holds items with a reference to a file.


getDefaultSortFieldIdx

public int getDefaultSortFieldIdx()
Retrieves the index of the field on which is sorted by default. Return 1 if this field exists or else the defined default index.


getDisplayIndex

public int getDisplayIndex()
The location of the module in the module bar.


getNameFieldIdx

public int getNameFieldIdx()
The field index holding the title of the item.


getIcon16Filename

public java.lang.String getIcon16Filename()

getIcon32Filename

public java.lang.String getIcon32Filename()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getXmlModule

public XmlModule getXmlModule()
Retrieves the XML definition of this module.

Returns:
The XML definition or null.

setXmlModule

public void setXmlModule(XmlModule xmlModule)
Sets the XML definition for this module.


getLabel

public java.lang.String getLabel()

compareTo

public int compareTo(DcModule module)
Compares the supplied module with the current module. The check is performed by comparing the labels.

Specified by:
compareTo in interface java.lang.Comparable<DcModule>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

delete

public void delete()
            throws java.lang.Exception
Deletes this module. Cannot be undone.

Throws:
java.lang.Exception

getDefaultData

public java.util.Collection<DcObject> getDefaultData()
                                              throws java.lang.Exception
Retrieves the default data for this module. The default data is inserted on new installations. Default data is located in the data folder of the modules folder.

Returns:
The default data or null.
Throws:
java.lang.Exception