/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2012, 2014 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* An entry for use in the time graph views
private TimeGraphEntry fParent = null;
/** List of child entries */
- private final List<TimeGraphEntry> fChildren = new ArrayList<>();
+ private final List<TimeGraphEntry> fChildren = new CopyOnWriteArrayList<>();
/** Name of this entry (text to show) */
private String fName;
return fEndTime;
}
+ /**
+ * Updates the end time
+ *
+ * @param endTime
+ * the end time
+ *
+ * @since 3.0
+ */
+ public void updateEndTime(long endTime) {
+ fEndTime = Math.max(endTime, fEndTime);
+ }
+
@Override
public boolean hasTimeEvents() {
return true;
/**
* Add an event to this entry's event list. If necessary, update the start
- * and end time of the entry.
+ * and end time of the entry. If the event list's last event starts at the
+ * same time as the event to add, it is replaced by the new event.
*
* @param event
- * The time event
+ * The time event to add
*/
public void addEvent(ITimeEvent event) {
long start = event.getTime();
long end = start + event.getDuration();
synchronized (fEventList) {
- fEventList.add(event);
+ int lastIndex = fEventList.size() - 1;
+ if (lastIndex >= 0 && fEventList.get(lastIndex).getTime() == event.getTime()) {
+ fEventList.set(lastIndex, event);
+ } else {
+ fEventList.add(event);
+ }
if (fStartTime == -1 || start < fStartTime) {
fStartTime = start;
}