| | | | Browse by category |
Question
How can I disable movements and other interactions of reservations on an IlvScheduleChart or activities on an IlvGanttChart?
Answer
Each IlvHierarchyChart
contains an IlvGanttSheet
that is responsible for displaying the activities, constraints, and reservations as well as handling the interactions/events on the view. You can obtain the Gantt sheet instance by calling the getGanttSheet()
method of the chart. You can then disable all user-interactions on the Gantt sheet by calling its removeAllInteractors()
method (this method is defined at the IlvManagerView
class level).
For example:
IlvHierarchyChart myChart = ... (a gantt or schedule chart) ...
myChart.getGanttSheet().removeAllInteractors();
If instead you want to preserve interactive selection of activities within the Gantt sheet, but disable moving, resizing, and reservation copying, you can customize the selection interactor like this:
IlvGanttSelectInteractor selectInteractor = new IlvGanttSelectInteractor();
selectInteractor.setMoveAllowed(false); // prevents moving activities
selectInteractor.setEditionAllowed(false); // prevents resizing activities
selectInteractor.setDuplicationAllowed(false); // prevents copying reservations in a Schedule chart
myChart.getGanttSheet().setInteractor(selectInteractor);
If you want to manage the interactions independently on specific activities within the Gantt sheet, you can set the selectable, movable, and editable properties of the IlvActivityGraphic
within the Gantt sheet's IlvManager
. Note, that the Gantt sheet is a type of IlvManagerView
. The selectable property of a graphic controls whether it can be selected, the movable property controls whether it can be interactively dragged or moved, and the editable property controls whether the graphic can be interactively resized or reshaped.
If you want to control the editability of individual activities based upon the value of one of their properties, here is a general outline:
- Before any Gantt data model is bound to the chart, register a
ManagerContentChangedListener
on the manager of the Gantt sheet and anActivityListener
on the data model. - In the event handler, watch for when
IlvActivityGraphics
are added to the sheet and when the relevant property value changes. - At this point, update the activity graphic's editable property by calling
ganttSheet.getManager().setEditable(activityGraphic, ...)
See the attached sample, at the bottom of thsi page, that illustrates how to allow only activities whose names begin with the letters A-M to be edited (check the creation of the ActivityNameFilter
).
You can also disable editing within the table by removing the cell editor from each of its columns like this:
IlvJTable table = myChart.getTable();for (int i = 0; i < table.getColumnCount(); i++) {
table.getColumn(i).setCellEditor(null);
}