public class IlvTableGanttModel extends IlvAbstractGanttModel implements TableModelListener
IlvGanttModel
interface
builds a model from several instances of Swing TableModel
s for:
TableModel
and the different Gantt
model properties can be configured using
IlvTableModelMapper
instances. If no mappers
are set, the mapping to the properties is done by looking up for columns that
have the same names as the Gantt properties
(IlvTableActivity.ID_PROPERTY
and
IlvTableActivity.PARENT_ID_PROPERTY
...)
in the different TableModel
s.
This mapping works both ways however:
TableModelEvent
with the type
TableModelEvent.DELETE
the TableModel
must fire a
TableModelEvent
with type
IlvTableModelEvent.BEFORE_DELETE
(possibly using
IlvTableModelEvent.fireBeforeTableRowsDeleted(javax.swing.table.AbstractTableModel, int, int)
).
IlvTableModelEvent.fireBeforeTableStructureChanged(javax.swing.table.AbstractTableModel)
on the given model, before the actual changes and the call to
AbstractTableModel.fireTableStructureChanged()
take place.
IlvTableModelEvent.fireBeforeTableDataChanged(javax.swing.table.AbstractTableModel)
on the given model, before the actual changes and the call to
AbstractTableMode.fireTableDataChange()
take place.
TableModel
must implement the
IlvTableModel
interface that allows rows to be
inserted and removed in the tables.
TableModel
instances
except the ID property of activities and resources.
ADJUSTING_PROPERTY, BATCHING_PROPERTY
Constructor and Description |
---|
IlvTableGanttModel()
Builds an
IlvTableGanttModel that will have to be
initialized later on with the different mappers, and the call to
initializeMapping() . |
IlvTableGanttModel(IlvTableModelMapper activitiesMapper,
IlvTableModelMapper resourcesMapper,
IlvTableModelMapper constraintsMapper,
IlvTableModelMapper reservationsMapper)
Builds an
IlvTableGanttModel from the given IlvTableModelMapper instances. |
IlvTableGanttModel(TableModel activities,
TableModel resources,
TableModel constraints,
TableModel reservations)
Builds an
IlvTableGanttModel from the given
TableModel instances. |
Modifier and Type | Method and Description |
---|---|
void |
addActivity(IlvActivity newActivity,
IlvActivity parent,
int index)
Adds
newActivity as a child of the parent
activity at the specified location in its list of child activities. |
void |
addConstraint(IlvConstraint newConstraint)
Adds a
newConstraint to the data model. |
void |
addReservation(IlvReservation newReservation)
Adds a
newReservation to the data model. |
void |
addResource(IlvResource newResource,
IlvResource parent,
int index)
Adds
newResource as a child of the parent
resource at the specified location in its list of child resources. |
void |
configureHierarchyChart(IlvHierarchyChart chart)
Configures the given
IlvHierarchyChart so that it fits the
IlvTableGanttModel . |
void |
configureHierarchyChart(IlvHierarchyChart chart,
boolean IDAutoIncrement)
Configures the given
IlvHierarchyChart so that it fits the
IlvTableGanttModel . |
Iterator |
constraintIterator()
Returns an iterator over all the constraints in the data model.
|
Iterator |
constraintIteratorFromActivity(IlvActivity fromActivity)
Returns an iterator over the constraints in the data model that have the
specified activity as their source or from the activity.
|
Iterator |
constraintIteratorToActivity(IlvActivity toActivity)
Returns an iterator over the constraints in the data model that have the
specified activity as their target or the to activity.
|
boolean |
contains(IlvConstraint constraint)
Returns whether the specified constraint is a member of the data model.
|
boolean |
contains(IlvHierarchyNode activityOrResource)
Returns whether the specified activity or resource is a member of the data
model.
|
boolean |
contains(IlvReservation reservation)
Returns whether the specified reservation is a member of the data model.
|
static IlvTableModelMapper |
createActivityMapper(TableModel model,
int id,
int name,
int startTime,
int endTime,
int parentID)
Creates a new
IlvTableModelMapper that maps the different activity
properties to the specified column indexes. |
static IlvTableModelMapper |
createActivityMapper(TableModel model,
Map mapping)
Creates a new
IlvTableModelMapper that maps the different
properties to the specified columns referenced by their names. |
static IlvTableModelMapper |
createActivityMapper(TableModel model,
String id,
String name,
String startTime,
String endTime,
String parentID)
Creates a new
IlvTableModelMapper that maps the different
properties to the specified columns referenced by their names. |
static IlvTableModelMapper |
createConstraintMapper(TableModel model,
int fromActivityID,
int toActivityID,
int constraintType,
Object[] typesMapping)
Creates a new
IlvTableModelMapper that maps the different
constraint properties to the specified column indexes. |
static IlvTableModelMapper |
createConstraintMapper(TableModel model,
Map mapping,
Object[] typesMapping)
Creates a new
IlvTableModelMapper that maps the different
constraint properties to the specified column indexes. |
static IlvTableModelMapper |
createConstraintMapper(TableModel model,
String fromActivityID,
String toActivityID,
String constraintType,
Object[] typesMapping)
Creates a new
IlvTableModelMapper that maps the different
constraint properties to the specified column indexes. |
static IlvTableModelMapper |
createReservationMapper(TableModel model,
int activityID,
int resourceID)
Creates a new
IlvTableModelMapper that maps the different
properties to the specified column indexes. |
static IlvTableModelMapper |
createReservationMapper(TableModel model,
Map mapping)
Creates a new
IlvTableModelMapper that maps the different
properties to the specified columns referenced by their names. |
static IlvTableModelMapper |
createReservationMapper(TableModel model,
String activityID,
String resourceID)
Creates a new
IlvTableModelMapper that maps the different
properties to the specified columns referenced by their names. |
static IlvTableModelMapper |
createResourceMapper(TableModel model,
int id,
int name,
int quantity,
int parentID)
Creates a new
IlvTableModelMapper that maps the different resource
properties to the specified column indexes. |
static IlvTableModelMapper |
createResourceMapper(TableModel model,
Map mapping)
Creates a new
IlvTableModelMapper that maps the different
properties to the specified columns referenced by their names. |
static IlvTableModelMapper |
createResourceMapper(TableModel model,
String id,
String name,
String quantity,
String parentID)
Creates a new
IlvTableModelMapper that maps the different
properties to the specified columns referenced by their names. |
void |
fireReservationEvent(ReservationEvent event)
Fires a reservation event to all subscribed listeners.
|
TableModel |
getActivitiesTableModel()
Returns the
TableModel for activities. |
IlvTableModelMapper |
getActivityMapper()
Returns a copy of
IlvTableModelMapper for activities. |
IlvActivity |
getChildActivity(IlvActivity parent,
int index)
Returns the child of the specified parent activity at the specified
index . |
int |
getChildActivityCount(IlvActivity parent)
Returns the number of children of the specified parent activity.
|
int |
getChildActivityIndex(IlvActivity parent,
IlvActivity child)
Returns the index of the specified child in the list of children of the
parent activity.
|
IlvResource |
getChildResource(IlvResource parent,
int index)
Returns the child of the specified parent resource at the specified
index . |
int |
getChildResourceCount(IlvResource parent)
Returns the number of children of the specified parent resource.
|
int |
getChildResourceIndex(IlvResource parent,
IlvResource child)
Returns the index of the specified child to the list of children of the
parent resource.
|
IlvTableModelMapper |
getConstraintMapper()
Returns a copy of
IlvTableModelMapper for constraints. |
TableModel |
getConstraintsTableModel()
Returns the
TableModel for constraints. |
IlvActivity |
getParentActivity(IlvActivity activity)
Returns the parent activity of the specified activity or
null
if the activity is the root activity of the data model. |
int |
getParentActivityIndex(IlvActivity activity)
Returns the index of the specified activity within its parent activity.
|
IlvResource |
getParentResource(IlvResource resource)
Returns the parent resource of the specified resource or
null
if the resource is the root resource of the data model. |
int |
getParentResourceIndex(IlvResource resource)
Returns the index of the specified resource within its parent resource.
|
IlvTableModelMapper |
getReservationMapper()
Returns a copy of
IlvTableModelMapper for reservations. |
TableModel |
getReservationsTableModel()
Returns the
TableModel for reservations. |
IlvTableModelMapper |
getResourceMapper()
Returns a copy of
IlvTableModelMapper for resources. |
TableModel |
getResourcesTableModel()
Returns the
TableModel for resources. |
IlvActivity |
getRootActivity()
Returns the root activity of the data model or
null if the
data model contains no activities. |
IlvResource |
getRootResource()
Returns the root resource of the data model or
null if the
data model contains no resources. |
void |
initializeMapping()
Performs the mapping of all the
TableModel s to the
IlvGanttModel . |
boolean |
isAdvanceCheckEnabled()
Returns whether or not the
IlvGanttModel will perform
advance checking each time an object is added to the model. |
boolean |
isMultipleRootModeOn(boolean value)
Returns
true if the IlvTableGanttModel has to
accept multiple root (for both activities and resources). |
void |
moveActivity(IlvActivity activity,
IlvActivity newParent,
int newIndex)
Moves the specified activity from its current location in the tree
to a new location.
|
void |
moveResource(IlvResource resource,
IlvResource newParent,
int newIndex)
Moves the specified resource from its current location in the tree
to a new location.
|
void |
removeActivity(IlvActivity activity)
Removes the specified child activity from its parent.
|
void |
removeActivity(IlvActivity parent,
int index)
Removes the child activity from the parent that is at the
specified location in its list of child activities.
|
void |
removeConstraint(IlvConstraint constraint)
Removes the specified
constraint from the data model. |
void |
removeReservation(IlvReservation reservation)
Removes the specified
reservation from the data model. |
void |
removeResource(IlvResource resource)
Removes the specified child resource from its parent.
|
void |
removeResource(IlvResource parent,
int index)
Removes the child resource from the parent that is at the
specified location in its list of child resources.
|
Iterator |
reservationIterator()
Returns an iterator over all the reservations in the data model.
|
Iterator |
reservationIterator(IlvActivity activity)
Returns an iterator over all the reservations in the data model that are
associated with the specified activity.
|
Iterator |
reservationIterator(IlvResource resource)
Returns an iterator over all the reservations in the data model that are
associated with the specified resource.
|
Iterator |
reservationIterator(IlvResource resource,
IlvTimeInterval interval)
Returns an iterator over all the reservations in the data model that are
associated with the specified resource and where the assigned activity
intersects the specified time interval.
|
void |
setActivitiesTableModel(TableModel model)
Sets the
TableModel for activities. |
void |
setActivityMapper(IlvTableModelMapper mapper)
Copies and sets the
IlvTableModelMapper for activities. |
void |
setAdvanceCheckEnabled(boolean value)
Sets whether or not the
IlvGanttModel will perform advance
checking each time an object is added to the model. |
void |
setConstraintMapper(IlvTableModelMapper mapper)
Copies and sets the
IlvTableModelMapper for constraints. |
void |
setConstraintsTableModel(TableModel model)
Sets the
TableModel for constraints. |
void |
setMultipleRootModeOn(boolean value)
When set to
true , this forces the
IlvTableGanttModel to accept multiple root (for both
activities and resources). |
void |
setReservationMapper(IlvTableModelMapper mapper)
Copies and sets the
IlvTableModelMapper for reservations. |
void |
setReservationsTableModel(TableModel model)
Sets the
TableModel for reservations. |
void |
setResourceMapper(IlvTableModelMapper mapper)
Copies and sets the
IlvTableModelMapper for resources. |
void |
setResourcesTableModel(TableModel model)
Sets the
TableModel for resources. |
void |
setRootActivity(IlvActivity root)
This method must not be called.
|
void |
setRootResource(IlvResource root)
This method must not be called.
|
void |
tableChanged(TableModelEvent e)
The
IlvTableGanttModel listens to the changes on the
different TableModel instances to forward row or cell
updates to the Gantt model. |
activityPreorderIterator, activityPreorderIterator, addActivity, addActivityHierarchyListener, addActivityListener, addConstraintListener, addGanttModelPropertyListener, addReservationListener, addResource, addResourceHierarchyListener, addResourceListener, childActivityIterator, childResourceIterator, clear, fireActivitiesInserted, fireActivitiesInserted, fireActivitiesRemoved, fireActivitiesRemoved, fireActivityEvent, fireActivityInserted, fireActivityMoved, fireActivityRemoved, fireConstraintEvent, fireConstraintInserted, fireConstraintRemoved, fireConstraintRemoved, fireGanttModelPropertyEvent, fireReservationInserted, fireReservationRemoved, fireReservationRemoved, fireResourceEvent, fireResourceInserted, fireResourceMoved, fireResourceRemoved, fireResourcesInserted, fireResourcesInserted, fireResourcesRemoved, fireResourcesRemoved, getActivityHierarchyListeners, getActivityListeners, getChild, getChildCount, getChildIndex, getParent, getParentIndex, getResourceHierarchyListeners, getResourceListeners, isAdjusting, isBatching, registerEventListener, removeActivityHierarchyListener, removeActivityListener, removeConstraintListener, removeGanttModelPropertyListener, removeReservationListener, removeResourceHierarchyListener, removeResourceListener, resourcePreorderIterator, resourcePreorderIterator, setAdjusting, setBatching, writeEventListeners
public IlvTableGanttModel()
IlvTableGanttModel
that will have to be
initialized later on with the different mappers, and the call to
initializeMapping()
.public IlvTableGanttModel(TableModel activities, TableModel resources, TableModel constraints, TableModel reservations)
IlvTableGanttModel
from the given
TableModel
instances.
The model uses the default IlvTableModelMapper
instances
that look up properties in the table by matching property names and
column names.
If a different behavior is needed, other IlvTableModelMapper
s
must then be configured and set after calling the constructor.
In all cases initializeMapping()
needs to be called to
initialize the model.activities
- Contains a row for each IlvActivity
.resources
- Contains a row for each IlvResource
.constraints
- Contains a row for each IlvConstraint
.reservations
- Contains a row for each IlvReservation
.setActivityMapper(IlvTableModelMapper)
,
setResourceMapper(IlvTableModelMapper)
,
setConstraintMapper(IlvTableModelMapper)
,
setReservationMapper(IlvTableModelMapper)
public IlvTableGanttModel(IlvTableModelMapper activitiesMapper, IlvTableModelMapper resourcesMapper, IlvTableModelMapper constraintsMapper, IlvTableModelMapper reservationsMapper) throws IlvTableModelMappingException
IlvTableGanttModel
from the given IlvTableModelMapper
instances. This constructor supposes that the given
mappers are already configured and directly initializes the
IlvTableGanttModel
by calling initializeMapping()
.activitiesMapper
- The mapper that references the activities.resourcesMapper
- The mapper that references the resources.constraintsMapper
- The mapper that references the constraints.reservationsMapper
- The mapper that references the reservations.IlvTableModelMappingException
- If one of the mappers is not
correctly configured.public void configureHierarchyChart(IlvHierarchyChart chart)
IlvHierarchyChart
so that it fits the
IlvTableGanttModel
.
It calls configureHierarchyChart(IlvHierarchyChart, boolean)
with the second parameter to false
.chart
- The IlvHierarchyChart
to configure.public void configureHierarchyChart(IlvHierarchyChart chart, boolean IDAutoIncrement)
IlvHierarchyChart
so that it fits the
IlvTableGanttModel
.chart
- The IlvHierarchyChart
to configure.IDAutoIncrement
- Whether or not the ID fields will be auto
incremented by the backend TableModel
(this is usually the case when it is connected to a
database primary key column in auto increment
mode).public final void setAdvanceCheckEnabled(boolean value)
IlvGanttModel
will perform advance
checking each time an object is added to the model.
The default value is false
.
Setting it to true
allows you to get more feedback
(i.e. exception) on bad mapping configuration at insertion time,
but this also slows down the performance. When mapping is known to be
correctly configured, it is better to keep the default value.value
- The new value.public final boolean isAdvanceCheckEnabled()
IlvGanttModel
will perform
advance checking each time an object is added to the model.
The default value is false
.
Setting it to true
allows you to get more feedback
(i.e. exception) on bad mapping configuration at insertion time,
but this also slows down the performance. When mapping is known to be
correctly configured, it is better to keep the default value.setAdvanceCheckEnabled(boolean)
public final void initializeMapping() throws IlvTableModelMappingException
TableModel
s to the
IlvGanttModel
.IlvTableModelMappingException
- If one of the mappers is not
correctly configured.IlvTableGanttModel(TableModel, TableModel, TableModel, TableModel)
,
setActivityMapper(IlvTableModelMapper)
,
setResourceMapper(IlvTableModelMapper)
,
setConstraintMapper(IlvTableModelMapper)
,
setReservationMapper(IlvTableModelMapper)
public final void setMultipleRootModeOn(boolean value)
true
, this forces the
IlvTableGanttModel
to accept multiple root (for both
activities and resources).
This is usually not necessary as the IlvTableGanttModel
introspects the activity and resource tables when
initializeMapping()
mapping occurs, to see if there are
several activity and/or resource rows that have null
parents ID (i.e. there are several roots).
This method may be useful if you want to add roots at a later stage,
and if you want the model to be correctly configured from the beginning.
The default value is false
.
The method must be called before initializeMapping()
.public final boolean isMultipleRootModeOn(boolean value)
true
if the IlvTableGanttModel
has to
accept multiple root (for both activities and resources).
The default value is false
.setMultipleRootModeOn(boolean)
public final TableModel getActivitiesTableModel()
TableModel
for activities. It can be
null
if no model for activities has been specified.public final void setActivitiesTableModel(TableModel model)
TableModel
for activities.
Once models are set initializeMapping()
must be called.
Can be null
if no activities have to be added.public final IlvTableModelMapper getActivityMapper()
IlvTableModelMapper
for activities. It can be
null
if it has not been specified, otherwise it can be
modified and set using setActivityMapper(IlvTableModelMapper)
.public final void setActivityMapper(IlvTableModelMapper mapper)
IlvTableModelMapper
for activities.
Once mappers are set initializeMapping()
must be called.public final TableModel getResourcesTableModel()
TableModel
for resources.
It can be null
if no model for resources has been specified.public final void setResourcesTableModel(TableModel model)
TableModel
for resources.
Once models are set initializeMapping()
must be called.
It can be null
if no resources have to be added.public final IlvTableModelMapper getResourceMapper()
IlvTableModelMapper
for resources.
It can be null
if it has not been specified, otherwise
it can be modified and set using
setResourceMapper(IlvTableModelMapper)
.public final void setResourceMapper(IlvTableModelMapper mapper)
IlvTableModelMapper
for resources.
Once mappers are set initializeMapping()
must be called.public final TableModel getConstraintsTableModel()
TableModel
for constraints.
It can be null
if no model for constraints has been
specified.public final void setConstraintsTableModel(TableModel model)
TableModel
for constraints.
Once models are set initializeMapping()
must be called.
It can be null
if no constraints have to be added.public final IlvTableModelMapper getConstraintMapper()
IlvTableModelMapper
for constraints.
It can be null
if it has not been specified, otherwise
it can be modified and set using
setConstraintMapper(IlvTableModelMapper)
.public final void setConstraintMapper(IlvTableModelMapper mapper)
IlvTableModelMapper
for constraints.
Once mappers are set initializeMapping()
must be called.public final TableModel getReservationsTableModel()
TableModel
for reservations.
It can be null
if no model for reservations has been
specified.public final void setReservationsTableModel(TableModel model)
TableModel
for reservations.
Once models are set initializeMapping()
must be called.
Can be null
if no reservations have to be added.public final IlvTableModelMapper getReservationMapper()
IlvTableModelMapper
for reservations.
It can be null
if it has not been specified, otherwise
it can be modified and set using
setReservationMapper(IlvTableModelMapper)
.public final void setReservationMapper(IlvTableModelMapper mapper)
IlvTableModelMapper
for reservations.
Once mappers are set initializeMapping()
must be called.public boolean contains(IlvHierarchyNode activityOrResource)
contains
in interface IlvGanttModel
activityOrResource
- The activity or resource.public IlvActivity getRootActivity()
null
if the
data model contains no activities.getRootActivity
in interface IlvGanttModel
null
.public void setRootActivity(IlvActivity root)
getActivitiesTableModel()
.setRootActivity
in interface IlvGanttModel
root
- The new root activity or null
if the data model
is to contain no activities.ActivityHierarchyListener.activitiesInserted(ilog.views.gantt.event.ActivitiesInsertedEvent)
,
ActivityHierarchyListener.activitiesRemoved(ilog.views.gantt.event.ActivitiesRemovedEvent)
public IlvActivity getParentActivity(IlvActivity activity)
null
if the activity is the root activity of the data model.getParentActivity
in interface IlvGanttModel
activity
- The implementation of this method uses IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate
activity
.null
.IllegalArgumentException
- if activity
is not a member
of this data model.public int getParentActivityIndex(IlvActivity activity)
-1
is returned.getParentActivityIndex
in interface IlvGanttModel
activity
- The implementation of this method uses IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate
activity
.-1
.IllegalArgumentException
- if activity
is not a member
of this data model.public int getChildActivityCount(IlvActivity parent)
getChildActivityCount
in interface IlvGanttModel
parent
- The implementation of this method uses IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate the
parent
.IllegalArgumentException
- if the parent
is not a member
of this data model.public IlvActivity getChildActivity(IlvActivity parent, int index)
index
.getChildActivity
in interface IlvGanttModel
parent
- The implementation of this method uses IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate the
parent
.index
- The child index.index
.IllegalArgumentException
- if the parent
is not a
member of this data model.IndexOutOfBoundsException
- if index
is out of range
(index < 0 || index >=
getChildActivityCount(parent)).public int getChildActivityIndex(IlvActivity parent, IlvActivity child)
getChildActivityIndex
in interface IlvGanttModel
parent
- The parent activity. The implementation of this method uses
IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to
validate the parent
.child
- The child activity to find the index of.-1
if the activity
is not a child of the parent
.IllegalArgumentException
- if the parent
is not a member
of this data model.public void addActivity(IlvActivity newActivity, IlvActivity parent, int index)
newActivity
as a child of the parent
activity at the specified location in its list of child activities.
The current child activity at index
and any subsequent
activities are shifted to the right by having their indices
incremented. After the activity has been added, the data model fires
an ActivitiesInsertedEvent
. As the
TableModel
does not allow insertion of rows, the activity
is added only if the activity model is of type IlvTableModel
.addActivity
in interface IlvGanttModel
newActivity
- The activity to add.parent
- The parent activity to which newActivity
is
added. The implementation of this method uses IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate
the parent
.index
- The location within the list of children of the parent
activity to insert the new activity. Note that this
information will not be stored in the
TableModel
and thus will not be
persistent. The order of the rows in the table model
will be used at launch time to index activities.
If index >= getChildActivityCount(parent)
then newActivity
is appended as the last
child of the parent
.IllegalArgumentException
- if newActivity
is
null
or parent
is not a member of this data model.IndexOutOfBoundsException
- if index
is out of range
(index < 0).ActivityHierarchyListener.activitiesInserted(ilog.views.gantt.event.ActivitiesInsertedEvent)
public void removeActivity(IlvActivity parent, int index)
ConstraintRemovedEvent
s and
ReservationRemovedEvent
s for each removed constraint and
reservation. The removingActivity
property of these
events is true
. Then, the data model fires an
ActivitiesRemovedEvent
. As the
TableModel
does not allow the removal of rows, the
activity is removed only if the activity model is of type
IlvTableModel
.removeActivity
in interface IlvGanttModel
parent
- The parent activity from which to remove the child activity.
The implementation of this method uses IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate the
parent
.index
- The location within the list of children of the parent
to remove the child activity.IllegalArgumentException
- if the parent is null
or is not a member of this data model.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >=
getChildActivityCount(parent)).ActivityHierarchyListener.activitiesRemoved(ilog.views.gantt.event.ActivitiesRemovedEvent)
public void removeActivity(IlvActivity activity)
ConstraintRemovedEvent
s and
ReservationRemovedEvent
s for each removed constraint and
reservation. The removingActivity
property of these
events is true
. Then, the data model fires an
ActivitiesRemovedEvent
.
This method cannot be used to remove the root activity of the data
model. As the TableModel
does not allow the removal of
rows, the activity isremoved only if the activity model is of type
IlvTableModel
.removeActivity
in interface IlvGanttModel
activity
- The activity to remove. It must be a member of this data
model, but cannot be the root activity. The implementation
of this method uses
IlvGanttModelUtil.checkValidNonRootMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate the activity before removing it.IllegalArgumentException
- if the activity is null
,
is not a member of this data model, or is
the root activity.ActivityHierarchyListener.activitiesRemoved(ilog.views.gantt.event.ActivitiesRemovedEvent)
public void moveActivity(IlvActivity activity, IlvActivity newParent, int newIndex)
ActivityMovedEvent
.moveActivity
in interface IlvGanttModel
activity
- The activity to move. It must be a member of this data
model, but cannot be the root activity. The implementation
of this method uses
IlvGanttModelUtil.checkValidNonRootMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate the activity.newParent
- The parent activity for which the activity
will be made a child. It must be a member of this data
model. The implementation of this method uses IlvGanttModelUtil.checkValidMemberActivity(ilog.views.gantt.IlvActivity, ilog.views.gantt.IlvGanttModel)
to validate
the newParent
.newIndex
- The location within the list of children of the
newParent
in which the activity
is inserted.
If newIndex >= getChildActivityCount(newParent)
then the activity
is appended as
the last child of the newParent
.IllegalArgumentException
- if the activity
is
null
, is not a member of
this data model, or is the root activity.
Also, if the newParent
is
not a member of this data model.IndexOutOfBoundsException
- if newIndex
is out of range
(newIndex < 0).ActivityHierarchyListener.activityMoved(ilog.views.gantt.event.ActivityMovedEvent)
public IlvResource getRootResource()
null
if the
data model contains no resources.getRootResource
in interface IlvGanttModel
null
.public void setRootResource(IlvResource root)
getResourcesTableModel()
.setRootResource
in interface IlvGanttModel
root
- The new root resource or null
if the data model
is to contain no resources.ResourceHierarchyListener.resourcesInserted(ilog.views.gantt.event.ResourcesInsertedEvent)
,
ResourceHierarchyListener.resourcesRemoved(ilog.views.gantt.event.ResourcesRemovedEvent)
public IlvResource getParentResource(IlvResource resource)
null
if the resource is the root resource of the data model.getParentResource
in interface IlvGanttModel
resource
- The resource. The implementation of this method uses
IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to
validate the resource
.null
.IllegalArgumentException
- if the resource
is not a
member of this data model.public int getParentResourceIndex(IlvResource resource)
-1
is returned.getParentResourceIndex
in interface IlvGanttModel
resource
- The resource. The implementation of this method uses IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to validate the
resource
.-1
.IllegalArgumentException
- if the resource
is not a
member of this data model.public int getChildResourceCount(IlvResource parent)
getChildResourceCount
in interface IlvGanttModel
parent
- The parent resource. The implementation of this method uses
IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to
validate the parent
.IllegalArgumentException
- if the parent
is not a member
of this data model.public IlvResource getChildResource(IlvResource parent, int index)
index
.getChildResource
in interface IlvGanttModel
parent
- The parent resource. The implementation of this method uses
IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to
validate parent
.index
- The child index.index
.IllegalArgumentException
- if the parent
is not a
member of this data model.IndexOutOfBoundsException
- if index
is out of range
(index < 0 || index >=
getChildResourceCount(parent)).public int getChildResourceIndex(IlvResource parent, IlvResource child)
getChildResourceIndex
in interface IlvGanttModel
parent
- The parent resource. The implementation of this method uses
IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to
validate the parent
.child
- The child resource to find the index of.-1
if the resource
is not a child of the parent
.IllegalArgumentException
- if the parent
is not a member
of this data model.public void addResource(IlvResource newResource, IlvResource parent, int index)
newResource
as a child of the parent
resource at the specified location in its list of child resources.
The current child resource to the index
.
Any subsequent resources are shifted to the right by having their
indices incremented. After the resource has been added, the data
model fires a ResourcesInsertedEvent
.
As the TableModel
does not allow the insertion of rows,
the resource is added only if the resource model is of type
IlvTableModel
.addResource
in interface IlvGanttModel
newResource
- The resource to add.parent
- The parent resource to which newResource
is
added. The implementation of this method uses IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to validate
parent
.index
- The location within the list of children of the parent
resource to insert the new resource. If index
>= parent.getChildCount()
then
newResource
is appended as the last child
of the parent
. Note that this information
will not be stored in the TableModel
and
thus will not be persistent. The order of the rows in
the table model will be used at launch time to index
resources.IllegalArgumentException
- if newResource
is
null
or the
parent
is not a member
of this data model.IndexOutOfBoundsException
- if index
is out of range
(index < 0).ResourceHierarchyListener.resourcesInserted(ilog.views.gantt.event.ResourcesInsertedEvent)
public void removeResource(IlvResource parent, int index)
ReservationRemovedEvent
s for each removed
reservation. The removingResource
property of these events is true
.
ResourcesRemovedEvent
.
TableModel
does not allow the removal of rows,
the resource is removed only if the resource model is of type
IlvTableModel
.removeResource
in interface IlvGanttModel
parent
- The parent resource from which to remove the child resource.
The implementation of this method uses IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to validate the
parent
.index
- The location within the list of children of the parent
to remove the child resource.IllegalArgumentException
- if the parent is null
or is not a member of this data model.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >=
getChildResourceCount(parent)).ResourceHierarchyListener.resourcesRemoved(ilog.views.gantt.event.ResourcesRemovedEvent)
public void removeResource(IlvResource resource)
ReservationRemovedEvent
s for each removed
reservation. The
removingResource
property of these events is
true
.ResourcesRemovedEvent
.
This method cannot be used to remove the root resource of the
data model.TableModel
does not allow the removal of rows,
the resource is removed only if the resource model is of type
IlvTableModel
.removeResource
in interface IlvGanttModel
resource
- The resource to remove. It must be a member of this data
model, but cannot be the root resource. The implementation
of this method uses
IlvGanttModelUtil.checkValidNonRootMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to validate the resource before removing it.IllegalArgumentException
- if the resource is
null
, is not a member of
this data model, or is the root resource.ResourceHierarchyListener.resourcesRemoved(ilog.views.gantt.event.ResourcesRemovedEvent)
public void moveResource(IlvResource resource, IlvResource newParent, int newIndex)
ResourceMovedEvent
.moveResource
in interface IlvGanttModel
resource
- The resource to move. It must be a member of this data
model, but cannot be the root resource.
The implementation of this method uses
IlvGanttModelUtil.checkValidNonRootMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to validate the resource.newParent
- The parent resource to which the resource
is
made a child. It must be a member of this data model. The
implementation of this method uses IlvGanttModelUtil.checkValidMemberResource(ilog.views.gantt.IlvResource, ilog.views.gantt.IlvGanttModel)
to validate
the newParent
.newIndex
- The location within the list of children of the
newParent
to which the resource
is inserted.
If newIndex >= getChildResourceCount(newParent)
then the resource
is appended as
the last child of the newParent
.IllegalArgumentException
- if the resource
is
null
, is not a member of
this data model, or is the root resource.
Also, if the newParent
is
not a member of this data model.IndexOutOfBoundsException
- if the newIndex
is out of
range (newIndex < 0).ResourceHierarchyListener.resourceMoved(ilog.views.gantt.event.ResourceMovedEvent)
public boolean contains(IlvConstraint constraint)
contains
in interface IlvGanttModel
constraint
- The constraint.public Iterator constraintIterator()
constraintIterator
in interface IlvGanttModel
public Iterator constraintIteratorFromActivity(IlvActivity fromActivity)
constraintIteratorFromActivity
in interface IlvGanttModel
fromActivity
- The from activity.public Iterator constraintIteratorToActivity(IlvActivity toActivity)
constraintIteratorToActivity
in interface IlvGanttModel
toActivity
- The to activity.public void addConstraint(IlvConstraint newConstraint)
newConstraint
to the data model.
The from and to activities of the constraint
must already be members of this data model.
After the constraint has been added, the data model fires a
ConstraintInsertedEvent
. As the
TableModel
does not allow the insertion of rows, the
constraint is added only if the constraint model is of type
IlvTableModel
.addConstraint
in interface IlvGanttModel
newConstraint
- The constraint to add. The implementation of this
method uses
IlvGanttModelUtil.checkValidNewConstraint(ilog.views.gantt.IlvConstraint, ilog.views.gantt.IlvGanttModel)
to validate the newConstraint
.IllegalArgumentException
- if the newConstraint
is
null
, is a member of a data
model already, or its constrained
activities are not members of this data
model.ConstraintListener.constraintChanged(ilog.views.gantt.event.ConstraintEvent)
public void removeConstraint(IlvConstraint constraint)
constraint
from the data model.
After the constraint has been removed, the data model fires a
ConstraintRemovedEvent
.
As the TableModel
does not allow the removal of rows,
the constraint is removed only if the constraint model is of type
IlvTableModel
.removeConstraint
in interface IlvGanttModel
constraint
- The constraint to remove. The implementation of this
method uses
IlvGanttModelUtil.checkValidMemberConstraint(ilog.views.gantt.IlvConstraint, ilog.views.gantt.IlvGanttModel)
to validate constraint
before removing it.IllegalArgumentException
- if the constraint
is
null
or is not a member of
this data model.ConstraintListener.constraintChanged(ilog.views.gantt.event.ConstraintEvent)
public boolean contains(IlvReservation reservation)
contains
in interface IlvGanttModel
reservation
- The reservation.public Iterator reservationIterator()
reservationIterator
in interface IlvGanttModel
public Iterator reservationIterator(IlvActivity activity)
reservationIterator
in interface IlvGanttModel
activity
- The activity.public Iterator reservationIterator(IlvResource resource)
reservationIterator
in interface IlvGanttModel
resource
- The resource.public Iterator reservationIterator(IlvResource resource, IlvTimeInterval interval)
interval
by evaluating
anActivity.getTimeInterval().overlaps(interval)
.reservationIterator
in interface IlvGanttModel
resource
- The resource.interval
- The activity time interval of interest.IlvActivity.getTimeInterval()
public void addReservation(IlvReservation newReservation)
newReservation
to the data model. The resource and
activity of the reservation must already be members of this data model.
After the reservation has been added, the data model fires a ReservationInsertedEvent
. As the
TableModel
does not allow the insertion of rows, the
reservation is added only if the reservation model is of type IlvTableModel
.addReservation
in interface IlvGanttModel
newReservation
- The reservation to add. The implementation of this
method uses
IlvGanttModelUtil.checkValidNewReservation(ilog.views.gantt.IlvReservation, ilog.views.gantt.IlvGanttModel)
to validate the newReservation
.IllegalArgumentException
- if the newReservation
is
null
, is a member of a data
model already, its resource is is not a
member of this data model, or its activity
is not a member of this data model.ReservationListener.reservationChanged(ilog.views.gantt.event.ReservationEvent)
public void removeReservation(IlvReservation reservation)
reservation
from the data model. After
the reservation has been removed, the data model fires a ReservationRemovedEvent
. As the TableModel
does not allow the
removal of rows, the reservation is removed only if the reservation model
is of type IlvTableModel
.removeReservation
in interface IlvGanttModel
reservation
- The reservation to remove. The implementation of this
method uses
IlvGanttModelUtil.checkValidMemberReservation(ilog.views.gantt.IlvReservation, ilog.views.gantt.IlvGanttModel)
to validate reservation
before removing
it.IllegalArgumentException
- if the reservation
is
null
or is not a member of
this data model.ReservationListener.reservationChanged(ilog.views.gantt.event.ReservationEvent)
public void fireReservationEvent(ReservationEvent event)
IlvAbstractGanttModel
so that when a ReservedResourceEvent
is fired, the data model updates its internal
hashtables with the new activity-to-resource mapping.
Warning: This method is considered to be part of
an IlvGanttModel
's internal implementation
and not a public API. You should only invoke this method directly
if you have created your own IlvReservation
implementation
that does not subclass
IlvAbstractReservation
.
fireReservationEvent
in interface IlvGanttModel
fireReservationEvent
in class IlvAbstractGanttModel
event
- The reservation event.ReservationListener.reservationChanged(ilog.views.gantt.event.ReservationEvent)
public void tableChanged(TableModelEvent e)
IlvTableGanttModel
listens to the changes on the
different TableModel
instances to forward row or cell
updates to the Gantt model.
This method must not be called directly.
In order to remove :
TableModelEvent
with type
TableModelEvent.DELETE
,TableModelEvent
with type
IlvTableModelEvent.BEFORE_DELETE
(possibly using IlvTableModelEvent.fireBeforeTableRowsDeleted(javax.swing.table.AbstractTableModel, int,
int)
).
For the Gantt model to be correctly updated with the structure
changes in the tables models, you must call the method
IlvTableModelEvent.fireBeforeTableStructureChanged(
javax.swing.table.AbstractTableModel)
on the given model, before the actual changes and the call to
AbstractTableModel.fireTableStructureChanged()
take
place.
For the Gantt model to be correctly updated with the full changes
in the table models, you must call the method
IlvTableModelEvent.fireBeforeTableDataChanged(
javax.swing.table.AbstractTableModel)
on the given model, before the actual changes and the call to
AbstractTableMode.fireTableDataChange()
take place.
All properties can be updated in the TableModel
instances except the ID property of activities and resources.
tableChanged
in interface TableModelListener
public static IlvTableModelMapper createActivityMapper(TableModel model, int id, int name, int startTime, int endTime, int parentID)
IlvTableModelMapper
that maps the different activity
properties to the specified column indexes.model
- The model to be mapped.id
- The column index for the id
property.name
- The column index for the name
property.startTime
- The column index for the startTime
property.endTime
- The column index for the endTime
property.parentID
- The column index for the parentID
property.public static IlvTableModelMapper createResourceMapper(TableModel model, int id, int name, int quantity, int parentID)
IlvTableModelMapper
that maps the different resource
properties to the specified column indexes.model
- The model to be mapped.id
- The column index for the id
property.name
- The column index for the name
property.quantity
- The column index for the quantity
property.parentID
- The column index for the parentID
property.public static IlvTableModelMapper createConstraintMapper(TableModel model, int fromActivityID, int toActivityID, int constraintType, Object[] typesMapping)
IlvTableModelMapper
that maps the different
constraint properties to the specified column indexes.model
- The model to be mapped.fromActivityID
- The column index for the from
ID
property.toActivityID
- The column index for the to
ID
property.constraintType
- The column index for the constraint type.typesMapping
- Contains the Object
s in the
TableModel
that will be represented in
the following order:
public static IlvTableModelMapper createReservationMapper(TableModel model, int activityID, int resourceID)
IlvTableModelMapper
that maps the different
properties to the specified column indexes.model
- The model to be mapped.activityID
- The column index for the activityID
property.resourceID
- The column index for the resourceID
property.public static IlvTableModelMapper createActivityMapper(TableModel model, String id, String name, String startTime, String endTime, String parentID)
IlvTableModelMapper
that maps the different
properties to the specified columns referenced by their names.model
- The model to be mapped.id
- The column names for the ID property.name
- The column name for the name
property.startTime
- The column name for the startTime
property.endTime
- The column name for the endTime
property.parentID
- The column name for the parentID
property.public static IlvTableModelMapper createResourceMapper(TableModel model, String id, String name, String quantity, String parentID)
IlvTableModelMapper
that maps the different
properties to the specified columns referenced by their names.model
- The model to be mapped.id
- The column name for the id
property.name
- The column name for the name
property.quantity
- The column name for the quantity
property.parentID
- The column name for the parentID
property.public static IlvTableModelMapper createConstraintMapper(TableModel model, String fromActivityID, String toActivityID, String constraintType, Object[] typesMapping)
IlvTableModelMapper
that maps the different
constraint properties to the specified column indexes.model
- The model to be mapped.fromActivityID
- The column name for the from
ID
property.toActivityID
- The column name for the to
ID property.constraintType
- The column name for the constraint type.typesMapping
- Contains the Object
s in the
TableModel
that are represented in the
following order:
public static IlvTableModelMapper createReservationMapper(TableModel model, String activityID, String resourceID)
IlvTableModelMapper
that maps the different
properties to the specified columns referenced by their names.model
- The model to be mapped.activityID
- The column name for the activityID
property.resourceID
- The column name for the resourceID
property.public static IlvTableModelMapper createActivityMapper(TableModel model, Map mapping)
IlvTableModelMapper
that maps the different
properties to the specified columns referenced by their names.model
- The model to be mapped.mapping
- A Map
filled with the association between the
IlvTableActivity
properties (such as IlvTableActivity.ID_PROPERTY
(keys) and column indexes
(Integer
) or names (String
) in the
JDBC query (values).public static IlvTableModelMapper createResourceMapper(TableModel model, Map mapping)
IlvTableModelMapper
that maps the different
properties to the specified columns referenced by their names.model
- The model to be mapped.mapping
- A Map
filled with the association between the
IlvTableResource
properties (such as IlvTableResource.ID_PROPERTY
(keys) and columns indexes
(Integer
) or names (String
) in the
JDBC query (values).public static IlvTableModelMapper createConstraintMapper(TableModel model, Map mapping, Object[] typesMapping)
IlvTableModelMapper
that maps the different
constraint properties to the specified column indexes.model
- The model to be mapped.mapping
- A Map
filled with the association between
the IlvTableConstraint
properties (such as
IlvTableConstraint.FROM_ACTIVITY_ID_PROPERTY
(keys) and columns indexes (Integer
) or
names (String
) in the JDBC query
(values).typesMapping
- Contains the Object
s in the
TableModel
that are represented in the
following order:
public static IlvTableModelMapper createReservationMapper(TableModel model, Map mapping)
IlvTableModelMapper
that maps the different
properties to the specified columns referenced by their names.model
- The model to be mapped.mapping
- A Map
filled with the association between the
IlvTableReservation
properties (such as IlvTableReservation.ACTIVITY_ID_PROPERTY
(keys) and columns
indexes (Integer
) or names (String
)
in the JDBC query (values).© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.