Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » GanttEvents from GanntChart?(I have created a GanttChart populating it with Events and I want now to access the events. How do I do that?)
GanttEvents from GanntChart? [message #1072769] Tue, 23 July 2013 13:08 Go to next message
Luis Fernando Robledano-Esteban is currently offline Luis Fernando Robledano-Esteban
Messages: 30
Registered: February 2013
Member
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.


ArkosX
Re: GanttEvents from GanntChart? [message #1075349 is a reply to message #1072769] Mon, 29 July 2013 09:14 Go to previous messageGo to next message
Dirk Fauth is currently online Dirk Fauth
Messages: 1335
Registered: July 2012
Senior Member
Why don't you do it then using the following code?

for (Object eventObject : myGantt.getGanttComposite().getEvents()) {
	GanttEvent event = (GanttEvent) eventObject;
}


The API exists.
Re: GanttEvents from GanntChart? [message #1075492 is a reply to message #1075349] Mon, 29 July 2013 14:19 Go to previous messageGo to next message
Luis Fernando Robledano-Esteban is currently offline Luis Fernando Robledano-Esteban
Messages: 30
Registered: February 2013
Member
Hi, thanks Dirk,
yes I am using that way Smile
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.


ArkosX
Re: GanttEvents from GanntChart? [message #1075527 is a reply to message #1075492] Mon, 29 July 2013 15:30 Go to previous message
Dirk Fauth is currently online Dirk Fauth
Messages: 1335
Registered: July 2012
Senior Member
Well as there is no MUST to add data to an event, there is no such convenience API to retrieve an event by data. At least that is my understanding.
Previous Topic:how to move up/down the row
Next Topic: NoClassDefFoundError when creating PageableTable in RAP appliction
Goto Forum:
  


Current Time: Tue Oct 21 07:16:06 GMT 2014

Powered by FUDForum. Page generated in 0.01681 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software