/**********************************************************************
- * Copyright (c) 2011, 2012 Ericsson
- *
+ * Copyright (c) 2011, 2013 Ericsson
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent;
import org.eclipse.linuxtools.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent;
+import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressConstants;
/**
* <p>
- * This class is a reference implementation of the <code>org.eclipse.linuxtools.tmf.ui.Uml2SDLoader</code> extension point. It provides
- * a Sequence Diagram loader for a user space trace with specific trace content for sending and
- * receiving signals between components. I also includes a default implementation for the <code>ITmfEvent</code> parsing.
+ * This class is a reference implementation of the
+ * <code>org.eclipse.linuxtools.tmf.ui.Uml2SDLoader</code> extension point. It
+ * provides a Sequence Diagram loader for a user space trace with specific trace
+ * content for sending and receiving signals between components. I also includes
+ * a default implementation for the <code>ITmfEvent</code> parsing.
* </p>
- *
- * The class <code>TmfUml2SDSyncLoader</code> analyzes events from type <code>ITmfEvent</code> and creates events type
- * <code>ITmfSyncSequenceDiagramEvent</code> if the <code>ITmfEvent</code> contains all relevant information.
- * The analysis checks that the event type strings contains either string SEND or RECEIVE. If event type matches these key
- * words, the analyzer will look for strings sender, receiver and signal in the event fields of type <code>ITmfEventField</code>.
- * If all the data is found a sequence diagram event from can be created. Note that Sync Messages are assumed, which
- * means start and end time are the same. <br>
+ *
+ * The class <code>TmfUml2SDSyncLoader</code> analyzes events from type
+ * <code>ITmfEvent</code> and creates events type
+ * <code>ITmfSyncSequenceDiagramEvent</code> if the <code>ITmfEvent</code>
+ * contains all relevant information. The analysis checks that the event type
+ * strings contains either string SEND or RECEIVE. If event type matches these
+ * key words, the analyzer will look for strings sender, receiver and signal in
+ * the event fields of type <code>ITmfEventField</code>. If all the data is
+ * found a sequence diagram event from can be created. Note that Sync Messages
+ * are assumed, which means start and end time are the same. <br>
+ * <br>
+ * The parsing of the <code>ITmfEvent</code> is done in the method
+ * <code>getSequnceDiagramEvent()</code> of class
+ * <code>TmfUml2SDSyncLoader</code>. By extending the class
+ * <code>TmfUml2SDSyncLoader</code> and overwriting
+ * <code>getSequnceDiagramEvent()</code> a customized parsing algorithm can be
+ * implemented.<br>
* <br>
- * The parsing of the <code>ITmfEvent</code> is done in the method <code>getSequnceDiagramEvent()</code> of class
- * <code>TmfUml2SDSyncLoader</code>. By extending the class <code>TmfUml2SDSyncLoader</code> and overwriting
- * <code>getSequnceDiagramEvent()</code> a customized parsing algorithm can be implemented.<br>
- * <br>
- * Note that combined traces of multiple components, that contain the trace information about the same interactions are not
- * supported in the class <code>TmfUml2SDSyncLoader</code>.
- *
+ * Note that combined traces of multiple components, that contain the trace
+ * information about the same interactions are not supported in the class
+ * <code>TmfUml2SDSyncLoader</code>.
+ *
* @version 1.0
* @author Bernd Hufmann
*/
* Maximum number of messages per page.
*/
protected final static int MAX_NUM_OF_MSG = 10000;
- /**
- * Initial time range window.
- */
- protected final static long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec
// ------------------------------------------------------------------------
// Attributes
// Experiment attributes
/**
- * The TMF experiment reference.
+ * The TMF trace reference.
+ * @since 2.0
*/
- protected TmfExperiment<ITmfEvent> fExperiment = null;
+ protected ITmfTrace fTrace = null;
/**
* The current indexing event request.
*/
- protected ITmfEventRequest<ITmfEvent> fIndexRequest = null;
+ protected ITmfEventRequest fIndexRequest = null;
/**
* The current request to fill a page.
*/
- protected ITmfEventRequest<ITmfEvent> fPageRequest = null;
+ protected ITmfEventRequest fPageRequest = null;
/**
* Flag whether the time range signal was sent by this loader class or not
*/
volatile protected boolean fIsSignalSent = false;
- /**
- * The initial request window size.
- */
- volatile protected long fInitialWindow = INITIAL_WINDOW_OFFSET;
// The view and event attributes
/**
/**
* Flag to specify that selection of message is done by selection or by signal.
*/
- volatile protected boolean fIsSelect = false;
+ volatile protected boolean fIsSelect = false;
// Search attributes
/**
- * The job for searching across pages.
+ * The job for searching across pages.
*/
protected SearchJob fFindJob = null;
/**
* The list of active filters.
*/
protected List<FilterCriteria> fFilterCriteria = null;
-
+
// Thread synchronization
/**
* The synchronization lock.
*/
protected ReentrantLock fLock = new ReentrantLock();
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
* Constructor
- *
+ *
* @param name Name of loader
*/
public TmfUml2SDSyncLoader(String name) {
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+
/**
* Returns the current time if available else null.
- *
+ *
* @return the current time if available else null
+ * @since 2.0
*/
public ITmfTimestamp getCurrentTime() {
- fLock.lock();
+ fLock.lock();
try {
- if (fCurrentTime != null) {
- return fCurrentTime.clone();
+ if (fCurrentTime != null) {
+ return fCurrentTime;
}
return null;
} finally {
fLock.unlock();
}
}
-
+
/**
* Waits for the page request to be completed
*/
public void waitForCompletion() {
fLock.lock();
- ITmfEventRequest<ITmfEvent> request = fPageRequest;
+ ITmfEventRequest request = fPageRequest;
fLock.unlock();
- if (request != null)
- try {
- request.waitForCompletion();
- } catch (InterruptedException e) {
- // ignore
+ if (request != null) {
+ try {
+ request.waitForCompletion();
+ } catch (InterruptedException e) {
+ // ignore
+ }
}
}
/**
- * Signal handler for the experiment selected signal.
- *
- * Spawns a request to index the experiment (checkpoints creation) as well as it fills
+ * Signal handler for the trace selected signal.
+ *
+ * Spawns a request to index the trace (checkpoints creation) as well as it fills
* the first page.
- *
- * @param signal The experiment selected signal
+ *
+ * @param signal The trace selected signal
+ * @since 2.0
*/
- @SuppressWarnings("unchecked")
@TmfSignalHandler
- public void experimentSelected(TmfExperimentSelectedSignal<ITmfEvent> signal) {
-
- final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- while (!monitor.isCanceled()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- return Status.OK_STATUS;
- }
- }
- monitor.done();
- return Status.OK_STATUS;
- }
- };
- job.setUser(false);
- job.schedule();
+ public void traceSelected(TmfTraceSelectedSignal signal) {
- fLock.lock();
+ ITmfEventRequest indexRequest = null;
+ fLock.lock();
try {
// Update the trace reference
- TmfExperiment<ITmfEvent> exp = (TmfExperiment<ITmfEvent>) signal.getExperiment();
- if (!exp.equals(fExperiment)) {
- fExperiment = exp;
+ ITmfTrace trace = signal.getTrace();
+ if (!trace.equals(fTrace)) {
+ fTrace = trace;
+ } else {
+ return;
}
+ final Job job = new IndexingJob("Indexing " + getName() + "..."); //$NON-NLS-1$ //$NON-NLS-2$
+ job.setUser(false);
+ job.schedule();
+
+ indexRequest = fIndexRequest;
+
+ cancelOngoingRequests();
+
TmfTimeRange window = TmfTimeRange.ETERNITY;
- fIndexRequest = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) {
+ fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) {
private ITmfTimestamp fFirstTime = null;
private ITmfTimestamp fLastTime = null;
public void handleData(ITmfEvent event) {
super.handleData(event);
- ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
+ ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
if (sdEvent != null) {
++fNbSeqEvents;
if (fFirstTime == null) {
- fFirstTime = event.getTimestamp().clone();
+ fFirstTime = event.getTimestamp();
}
- fLastTime = event.getTimestamp().clone();
+ fLastTime = event.getTimestamp();
if ((fNbSeqEvents % MAX_NUM_OF_MSG) == 0) {
fLock.lock();
*/
@Override
public void handleCompleted() {
- if (fEvents.size() == 0) {
+ if (fEvents.isEmpty()) {
fFrame = new Frame();
fView.setFrameSync(fFrame);
}
}
};
- fExperiment.sendRequest(fIndexRequest);
} finally {
fLock.unlock();
}
-
+ if (indexRequest != null && !indexRequest.isCompleted()) {
+ indexRequest.cancel();
+ }
+ resetLoader();
+ fTrace.sendRequest(fIndexRequest);
+
}
/**
- * Signal handler for the experiment disposed signal.
- *
- * @param signal The experiment disposed signal
+ * Signal handler for the trace closed signal.
+ *
+ * @param signal The trace closed signal
+ * @since 2.0
*/
@TmfSignalHandler
- public void experimentDisposed(TmfExperimentDisposedSignal<ITmfEvent> signal) {
- if (signal.getExperiment() != TmfExperiment.getCurrentExperiment()) {
+ public void traceClosed(TmfTraceClosedSignal signal) {
+ if (signal.getTrace() != fTrace) {
return;
}
+ ITmfEventRequest indexRequest = null;
fLock.lock();
try {
- if ((fIndexRequest != null) && !fIndexRequest.isCompleted()) {
- fIndexRequest.cancel();
- fIndexRequest = null;
- }
+ indexRequest = fIndexRequest;
+ fIndexRequest = null;
cancelOngoingRequests();
}
FilterListDialog.deactivateSavedGlobalFilters();
-
- resetLoader();
} finally {
+ fTrace = null;
fLock.unlock();
}
+ if (indexRequest != null && !indexRequest.isCompleted()) {
+ indexRequest.cancel();
+ }
+
+ resetLoader();
}
/**
public void synchToTime(TmfTimeSynchSignal signal) {
fLock.lock();
try {
- if ((signal.getSource() != this) && (fFrame != null)) {
-
+ if ((signal.getSource() != this) && (fFrame != null) && (fCheckPoints.size() > 0)) {
fCurrentTime = signal.getCurrentTime();
fIsSelect = true;
moveToMessage();
}
/**
- * Moves to the page that contains the current time provided by signal.
- * No message will be selected however the focus will be set to the message
+ * Moves to the page that contains the current time provided by signal.
+ * No message will be selected however the focus will be set to the message
* if the provided time is the time of a message.
- *
+ *
* @param signal The time range sync signal
*/
@TmfSignalHandler
public void synchToTimeRange(TmfRangeSynchSignal signal) {
fLock.lock();
try {
- if ((signal.getSource() != this) && (fFrame != null) && !fIsSignalSent) {
+ if ((signal.getSource() != this) && (fFrame != null) && !fIsSignalSent && (fCheckPoints.size() > 0)) {
TmfTimeRange newTimeRange = signal.getCurrentRange();
- ITmfTimestamp delta = newTimeRange.getEndTime().getDelta(newTimeRange.getStartTime());
- fInitialWindow = delta.getValue();
fIsSelect = false;
fCurrentTime = newTimeRange.getStartTime();
* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
*/
- @SuppressWarnings("unchecked")
@Override
public void setViewer(SDView viewer) {
resetLoader();
- fExperiment = (TmfExperiment<ITmfEvent>) TmfExperiment.getCurrentExperiment();
- if (fExperiment != null) {
- experimentSelected(new TmfExperimentSelectedSignal<ITmfEvent>(this, fExperiment));
+ IEditorPart editor = fView.getSite().getPage().getActiveEditor();
+ if (editor instanceof ITmfTraceEditor) {
+ ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
+ if (trace != null) {
+ traceSelected(new TmfTraceSelectedSignal(this, trace));
+ }
}
} finally {
fLock.unlock();
@Override
public void dispose() {
super.dispose();
+ ITmfEventRequest indexRequest = null;
fLock.lock();
try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(this);
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ // During Eclipse shutdown the active workbench window is null
+ if (window != null) {
+ window.getSelectionService().removePostSelectionListener(this);
+ }
+
+ indexRequest = fIndexRequest;
+ fIndexRequest = null;
+ cancelOngoingRequests();
+
fView.setSDFindProvider(null);
fView.setSDPagingProvider(null);
fView.setSDFilterProvider(null);
} finally {
fLock.unlock();
}
+ if (indexRequest != null && !indexRequest.isCompleted()) {
+ indexRequest.cancel();
+ }
}
/*
return Messages.TmfUml2SDSyncLoader_CategoryLifeline;
case ISDGraphNodeSupporter.SYNCMESSAGE:
return Messages.TmfUml2SDSyncLoader_CategoryMessage;
+ default:
+ break;
}
return ""; //$NON-NLS-1$
}
}
}
- if (msgs.size() > 0) {
+ if (!msgs.isEmpty()) {
fFindResults.addAll(msgs);
}
GraphNode current = fFindResults.get(fCurrentFindIndex);
fView.getSDWidget().moveTo(current);
return true;
- } else {
- fFindResults = null;
- fCurrentFindIndex =0;
- return findInNextPages(fFindCriteria); // search in other page
}
+ fFindResults = null;
+ fCurrentFindIndex =0;
+ return findInNextPages(fFindCriteria); // search in other page
} finally {
fLock.unlock();
}
try {
cancelOngoingRequests();
- List<FilterCriteria> list = (List<FilterCriteria>)filters;
- fFilterCriteria = new ArrayList<FilterCriteria>(list);
+ if (filters == null) {
+ fFilterCriteria = new ArrayList<FilterCriteria>();
+ } else {
+ List<FilterCriteria> list = (List<FilterCriteria>)filters;
+ fFilterCriteria = new ArrayList<FilterCriteria>(list);
+ }
fillCurrentPage(fEvents);
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider#pageNumberChanged(int)
*/
@Override
- public void pageNumberChanged(int pageNumber) {
+ public void pageNumberChanged(int pagenNumber) {
+ int localPageNumber = pagenNumber;
+
fLock.lock();
try {
cancelOngoingRequests();
- if (pageNumber < 0) {
- pageNumber = 0;
+ if (localPageNumber < 0) {
+ localPageNumber = 0;
}
int size = fCheckPoints.size();
- if (pageNumber > (size - 1)) {
- pageNumber = size - 1;
+ if (localPageNumber > (size - 1)) {
+ localPageNumber = size - 1;
}
- fCurrentPage = pageNumber;
+ fCurrentPage = localPageNumber;
moveToPage();
} finally {
fLock.unlock();
*/
protected void cancelOngoingRequests() {
fLock.lock();
+ ITmfEventRequest pageRequest = null;
try {
// Cancel the search thread
if (fFindJob != null) {
fFindCriteria = null;
fCurrentFindIndex = 0;
- if ((fPageRequest != null) && !fPageRequest.isCompleted()) {
- fPageRequest.cancel();
- fPageRequest = null;
- }
+ pageRequest = fPageRequest;
+ fPageRequest = null;
} finally {
fLock.unlock();
}
+ if (pageRequest != null && !pageRequest.isCompleted()) {
+ pageRequest.cancel();
+ }
}
/**
fCurrentFindIndex = 0;
fFindCriteria = null;
fFindResults = null;
- fInitialWindow = INITIAL_WINDOW_OFFSET;
fView.setFrameSync(new Frame());
fFrame = null;
}
/**
* Fills current page with sequence diagram content.
- *
+ *
* @param events sequence diagram events
*/
protected void fillCurrentPage(List<ITmfSyncSequenceDiagramEvent> events) {
fLock.lock();
try {
fEvents = new ArrayList<ITmfSyncSequenceDiagramEvent>(events);
- if (fView != null) {
+ if (fView != null && !events.isEmpty()) {
fView.toggleWaitCursorAsync(true);
}
} finally {
final Frame frame = new Frame();
- if (events.size() > 0) {
- HashMap<String, Lifeline> nodeToLifelineMap = new HashMap<String, Lifeline>();
+ if (!events.isEmpty()) {
+ Map<String, Lifeline> nodeToLifelineMap = new HashMap<String, Lifeline>();
frame.setName(Messages.TmfUml2SDSyncLoader_FrameName);
if (syncMessage.getStartTime().compareTo(fCurrentTime, false) == 0) {
isExactTime = true;
break;
- }
- else if (syncMessage.getStartTime().compareTo(fCurrentTime, false) > 0) {
- if (prevMessage != null) {
- syncMessage = prevMessage;
- break;
- }
+ } else if ((syncMessage.getStartTime().compareTo(fCurrentTime, false) > 0) && (prevMessage != null)) {
+ syncMessage = prevMessage;
+ break;
}
prevMessage = syncMessage;
}
/**
* Moves to a certain page.
- *
+ *
* @param notifyAll true to broadcast time range signal to other signal handlers else false
*/
protected void moveToPage(boolean notifyAll) {
- TmfTimeRange window = TmfTimeRange.ETERNITY;
+ TmfTimeRange window = null;
fLock.lock();
try {
fLock.unlock();
}
- fPageRequest = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.FOREGROUND) {
+ if (window == null) {
+ window = TmfTimeRange.ETERNITY;
+ }
+
+ fPageRequest = new TmfEventRequest(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.FOREGROUND) {
private final List<ITmfSyncSequenceDiagramEvent> fSdEvent = new ArrayList<ITmfSyncSequenceDiagramEvent>();
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
- ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
+ ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
if (sdEvent != null) {
fSdEvent.add(sdEvent);
};
- fExperiment.sendRequest(fPageRequest);
+ fTrace.sendRequest(fPageRequest);
if (notifyAll) {
TmfTimeRange timeRange = getSignalTimeRange(window.getStartTime());
/**
* Gets page that contains timestamp
- *
+ *
* @param time The timestamp
* @return page that contains the time
+ * @since 2.0
*/
protected int getPage(ITmfTimestamp time) {
int page;
/**
* Background search in trace for expression in criteria.
- *
+ *
* @param findCriteria The find criteria
* @return true if background request was started else false
*/
return false;
}
- TmfTimeRange window = new TmfTimeRange(fCheckPoints.get(nextPage).getStartTime().clone(), fCheckPoints.get(fCheckPoints.size()-1).getEndTime().clone());
+ TmfTimeRange window = new TmfTimeRange(fCheckPoints.get(nextPage).getStartTime(), fCheckPoints.get(fCheckPoints.size()-1).getEndTime());
fFindJob = new SearchJob(findCriteria, window);
fFindJob.schedule();
fView.toggleWaitCursorAsync(true);
/**
* Gets time range for time range signal.
- *
+ *
* @param startTime The start time of time range.
* @return the time range
+ * @since 2.0
*/
protected TmfTimeRange getSignalTimeRange(ITmfTimestamp startTime) {
fLock.lock();
try {
- TmfTimestamp initialEndOfWindow = new TmfTimestamp(startTime.getValue() + fInitialWindow, startTime.getScale(), startTime.getPrecision());
+ long offset = fTrace == null ? 0 : fTrace.getCurrentRange().getEndTime().getDelta(fTrace.getCurrentRange().getStartTime()).normalize(0, startTime.getScale()).getValue();
+ TmfTimestamp initialEndOfWindow = new TmfTimestamp(startTime.getValue() + offset, startTime.getScale(), startTime.getPrecision());
return new TmfTimeRange(startTime, initialEndOfWindow);
}
finally {
/**
* Checks if filter criteria matches the message name in given SD event.
- *
+ *
* @param sdEvent The SD event to check
* @return true if match else false.
*/
try {
if (fFilterCriteria != null) {
for(FilterCriteria criteria : fFilterCriteria) {
- if (criteria.isActive() && criteria.getCriteria().isSyncMessageSelected() ) {
-
- if(criteria.getCriteria().matches(sdEvent.getName())) {
- return true;
- }
+ if (criteria.isActive() && criteria.getCriteria().isSyncMessageSelected() && criteria.getCriteria().matches(sdEvent.getName())) {
+ return true;
}
}
}
/**
* Checks if filter criteria matches a lifeline name (sender or receiver) in given SD event.
- *
+ *
* @param lifeline the message receiver
* @return true if match else false.
*/
try {
if (fFilterCriteria != null) {
for(FilterCriteria criteria : fFilterCriteria) {
- if (criteria.isActive() && criteria.getCriteria().isLifeLineSelected()) {
-
- if(criteria.getCriteria().matches(lifeline)) {
- return true;
- }
+ if (criteria.isActive() && criteria.getCriteria().isLifeLineSelected() && criteria.getCriteria().matches(lifeline)) {
+ return true;
}
}
}
protected class SearchJob extends Job {
/**
- * The search event request.
+ * The search event request.
*/
final protected SearchEventRequest fSearchRequest;
*
* @param findCriteria The search criteria
* @param window Time range to search in
+ * @since 2.0
*/
public SearchJob(Criteria findCriteria, TmfTimeRange window) {
super(Messages.TmfUml2SDSyncLoader_SearchJobDescrition);
protected IStatus run(IProgressMonitor monitor) {
fSearchRequest.setMonitor(monitor);
- fExperiment.sendRequest(fSearchRequest);
+ fTrace.sendRequest(fSearchRequest);
try {
fSearchRequest.waitForCompletion();
} catch (InterruptedException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Search request interrupted!", e); //$NON-NLS-1$
}
IStatus status = Status.OK_STATUS;
}
else {
// String was not found
- status = new Status(Status.WARNING, TmfUiPlugin.PLUGIN_ID, Messages.TmfUml2SDSyncLoader_SearchNotFound);
+ status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, Messages.TmfUml2SDSyncLoader_SearchNotFound);
}
setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
}
/**
* TMF event request for searching within trace.
*/
- protected class SearchEventRequest extends TmfEventRequest<ITmfEvent> {
+ protected class SearchEventRequest extends TmfEventRequest {
/**
* The find criteria.
return;
}
- ITmfSyncSequenceDiagramEvent sdEvent = getSequnceDiagramEvent(event);
+ ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
if (sdEvent != null) {
if (fCriteria.isLifeLineSelected()) {
if (fCriteria.matches(sdEvent.getSender())) {
- fFoundTime = event.getTimestamp().clone();
+ fFoundTime = event.getTimestamp();
fIsFound = true;
super.cancel();
}
if (fCriteria.matches(sdEvent.getReceiver())) {
- fFoundTime = event.getTimestamp().clone();
+ fFoundTime = event.getTimestamp();
fIsFound = true;
super.cancel();
}
}
- if (fCriteria.isSyncMessageSelected()) {
- if (fCriteria.matches(sdEvent.getName())) {
- fFoundTime = event.getTimestamp().clone();
- fIsFound = true;
- super.cancel();
- }
+ if (fCriteria.isSyncMessageSelected() && fCriteria.matches(sdEvent.getName())) {
+ fFoundTime = event.getTimestamp();
+ fIsFound = true;
+ super.cancel();
}
}
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
- */
- @Override
- public void handleCompleted() {
- super.handleCompleted();
- }
-
/**
* Set progress monitor.
- *
- * @param monitor
+ *
+ * @param monitor The monitor to assign
*/
public void setMonitor(IProgressMonitor monitor) {
fMonitor = monitor;
/**
* Check if find criteria was met.
- *
+ *
* @return true if find criteria was met.
*/
public boolean isFound() {
/**
* Returns timestamp of found time.
- *
+ *
* @return timestamp of found time.
+ * @since 2.0
*/
public ITmfTimestamp getFoundTime() {
return fFoundTime;
}
}
+ /**
+ * Job class to provide progress monitor feedback.
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
+ *
+ */
+ protected static class IndexingJob extends Job {
+
+ /**
+ * @param name The job name
+ */
+ public IndexingJob(String name) {
+ super(name);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ while (!monitor.isCanceled()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ return Status.OK_STATUS;
+ }
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ }
+
+
/**
* Returns sequence diagram event if details in given event are available else null.
- *
+ *
* @param tmfEvent Event to parse for sequence diagram event details
* @return sequence diagram event if details are available else null
+ * @since 2.0
*/
- protected ITmfSyncSequenceDiagramEvent getSequnceDiagramEvent(ITmfEvent tmfEvent){
+ protected ITmfSyncSequenceDiagramEvent getSequenceDiagramEvent(ITmfEvent tmfEvent){
//type = .*RECEIVE.* or .*SEND.*
//content = sender:<sender name>:receiver:<receiver name>,signal:<signal name>
String eventType = tmfEvent.getType().toString();
- if (eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeSend) || eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeReceive)) {
- Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSender);
- Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldReceiver);
- Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSignal);
+ if (eventType.contains(Messages.TmfUml2SDSyncLoader_EventTypeSend) || eventType.contains(Messages.TmfUml2SDSyncLoader_EventTypeReceive)) {
+ Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldSender);
+ Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldReceiver);
+ Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldSignal);
if ((sender instanceof ITmfEventField) && (receiver instanceof ITmfEventField) && (name instanceof ITmfEventField)) {
ITmfSyncSequenceDiagramEvent sdEvent = new TmfSyncSequenceDiagramEvent(tmfEvent,
((ITmfEventField) sender).getValue().toString(),