Interacting with the Gantt sheet using the mouse
Explains how to use the mouse to create activity and reservation graphics in a Schedule chart or constraints in a Gantt chart.
Explains how to install the appropriate interactor to the Gantt sheet
Explains how to install the appropriate interactor to a Gantt sheet.
Explains how to enable and share pop-up menus in a Gantt sheet.
Creating activities and reservations
To create activity and reservation graphics by using the mouse in a Schedule chart, you must install the appropriate interactor to the Gantt sheet.
To install the appropriate interactor:
2. Attach this interactor to the Gantt sheet by calling the
pushInteractor method of the Gantt sheet.
Once the interactor is installed, you can create an activity or a reservation by drawing a rectangle in the Gantt sheet. The interactor first creates a new instance of
IlvActivity and then assigns the new activity to the resource where you clicked by creating a new instance of
IlvReservation.
To create the new activity or reservation, the interactor uses the activity factory or the reservation factory registered with the Gantt sheet. See the methods
getActivityFactory and the
getReservationFactory of the
IlvGanttSheet class.
Creating constraints
In a Gantt chart, you can create constraints using the mouse. To do so, you must install the appropriate interactor to the Gantt sheet:
2. Attach the interactor to the Gantt sheet by calling the
pushInteractor method of the Gantt sheet.
Once the interactor is installed, you can use it to create
IlvConstraint objects.
3. Click the source activity graphic (also called
From activity).
Click the left end or right end depending on whether you want to constrain the start time or the end time of the source activity. When you move the mouse, a “ghost” line follows the pointer.
4. Click the target activity graphic (also called
To activity).
Click the left end or right end depending on whether you want to link the source activity to the start time or the end time of the target activity. As soon as you release the mouse button, the arrowed polyline link representing the constraint appears between the two activities.
To create constraints, the interactor uses the constraint factory registered with the Gantt sheet. See the
getConstraintFactory method of the class Gantt sheet.
Pop-up menus
Pop-up menu support in a Gantt sheet is based on the pop-up menu support in Rogue Wave® JViews. For information in pop-up menu support, see Tooltips and pop-up menus on graphic objects in The Essential Rogue Wave® JViews Framework.
To set up pop-up support in your application:
1. Call the following code to enable pop-up menus in a Gantt sheet:
IlvGanttSheet.setPopupMenusEnabled(true) :
2. Create a JPopupMenu object and link it to the graphic in order to associate a specific pop-up menu with an activity graphic or a constraint.
activityGraphic.setPopupMenu(activityMenu);
constraintGraphic.setPopupMenu(constraintMenu);
After the pop-up menu is registered, whenever a user right-clicks the graphic, its pop-up menu appears.
3. Share pop-up menus among multiple graphic objects.
Pop-up menus use a lot of memory. To avoid wasting memory, instead of registering a pop-up menu with an individual graphic using graphic.setPopupMenu(...), register the pop-up menu directly with the pop-up menu manager by calling:
IlvPopupMenuManager.registerMenu("ActivityPopupMenu ", activityMenu);
IlvPopupMenuManager.registerMenu("ConstraintPopupMenu ", constraintMenu);
4. Assign this pop-up menu to the graphic renderer:
graphicRenderer1.setPopupMenuName("ActivityPopupMenu ");
graphicRenderer2.setPopupMenuName("ActivityPopupMenu ");
constraintGraphic.setPopupMenuName("ConstraintPopupMenu ");
5. Associate an action listener with pop-up menu items to know which graphic object triggered the event.
public void actionPerformed(ActionEvent e) {
// retrieve the selected menu item
JMenuItem m = (JMenuItem) e.getSource();
// retrieve the graphic that has this popup menu
IlvPopupMenuContext context = IlvPopupMenuManager.getPopupMenuContext(m);
if (context == null
|| !(context instanceof IlvPopupMenuActivityContext)) {
return;
}
IlvPopupMenuActivityContext activityContext = (IlvPopupMenuActivityContext) context;
// retrieve the activity of the graphic
IlvGeneralActivity activity = (IlvGeneralActivity) activityContext.getActivity();
//Do the action on this activity for this view.
}
For information on pop-up menus, see
IlvPopupMenuContext and
IlvPopupMenuManager in the Java API Reference Manual.
IlvSimplePopupMenu is a subclass of
JPopupMenu that allows you to configure pop-up menus easily. For information on configuring pop-up menus, see
IlvSimplePopupMenu.
A sample that illustrates how to use pop-up menus with names defined in a CSS file can be found at:
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.