GanttEvents from GanntChart? [message #1072769] |
Tue, 23 July 2013 13:08  |
Eclipse User |
|
|
|
I have created a GanttChart populating it with Events and I want now to access the events. How do I do that?
I am starting to work with the GanntChart widget and the fact is that I think is wonderfully programmed. Very well encapsulated! (dependencies with other stuff, such as SWT, etc.), which I think in Eclipse world is quite difficult. Chapeau.
I however don't find a way to access the events that I've already added to a GanttChart.
I would like something like "ganttchart.getEvents(): list" (or through the GanttComposite)
Can't it be done? Should I keep an copy of the events?
The main goal I want right now, is adding the connections after I've already created the Chart and added the events.
PS. BTW, I think it would be interesting to synchonise names with Project Scheduling field. A more appropriate name for what MS-Project calls "Tasks" and GanttChart calls "Event" is "Activity" -although everybody understands "Task" as well". Events is usually understood as something punctual (no duration), normally identified with a milestone.
|
|
|
|
Re: GanttEvents from GanntChart? [message #1075492 is a reply to message #1075349] |
Mon, 29 July 2013 14:19   |
Eclipse User |
|
|
|
Hi, thanks Dirk,
yes I am using that way 
The problem comes by the fact that there is no direct access to an Event whose Content is X. I have to go through the list in order to look for it.
There is no myGantt.getEvent( Data data ), right?
Since a Data element has already been set, it would be nice if Gantt saves an inverse relation, to accesses it efficiently.
I know I can do it externally... but it seemed so common that maybe is already encapsulated inside GanttChart library.
Thinking about my particular case, from the model, for each task, I get their successors and in the Gantt I add the link from this Event to each of the Successors; for this last part I need to find the Event which contains the successor Task object.
/***
* setLinks adds the connections among different Events.
* It assumes:
* - m_ganttchart has been created
* - has the events set
* - the events contains the Data (Task).
*/
private void setLinks()
{
System.out.println("*** setLinks\n");
GanttComposite ganttcomposite = m_ganttchart.getGanttComposite();
GanttEvent[] ganttevents = (GanttEvent[]) ganttcomposite.getEvents().toArray( new GanttEvent[0] );
//
// Checks all events in order to see which ones has a task with successors
//
for( GanttEvent gantteventSource: ganttevents ){
Task task = (Task) gantteventSource.getData();
printlnTask( task );
//
// For Each successor connection is added.
//
List<Relation> listrelationSuccessors = task.getSuccessors();
if( listrelationSuccessors==null )
continue;
Relation[] relationsSuccessors = listrelationSuccessors.toArray( new Relation[0]);
for( Relation relationSuccessor: relationsSuccessors ){
Task taskSuccessor = relationSuccessor.getTargetTask();
GanttEvent gantteventSuccessor = findEvent( taskSuccessor ); // efficientcy depends on findEvent
if( gantteventSuccessor!=null){
m_ganttchart.addConnection( gantteventSource, gantteventSuccessor );
} else {
// TODO: Control this error with an exception. Tasks says there is a successor but event doesn't have it
System.out.println("TODO: There is a problem. Tasks says there is a successor but event doesn't have it");
}//- else
}//- for taskSuccessors
}//- for ganttevenSource
}//- setLinks
/***
* finEvent finds the Event containing the Task given. assummes there is only one.
*
* @param task for wich we want the graphical event.
* @return the Event containing the task or null
*/
private GanttEvent findEvent( Task task )
{
...
}
Thanks for your help.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02971 seconds