- // The next resource action
- private Action fNextResourceAction;
-
- // The previous resource action
- private Action fPreviousResourceAction;
-
- // The zoom thread
- private ZoomThread fZoomThread;
-
- // The redraw state used to prevent unnecessary queuing of display runnables
- private State fRedrawState = State.IDLE;
-
- // The redraw synchronization object
- final private Object fSyncObj = new Object();
-
- // ------------------------------------------------------------------------
- // Classes
- // ------------------------------------------------------------------------
-
- private class TraceEntry implements ITimeGraphEntry {
- // The Trace
- private final CtfKernelTrace fKernelTrace;
- // The start time
- private final long fTraceStartTime;
- // The end time
- private final long fTraceEndTime;
- // The children of the entry
- private final ArrayList<ResourcesEntry> fChildren;
- // The name of entry
- private final String fName;
-
- public TraceEntry(CtfKernelTrace trace, String name, long startTime, long endTime) {
- fKernelTrace = trace;
- fChildren = new ArrayList<ResourcesEntry>();
- fName = name;
- fTraceStartTime = startTime;
- fTraceEndTime = endTime;
- }
-
- @Override
- public ITimeGraphEntry getParent() {
- return null;
- }
-
- @Override
- public boolean hasChildren() {
- return fChildren != null && fChildren.size() > 0;
- }
-
- @Override
- public List<ResourcesEntry> getChildren() {
- return fChildren;
- }
-
- @Override
- public String getName() {
- return fName;
- }
-
- @Override
- public long getStartTime() {
- return fTraceStartTime;
- }
-
- @Override
- public long getEndTime() {
- return fTraceEndTime;
- }
-
- @Override
- public boolean hasTimeEvents() {
- return false;
- }
-
- @Override
- public Iterator<ITimeEvent> getTimeEventsIterator() {
- return null;
- }
-
- @Override
- public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
- return null;
- }
-
- public CtfKernelTrace getTrace() {
- return fKernelTrace;
- }
-
- public void addChild(ResourcesEntry entry) {
- int index;
- for (index = 0; index < fChildren.size(); index++) {
- ResourcesEntry other = fChildren.get(index);
- if (entry.getType().compareTo(other.getType()) < 0) {
- break;
- } else if (entry.getType().equals(other.getType())) {
- if (entry.getId() < other.getId()) {
- break;
- }
- }
- }
- entry.setParent(this);
- fChildren.add(index, entry);
- }
- }
-
- private static class TraceEntryComparator implements Comparator<ITimeGraphEntry> {
- @Override
- public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {
- int result = o1.getStartTime() < o2.getStartTime() ? -1 : o1.getStartTime() > o2.getStartTime() ? 1 : 0;
- if (result == 0) {
- result = o1.getName().compareTo(o2.getName());
- }
- return result;
- }
- }
-
- private class BuildThread extends Thread {
- private final ITmfTrace fBuildTrace;
- private final IProgressMonitor fMonitor;
-
- public BuildThread(ITmfTrace trace) {
- super("ResourcesView build"); //$NON-NLS-1$
- fBuildTrace = trace;
- fMonitor = new NullProgressMonitor();
- }
-
- @Override
- public void run() {
- buildEventList(fBuildTrace, fMonitor);
- synchronized (fBuildThreadMap) {
- fBuildThreadMap.remove(this);
- }
- }
-
- public void cancel() {
- fMonitor.setCanceled(true);
- }
- }
-
- private class ZoomThread extends Thread {
- private final ArrayList<TraceEntry> fZoomEntryList;
- private final long fZoomStartTime;
- private final long fZoomEndTime;
- private final IProgressMonitor fMonitor;
-
- public ZoomThread(ArrayList<TraceEntry> entryList, long startTime, long endTime) {
- super("ResourcesView zoom"); //$NON-NLS-1$
- fZoomEntryList = entryList;
- fZoomStartTime = startTime;
- fZoomEndTime = endTime;
- fMonitor = new NullProgressMonitor();
- }
-
- @Override
- public void run() {
- if (fZoomEntryList == null) {
- return;
- }
- long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
- for (TraceEntry traceEntry : fZoomEntryList) {
- if (!traceEntry.fKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID).waitUntilBuilt()) {
- return;
- }
- for (ITimeGraphEntry child : traceEntry.getChildren()) {
- if (fMonitor.isCanceled()) {
- break;
- }
- ResourcesEntry entry = (ResourcesEntry) child;
- if (fZoomStartTime <= fStartTime && fZoomEndTime >= fEndTime) {
- entry.setZoomedEventList(null);
- } else {
- List<ITimeEvent> zoomedEventList = getEventList(entry, fZoomStartTime, fZoomEndTime, resolution, true, fMonitor);
- if (zoomedEventList != null) {
- entry.setZoomedEventList(zoomedEventList);
- }
- }
- redraw();
- }
- }
- }
-
- public void cancel() {
- fMonitor.setCanceled(true);
- }
- }