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