Fix ArrayIndexOutOfBoundsException for sync signals (Bug 391716)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / loader / TmfUml2SDSyncLoader.java
1 /**********************************************************************
2 * Copyright (c) 2011, 2012 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader;
13
14 import java.util.ArrayList;
15 import java.util.HashMap;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.concurrent.CopyOnWriteArrayList;
19 import java.util.concurrent.locks.ReentrantLock;
20
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.core.runtime.IStatus;
23 import org.eclipse.core.runtime.Status;
24 import org.eclipse.core.runtime.jobs.Job;
25 import org.eclipse.jface.viewers.ISelection;
26 import org.eclipse.jface.viewers.StructuredSelection;
27 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
28 import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
29 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
30 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
31 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
32 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
33 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
34 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
35 import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
36 import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
37 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
38 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
39 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
40 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
41 import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
42 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
43 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
44 import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
45 import org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent;
46 import org.eclipse.linuxtools.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent;
47 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
48 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
49 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
50 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
51 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
52 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterCriteria;
53 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterListDialog;
54 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider;
55 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
56 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFindProvider;
57 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
58 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
59 import org.eclipse.swt.widgets.Display;
60 import org.eclipse.ui.ISelectionListener;
61 import org.eclipse.ui.IWorkbenchPart;
62 import org.eclipse.ui.IWorkbenchWindow;
63 import org.eclipse.ui.PlatformUI;
64 import org.eclipse.ui.progress.IProgressConstants;
65
66 /**
67 * <p>
68 * This class is a reference implementation of the
69 * <code>org.eclipse.linuxtools.tmf.ui.Uml2SDLoader</code> extension point. It
70 * provides a Sequence Diagram loader for a user space trace with specific trace
71 * content for sending and receiving signals between components. I also includes
72 * a default implementation for the <code>ITmfEvent</code> parsing.
73 * </p>
74 *
75 * The class <code>TmfUml2SDSyncLoader</code> analyzes events from type
76 * <code>ITmfEvent</code> and creates events type
77 * <code>ITmfSyncSequenceDiagramEvent</code> if the <code>ITmfEvent</code>
78 * contains all relevant information. The analysis checks that the event type
79 * strings contains either string SEND or RECEIVE. If event type matches these
80 * key words, the analyzer will look for strings sender, receiver and signal in
81 * the event fields of type <code>ITmfEventField</code>. If all the data is
82 * found a sequence diagram event from can be created. Note that Sync Messages
83 * are assumed, which means start and end time are the same. <br>
84 * <br>
85 * The parsing of the <code>ITmfEvent</code> is done in the method
86 * <code>getSequnceDiagramEvent()</code> of class
87 * <code>TmfUml2SDSyncLoader</code>. By extending the class
88 * <code>TmfUml2SDSyncLoader</code> and overwriting
89 * <code>getSequnceDiagramEvent()</code> a customized parsing algorithm can be
90 * implemented.<br>
91 * <br>
92 * Note that combined traces of multiple components, that contain the trace
93 * information about the same interactions are not supported in the class
94 * <code>TmfUml2SDSyncLoader</code>.
95 *
96 * @version 1.0
97 * @author Bernd Hufmann
98 */
99 public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader, ISDFindProvider, ISDFilterProvider, ISDAdvancedPagingProvider, ISelectionListener {
100
101 // ------------------------------------------------------------------------
102 // Constants
103 // ------------------------------------------------------------------------
104 /**
105 * Default title name.
106 */
107 protected final static String TITLE = Messages.TmfUml2SDSyncLoader_ViewName;
108 /**
109 * Default block size for background request.
110 */
111 protected final static int DEFAULT_BLOCK_SIZE = 50000;
112 /**
113 * Maximum number of messages per page.
114 */
115 protected final static int MAX_NUM_OF_MSG = 10000;
116 /**
117 * Initial time range window.
118 */
119 protected final static long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec
120
121 // ------------------------------------------------------------------------
122 // Attributes
123 // ------------------------------------------------------------------------
124
125 // Experiment attributes
126 /**
127 * The TMF experiment reference.
128 */
129 protected TmfExperiment<ITmfEvent> fExperiment = null;
130 /**
131 * The current indexing event request.
132 */
133 protected ITmfEventRequest<ITmfEvent> fIndexRequest = null;
134 /**
135 * The current request to fill a page.
136 */
137 protected ITmfEventRequest<ITmfEvent> fPageRequest = null;
138 /**
139 * Flag whether the time range signal was sent by this loader class or not
140 */
141 volatile protected boolean fIsSignalSent = false;
142 /**
143 * The initial request window size.
144 */
145 volatile protected long fInitialWindow = INITIAL_WINDOW_OFFSET;
146
147 // The view and event attributes
148 /**
149 * The sequence diagram view reference.
150 */
151 protected SDView fView = null;
152 /**
153 * The current sequence diagram frame reference.
154 */
155 protected Frame fFrame = null;
156 /**
157 * The list of sequence diagram events of current page.
158 */
159 protected List<ITmfSyncSequenceDiagramEvent> fEvents = new ArrayList<ITmfSyncSequenceDiagramEvent>();
160
161 // Checkpoint and page attributes
162 /**
163 * The checkpoints of the whole sequence diagram trace (i.e. start time stamp of each page)
164 */
165 protected List<TmfTimeRange> fCheckPoints = new ArrayList<TmfTimeRange>(MAX_NUM_OF_MSG);
166 /**
167 * The current page displayed.
168 */
169 volatile protected int fCurrentPage = 0;
170 /**
171 * The current time selected.
172 */
173 protected ITmfTimestamp fCurrentTime = null;
174 /**
175 * Flag to specify that selection of message is done by selection or by signal.
176 */
177 volatile protected boolean fIsSelect = false;
178
179 // Search attributes
180 /**
181 * The job for searching across pages.
182 */
183 protected SearchJob fFindJob = null;
184 /**
185 * List of found nodes within a page.
186 */
187 protected List<GraphNode> fFindResults = new ArrayList<GraphNode>();
188 /**
189 * The current find criteria reference
190 */
191 protected Criteria fFindCriteria = null;
192 /**
193 * The current find index within the list of found nodes (<code>fFindeResults</code> within a page.
194 */
195 volatile protected int fCurrentFindIndex = 0;
196
197 // Filter attributes
198 /**
199 * The list of active filters.
200 */
201 protected List<FilterCriteria> fFilterCriteria = null;
202
203 // Thread synchronization
204 /**
205 * The synchronization lock.
206 */
207 protected ReentrantLock fLock = new ReentrantLock();
208
209 // ------------------------------------------------------------------------
210 // Constructors
211 // ------------------------------------------------------------------------
212 /**
213 * Default constructor
214 */
215 public TmfUml2SDSyncLoader() {
216 super(TITLE);
217 }
218
219 /**
220 * Constructor
221 *
222 * @param name Name of loader
223 */
224 public TmfUml2SDSyncLoader(String name) {
225 super(name);
226 }
227
228 // ------------------------------------------------------------------------
229 // Operations
230 // ------------------------------------------------------------------------
231 /**
232 * Returns the current time if available else null.
233 *
234 * @return the current time if available else null
235 */
236 public ITmfTimestamp getCurrentTime() {
237 fLock.lock();
238 try {
239 if (fCurrentTime != null) {
240 return fCurrentTime.clone();
241 }
242 return null;
243 } finally {
244 fLock.unlock();
245 }
246 }
247
248 /**
249 * Waits for the page request to be completed
250 */
251 public void waitForCompletion() {
252 fLock.lock();
253 ITmfEventRequest<ITmfEvent> request = fPageRequest;
254 fLock.unlock();
255 if (request != null) {
256 try {
257 request.waitForCompletion();
258 } catch (InterruptedException e) {
259 // ignore
260 }
261 }
262 }
263
264 /**
265 * Signal handler for the experiment selected signal.
266 *
267 * Spawns a request to index the experiment (checkpoints creation) as well as it fills
268 * the first page.
269 *
270 * @param signal The experiment selected signal
271 */
272 @TmfSignalHandler
273 public void experimentSelected(TmfExperimentSelectedSignal<ITmfEvent> signal) {
274
275 final Job job = new IndexingJob("Indexing " + getName() + "..."); //$NON-NLS-1$ //$NON-NLS-2$
276 job.setUser(false);
277 job.schedule();
278
279 fLock.lock();
280 try {
281 // Update the trace reference
282 TmfExperiment<ITmfEvent> exp = (TmfExperiment<ITmfEvent>) signal.getExperiment();
283 if (!exp.equals(fExperiment)) {
284 fExperiment = exp;
285 }
286
287 TmfTimeRange window = TmfTimeRange.ETERNITY;
288
289 fIndexRequest = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) {
290
291 private ITmfTimestamp fFirstTime = null;
292 private ITmfTimestamp fLastTime = null;
293 private int fNbSeqEvents = 0;
294 private final List<ITmfSyncSequenceDiagramEvent> fSdEvents = new ArrayList<ITmfSyncSequenceDiagramEvent>(MAX_NUM_OF_MSG);
295
296 /*
297 * (non-Javadoc)
298 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
299 */
300 @Override
301 public void handleData(ITmfEvent event) {
302 super.handleData(event);
303
304 ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
305
306 if (sdEvent != null) {
307 ++fNbSeqEvents;
308
309 if (fFirstTime == null) {
310 fFirstTime = event.getTimestamp().clone();
311 }
312
313 fLastTime = event.getTimestamp().clone();
314
315 if ((fNbSeqEvents % MAX_NUM_OF_MSG) == 0) {
316 fLock.lock();
317 try {
318 fCheckPoints.add(new TmfTimeRange(fFirstTime, fLastTime));
319 if (fView != null) {
320 fView.updateCoolBar();
321 }
322 } finally {
323 fLock.unlock();
324 }
325 fFirstTime = null;
326
327 }
328
329 if (fNbSeqEvents > MAX_NUM_OF_MSG) {
330 // page is full
331 return;
332 }
333
334 fSdEvents.add(sdEvent);
335
336 if (fNbSeqEvents == MAX_NUM_OF_MSG) {
337 fillCurrentPage(fSdEvents);
338 }
339 }
340 }
341
342 /*
343 * (non-Javadoc)
344 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleSuccess()
345 */
346 @Override
347 public void handleSuccess() {
348 if ((fFirstTime != null) && (fLastTime != null)) {
349
350 fLock.lock();
351 try {
352 fCheckPoints.add(new TmfTimeRange(fFirstTime, fLastTime));
353 if (fView != null) {
354 fView.updateCoolBar();
355 }
356 } finally {
357 fLock.unlock();
358 }
359 }
360
361 if (fNbSeqEvents <= MAX_NUM_OF_MSG) {
362 fillCurrentPage(fSdEvents);
363 }
364
365 super.handleSuccess();
366 }
367
368 /*
369 * (non-Javadoc)
370 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
371 */
372 @Override
373 public void handleCompleted() {
374 if (fEvents.isEmpty()) {
375 fFrame = new Frame();
376 fView.setFrameSync(fFrame);
377 }
378 super.handleCompleted();
379 job.cancel();
380 }
381 };
382
383 fExperiment.sendRequest(fIndexRequest);
384 } finally {
385 fLock.unlock();
386 }
387
388 }
389
390 /**
391 * Signal handler for the experiment disposed signal.
392 *
393 * @param signal The experiment disposed signal
394 */
395 @TmfSignalHandler
396 public void experimentDisposed(TmfExperimentDisposedSignal<ITmfEvent> signal) {
397 if (signal.getExperiment() != TmfExperiment.getCurrentExperiment()) {
398 return;
399 }
400 fLock.lock();
401 try {
402 if ((fIndexRequest != null) && !fIndexRequest.isCompleted()) {
403 fIndexRequest.cancel();
404 fIndexRequest = null;
405 }
406
407 cancelOngoingRequests();
408
409 if (fFilterCriteria != null) {
410 fFilterCriteria.clear();
411 }
412
413 FilterListDialog.deactivateSavedGlobalFilters();
414
415 resetLoader();
416 } finally {
417 fLock.unlock();
418 }
419 }
420
421 /**
422 * Moves to the page that contains the time provided by the signal. The messages will be selected
423 * if the provided time is the time of a message.
424 *
425 * @param signal The Time synch signal.
426 */
427 @TmfSignalHandler
428 public void synchToTime(TmfTimeSynchSignal signal) {
429 fLock.lock();
430 try {
431 if ((signal.getSource() != this) && (fFrame != null) && (fCheckPoints.size() > 0)) {
432 fCurrentTime = signal.getCurrentTime();
433 fIsSelect = true;
434 moveToMessage();
435 }
436 } finally {
437 fLock.unlock();
438 }
439 }
440
441 /**
442 * Moves to the page that contains the current time provided by signal.
443 * No message will be selected however the focus will be set to the message
444 * if the provided time is the time of a message.
445 *
446 * @param signal The time range sync signal
447 */
448 @TmfSignalHandler
449 public void synchToTimeRange(TmfRangeSynchSignal signal) {
450 fLock.lock();
451 try {
452 if ((signal.getSource() != this) && (fFrame != null) && !fIsSignalSent && (fCheckPoints.size() > 0)) {
453 TmfTimeRange newTimeRange = signal.getCurrentRange();
454 ITmfTimestamp delta = newTimeRange.getEndTime().getDelta(newTimeRange.getStartTime());
455 fInitialWindow = delta.getValue();
456
457 fIsSelect = false;
458 fCurrentTime = newTimeRange.getStartTime();
459
460 moveToMessage();
461 }
462 } finally {
463 fLock.unlock();
464 }
465
466 }
467
468 /*
469 * (non-Javadoc)
470 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
471 */
472 @Override
473 public void setViewer(SDView viewer) {
474
475 fLock.lock();
476 try {
477 fView = viewer;
478 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
479 fView.setSDFindProvider(this);
480 fView.setSDPagingProvider(this);
481 fView.setSDFilterProvider(this);
482
483 resetLoader();
484
485 fExperiment = (TmfExperiment<ITmfEvent>) TmfExperiment.getCurrentExperiment();
486 if (fExperiment != null) {
487 experimentSelected(new TmfExperimentSelectedSignal<ITmfEvent>(this, fExperiment));
488 }
489 } finally {
490 fLock.unlock();
491 }
492 }
493
494 /*
495 * (non-Javadoc)
496 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
497 */
498 @Override
499 public String getTitleString() {
500 return getName();
501 }
502
503 /*
504 * (non-Javadoc)
505 * @see org.eclipse.linuxtools.tmf.component.TmfComponent#dispose()
506 */
507 @Override
508 public void dispose() {
509 super.dispose();
510 fLock.lock();
511 try {
512 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
513 // During Eclipse shutdown the active workbench window is null
514 if (window != null) {
515 window.getSelectionService().removePostSelectionListener(this);
516 }
517 fView.setSDFindProvider(null);
518 fView.setSDPagingProvider(null);
519 fView.setSDFilterProvider(null);
520 fView = null;
521 } finally {
522 fLock.unlock();
523 }
524 }
525
526 /*
527 * (non-Javadoc)
528 * @see org.eclipse.hyades.uml2sd.ui.actions.provider.ISDGraphNodeSupporter#isNodeSupported(int)
529 */
530 @Override
531 public boolean isNodeSupported(int nodeType) {
532 switch (nodeType) {
533 case ISDGraphNodeSupporter.LIFELINE:
534 case ISDGraphNodeSupporter.SYNCMESSAGE:
535 return true;
536
537 default:
538 break;
539 }
540 return false;
541 }
542
543 /*
544 * (non-Javadoc)
545 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter#getNodeName(int, java.lang.String)
546 */
547 @Override
548 public String getNodeName(int nodeType, String loaderClassName) {
549 switch (nodeType) {
550 case ISDGraphNodeSupporter.LIFELINE:
551 return Messages.TmfUml2SDSyncLoader_CategoryLifeline;
552 case ISDGraphNodeSupporter.SYNCMESSAGE:
553 return Messages.TmfUml2SDSyncLoader_CategoryMessage;
554 default:
555 break;
556 }
557 return ""; //$NON-NLS-1$
558 }
559
560 /*
561 * (non-Javadoc)
562 * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
563 */
564 @Override
565 public void selectionChanged(IWorkbenchPart part, ISelection selection) {
566 ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
567 if ((sel != null) && (sel instanceof StructuredSelection)) {
568 StructuredSelection stSel = (StructuredSelection) sel;
569 if (stSel.getFirstElement() instanceof TmfSyncMessage) {
570 TmfSyncMessage syncMsg = ((TmfSyncMessage) stSel.getFirstElement());
571 broadcast(new TmfTimeSynchSignal(this, syncMsg.getStartTime()));
572 }
573 }
574 }
575
576 /*
577 * (non-Javadoc)
578 * @see
579 * org.eclipse.hyades.uml2sd.ui.actions.provider.ISDFindProvider#find(org.eclipse.hyades.uml2sd.ui.actions.widgets.Criteria)
580 */
581 @Override
582 public boolean find(Criteria toSearch) {
583 fLock.lock();
584 try {
585 if (fFrame == null) {
586 return false;
587 }
588
589 if ((fFindResults == null) || (fFindCriteria == null) || !fFindCriteria.compareTo(toSearch)) {
590 fFindResults = new CopyOnWriteArrayList<GraphNode>();
591 fFindCriteria = toSearch;
592 if (fFindCriteria.isLifeLineSelected()) {
593 for (int i = 0; i < fFrame.lifeLinesCount(); i++) {
594 if (fFindCriteria.matches(fFrame.getLifeline(i).getName())) {
595 fFindResults.add(fFrame.getLifeline(i));
596 }
597 }
598 }
599
600 ArrayList<GraphNode> msgs = new ArrayList<GraphNode>();
601 if (fFindCriteria.isSyncMessageSelected()) {
602 for (int i = 0; i < fFrame.syncMessageCount(); i++) {
603 if (fFindCriteria.matches(fFrame.getSyncMessage(i).getName())) {
604 msgs.add(fFrame.getSyncMessage(i));
605 }
606 }
607 }
608
609 if (!msgs.isEmpty()) {
610 fFindResults.addAll(msgs);
611 }
612
613 @SuppressWarnings("rawtypes")
614 List selection = fView.getSDWidget().getSelection();
615 if ((selection != null) && (selection.size() == 1)) {
616 fCurrentFindIndex = fFindResults.indexOf(selection.get(0)) + 1;
617 } else {
618 fCurrentFindIndex = 0;
619 }
620 } else {
621 fCurrentFindIndex++;
622 }
623
624 if (fFindResults.size() > fCurrentFindIndex) {
625 GraphNode current = fFindResults.get(fCurrentFindIndex);
626 fView.getSDWidget().moveTo(current);
627 return true;
628 }
629 fFindResults = null;
630 fCurrentFindIndex =0;
631 return findInNextPages(fFindCriteria); // search in other page
632 } finally {
633 fLock.unlock();
634 }
635 }
636
637 /*
638 * (non-Javadoc)
639 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFindProvider#cancel()
640 */
641 @Override
642 public void cancel() {
643 cancelOngoingRequests();
644 }
645
646 /*
647 * (non-Javadoc)
648 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider#filter(java.util.List)
649 */
650 @SuppressWarnings("unchecked")
651 @Override
652 public boolean filter(List<?> filters) {
653 fLock.lock();
654 try {
655 cancelOngoingRequests();
656
657 List<FilterCriteria> list = (List<FilterCriteria>)filters;
658 fFilterCriteria = new ArrayList<FilterCriteria>(list);
659
660 fillCurrentPage(fEvents);
661
662 } finally {
663 fLock.unlock();
664 }
665 return true;
666 }
667
668 /*
669 * (non-Javadoc)
670 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider#hasNextPage()
671 */
672 @Override
673 public boolean hasNextPage() {
674 fLock.lock();
675 try {
676 int size = fCheckPoints.size();
677 if (size > 0) {
678 return fCurrentPage < (size - 1);
679 }
680 } finally {
681 fLock.unlock();
682 }
683 return false;
684 }
685
686 /*
687 * (non-Javadoc)
688 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider#hasPrevPage()
689 */
690 @Override
691 public boolean hasPrevPage() {
692 fLock.lock();
693 try {
694 return fCurrentPage > 0;
695 } finally {
696 fLock.unlock();
697 }
698 }
699
700 /*
701 * (non-Javadoc)
702 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider#nextPage()
703 */
704 @Override
705 public void nextPage() {
706 fLock.lock();
707 try {
708 // Safety check
709 if (fCurrentPage >= (fCheckPoints.size() - 1)) {
710 return;
711 }
712
713 cancelOngoingRequests();
714 fCurrentTime = null;
715 fCurrentPage++;
716 moveToPage();
717 } finally {
718 fLock.unlock();
719 }
720 }
721
722 /*
723 * (non-Javadoc)
724 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider#prevPage()
725 */
726 @Override
727 public void prevPage() {
728 fLock.lock();
729 try {
730 // Safety check
731 if (fCurrentPage <= 0) {
732 return;
733 }
734
735 cancelOngoingRequests();
736 fCurrentTime = null;
737 fCurrentPage--;
738 moveToPage();
739 } finally {
740 fLock.unlock();
741 }
742 }
743
744 /*
745 * (non-Javadoc)
746 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider#firstPage()
747 */
748 @Override
749 public void firstPage() {
750 fLock.lock();
751 try {
752
753 cancelOngoingRequests();
754 fCurrentTime = null;
755 fCurrentPage = 0;
756 moveToPage();
757 } finally {
758 fLock.unlock();
759 }
760 }
761
762 /*
763 * (non-Javadoc)
764 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider#lastPage()
765 */
766 @Override
767 public void lastPage() {
768 fLock.lock();
769 try {
770 cancelOngoingRequests();
771 fCurrentTime = null;
772 fCurrentPage = fCheckPoints.size() - 1;
773 moveToPage();
774 } finally {
775 fLock.unlock();
776 }
777 }
778
779 /*
780 * (non-Javadoc)
781 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider#currentPage()
782 */
783 @Override
784 public int currentPage() {
785 fLock.lock();
786 try {
787 return fCurrentPage;
788 } finally {
789 fLock.unlock();
790 }
791 }
792
793 /*
794 * (non-Javadoc)
795 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider#pagesCount()
796 */
797 @Override
798 public int pagesCount() {
799 fLock.lock();
800 try {
801 return fCheckPoints.size();
802 } finally {
803 fLock.unlock();
804 }
805 }
806
807 /*
808 * (non-Javadoc)
809 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider#pageNumberChanged(int)
810 */
811 @Override
812 public void pageNumberChanged(int pagenNumber) {
813 int localPageNumber = pagenNumber;
814
815 fLock.lock();
816 try {
817 cancelOngoingRequests();
818
819 if (localPageNumber < 0) {
820 localPageNumber = 0;
821 }
822 int size = fCheckPoints.size();
823 if (localPageNumber > (size - 1)) {
824 localPageNumber = size - 1;
825 }
826 fCurrentPage = localPageNumber;
827 moveToPage();
828 } finally {
829 fLock.unlock();
830 }
831 }
832
833 /*
834 * (non-Javadoc)
835 * @see org.eclipse.linuxtools.tmf.component.TmfComponent#broadcast(org.eclipse.linuxtools.tmf.signal.TmfSignal)
836 */
837 @Override
838 public void broadcast(TmfSignal signal) {
839 fIsSignalSent = true;
840 super.broadcast(signal);
841 fIsSignalSent = false;
842 }
843
844 /**
845 * Cancels any ongoing find operation
846 */
847 protected void cancelOngoingRequests() {
848 fLock.lock();
849 try {
850 // Cancel the search thread
851 if (fFindJob != null) {
852 fFindJob.cancel();
853 }
854
855 fFindResults = null;
856 fFindCriteria = null;
857 fCurrentFindIndex = 0;
858
859 if ((fPageRequest != null) && !fPageRequest.isCompleted()) {
860 fPageRequest.cancel();
861 fPageRequest = null;
862 }
863 } finally {
864 fLock.unlock();
865 }
866 }
867
868 /**
869 * Resets loader attributes
870 */
871 protected void resetLoader() {
872 fLock.lock();
873 try {
874 fCurrentTime = null;
875 fEvents.clear();
876 fCheckPoints.clear();
877 fCurrentPage = 0;
878 fCurrentFindIndex = 0;
879 fFindCriteria = null;
880 fFindResults = null;
881 fInitialWindow = INITIAL_WINDOW_OFFSET;
882 fView.setFrameSync(new Frame());
883 fFrame = null;
884 }
885 finally {
886 fLock.unlock();
887 }
888
889 }
890
891 /**
892 * Fills current page with sequence diagram content.
893 *
894 * @param events sequence diagram events
895 */
896 protected void fillCurrentPage(List<ITmfSyncSequenceDiagramEvent> events) {
897
898 fLock.lock();
899 try {
900 fEvents = new ArrayList<ITmfSyncSequenceDiagramEvent>(events);
901 if (fView != null) {
902 fView.toggleWaitCursorAsync(true);
903 }
904 } finally {
905 fLock.unlock();
906 }
907
908 final Frame frame = new Frame();
909
910 if (!events.isEmpty()) {
911 Map<String, Lifeline> nodeToLifelineMap = new HashMap<String, Lifeline>();
912
913 frame.setName(Messages.TmfUml2SDSyncLoader_FrameName);
914
915 for (int i = 0; i < events.size(); i++) {
916
917 ITmfSyncSequenceDiagramEvent sdEvent = events.get(i);
918
919 if ((nodeToLifelineMap.get(sdEvent.getSender()) == null) && (!filterLifeLine(sdEvent.getSender()))) {
920 Lifeline lifeline = new Lifeline();
921 lifeline.setName(sdEvent.getSender());
922 nodeToLifelineMap.put(sdEvent.getSender(), lifeline);
923 frame.addLifeLine(lifeline);
924 }
925
926 if ((nodeToLifelineMap.get(sdEvent.getReceiver()) == null) && (!filterLifeLine(sdEvent.getReceiver()))) {
927 Lifeline lifeline = new Lifeline();
928 lifeline.setName(sdEvent.getReceiver());
929 nodeToLifelineMap.put(sdEvent.getReceiver(), lifeline);
930 frame.addLifeLine(lifeline);
931 }
932 }
933
934 int eventOccurence = 1;
935
936 for (int i = 0; i < events.size(); i++) {
937 ITmfSyncSequenceDiagramEvent sdEvent = events.get(i);
938
939 // Check message filter
940 if (filterMessage(sdEvent)) {
941 continue;
942 }
943
944 // Set the message sender and receiver
945 Lifeline startLifeline = nodeToLifelineMap.get(sdEvent.getSender());
946 Lifeline endLifeline = nodeToLifelineMap.get(sdEvent.getReceiver());
947
948 // Check if any of the lifelines were filtered
949 if ((startLifeline == null) || (endLifeline == null)) {
950 continue;
951 }
952
953 int tmp = Math.max(startLifeline.getEventOccurrence(), endLifeline.getEventOccurrence());
954 eventOccurence = Math.max(eventOccurence, tmp);
955
956 startLifeline.setCurrentEventOccurrence(eventOccurence);
957 endLifeline.setCurrentEventOccurrence(eventOccurence);
958
959 TmfSyncMessage message = new TmfSyncMessage(sdEvent, eventOccurence++);
960
961 message.setStartLifeline(startLifeline);
962 message.setEndLifeline(endLifeline);
963
964 message.setTime(sdEvent.getStartTime());
965
966 // add the message to the frame
967 frame.addMessage(message);
968
969 }
970 fLock.lock();
971 try {
972 if (!fView.getSDWidget().isDisposed()) {
973 fView.getSDWidget().getDisplay().asyncExec(new Runnable() {
974
975 @Override
976 public void run() {
977
978 fLock.lock();
979 try {
980 // check if view was disposed in the meanwhile
981 if ((fView != null) && (!fView.getSDWidget().isDisposed())) {
982 fFrame = frame;
983 fView.setFrame(fFrame);
984
985 if (fCurrentTime != null) {
986 moveToMessageInPage();
987 }
988
989 if (fFindCriteria != null) {
990 find(fFindCriteria);
991 }
992
993 fView.toggleWaitCursorAsync(false);
994 }
995 } finally {
996 fLock.unlock();
997 }
998
999 }
1000 });
1001 }
1002 }
1003 finally {
1004 fLock.unlock();
1005 }
1006 }
1007 }
1008
1009 /**
1010 * Moves to a certain message defined by timestamp (across pages)
1011 */
1012 protected void moveToMessage() {
1013 int page = 0;
1014
1015 fLock.lock();
1016 try {
1017 page = getPage(fCurrentTime);
1018
1019 if (page == fCurrentPage) {
1020 moveToMessageInPage();
1021 return;
1022 }
1023 fCurrentPage = page;
1024 moveToPage(false);
1025 } finally {
1026 fLock.unlock();
1027 }
1028 }
1029
1030 /**
1031 * Moves to a certain message defined by timestamp in current page
1032 */
1033 protected void moveToMessageInPage() {
1034 fLock.lock();
1035 try {
1036 if (!fView.getSDWidget().isDisposed()) {
1037 // Check for GUI thread
1038 if(Display.getCurrent() != null) {
1039 // Already in GUI thread - execute directly
1040 TmfSyncMessage prevMessage = null;
1041 TmfSyncMessage syncMessage = null;
1042 boolean isExactTime = false;
1043 for (int i = 0; i < fFrame.syncMessageCount(); i++) {
1044 if (fFrame.getSyncMessage(i) instanceof TmfSyncMessage) {
1045 syncMessage = (TmfSyncMessage) fFrame.getSyncMessage(i);
1046 if (syncMessage.getStartTime().compareTo(fCurrentTime, false) == 0) {
1047 isExactTime = true;
1048 break;
1049 } else if ((syncMessage.getStartTime().compareTo(fCurrentTime, false) > 0) && (prevMessage != null)) {
1050 syncMessage = prevMessage;
1051 break;
1052 }
1053 prevMessage = syncMessage;
1054 }
1055 }
1056 if (fIsSelect && isExactTime) {
1057 fView.getSDWidget().moveTo(syncMessage);
1058 }
1059 else {
1060 fView.getSDWidget().ensureVisible(syncMessage);
1061 fView.getSDWidget().clearSelection();
1062 fView.getSDWidget().redraw();
1063 }
1064 }
1065 else {
1066 // Not in GUI thread - queue action in GUI thread.
1067 fView.getSDWidget().getDisplay().asyncExec(new Runnable() {
1068 @Override
1069 public void run() {
1070 moveToMessageInPage();
1071 }
1072 });
1073 }
1074 }
1075 }
1076 finally {
1077 fLock.unlock();
1078 }
1079 }
1080
1081 /**
1082 * Moves to a certain message defined by timestamp (across pages)
1083 */
1084 protected void moveToPage() {
1085 moveToPage(true);
1086 }
1087
1088 /**
1089 * Moves to a certain page.
1090 *
1091 * @param notifyAll true to broadcast time range signal to other signal handlers else false
1092 */
1093 protected void moveToPage(boolean notifyAll) {
1094
1095 TmfTimeRange window = null;
1096
1097 fLock.lock();
1098 try {
1099 // Safety check
1100 if (fCurrentPage > fCheckPoints.size()) {
1101 return;
1102 }
1103 window = fCheckPoints.get(fCurrentPage);
1104 } finally {
1105 fLock.unlock();
1106 }
1107
1108 if (window == null) {
1109 window = TmfTimeRange.ETERNITY;
1110 }
1111
1112 fPageRequest = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.FOREGROUND) {
1113 private final List<ITmfSyncSequenceDiagramEvent> fSdEvent = new ArrayList<ITmfSyncSequenceDiagramEvent>();
1114
1115 @Override
1116 public void handleData(ITmfEvent event) {
1117 super.handleData(event);
1118
1119 ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
1120
1121 if (sdEvent != null) {
1122 fSdEvent.add(sdEvent);
1123 }
1124 }
1125
1126 @Override
1127 public void handleSuccess() {
1128 fillCurrentPage(fSdEvent);
1129 super.handleSuccess();
1130 }
1131
1132 };
1133
1134 fExperiment.sendRequest(fPageRequest);
1135
1136 if (notifyAll) {
1137 TmfTimeRange timeRange = getSignalTimeRange(window.getStartTime());
1138 broadcast(new TmfRangeSynchSignal(this, timeRange, timeRange.getStartTime()));
1139 }
1140 }
1141
1142 /**
1143 * Gets page that contains timestamp
1144 *
1145 * @param time The timestamp
1146 * @return page that contains the time
1147 */
1148 protected int getPage(ITmfTimestamp time) {
1149 int page;
1150 int size;
1151 fLock.lock();
1152 try {
1153 size = fCheckPoints.size();
1154 for (page = 0; page < size; page++) {
1155 TmfTimeRange timeRange = fCheckPoints.get(page);
1156 if (timeRange.getEndTime().compareTo(time, false) >= 0) {
1157 break;
1158 }
1159 }
1160 if (page >= size) {
1161 page = size - 1;
1162 }
1163 return page;
1164 } finally {
1165 fLock.unlock();
1166 }
1167 }
1168
1169 /**
1170 * Background search in trace for expression in criteria.
1171 *
1172 * @param findCriteria The find criteria
1173 * @return true if background request was started else false
1174 */
1175 protected boolean findInNextPages(Criteria findCriteria) {
1176 fLock.lock();
1177 try {
1178 if (fFindJob != null) {
1179 return true;
1180 }
1181
1182 int nextPage = fCurrentPage + 1;
1183
1184 if ((nextPage) >= fCheckPoints.size()) {
1185 // we are at the end
1186 return false;
1187 }
1188
1189 TmfTimeRange window = new TmfTimeRange(fCheckPoints.get(nextPage).getStartTime().clone(), fCheckPoints.get(fCheckPoints.size()-1).getEndTime().clone());
1190 fFindJob = new SearchJob(findCriteria, window);
1191 fFindJob.schedule();
1192 fView.toggleWaitCursorAsync(true);
1193 } finally {
1194 fLock.unlock();
1195 }
1196 return true;
1197 }
1198
1199 /**
1200 * Gets time range for time range signal.
1201 *
1202 * @param startTime The start time of time range.
1203 * @return the time range
1204 */
1205 protected TmfTimeRange getSignalTimeRange(ITmfTimestamp startTime) {
1206 fLock.lock();
1207 try {
1208 TmfTimestamp initialEndOfWindow = new TmfTimestamp(startTime.getValue() + fInitialWindow, startTime.getScale(), startTime.getPrecision());
1209 return new TmfTimeRange(startTime, initialEndOfWindow);
1210 }
1211 finally {
1212 fLock.unlock();
1213 }
1214 }
1215
1216 /**
1217 * Checks if filter criteria matches the message name in given SD event.
1218 *
1219 * @param sdEvent The SD event to check
1220 * @return true if match else false.
1221 */
1222 protected boolean filterMessage(ITmfSyncSequenceDiagramEvent sdEvent) {
1223 fLock.lock();
1224 try {
1225 if (fFilterCriteria != null) {
1226 for(FilterCriteria criteria : fFilterCriteria) {
1227 if (criteria.isActive() && criteria.getCriteria().isSyncMessageSelected() && criteria.getCriteria().matches(sdEvent.getName())) {
1228 return true;
1229 }
1230 }
1231 }
1232 } finally {
1233 fLock.unlock();
1234 }
1235 return false;
1236 }
1237
1238 /**
1239 * Checks if filter criteria matches a lifeline name (sender or receiver) in given SD event.
1240 *
1241 * @param lifeline the message receiver
1242 * @return true if match else false.
1243 */
1244 protected boolean filterLifeLine(String lifeline) {
1245 fLock.lock();
1246 try {
1247 if (fFilterCriteria != null) {
1248 for(FilterCriteria criteria : fFilterCriteria) {
1249 if (criteria.isActive() && criteria.getCriteria().isLifeLineSelected() && criteria.getCriteria().matches(lifeline)) {
1250 return true;
1251 }
1252 }
1253 }
1254 } finally {
1255 fLock.unlock();
1256 }
1257 return false;
1258 }
1259
1260 /**
1261 * Job to search in trace for given time range.
1262 */
1263 protected class SearchJob extends Job {
1264
1265 /**
1266 * The search event request.
1267 */
1268 final protected SearchEventRequest fSearchRequest;
1269
1270 /**
1271 * Constructor
1272 *
1273 * @param findCriteria The search criteria
1274 * @param window Time range to search in
1275 */
1276 public SearchJob(Criteria findCriteria, TmfTimeRange window) {
1277 super(Messages.TmfUml2SDSyncLoader_SearchJobDescrition);
1278 fSearchRequest = new SearchEventRequest(window, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.FOREGROUND, findCriteria);
1279 }
1280
1281 /*
1282 * (non-Javadoc)
1283 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
1284 */
1285 @Override
1286 protected IStatus run(IProgressMonitor monitor) {
1287 fSearchRequest.setMonitor(monitor);
1288
1289 fExperiment.sendRequest(fSearchRequest);
1290
1291 try {
1292 fSearchRequest.waitForCompletion();
1293 } catch (InterruptedException e) {
1294 Activator.getDefault().logError("Search request interrupted!", e); //$NON-NLS-1$
1295 }
1296
1297 IStatus status = Status.OK_STATUS;
1298 if (fSearchRequest.isFound() && (fSearchRequest.getFoundTime() != null)) {
1299 fCurrentTime = fSearchRequest.getFoundTime();
1300
1301 // Avoid double-selection. Selection will be done when calling find(criteria)
1302 // after moving to relevant page
1303 fIsSelect = false;
1304 if (!fView.getSDWidget().isDisposed()) {
1305 fView.getSDWidget().getDisplay().asyncExec(new Runnable() {
1306
1307 @Override
1308 public void run() {
1309 moveToMessage();
1310 }
1311 });
1312 }
1313 }
1314 else {
1315 if (monitor.isCanceled()) {
1316 status = Status.CANCEL_STATUS;
1317 }
1318 else {
1319 // String was not found
1320 status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, Messages.TmfUml2SDSyncLoader_SearchNotFound);
1321 }
1322 setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
1323 }
1324 monitor.done();
1325
1326 fLock.lock();
1327 try {
1328 fView.toggleWaitCursorAsync(false);
1329 fFindJob = null;
1330 } finally {
1331 fLock.unlock();
1332 }
1333
1334 return status;
1335 }
1336
1337 /*
1338 * (non-Javadoc)
1339 * @see org.eclipse.core.runtime.jobs.Job#canceling()
1340 */
1341 @Override
1342 protected void canceling() {
1343 fSearchRequest.cancel();
1344 fLock.lock();
1345 try {
1346 fFindJob = null;
1347 } finally {
1348 fLock.unlock();
1349 }
1350 }
1351 }
1352
1353 /**
1354 * TMF event request for searching within trace.
1355 */
1356 protected class SearchEventRequest extends TmfEventRequest<ITmfEvent> {
1357
1358 /**
1359 * The find criteria.
1360 */
1361 final private Criteria fCriteria;
1362 /**
1363 * A progress monitor
1364 */
1365 private IProgressMonitor fMonitor;
1366 /**
1367 * Flag to indicate that node was found according the criteria .
1368 */
1369 private boolean fIsFound = false;
1370 /**
1371 * Time stamp of found item.
1372 */
1373 private ITmfTimestamp fFoundTime = null;
1374
1375 /**
1376 * Constructor
1377 * @param range @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
1378 * @param nbRequested @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#handleData(...)
1379 * @param blockSize @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#handleData(...)
1380 * @param execType @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#handleData(...)
1381 * @param criteria The search criteria
1382 */
1383 public SearchEventRequest(TmfTimeRange range, int nbRequested, int blockSize, ExecutionType execType, Criteria criteria) {
1384 this(range, nbRequested, blockSize, execType, criteria, null);
1385 }
1386
1387 /**
1388 * Constructor
1389 * @param range @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
1390 * @param nbRequested @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
1391 * @param blockSize @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
1392 * @param execType @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
1393 * @param criteria The search criteria
1394 * @param monitor progress monitor
1395 */
1396 public SearchEventRequest(TmfTimeRange range, int nbRequested, int blockSize, ExecutionType execType, Criteria criteria, IProgressMonitor monitor) {
1397 super(ITmfEvent.class, range, nbRequested, blockSize, execType);
1398 fCriteria = new Criteria(criteria);
1399 fMonitor = monitor;
1400 }
1401
1402 /*
1403 * (non-Javadoc)
1404 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.event.TmfData)
1405 */
1406 @Override
1407 public void handleData(ITmfEvent event) {
1408 super.handleData(event);
1409
1410 if ((fMonitor!= null) && fMonitor.isCanceled()) {
1411 super.cancel();
1412 return;
1413 }
1414
1415 ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
1416
1417 if (sdEvent != null) {
1418
1419 if (fCriteria.isLifeLineSelected()) {
1420 if (fCriteria.matches(sdEvent.getSender())) {
1421 fFoundTime = event.getTimestamp().clone();
1422 fIsFound = true;
1423 super.cancel();
1424 }
1425
1426 if (fCriteria.matches(sdEvent.getReceiver())) {
1427 fFoundTime = event.getTimestamp().clone();
1428 fIsFound = true;
1429 super.cancel();
1430 }
1431 }
1432
1433 if (fCriteria.isSyncMessageSelected() && fCriteria.matches(sdEvent.getName())) {
1434 fFoundTime = event.getTimestamp().clone();
1435 fIsFound = true;
1436 super.cancel();
1437 }
1438 }
1439 }
1440
1441 /**
1442 * Set progress monitor.
1443 *
1444 * @param monitor The monitor to assign
1445 */
1446 public void setMonitor(IProgressMonitor monitor) {
1447 fMonitor = monitor;
1448 }
1449
1450 /**
1451 * Check if find criteria was met.
1452 *
1453 * @return true if find criteria was met.
1454 */
1455 public boolean isFound() {
1456 return fIsFound;
1457 }
1458
1459 /**
1460 * Returns timestamp of found time.
1461 *
1462 * @return timestamp of found time.
1463 */
1464 public ITmfTimestamp getFoundTime() {
1465 return fFoundTime;
1466 }
1467 }
1468
1469 /**
1470 * Job class to provide progress monitor feedback.
1471 *
1472 * @version 1.0
1473 * @author Bernd Hufmann
1474 *
1475 */
1476 protected static class IndexingJob extends Job {
1477
1478 public IndexingJob(String name) {
1479 super(name);
1480 }
1481
1482 @Override
1483 protected IStatus run(IProgressMonitor monitor) {
1484 while (!monitor.isCanceled()) {
1485 try {
1486 Thread.sleep(100);
1487 } catch (InterruptedException e) {
1488 return Status.OK_STATUS;
1489 }
1490 }
1491 monitor.done();
1492 return Status.OK_STATUS;
1493 }
1494 }
1495
1496
1497 /**
1498 * Returns sequence diagram event if details in given event are available else null.
1499 *
1500 * @param tmfEvent Event to parse for sequence diagram event details
1501 * @return sequence diagram event if details are available else null
1502 */
1503 protected ITmfSyncSequenceDiagramEvent getSequnceDiagramEvent(ITmfEvent tmfEvent){
1504 //type = .*RECEIVE.* or .*SEND.*
1505 //content = sender:<sender name>:receiver:<receiver name>,signal:<signal name>
1506 String eventType = tmfEvent.getType().toString();
1507 if (eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeSend) || eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeReceive)) {
1508 Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSender);
1509 Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldReceiver);
1510 Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSignal);
1511 if ((sender instanceof ITmfEventField) && (receiver instanceof ITmfEventField) && (name instanceof ITmfEventField)) {
1512 ITmfSyncSequenceDiagramEvent sdEvent = new TmfSyncSequenceDiagramEvent(tmfEvent,
1513 ((ITmfEventField) sender).getValue().toString(),
1514 ((ITmfEventField) receiver).getValue().toString(),
1515 ((ITmfEventField) name).getValue().toString());
1516
1517 return sdEvent;
1518 }
1519 }
1520 return null;
1521 }
1522 }
This page took 0.064139 seconds and 6 git commands to generate.